aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@suse.com>2015-06-04 12:44:47 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2015-06-16 02:42:11 -0400
commit6b41f27dce701f2be0c47e7f42a885afa6f23477 (patch)
treea5b59daca6cb49aba038d064d6fe4c86e6e01d1f
parent87b81762a893319921405ad6932f220c02ca88a7 (diff)
video: fbdev: vesafb: add missing mtrr_del() for added MTRR
The MTRR added was never being deleted, in order to store the MTRR cookie we need to make use of the private info->par so we create a struct for this. This driver was already using the extra space typically used for info->par for the info->pseudo_palette which typically used stuffed on driver's own private structs (the respective info->par), so we just move the pseudo_palette into the private struct as well. Cc: Toshi Kani <toshi.kani@hp.com> Cc: Suresh Siddha <sbsiddha@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Juergen Gross <jgross@suse.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Dave Airlie <airlied@redhat.com> Cc: Antonino Daplas <adaplas@gmail.com> Cc: Rob Clark <robdclark@gmail.com> Cc: Jingoo Han <jg1.han@samsung.com> Cc: Wolfram Sang <wsa@the-dreams.de> Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com> Cc: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--drivers/video/fbdev/vesafb.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c
index 191156bdf638..3db390885d71 100644
--- a/drivers/video/fbdev/vesafb.c
+++ b/drivers/video/fbdev/vesafb.c
@@ -29,6 +29,11 @@
29 29
30/* --------------------------------------------------------------------- */ 30/* --------------------------------------------------------------------- */
31 31
32struct vesafb_par {
33 u32 pseudo_palette[256];
34 int wc_cookie;
35};
36
32static struct fb_var_screeninfo vesafb_defined = { 37static struct fb_var_screeninfo vesafb_defined = {
33 .activate = FB_ACTIVATE_NOW, 38 .activate = FB_ACTIVATE_NOW,
34 .height = -1, 39 .height = -1,
@@ -175,7 +180,16 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green,
175 180
176static void vesafb_destroy(struct fb_info *info) 181static void vesafb_destroy(struct fb_info *info)
177{ 182{
183#ifdef CONFIG_MTRR
184 struct vesafb_par *par = info->par;
185#endif
186
178 fb_dealloc_cmap(&info->cmap); 187 fb_dealloc_cmap(&info->cmap);
188
189#ifdef CONFIG_MTRR
190 if (par->wc_cookie >= 0)
191 mtrr_del(par->wc_cookie, 0, 0);
192#endif
179 if (info->screen_base) 193 if (info->screen_base)
180 iounmap(info->screen_base); 194 iounmap(info->screen_base);
181 release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size); 195 release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size);
@@ -228,6 +242,7 @@ static int vesafb_setup(char *options)
228static int vesafb_probe(struct platform_device *dev) 242static int vesafb_probe(struct platform_device *dev)
229{ 243{
230 struct fb_info *info; 244 struct fb_info *info;
245 struct vesafb_par *par;
231 int i, err; 246 int i, err;
232 unsigned int size_vmode; 247 unsigned int size_vmode;
233 unsigned int size_remap; 248 unsigned int size_remap;
@@ -291,14 +306,14 @@ static int vesafb_probe(struct platform_device *dev)
291 spaces our resource handlers simply don't know about */ 306 spaces our resource handlers simply don't know about */
292 } 307 }
293 308
294 info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev); 309 info = framebuffer_alloc(sizeof(struct vesafb_par), &dev->dev);
295 if (!info) { 310 if (!info) {
296 release_mem_region(vesafb_fix.smem_start, size_total); 311 release_mem_region(vesafb_fix.smem_start, size_total);
297 return -ENOMEM; 312 return -ENOMEM;
298 } 313 }
299 platform_set_drvdata(dev, info); 314 platform_set_drvdata(dev, info);
300 info->pseudo_palette = info->par; 315 par = info->par;
301 info->par = NULL; 316 info->pseudo_palette = par->pseudo_palette;
302 317
303 /* set vesafb aperture size for generic probing */ 318 /* set vesafb aperture size for generic probing */
304 info->apertures = alloc_apertures(1); 319 info->apertures = alloc_apertures(1);
@@ -407,17 +422,17 @@ static int vesafb_probe(struct platform_device *dev)
407 if (mtrr == 3) { 422 if (mtrr == 3) {
408#ifdef CONFIG_MTRR 423#ifdef CONFIG_MTRR
409 unsigned int temp_size = size_total; 424 unsigned int temp_size = size_total;
410 int rc;
411 425
412 /* Find the largest power-of-two */ 426 /* Find the largest power-of-two */
413 temp_size = roundup_pow_of_two(temp_size); 427 temp_size = roundup_pow_of_two(temp_size);
414 428
415 /* Try and find a power of two to add */ 429 /* Try and find a power of two to add */
416 do { 430 do {
417 rc = mtrr_add(vesafb_fix.smem_start, temp_size, 431 par->wc_cookie = mtrr_add(vesafb_fix.smem_start,
418 MTRR_TYPE_WRCOMB, 1); 432 temp_size,
433 MTRR_TYPE_WRCOMB, 1);
419 temp_size >>= 1; 434 temp_size >>= 1;
420 } while (temp_size >= PAGE_SIZE && rc == -EINVAL); 435 } while (temp_size >= PAGE_SIZE && par->wc_cookie == -EINVAL);
421#endif 436#endif
422 info->screen_base = ioremap_wc(vesafb_fix.smem_start, vesafb_fix.smem_len); 437 info->screen_base = ioremap_wc(vesafb_fix.smem_start, vesafb_fix.smem_len);
423 } else { 438 } else {
@@ -462,6 +477,10 @@ static int vesafb_probe(struct platform_device *dev)
462 fb_info(info, "%s frame buffer device\n", info->fix.id); 477 fb_info(info, "%s frame buffer device\n", info->fix.id);
463 return 0; 478 return 0;
464err: 479err:
480#ifdef CONFIG_MTRR
481 if (par->wc_cookie >= 0)
482 mtrr_del(par->wc_cookie, 0, 0);
483#endif
465 if (info->screen_base) 484 if (info->screen_base)
466 iounmap(info->screen_base); 485 iounmap(info->screen_base);
467 framebuffer_release(info); 486 framebuffer_release(info);