Currently, userspace fails to obtain the SAREA mapping on some platforms
because they pass SAREA_MAX to drmAddMap without aligning it to the page
size. This breaks for example on PowerPC with 64K pages.

The way SAREA_MAX is defined with a bunch of ifdef's and duplicated between
libdrm and the X server is gross, ultimately it should be retrieved by
userspace from the kernel, but in the meantime, we have plenty of existing
userspace built with bad values that need to work.

The actual SAREA in the kernel is created with an aligned size by the
radeon driver (I haven't tested others) so it's purely a userspace problem.

This works around it by rounding the requested size in drmAddMap to the page
size. There should never be any need to manipulate maps smaller than a page
(MMIO regions might but there isn't much we can do about it) and our mmap()
calls has enough sanity checks here if the map is actually too small to be
mapped. We also only do that fir the ioctl, not the in-kernel call.

Signed-off-by: Benjamin Herrenschmidt <b...@kernel.crashing.org>
---

This fixes DRM with 16K and 64K pages on PowerPC embedded machines. Dunno
if you want that in 2.6.30, I would personally like that but I'm not going
to force your hand :-)

Cheers,
Ben.

Index: linux-work/drivers/gpu/drm/drm_bufs.c
===================================================================
--- linux-work.orig/drivers/gpu/drm/drm_bufs.c  2009-05-18 10:50:04.000000000 
+1000
+++ linux-work/drivers/gpu/drm/drm_bufs.c       2009-05-18 10:51:01.000000000 
+1000
@@ -404,6 +404,8 @@ int drm_addmap_ioctl(struct drm_device *
        if (!(capable(CAP_SYS_ADMIN) || map->type == _DRM_AGP || map->type == 
_DRM_SHM))
                return -EPERM;
 
+       /* Workaround for userspace passing smaller than page size quantities */
+       map->size = PAGE_ALIGN(map->size);
        err = drm_addmap_core(dev, map->offset, map->size, map->type,
                              map->flags, &maplist);
 



------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
--
_______________________________________________
Dri-devel mailing list
Dri-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to