diff options
author | Dave Airlie <airlied@linux.ie> | 2007-07-11 11:23:41 +1000 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2007-07-11 11:23:41 +1000 |
commit | 2c9e05cf4c6eb18c941321f764ed1b282a314ba9 (patch) | |
tree | d5bcbe9114fac7e03549ae05a9e6dffc793fcbaf /bsd-core | |
parent | 9b9a127ed0fe9a6a8e2fde84739ccff6fa0bc5ac (diff) | |
parent | 694e1c5c3f768436651ddf95e11ab5a89ccc8ffa (diff) |
Merge branch 'master' into cleanup
Conflicts:
libdrm/xf86drm.c
linux-core/drm_bo.c
linux-core/drm_fence.c
Diffstat (limited to 'bsd-core')
-rw-r--r-- | bsd-core/Makefile | 1 | ||||
-rw-r--r-- | bsd-core/ati_pcigart.c | 21 | ||||
-rw-r--r-- | bsd-core/drmP.h | 31 | ||||
-rw-r--r-- | bsd-core/drm_agpsupport.c | 2 | ||||
-rw-r--r-- | bsd-core/drm_drv.c | 14 | ||||
-rw-r--r-- | bsd-core/drm_scatter.c | 39 |
6 files changed, 67 insertions, 41 deletions
diff --git a/bsd-core/Makefile b/bsd-core/Makefile index db563a65..00889dae 100644 --- a/bsd-core/Makefile +++ b/bsd-core/Makefile @@ -69,4 +69,3 @@ drm_pciids.h: ${SHARED}/drm_pciids.txt ${SHAREDFILES}: ln -sf ${SHARED}/$@ $@ - diff --git a/bsd-core/ati_pcigart.c b/bsd-core/ati_pcigart.c index d48d0a80..682eace6 100644 --- a/bsd-core/ati_pcigart.c +++ b/bsd-core/ati_pcigart.c @@ -32,8 +32,6 @@ #include "drmP.h" #define ATI_PCIGART_PAGE_SIZE 4096 /* PCI GART page size */ -#define ATI_MAX_PCIGART_PAGES 8192 /* 32 MB aperture, 4K pages */ -#define ATI_PCIGART_TABLE_SIZE 32768 int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) { @@ -48,7 +46,7 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) { /* GART table in system memory */ - dev->sg->dmah = drm_pci_alloc(dev, ATI_PCIGART_TABLE_SIZE, 0, + dev->sg->dmah = drm_pci_alloc(dev, gart_info->table_size, 0, 0xfffffffful); if (dev->sg->dmah == NULL) { DRM_ERROR("cannot allocate PCI GART table!\n"); @@ -63,9 +61,9 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) pci_gart = gart_info->addr; } - pages = DRM_MIN(dev->sg->pages, ATI_MAX_PCIGART_PAGES); + pages = DRM_MIN(dev->sg->pages, gart_info->table_size / sizeof(u32)); - bzero(pci_gart, ATI_PCIGART_TABLE_SIZE); + bzero(pci_gart, gart_info->table_size); KASSERT(PAGE_SIZE >= ATI_PCIGART_PAGE_SIZE, ("page size too small")); @@ -73,10 +71,17 @@ int drm_ati_pcigart_init(drm_device_t *dev, drm_ati_pcigart_info *gart_info) page_base = (u32) dev->sg->busaddr[i]; for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) { - if (gart_info->is_pcie) - *pci_gart = (cpu_to_le32(page_base) >> 8) | 0xc; - else + switch(gart_info->gart_reg_if) { + case DRM_ATI_GART_IGP: + *pci_gart = cpu_to_le32(page_base | 0xc); + break; + case DRM_ATI_GART_PCIE: + *pci_gart = cpu_to_le32((page_base >> 8) | 0xc); + break; + default: *pci_gart = cpu_to_le32(page_base); + break; + } pci_gart++; page_base += ATI_PCIGART_PAGE_SIZE; } diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h index 9ebb12ae..6e05b58f 100644 --- a/bsd-core/drmP.h +++ b/bsd-core/drmP.h @@ -47,6 +47,9 @@ typedef struct drm_file drm_file_t; #include <sys/systm.h> #include <sys/conf.h> #include <sys/stat.h> +#if __FreeBSD_version >= 700000 +#include <sys/priv.h> +#endif #include <sys/proc.h> #include <sys/lock.h> #include <sys/fcntl.h> @@ -230,7 +233,11 @@ enum { #define PAGE_ALIGN(addr) round_page(addr) /* DRM_SUSER returns true if the user is superuser */ +#if __FreeBSD_version >= 700000 +#define DRM_SUSER(p) (priv_check(p, PRIV_DRIVER) == 0) +#else #define DRM_SUSER(p) (suser(p) == 0) +#endif #define DRM_AGP_FIND_DEVICE() agp_find_device() #define DRM_MTRR_WC MDF_WRITECOMBINE #define jiffies ticks @@ -394,19 +401,6 @@ do { \ } \ } while (0) -#define DRM_GETSAREA() \ -do { \ - drm_local_map_t *map; \ - DRM_SPINLOCK_ASSERT(&dev->dev_lock); \ - TAILQ_FOREACH(map, &dev->maplist, link) { \ - if (map->type == _DRM_SHM && \ - map->flags & _DRM_CONTAINS_LOCK) { \ - dev_priv->sarea = map; \ - break; \ - } \ - } \ -} while (0) - #if defined(__FreeBSD__) && __FreeBSD_version > 500000 #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ for ( ret = 0 ; !ret && !(condition) ; ) { \ @@ -627,12 +621,17 @@ typedef struct drm_vbl_sig { #define DRM_ATI_GART_MAIN 1 #define DRM_ATI_GART_FB 2 +#define DRM_ATI_GART_PCI 1 +#define DRM_ATI_GART_PCIE 2 +#define DRM_ATI_GART_IGP 3 + typedef struct ati_pcigart_info { int gart_table_location; - int is_pcie; + int gart_reg_if; void *addr; dma_addr_t bus_addr; drm_local_map_t mapping; + int table_size; } drm_ati_pcigart_info; struct drm_driver_info { @@ -822,6 +821,7 @@ dev_type_read(drm_read); dev_type_poll(drm_poll); dev_type_mmap(drm_mmap); #endif +extern drm_local_map_t *drm_getsarea(drm_device_t *dev); /* File operations helpers (drm_fops.c) */ #ifdef __FreeBSD__ @@ -915,6 +915,7 @@ int drm_agp_unbind(drm_device_t *dev, drm_agp_binding_t *request); /* Scatter Gather Support (drm_scatter.c) */ void drm_sg_cleanup(drm_sg_mem_t *entry); +int drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request); #ifdef __FreeBSD__ /* sysctl support (drm_sysctl.h) */ @@ -989,7 +990,7 @@ int drm_agp_unbind_ioctl(DRM_IOCTL_ARGS); int drm_agp_bind_ioctl(DRM_IOCTL_ARGS); /* Scatter Gather Support (drm_scatter.c) */ -int drm_sg_alloc(DRM_IOCTL_ARGS); +int drm_sg_alloc_ioctl(DRM_IOCTL_ARGS); int drm_sg_free(DRM_IOCTL_ARGS); /* consistent PCI memory functions (drm_pci.c) */ diff --git a/bsd-core/drm_agpsupport.c b/bsd-core/drm_agpsupport.c index 0406f50e..28239d1b 100644 --- a/bsd-core/drm_agpsupport.c +++ b/bsd-core/drm_agpsupport.c @@ -43,7 +43,7 @@ static int drm_device_find_capability(drm_device_t *dev, int cap) { #ifdef __FreeBSD__ -#if __FreeBSD_version >= 700010 +#if __FreeBSD_version >= 602102 return (pci_find_extcap(dev->device, cap, NULL) == 0); #else diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c index 9fb10c53..069774c1 100644 --- a/bsd-core/drm_drv.c +++ b/bsd-core/drm_drv.c @@ -117,7 +117,7 @@ static drm_ioctl_desc_t drm_ioctls[256] = { [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, - [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { drm_sg_alloc, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, + [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { drm_sg_alloc_ioctl, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { drm_sg_free, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY }, [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { drm_wait_vblank, 0 }, @@ -912,6 +912,18 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags, return DRM_ERR(retcode); } +drm_local_map_t *drm_getsarea(drm_device_t *dev) +{ + drm_local_map_t *map; + + DRM_SPINLOCK_ASSERT(&dev->dev_lock); + TAILQ_FOREACH(map, &dev->maplist, link) { + if (map->type == _DRM_SHM && (map->flags & _DRM_CONTAINS_LOCK)) + return map; + } + + return NULL; +} #if DRM_LINUX 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; } |