* [PATCH v2] RFC: framebuffer: provide generic get_fb_unmapped_area
@ 2014-02-03 17:14 Uwe Kleine-König
2014-03-14 21:06 ` Uwe Kleine-König
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2014-02-03 17:14 UTC (permalink / raw)
To: linux-fbdev
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.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,
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
a bit unsure about the size check, I just believed Geert that
PAGE_ALIGN(info->fix.smem_len) is the right value to check against.
Best regards
Uwe
drivers/video/fbmem.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 7309ac704e26..d0ccedafec8c 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1491,6 +1491,22 @@ __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 fb_size = PAGE_ALIGN(info->fix.smem_len);
+
+ if (pgoff > fb_size || len > fb_size - pgoff)
+ return -EINVAL;
+
+ return (unsigned long)info->screen_base + pgoff;
+}
+#endif
+
static const struct file_operations fb_fops = {
.owner = THIS_MODULE,
.read = fb_read,
@@ -1502,9 +1518,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
--
1.8.5.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] RFC: framebuffer: provide generic get_fb_unmapped_area
2014-02-03 17:14 [PATCH v2] RFC: framebuffer: provide generic get_fb_unmapped_area Uwe Kleine-König
@ 2014-03-14 21:06 ` Uwe Kleine-König
2014-03-17 11:23 ` Tomi Valkeinen
2014-03-17 12:15 ` David Herrmann
2 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2014-03-14 21:06 UTC (permalink / raw)
To: linux-fbdev
On Mon, Feb 03, 2014 at 06:14:44PM +0100, Uwe Kleine-König wrote:
> 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.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> Hello,
>
> 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
> a bit unsure about the size check, I just believed Geert that
> PAGE_ALIGN(info->fix.smem_len) is the right value to check against.
Do you still have this patch on your radar?
Best regards
Uwe
> drivers/video/fbmem.c | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index 7309ac704e26..d0ccedafec8c 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1491,6 +1491,22 @@ __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 fb_size = PAGE_ALIGN(info->fix.smem_len);
> +
> + if (pgoff > fb_size || len > fb_size - pgoff)
> + return -EINVAL;
> +
> + return (unsigned long)info->screen_base + pgoff;
> +}
> +#endif
> +
> static const struct file_operations fb_fops = {
> .owner = THIS_MODULE,
> .read = fb_read,
> @@ -1502,9 +1518,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
> --
> 1.8.5.2
>
>
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] RFC: framebuffer: provide generic get_fb_unmapped_area
2014-02-03 17:14 [PATCH v2] RFC: framebuffer: provide generic get_fb_unmapped_area Uwe Kleine-König
2014-03-14 21:06 ` Uwe Kleine-König
@ 2014-03-17 11:23 ` Tomi Valkeinen
2014-03-17 12:15 ` David Herrmann
2 siblings, 0 replies; 4+ messages in thread
From: Tomi Valkeinen @ 2014-03-17 11:23 UTC (permalink / raw)
To: linux-fbdev
[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]
Hi,
On 03/02/14 19:14, Uwe Kleine-König wrote:
> 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.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> Hello,
>
> 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
> a bit unsure about the size check, I just believed Geert that
> PAGE_ALIGN(info->fix.smem_len) is the right value to check against.
I don't know enough about mm to say much here, and the text above make
me feel a bit uneasy. I'd be happy if this would get a few
acks/reviewed-bys/tested-bys...
So what does this patch actually do? If I read things correctly,
currently .get_unmapped_area is null, except for sparc and blackfin. But
userspace's mmap() calls that, right? Is there a default implementation
somewhere? Why is that different for no-MMU case?
Tomi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] RFC: framebuffer: provide generic get_fb_unmapped_area
2014-02-03 17:14 [PATCH v2] RFC: framebuffer: provide generic get_fb_unmapped_area Uwe Kleine-König
2014-03-14 21:06 ` Uwe Kleine-König
2014-03-17 11:23 ` Tomi Valkeinen
@ 2014-03-17 12:15 ` David Herrmann
2 siblings, 0 replies; 4+ messages in thread
From: David Herrmann @ 2014-03-17 12:15 UTC (permalink / raw)
To: linux-fbdev
Hi
On Mon, Feb 3, 2014 at 6:14 PM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> 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.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> Hello,
>
> 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
> a bit unsure about the size check, I just believed Geert that
> PAGE_ALIGN(info->fix.smem_len) is the right value to check against.
>
> Best regards
> Uwe
>
> drivers/video/fbmem.c | 20 +++++++++++++++++---
> 1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
> index 7309ac704e26..d0ccedafec8c 100644
> --- a/drivers/video/fbmem.c
> +++ b/drivers/video/fbmem.c
> @@ -1491,6 +1491,22 @@ __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 fb_size = PAGE_ALIGN(info->fix.smem_len);
> +
> + if (pgoff > fb_size || len > fb_size - pgoff)
> + return -EINVAL;
> +
> + return (unsigned long)info->screen_base + pgoff;
> +}
> +#endif
> +
Doesn't this break mmu systems? x86 for instance has no
get_fb_unmapped_area(), therefore f_ops->get_unmapped_area() is NULL
and thus falls back to the generic handler of the task (see
mm/mmap.c). If you replace this with your handler, _every_ mmap() call
with be treated as MAP_FIXED with "info->screen_base + pgoff" as
address. This might work in test-cases on the first mmap() call, but
any further call will fail.
Thanks
David
> static const struct file_operations fb_fops = {
> .owner = THIS_MODULE,
> .read = fb_read,
> @@ -1502,9 +1518,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
> --
> 1.8.5.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-03-17 12:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-03 17:14 [PATCH v2] RFC: framebuffer: provide generic get_fb_unmapped_area Uwe Kleine-König
2014-03-14 21:06 ` Uwe Kleine-König
2014-03-17 11:23 ` Tomi Valkeinen
2014-03-17 12:15 ` David Herrmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).