From patchwork Thu Jun 4 16:44:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 6548251 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 90F079F3D1 for ; Thu, 4 Jun 2015 16:52:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3A4F20795 for ; Thu, 4 Jun 2015 16:52:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B0B8120792 for ; Thu, 4 Jun 2015 16:52:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932206AbbFDQv5 (ORCPT ); Thu, 4 Jun 2015 12:51:57 -0400 Received: from mail-qg0-f45.google.com ([209.85.192.45]:34165 "EHLO mail-qg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753887AbbFDQve (ORCPT ); Thu, 4 Jun 2015 12:51:34 -0400 Received: by qgf75 with SMTP id 75so18248600qgf.1; Thu, 04 Jun 2015 09:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=esu4ZFYiERlzJrQsKsK2txg8Uff2rxZsU/DgKAFDPiw=; b=uUQN+2D43iE5FoCiPu5ANMtNdZxCxbTEUs+Ete0kCpDzvv0g3mkoNTmqlqn849k6TM RRz6EJajbs47fj56QDt4amAoSoOMHKASzTwsCrg1tWsk8hOJ2/fkTfJdXYzIUmce9q/l aILnFoTYmvZGaXvssbhLb48iSxWomrv30SmLsEEBOK2pEMlKZmeMld0qGOP6sVIdMSa6 YYMerJc08CyGSreRl9TUop8WbeZp5T8LapLLPFrXZNC1LwwDT12z/mAUzYuHCOCUkd2H H5vq1Rx9BtID4+wnoHelHnbDR5+Bm1vmB71WLfu0BekstIhNumnaWwMeaVv0wS2IAUbQ GyRg== X-Received: by 10.55.51.210 with SMTP id z201mr72431961qkz.35.1433436693155; Thu, 04 Jun 2015 09:51:33 -0700 (PDT) Received: from mcgrof@gmail.com (c-98-234-145-61.hsd1.ca.comcast.net. [98.234.145.61]) by mx.google.com with ESMTPSA id c13sm2605073qkh.15.2015.06.04.09.51.29 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 04 Jun 2015 09:51:32 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Thu, 04 Jun 2015 09:49:21 -0700 From: "Luis R. Rodriguez" To: tomi.valkeinen@ti.com Cc: plagnioj@jcrosoft.com, bp@suse.de, hpa@zytor.com, linux-fbdev@vger.kernel.org, luto@amacapital.net, toshi.kani@hp.com, sbsiddha@gmail.com, mingo@elte.hu, tglx@linutronix.de, jgross@suse.com, daniel.vetter@ffwll.ch, airlied@redhat.com, adaplas@gmail.com, robdclark@gmail.com, jg1.han@samsung.com, wsa@the-dreams.de, linux-kernel@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH v4 2/3] video: fbdev: vesafb: add missing mtrr_del() for added MTRR Date: Thu, 4 Jun 2015 09:44:47 -0700 Message-Id: <1433436288-16792-3-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1433436288-16792-1-git-send-email-mcgrof@do-not-panic.com> References: <1433436288-16792-1-git-send-email-mcgrof@do-not-panic.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Luis R. Rodriguez" 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 Cc: Suresh Siddha Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Juergen Gross Cc: Daniel Vetter Cc: Andy Lutomirski Cc: Dave Airlie Cc: Antonino Daplas Cc: Rob Clark Cc: Jingoo Han Cc: Wolfram Sang Cc: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen Cc: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Luis R. Rodriguez --- drivers/video/fbdev/vesafb.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c index 191156b..3db3908 100644 --- a/drivers/video/fbdev/vesafb.c +++ b/drivers/video/fbdev/vesafb.c @@ -29,6 +29,11 @@ /* --------------------------------------------------------------------- */ +struct vesafb_par { + u32 pseudo_palette[256]; + int wc_cookie; +}; + static struct fb_var_screeninfo vesafb_defined = { .activate = FB_ACTIVATE_NOW, .height = -1, @@ -175,7 +180,16 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green, static void vesafb_destroy(struct fb_info *info) { +#ifdef CONFIG_MTRR + struct vesafb_par *par = info->par; +#endif + fb_dealloc_cmap(&info->cmap); + +#ifdef CONFIG_MTRR + if (par->wc_cookie >= 0) + mtrr_del(par->wc_cookie, 0, 0); +#endif if (info->screen_base) iounmap(info->screen_base); release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size); @@ -228,6 +242,7 @@ static int vesafb_setup(char *options) static int vesafb_probe(struct platform_device *dev) { struct fb_info *info; + struct vesafb_par *par; int i, err; unsigned int size_vmode; unsigned int size_remap; @@ -291,14 +306,14 @@ static int vesafb_probe(struct platform_device *dev) spaces our resource handlers simply don't know about */ } - info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev); + info = framebuffer_alloc(sizeof(struct vesafb_par), &dev->dev); if (!info) { release_mem_region(vesafb_fix.smem_start, size_total); return -ENOMEM; } platform_set_drvdata(dev, info); - info->pseudo_palette = info->par; - info->par = NULL; + par = info->par; + info->pseudo_palette = par->pseudo_palette; /* set vesafb aperture size for generic probing */ info->apertures = alloc_apertures(1); @@ -407,17 +422,17 @@ static int vesafb_probe(struct platform_device *dev) if (mtrr == 3) { #ifdef CONFIG_MTRR unsigned int temp_size = size_total; - int rc; /* Find the largest power-of-two */ temp_size = roundup_pow_of_two(temp_size); /* Try and find a power of two to add */ do { - rc = mtrr_add(vesafb_fix.smem_start, temp_size, - MTRR_TYPE_WRCOMB, 1); + par->wc_cookie = mtrr_add(vesafb_fix.smem_start, + temp_size, + MTRR_TYPE_WRCOMB, 1); temp_size >>= 1; - } while (temp_size >= PAGE_SIZE && rc == -EINVAL); + } while (temp_size >= PAGE_SIZE && par->wc_cookie == -EINVAL); #endif info->screen_base = ioremap_wc(vesafb_fix.smem_start, vesafb_fix.smem_len); } else { @@ -462,6 +477,10 @@ static int vesafb_probe(struct platform_device *dev) fb_info(info, "%s frame buffer device\n", info->fix.id); return 0; err: +#ifdef CONFIG_MTRR + if (par->wc_cookie >= 0) + mtrr_del(par->wc_cookie, 0, 0); +#endif if (info->screen_base) iounmap(info->screen_base); framebuffer_release(info);