From 04e4922c0c407a9f0cfe268f62130891e98fc682 Mon Sep 17 00:00:00 2001 From: Arthur Huillet Date: Wed, 11 Jul 2007 02:33:12 +0200 Subject: Made drm_sg_alloc accessible from inside the DRM - drm_sg_alloc_ioctl is the ioctl wrapper --- bsd-core/drm_scatter.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'bsd-core/drm_scatter.c') diff --git a/bsd-core/drm_scatter.c b/bsd-core/drm_scatter.c index 9dc280a4..46222f18 100644 --- a/bsd-core/drm_scatter.c +++ b/bsd-core/drm_scatter.c @@ -40,28 +40,20 @@ void drm_sg_cleanup(drm_sg_mem_t *entry) free(entry, M_DRM); } -int drm_sg_alloc(DRM_IOCTL_ARGS) +int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request) { - DRM_DEVICE; - drm_scatter_gather_t request; drm_sg_mem_t *entry; unsigned long pages; - int i; - - DRM_DEBUG( "%s\n", __FUNCTION__ ); if ( dev->sg ) return EINVAL; - DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data, - sizeof(request) ); - entry = malloc(sizeof(*entry), M_DRM, M_WAITOK | M_ZERO); if ( !entry ) return ENOMEM; pages = round_page(request.size) / PAGE_SIZE; - DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages ); + DRM_DEBUG( "sg size=%ld pages=%ld\n", request->size, pages ); entry->pages = pages; @@ -86,11 +78,7 @@ int drm_sg_alloc(DRM_IOCTL_ARGS) DRM_DEBUG( "sg alloc handle = %08lx\n", entry->handle ); entry->virtual = (void *)entry->handle; - request.handle = entry->handle; - - DRM_COPY_TO_USER_IOCTL( (drm_scatter_gather_t *)data, - request, - sizeof(request) ); + request->handle = entry->handle; DRM_LOCK(); if (dev->sg) { @@ -101,6 +89,27 @@ int drm_sg_alloc(DRM_IOCTL_ARGS) dev->sg = entry; DRM_UNLOCK(); +} + +int drm_sg_alloc_ioctl(DRM_IOCTL_ARGS) +{ + DRM_DEVICE; + drm_scatter_gather_t request; + int ret; + + DRM_DEBUG( "%s\n", __FUNCTION__ ); + + + DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data, + sizeof(request) ); + + ret = drm_sg_alloc(dev, &request); + if ( ret ) return ret; + + DRM_COPY_TO_USER_IOCTL( (drm_scatter_gather_t *)data, + request, + sizeof(request) ); + return 0; } -- cgit v1.2.3 From 3f04fe7890fe7728e7df37a6b65ad328a46699bf Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 16 Jul 2007 01:53:06 -0700 Subject: Fix FreeBSD build. --- bsd-core/drm_scatter.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bsd-core/drm_scatter.c') diff --git a/bsd-core/drm_scatter.c b/bsd-core/drm_scatter.c index 46222f18..99eae408 100644 --- a/bsd-core/drm_scatter.c +++ b/bsd-core/drm_scatter.c @@ -44,6 +44,7 @@ int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request) { drm_sg_mem_t *entry; unsigned long pages; + int i; if ( dev->sg ) return EINVAL; @@ -52,7 +53,7 @@ int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request) if ( !entry ) return ENOMEM; - pages = round_page(request.size) / PAGE_SIZE; + pages = round_page(request->size) / PAGE_SIZE; DRM_DEBUG( "sg size=%ld pages=%ld\n", request->size, pages ); entry->pages = pages; -- cgit v1.2.3 From 33a50412c21229610dbb75dee83f145e2f1ec128 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 18 Jul 2007 14:22:40 -0700 Subject: Add dry-coded DRM drawable private information storage for FreeBSD. With this, all modules build again. --- bsd-core/drm_scatter.c | 1 + 1 file changed, 1 insertion(+) (limited to 'bsd-core/drm_scatter.c') diff --git a/bsd-core/drm_scatter.c b/bsd-core/drm_scatter.c index 99eae408..3c0be4a0 100644 --- a/bsd-core/drm_scatter.c +++ b/bsd-core/drm_scatter.c @@ -90,6 +90,7 @@ int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request) dev->sg = entry; DRM_UNLOCK(); + return 0; } int drm_sg_alloc_ioctl(DRM_IOCTL_ARGS) -- cgit v1.2.3 From 5b38e134163cc375e91424c4688cc9328c6e9082 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 19 Jul 2007 17:11:11 -0700 Subject: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE. The data is now in kernel space, copied in/out as appropriate according to the This results in DRM_COPY_{TO,FROM}_USER going away, and error paths to deal with those failures. This also means that XFree86 4.2.0 support for i810 DRM is lost. --- bsd-core/drm_scatter.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'bsd-core/drm_scatter.c') diff --git a/bsd-core/drm_scatter.c b/bsd-core/drm_scatter.c index 3c0be4a0..91c3c6c5 100644 --- a/bsd-core/drm_scatter.c +++ b/bsd-core/drm_scatter.c @@ -93,43 +93,28 @@ int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request) return 0; } -int drm_sg_alloc_ioctl(DRM_IOCTL_ARGS) +int drm_sg_alloc_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; - drm_scatter_gather_t request; + drm_scatter_gather_t *request = data; int ret; DRM_DEBUG( "%s\n", __FUNCTION__ ); - - DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data, - sizeof(request) ); - - ret = drm_sg_alloc(dev, &request); - if ( ret ) return ret; - - DRM_COPY_TO_USER_IOCTL( (drm_scatter_gather_t *)data, - request, - sizeof(request) ); - - return 0; + ret = drm_sg_alloc(dev, request); + return ret; } -int drm_sg_free(DRM_IOCTL_ARGS) +int drm_sg_free(drm_device_t *dev, void *data, struct drm_file *file_priv) { - DRM_DEVICE; - drm_scatter_gather_t request; + drm_scatter_gather_t *request = data; drm_sg_mem_t *entry; - DRM_COPY_FROM_USER_IOCTL( request, (drm_scatter_gather_t *)data, - sizeof(request) ); - DRM_LOCK(); entry = dev->sg; dev->sg = NULL; DRM_UNLOCK(); - if ( !entry || entry->handle != request.handle ) + if ( !entry || entry->handle != request->handle ) return EINVAL; DRM_DEBUG( "sg free virtual = 0x%lx\n", entry->handle ); -- cgit v1.2.3 From 5346fc5f36b5e7c55fc7b5cd46f1e4d7563a86a4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 14 Aug 2007 14:41:24 -0700 Subject: BSD: Replace brief description in each file's first line with doxygen later on. The brief descriptions usually had the wrong filename in them. --- bsd-core/drm_scatter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bsd-core/drm_scatter.c') diff --git a/bsd-core/drm_scatter.c b/bsd-core/drm_scatter.c index 91c3c6c5..92e715e0 100644 --- a/bsd-core/drm_scatter.c +++ b/bsd-core/drm_scatter.c @@ -1,5 +1,3 @@ -/* drm_scatter.h -- IOCTLs to manage scatter/gather memory -*- linux-c -*- - * Created: Mon Dec 18 23:20:54 2000 by gareth@valinux.com */ /*- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. @@ -29,6 +27,13 @@ * */ +/** @file drm_scatter.c + * Allocation of memory for scatter-gather mappings by the graphics chip. + * + * The memory allocated here is then made into an aperture in the card + * by drm_ati_pcigart_init(). + */ + #include "drmP.h" #define DEBUG_SCATTER 0 -- cgit v1.2.3