1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Thomas Zimmermann <tzimmermann@suse.de>
3 Date: Tue, 25 Jan 2022 10:12:21 +0100
4 Subject: [PATCH] fbdev/simplefb: Request memory region in driver
6 Requesting the framebuffer memory in simpledrm marks the memory
7 range as busy. This used to be done by the firmware sysfb code,
8 but the driver is the correct place.
11 * store memory region in struct for later cleanup (Javier)
13 Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
14 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
15 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
17 drivers/video/fbdev/simplefb.c | 65 +++++++++++++++++++++++-----------
18 1 file changed, 45 insertions(+), 20 deletions(-)
20 diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c
21 index b63074fd892e..6885ac0203de 100644
22 --- a/drivers/video/fbdev/simplefb.c
23 +++ b/drivers/video/fbdev/simplefb.c
24 @@ -66,16 +66,36 @@ static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
29 +struct simplefb_par {
30 + u32 palette[PSEUDO_PALETTE_SIZE];
31 + struct resource *mem;
32 +#if defined CONFIG_OF && defined CONFIG_COMMON_CLK
34 + unsigned int clk_count;
37 +#if defined CONFIG_OF && defined CONFIG_REGULATOR
38 + bool regulators_enabled;
39 + u32 regulator_count;
40 + struct regulator **regulators;
44 static void simplefb_clocks_destroy(struct simplefb_par *par);
45 static void simplefb_regulators_destroy(struct simplefb_par *par);
47 static void simplefb_destroy(struct fb_info *info)
49 + struct simplefb_par *par = info->par;
50 + struct resource *mem = par->mem;
52 simplefb_regulators_destroy(info->par);
53 simplefb_clocks_destroy(info->par);
54 if (info->screen_base)
55 iounmap(info->screen_base);
58 + release_mem_region(mem->start, resource_size(mem));
61 static const struct fb_ops simplefb_ops = {
62 @@ -169,20 +189,6 @@ static int simplefb_parse_pd(struct platform_device *pdev,
66 -struct simplefb_par {
67 - u32 palette[PSEUDO_PALETTE_SIZE];
68 -#if defined CONFIG_OF && defined CONFIG_COMMON_CLK
70 - unsigned int clk_count;
73 -#if defined CONFIG_OF && defined CONFIG_REGULATOR
74 - bool regulators_enabled;
75 - u32 regulator_count;
76 - struct regulator **regulators;
80 #if defined CONFIG_OF && defined CONFIG_COMMON_CLK
82 * Clock handling code.
83 @@ -405,7 +411,7 @@ static int simplefb_probe(struct platform_device *pdev)
84 struct simplefb_params params;
86 struct simplefb_par *par;
87 - struct resource *mem;
88 + struct resource *res, *mem;
91 * Generic drivers must not be registered if a framebuffer exists.
92 @@ -430,15 +436,28 @@ static int simplefb_probe(struct platform_device *pdev)
96 - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
98 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
100 dev_err(&pdev->dev, "No memory resource\n");
104 + mem = request_mem_region(res->start, resource_size(res), "simplefb");
107 + * We cannot make this fatal. Sometimes this comes from magic
108 + * spaces our resource handlers simply don't know about. Use
109 + * the I/O-memory resource as-is and try to map that instead.
111 + dev_warn(&pdev->dev, "simplefb: cannot reserve video memory at %pR\n", res);
115 info = framebuffer_alloc(sizeof(struct simplefb_par), &pdev->dev);
120 + goto error_release_mem_region;
122 platform_set_drvdata(pdev, info);
125 @@ -495,6 +514,9 @@ static int simplefb_probe(struct platform_device *pdev)
126 info->var.xres, info->var.yres,
127 info->var.bits_per_pixel, info->fix.line_length);
130 + par->mem = mem; /* release in clean-up handler */
132 ret = register_framebuffer(info);
134 dev_err(&pdev->dev, "Unable to register simplefb: %d\n", ret);
135 @@ -513,6 +535,9 @@ static int simplefb_probe(struct platform_device *pdev)
136 iounmap(info->screen_base);
138 framebuffer_release(info);
139 +error_release_mem_region:
141 + release_mem_region(mem->start, resource_size(mem));