From patchwork Mon Nov 18 10:57:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 292019 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 93CD72C00CE for ; Mon, 18 Nov 2013 21:57:59 +1100 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ViMWb-0003Vv-1I; Mon, 18 Nov 2013 10:57:49 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ViMWY-0007Xw-Nk; Mon, 18 Nov 2013 10:57:46 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ViMWV-0007X8-EC for linux-arm-kernel@lists.infradead.org; Mon, 18 Nov 2013 10:57:44 +0000 Received: from ukl by metis.ext.pengutronix.de with local (Exim 4.72) (envelope-from ) id 1ViMW2-00037T-5O; Mon, 18 Nov 2013 11:57:14 +0100 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen Date: Mon, 18 Nov 2013 11:57:11 +0100 Message-Id: <1384772231-20993-1-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 1.8.4.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ukl@pengutronix.de X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on metis.extern.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=4.0 tests=BAYES_00,NO_RELAYS shortcircuit=no autolearn=ham version=3.3.2 Subject: [PATCH] RFC: framebuffer: provide generic get_fb_unmapped_area X-SA-Exim-Version: 4.2.1 (built Mon, 22 Mar 2010 06:51:10 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131118_055743_803671_C6BF5544 X-CRM114-Status: GOOD ( 14.69 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-arm-kernel@lists.infradead.org, linux-fbdev@vger.kernel.org, Jonathan Austin , kernel@pengutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org This patch makes mmapping the simple-framebuffer device work on a no-MMU ARM target. The code is mostly taken from arch/blackfin/kernel/sys_bfin.c. Note this is only tested on this no-MMU machine and I don't know enough about framebuffers and mm to decide if this patch is sane. Also I'm unsure about the size check because it triggers if userspace page aligns the len parameter. (I don't know how usual it is to do, I'd say it's wrong, but my test program (fbtest by Geert Uytterhoeven) does it.) Signed-off-by: Uwe Kleine-König --- drivers/video/fbmem.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index dacaf74..70b328c 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c @@ -1483,6 +1483,24 @@ __releases(&info->lock) return 0; } +#ifdef HAVE_ARCH_FB_UNMAPPED_AREA +#define fb_get_unmapped_area get_fb_unmapped_area +#else +unsigned long fb_get_unmapped_area(struct file *filp, unsigned long orig_addr, + unsigned long len, unsigned long pgoff, unsigned long flags) +{ + struct fb_info * const info = filp->private_data; + unsigned long screen_size = info->screen_size ?: info->fix.smem_len; + + if (len > screen_size) { + pr_info("%lu > %lu (%lu, %lu)\n", len, screen_size, info->screen_size, info->fix.smem_len); + return -EINVAL; + } + + return (unsigned long)info->screen_base; +} +#endif + static const struct file_operations fb_fops = { .owner = THIS_MODULE, .read = fb_read, @@ -1494,9 +1512,7 @@ static const struct file_operations fb_fops = { .mmap = fb_mmap, .open = fb_open, .release = fb_release, -#ifdef HAVE_ARCH_FB_UNMAPPED_AREA - .get_unmapped_area = get_fb_unmapped_area, -#endif + .get_unmapped_area = fb_get_unmapped_area, #ifdef CONFIG_FB_DEFERRED_IO .fsync = fb_deferred_io_fsync, #endif