From 36050cc958596ca81d667d8a51e124e9ea9eb866 Mon Sep 17 00:00:00 2001 From: Jon Smirl Date: Sun, 12 Sep 2004 03:23:50 +0000 Subject: Fix DRM to compile cleanly with recent kernel changes in PCI IO and DRM_COPY_FROM_USER. PCI IO changes in 2.6.9-rc1 bk currently. --- linux-core/drm_os_linux.h | 15 +++++++++++++++ linux/drm_os_linux.h | 15 +++++++++++++++ shared-core/via_dma.c | 6 ++++-- shared/via_dma.c | 6 ++++-- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/linux-core/drm_os_linux.h b/linux-core/drm_os_linux.h index ab16d7b3..7e53e0d5 100644 --- a/linux-core/drm_os_linux.h +++ b/linux-core/drm_os_linux.h @@ -15,6 +15,7 @@ /** Current process ID */ #define DRM_CURRENTPID current->pid #define DRM_UDELAY(d) udelay(d) +#if LINUX_VERSION_CODE <= 0x020608 /* KERNEL_VERSION(2,4,14) */ /** Read a byte from a MMIO region */ #define DRM_READ8(map, offset) readb(((unsigned long)(map)->handle) + (offset)) /** Read a word from a MMIO region */ @@ -27,6 +28,20 @@ #define DRM_WRITE16(map, offset, val) writew(val, ((unsigned long)(map)->handle) + (offset)) /** Write a dword into a MMIO region */ #define DRM_WRITE32(map, offset, val) writel(val, ((unsigned long)(map)->handle) + (offset)) +#else +/** Read a byte from a MMIO region */ +#define DRM_READ8(map, offset) readb((map)->handle + (offset)) +/** Read a word from a MMIO region */ +#define DRM_READ16(map, offset) readw((map)->handle + (offset)) +/** Read a dword from a MMIO region */ +#define DRM_READ32(map, offset) readl((map)->handle + (offset)) +/** Write a byte into a MMIO region */ +#define DRM_WRITE8(map, offset, val) writeb(val, (map)->handle + (offset)) +/** Write a word into a MMIO region */ +#define DRM_WRITE16(map, offset, val) writew(val, (map)->handle + (offset)) +/** Write a dword into a MMIO region */ +#define DRM_WRITE32(map, offset, val) writel(val, (map)->handle + (offset)) +#endif /** Read memory barrier */ #define DRM_READMEMORYBARRIER() rmb() /** Write memory barrier */ diff --git a/linux/drm_os_linux.h b/linux/drm_os_linux.h index ab16d7b3..7e53e0d5 100644 --- a/linux/drm_os_linux.h +++ b/linux/drm_os_linux.h @@ -15,6 +15,7 @@ /** Current process ID */ #define DRM_CURRENTPID current->pid #define DRM_UDELAY(d) udelay(d) +#if LINUX_VERSION_CODE <= 0x020608 /* KERNEL_VERSION(2,4,14) */ /** Read a byte from a MMIO region */ #define DRM_READ8(map, offset) readb(((unsigned long)(map)->handle) + (offset)) /** Read a word from a MMIO region */ @@ -27,6 +28,20 @@ #define DRM_WRITE16(map, offset, val) writew(val, ((unsigned long)(map)->handle) + (offset)) /** Write a dword into a MMIO region */ #define DRM_WRITE32(map, offset, val) writel(val, ((unsigned long)(map)->handle) + (offset)) +#else +/** Read a byte from a MMIO region */ +#define DRM_READ8(map, offset) readb((map)->handle + (offset)) +/** Read a word from a MMIO region */ +#define DRM_READ16(map, offset) readw((map)->handle + (offset)) +/** Read a dword from a MMIO region */ +#define DRM_READ32(map, offset) readl((map)->handle + (offset)) +/** Write a byte into a MMIO region */ +#define DRM_WRITE8(map, offset, val) writeb(val, (map)->handle + (offset)) +/** Write a word into a MMIO region */ +#define DRM_WRITE16(map, offset, val) writew(val, (map)->handle + (offset)) +/** Write a dword into a MMIO region */ +#define DRM_WRITE32(map, offset, val) writel(val, (map)->handle + (offset)) +#endif /** Read memory barrier */ #define DRM_READMEMORYBARRIER() rmb() /** Write memory barrier */ diff --git a/shared-core/via_dma.c b/shared-core/via_dma.c index c11652c0..4afc5215 100644 --- a/shared-core/via_dma.c +++ b/shared-core/via_dma.c @@ -275,11 +275,13 @@ static int via_dispatch_pci_cmdbuffer(drm_device_t *dev, } else if ( cmd->size > VIA_PREALLOCATED_PCI_SIZE ) { if (NULL == (hugebuf = (char *) kmalloc( cmd-> size, GFP_KERNEL ))) return DRM_ERR( ENOMEM ); - DRM_COPY_FROM_USER( hugebuf, cmd->buf, cmd->size ); + if (DRM_COPY_FROM_USER( hugebuf, cmd->buf, cmd->size )) + return DRM_ERR(EFAULT); ret = via_parse_pci_cmdbuffer( dev, hugebuf, cmd->size ); kfree( hugebuf ); } else { - DRM_COPY_FROM_USER( dev_priv->pci_buf, cmd->buf, cmd->size ); + if (DRM_COPY_FROM_USER( dev_priv->pci_buf, cmd->buf, cmd->size )) + return DRM_ERR(EFAULT); ret = via_parse_pci_cmdbuffer( dev, dev_priv->pci_buf, cmd->size ); } return ret; diff --git a/shared/via_dma.c b/shared/via_dma.c index c11652c0..4afc5215 100644 --- a/shared/via_dma.c +++ b/shared/via_dma.c @@ -275,11 +275,13 @@ static int via_dispatch_pci_cmdbuffer(drm_device_t *dev, } else if ( cmd->size > VIA_PREALLOCATED_PCI_SIZE ) { if (NULL == (hugebuf = (char *) kmalloc( cmd-> size, GFP_KERNEL ))) return DRM_ERR( ENOMEM ); - DRM_COPY_FROM_USER( hugebuf, cmd->buf, cmd->size ); + if (DRM_COPY_FROM_USER( hugebuf, cmd->buf, cmd->size )) + return DRM_ERR(EFAULT); ret = via_parse_pci_cmdbuffer( dev, hugebuf, cmd->size ); kfree( hugebuf ); } else { - DRM_COPY_FROM_USER( dev_priv->pci_buf, cmd->buf, cmd->size ); + if (DRM_COPY_FROM_USER( dev_priv->pci_buf, cmd->buf, cmd->size )) + return DRM_ERR(EFAULT); ret = via_parse_pci_cmdbuffer( dev, dev_priv->pci_buf, cmd->size ); } return ret; -- cgit v1.2.3