From patchwork Wed Oct 2 14:58:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2975591 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C95C39F245 for ; Wed, 2 Oct 2013 14:59:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19D4B20303 for ; Wed, 2 Oct 2013 14:59:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBB7D20328 for ; Wed, 2 Oct 2013 14:58:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753673Ab3JBO66 (ORCPT ); Wed, 2 Oct 2013 10:58:58 -0400 Received: from mail-ea0-f181.google.com ([209.85.215.181]:59344 "EHLO mail-ea0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753257Ab3JBO6z (ORCPT ); Wed, 2 Oct 2013 10:58:55 -0400 Received: by mail-ea0-f181.google.com with SMTP id d10so467571eaj.12 for ; Wed, 02 Oct 2013 07:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=+RQ1tfyY0DrmXLO4/cXOttD1CkPX9VJimvj7lcs8jBA=; b=T15PfpXbsnXwE5yvEMXDN+/imEiIbeJPftM7d8zuPTvZtEQSVdNRkecH49AAk4teGB NNdDeFMWdc6AWeeVTKciMdO0BzXxC1nS7IyuPTVm6poEb1CEZgPevCdQu4TwCZLpo0NK AxgiTRyJj2LK8UG/TSmTaovG+erUiGMXJ+Fk5rY3l95VOhFn9SO9mP6AI+1U5sB6nrLT rjkj5ALEVSiMOSCQE5ZR2HrOseSDNRBKriT2g/R11uHTKbhxVC1rLf7u4ov/t1kRNsyR ywFsdp7Sr5FDQicpcKG5fjhKhkV2CLZnDo8V2Q4xuaGDorbvwYMhukPROWJGG7J6l0FX KeaQ== X-Received: by 10.14.183.2 with SMTP id p2mr4307767eem.44.1380725934258; Wed, 02 Oct 2013 07:58:54 -0700 (PDT) Received: from localhost.localdomain (stgt-5f71b885.pool.mediaWays.net. [95.113.184.133]) by mx.google.com with ESMTPSA id z12sm4675926eev.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 07:58:53 -0700 (PDT) From: David Herrmann To: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Tom Gundersen , Alexandre Courbot , Stephen Warren , dri-devel@lists.freedesktop.org, Jean-Christophe Plagniol-Villard , Tomi Valkeinen , David Herrmann Subject: [PATCH 1/2] simplefb: fix unmapping fb during destruction Date: Wed, 2 Oct 2013 16:58:38 +0200 Message-Id: <1380725919-1961-1-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 Unfortunately, fbdev does not create its own "struct device" for framebuffers. Instead, it attaches to the device of the parent layer. This has the side-effect that devm_* managed resources are not cleaned up on framebuffer-destruction but rather during destruction of the parent-device. In case of fbdev this might be too late, though. remove_conflicting_framebuffer() may remove fbdev devices but keep the parent device as it is. Therefore, we now use plain ioremap() and unmap the framebuffer in the fb_destroy() callback. Note that we must not free the device here as this might race with the parent-device removal. Instead, we rely on unregister_framebuffer() as barrier and we're safe. Reported-by: Tom Gundersen Signed-off-by: David Herrmann Acked-by: Stephen Warren --- Hi I know that simplefb was supposed to stay "as simple as possible" but I really think this series is the last set of fixes I have. Unfortunately framebuffer DRM handover is mandatory so we cannot ignore it in simplefb. Both patches are not critical at all and are targeted at 3.13-rc1. Thanks David drivers/video/simplefb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/video/simplefb.c b/drivers/video/simplefb.c index 8d78106..74b016c 100644 --- a/drivers/video/simplefb.c +++ b/drivers/video/simplefb.c @@ -66,8 +66,15 @@ static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, return 0; } +static void simplefb_destroy(struct fb_info *info) +{ + if (info->screen_base) + iounmap(info->screen_base); +} + static struct fb_ops simplefb_ops = { .owner = THIS_MODULE, + .fb_destroy = simplefb_destroy, .fb_setcolreg = simplefb_setcolreg, .fb_fillrect = cfb_fillrect, .fb_copyarea = cfb_copyarea, @@ -212,8 +219,8 @@ static int simplefb_probe(struct platform_device *pdev) info->fbops = &simplefb_ops; info->flags = FBINFO_DEFAULT | FBINFO_MISC_FIRMWARE; - info->screen_base = devm_ioremap(&pdev->dev, info->fix.smem_start, - info->fix.smem_len); + info->screen_base = ioremap(info->fix.smem_start, + info->fix.smem_len); if (!info->screen_base) { framebuffer_release(info); return -ENODEV; @@ -223,6 +230,7 @@ static int simplefb_probe(struct platform_device *pdev) ret = register_framebuffer(info); if (ret < 0) { dev_err(&pdev->dev, "Unable to register simplefb: %d\n", ret); + iounmap(info->screen_base); framebuffer_release(info); return ret; }