Commit c25f5e81 authored by Dave Airlie's avatar Dave Airlie

From Eric Anholt: some cleanups from AlanH:

- Tie the DRM to a specific device: setunique no longer succeeds when given
a busid that doesn't correspond to the device the DRM is attached to. This
is a breaking of backwards-compatibility only for the multiple-DRI-head case
with X Servers that don't use interface 1.1.
- Move irq_busid to drm_irq.h and make it only return the IRQ for the current
device. Retains compatibility with previous X Servers, cleans up unnecessary
code. This means no irq_busid on !__HAVE_IRQ, but can be changed if
necessary.
- Bump interface version to 1.2. This version when set signifies that the
control ioctl should ignore the irq number passed in and enable the
interrupt handler for the attached device. Otherwise it errors out when
the passed-in irq is not equal to the device's.
- Store the highest version the interface has been set to in the device. 
parent 3b7273f0
...@@ -324,6 +324,7 @@ do { \ ...@@ -324,6 +324,7 @@ do { \
#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x)) #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
#define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist) #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
/** /**
* Get the private SAREA mapping. * Get the private SAREA mapping.
* *
...@@ -628,6 +629,7 @@ typedef struct drm_device { ...@@ -628,6 +629,7 @@ typedef struct drm_device {
dev_t device; /**< Device number for mknod */ dev_t device; /**< Device number for mknod */
char *devname; /**< For /proc/interrupts */ char *devname; /**< For /proc/interrupts */
int minor; /**< Minor device number */ int minor; /**< Minor device number */
int if_version; /**< Highest interface version set */
int blocked; /**< Blocked due to VC switch? */ int blocked; /**< Blocked due to VC switch? */
struct proc_dir_entry *root; /**< Root for this device's entries */ struct proc_dir_entry *root; /**< Root for this device's entries */
...@@ -685,6 +687,7 @@ typedef struct drm_device { ...@@ -685,6 +687,7 @@ typedef struct drm_device {
/** \name Context support */ /** \name Context support */
/*@{*/ /*@{*/
int irq; /**< Interrupt used by board */ int irq; /**< Interrupt used by board */
int irq_enabled; /**< True if irq handler is enabled */
__volatile__ long context_flag; /**< Context swapping flag */ __volatile__ long context_flag; /**< Context swapping flag */
__volatile__ long interrupt_flag; /**< Interruption handler flag */ __volatile__ long interrupt_flag; /**< Interruption handler flag */
__volatile__ long dma_flag; /**< DMA dispatch flag */ __volatile__ long dma_flag; /**< DMA dispatch flag */
...@@ -720,7 +723,12 @@ typedef struct drm_device { ...@@ -720,7 +723,12 @@ typedef struct drm_device {
#if __REALLY_HAVE_AGP #if __REALLY_HAVE_AGP
drm_agp_head_t *agp; /**< AGP data */ drm_agp_head_t *agp; /**< AGP data */
#endif #endif
struct pci_dev *pdev; /**< PCI device structure */
struct pci_dev *pdev; /**< PCI device structure */
int pci_domain; /**< PCI bus domain number */
int pci_bus; /**< PCI bus number */
int pci_slot; /**< PCI slot number */
int pci_func; /**< PCI function number */
#ifdef __alpha__ #ifdef __alpha__
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3)
struct pci_controler *hose; struct pci_controler *hose;
...@@ -810,8 +818,8 @@ extern int DRM(unbind_agp)(DRM_AGP_MEM *handle); ...@@ -810,8 +818,8 @@ extern int DRM(unbind_agp)(DRM_AGP_MEM *handle);
#endif #endif
/* Misc. IOCTL support (drm_ioctl.h) */ /* Misc. IOCTL support (drm_ioctl.h) */
extern int DRM(irq_busid)(struct inode *inode, struct file *filp, extern int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int DRM(getunique)(struct inode *inode, struct file *filp, extern int DRM(getunique)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int DRM(setunique)(struct inode *inode, struct file *filp, extern int DRM(setunique)(struct inode *inode, struct file *filp,
...@@ -916,7 +924,7 @@ extern int DRM(control)( struct inode *inode, struct file *filp, ...@@ -916,7 +924,7 @@ extern int DRM(control)( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg ); unsigned int cmd, unsigned long arg );
#endif #endif
#if __HAVE_IRQ #if __HAVE_IRQ
extern int DRM(irq_install)( drm_device_t *dev, int irq ); extern int DRM(irq_install)( drm_device_t *dev );
extern int DRM(irq_uninstall)( drm_device_t *dev ); extern int DRM(irq_uninstall)( drm_device_t *dev );
extern irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS ); extern irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS );
extern void DRM(driver_irq_preinstall)( drm_device_t *dev ); extern void DRM(driver_irq_preinstall)( drm_device_t *dev );
......
...@@ -173,7 +173,9 @@ static drm_ioctl_desc_t DRM(ioctls)[] = { ...@@ -173,7 +173,9 @@ static drm_ioctl_desc_t DRM(ioctls)[] = {
[DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_busid), 0, 1 }, #if __HAVE_IRQ
[DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_by_busid), 0, 1 },
#endif
[DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 },
...@@ -334,7 +336,7 @@ static int DRM(setup)( drm_device_t *dev ) ...@@ -334,7 +336,7 @@ static int DRM(setup)( drm_device_t *dev )
dev->queue_reserved = 0; dev->queue_reserved = 0;
dev->queue_slots = 0; dev->queue_slots = 0;
dev->queuelist = NULL; dev->queuelist = NULL;
dev->irq = 0; dev->irq_enabled = 0;
dev->context_flag = 0; dev->context_flag = 0;
dev->interrupt_flag = 0; dev->interrupt_flag = 0;
dev->dma_flag = 0; dev->dma_flag = 0;
...@@ -342,6 +344,7 @@ static int DRM(setup)( drm_device_t *dev ) ...@@ -342,6 +344,7 @@ static int DRM(setup)( drm_device_t *dev )
dev->last_switch = 0; dev->last_switch = 0;
dev->last_checked = 0; dev->last_checked = 0;
init_waitqueue_head( &dev->context_wait ); init_waitqueue_head( &dev->context_wait );
dev->if_version = 0;
dev->ctx_start = 0; dev->ctx_start = 0;
dev->lck_start = 0; dev->lck_start = 0;
...@@ -389,7 +392,7 @@ static int DRM(takedown)( drm_device_t *dev ) ...@@ -389,7 +392,7 @@ static int DRM(takedown)( drm_device_t *dev )
DRIVER_PRETAKEDOWN(); DRIVER_PRETAKEDOWN();
#if __HAVE_IRQ #if __HAVE_IRQ
if ( dev->irq ) DRM(irq_uninstall)( dev ); if ( dev->irq_enabled ) DRM(irq_uninstall)( dev );
#endif #endif
down( &dev->struct_sem ); down( &dev->struct_sem );
...@@ -573,7 +576,14 @@ static int DRM(probe)(struct pci_dev *pdev) ...@@ -573,7 +576,14 @@ static int DRM(probe)(struct pci_dev *pdev)
dev->pdev = pdev; dev->pdev = pdev;
#ifdef __alpha__ #ifdef __alpha__
dev->hose = pdev->sysdata; dev->hose = pdev->sysdata;
dev->pci_domain = dev->hose->bus->number;
#else
dev->pci_domain = 0;
#endif #endif
dev->pci_bus = pdev->bus->number;
dev->pci_slot = PCI_SLOT(pdev->devfn);
dev->pci_func = PCI_FUNC(pdev->devfn);
dev->irq = pdev->irq;
DRIVER_PREINIT(); DRIVER_PREINIT();
...@@ -626,7 +636,7 @@ static int DRM(probe)(struct pci_dev *pdev) ...@@ -626,7 +636,7 @@ static int DRM(probe)(struct pci_dev *pdev)
* *
* \return zero on success or a negative number on failure. * \return zero on success or a negative number on failure.
* *
* Allocates and initialize an array of drm_device structures, and attempts to * Initializes an array of drm_device structures, and attempts to
* initialize all available devices, using consecutive minors, registering the * initialize all available devices, using consecutive minors, registering the
* stubs and initializing the AGP device. * stubs and initializing the AGP device.
* *
......
...@@ -37,69 +37,6 @@ ...@@ -37,69 +37,6 @@
#include "linux/pci.h" #include "linux/pci.h"
/**
* Get interrupt from bus id.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_irq_busid structure.
* \return zero on success or a negative number on failure.
*
* Finds the PCI device with the specified bus id and gets its IRQ number.
*/
int DRM(irq_busid)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_irq_busid_t p;
struct pci_dev *dev;
if (copy_from_user(&p, (drm_irq_busid_t *)arg, sizeof(p)))
return -EFAULT;
#ifdef __alpha__
{
int domain = p.busnum >> 8;
p.busnum &= 0xff;
/*
* Find the hose the device is on (the domain number is the
* hose index) and offset the bus by the root bus of that
* hose.
*/
for(dev = pci_find_device(PCI_ANY_ID,PCI_ANY_ID,NULL);
dev;
dev = pci_find_device(PCI_ANY_ID,PCI_ANY_ID,dev)) {
struct pci_controller *hose = dev->sysdata;
if (hose->index == domain) {
p.busnum += hose->bus->number;
break;
}
}
}
#endif
dev = pci_find_slot(p.busnum, PCI_DEVFN(p.devnum, p.funcnum));
if (!dev) {
DRM_ERROR("pci_find_slot failed for %d:%d:%d\n",
p.busnum, p.devnum, p.funcnum);
p.irq = 0;
goto out;
}
if (pci_enable_device(dev) != 0) {
DRM_ERROR("pci_enable_device failed for %d:%d:%d\n",
p.busnum, p.devnum, p.funcnum);
p.irq = 0;
goto out;
}
p.irq = dev->irq;
out:
DRM_DEBUG("%d:%d:%d => IRQ %d\n",
p.busnum, p.devnum, p.funcnum, p.irq);
if (copy_to_user((drm_irq_busid_t *)arg, &p, sizeof(p)))
return -EFAULT;
return 0;
}
/** /**
* Get the bus id. * Get the bus id.
* *
...@@ -139,9 +76,9 @@ int DRM(getunique)(struct inode *inode, struct file *filp, ...@@ -139,9 +76,9 @@ int DRM(getunique)(struct inode *inode, struct file *filp,
* \param arg user argument, pointing to a drm_unique structure. * \param arg user argument, pointing to a drm_unique structure.
* \return zero on success or a negative number on failure. * \return zero on success or a negative number on failure.
* *
* Copies the bus id from userspace into drm_device::unique, and searches for * Copies the bus id from userspace into drm_device::unique, and verifies that
* the respective PCI device, updating drm_device::pdev. Deprecated in * it matches the device this DRM is attached to (EINVAL otherwise). Deprecated
* interface version 1.1 and will return EBUSY when setversion has requested * in interface version 1.1 and will return EBUSY when setversion has requested
* version 1.1 or greater. * version 1.1 or greater.
*/ */
int DRM(setunique)(struct inode *inode, struct file *filp, int DRM(setunique)(struct inode *inode, struct file *filp,
...@@ -150,6 +87,7 @@ int DRM(setunique)(struct inode *inode, struct file *filp, ...@@ -150,6 +87,7 @@ int DRM(setunique)(struct inode *inode, struct file *filp,
drm_file_t *priv = filp->private_data; drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev; drm_device_t *dev = priv->dev;
drm_unique_t u; drm_unique_t u;
int domain, bus, slot, func, ret;
if (dev->unique_len || dev->unique) return -EBUSY; if (dev->unique_len || dev->unique) return -EBUSY;
...@@ -167,55 +105,25 @@ int DRM(setunique)(struct inode *inode, struct file *filp, ...@@ -167,55 +105,25 @@ int DRM(setunique)(struct inode *inode, struct file *filp,
dev->devname = DRM(alloc)(strlen(dev->name) + strlen(dev->unique) + 2, dev->devname = DRM(alloc)(strlen(dev->name) + strlen(dev->unique) + 2,
DRM_MEM_DRIVER); DRM_MEM_DRIVER);
if(!dev->devname) { if (!dev->devname)
DRM(free)(dev->devname, sizeof(*dev->devname), DRM_MEM_DRIVER);
return -ENOMEM; return -ENOMEM;
}
sprintf(dev->devname, "%s@%s", dev->name, dev->unique);
do { sprintf(dev->devname, "%s@%s", dev->name, dev->unique);
struct pci_dev *pci_dev;
int domain, b, d, f;
char *p;
for(p = dev->unique; p && *p && *p != ':'; p++);
if (!p || !*p) break;
b = (int)simple_strtoul(p+1, &p, 10);
if (*p != ':') break;
d = (int)simple_strtoul(p+1, &p, 10);
if (*p != ':') break;
f = (int)simple_strtoul(p+1, &p, 10);
if (*p) break;
domain = b >> 8;
b &= 0xff;
#ifdef __alpha__
/*
* Find the hose the device is on (the domain number is the
* hose index) and offset the bus by the root bus of that
* hose.
*/
for(pci_dev = pci_find_device(PCI_ANY_ID,PCI_ANY_ID,NULL);
pci_dev;
pci_dev = pci_find_device(PCI_ANY_ID,PCI_ANY_ID,pci_dev)) {
struct pci_controller *hose = pci_dev->sysdata;
if (hose->index == domain) {
b += hose->bus->number;
break;
}
}
#endif
pci_dev = pci_find_slot(b, PCI_DEVFN(d,f)); /* Return error if the busid submitted doesn't match the device's actual
if (pci_dev) { * busid.
dev->pdev = pci_dev; */
#ifdef __alpha__ ret = sscanf(dev->unique, "PCI:%d:%d:%d", &bus, &slot, &func);
dev->hose = pci_dev->sysdata; if (ret != 3)
#endif return DRM_ERR(EINVAL);
} domain = bus >> 8;
} while(0); bus &= 0xff;
if ((domain != dev->pci_domain) ||
(bus != dev->pci_bus) ||
(slot != dev->pci_slot) ||
(func != dev->pci_func))
return -EINVAL;
return 0; return 0;
} }
...@@ -231,21 +139,8 @@ DRM(set_busid)(drm_device_t *dev) ...@@ -231,21 +139,8 @@ DRM(set_busid)(drm_device_t *dev)
if (dev->unique == NULL) if (dev->unique == NULL)
return ENOMEM; return ENOMEM;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74) snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d",
snprintf(dev->unique, dev->unique_len, "pci:%s", pci_name(dev->pdev)); dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func);
#else
{
int domain = 0;
#ifdef __alpha__
struct pci_controller *hose = pci_dev->sysdata;
domain = hose->bus->number;
#endif
snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d",
domain, dev->pdev->bus->number,
PCI_SLOT(dev->pdev->devfn), PCI_FUNC(dev->pdev->devfn));
}
#endif
return 0; return 0;
} }
...@@ -397,26 +292,31 @@ int DRM(getstats)( struct inode *inode, struct file *filp, ...@@ -397,26 +292,31 @@ int DRM(getstats)( struct inode *inode, struct file *filp,
return 0; return 0;
} }
#define DRM_IF_MAJOR 1
#define DRM_IF_MINOR 2
int DRM(setversion)(DRM_IOCTL_ARGS) int DRM(setversion)(DRM_IOCTL_ARGS)
{ {
DRM_DEVICE; DRM_DEVICE;
drm_set_version_t sv; drm_set_version_t sv;
drm_set_version_t retv; drm_set_version_t retv;
int if_version;
DRM_COPY_FROM_USER_IOCTL(sv, (drm_set_version_t *)data, sizeof(sv)); DRM_COPY_FROM_USER_IOCTL(sv, (drm_set_version_t *)data, sizeof(sv));
retv.drm_di_major = 1; retv.drm_di_major = DRM_IF_MAJOR;
retv.drm_di_minor = 1; retv.drm_di_minor = DRM_IF_MINOR;
retv.drm_dd_major = DRIVER_MAJOR; retv.drm_dd_major = DRIVER_MAJOR;
retv.drm_dd_minor = DRIVER_MINOR; retv.drm_dd_minor = DRIVER_MINOR;
DRM_COPY_TO_USER_IOCTL((drm_set_version_t *)data, retv, sizeof(sv)); DRM_COPY_TO_USER_IOCTL((drm_set_version_t *)data, retv, sizeof(sv));
if (sv.drm_di_major != -1) { if (sv.drm_di_major != -1) {
if (sv.drm_di_major != 1 || sv.drm_di_minor < 0) if (sv.drm_di_major != DRM_IF_MAJOR ||
return EINVAL; sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR)
if (sv.drm_di_minor > 1)
return EINVAL; return EINVAL;
if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_dd_minor);
dev->if_version = DRM_MAX(if_version, dev->if_version);
if (sv.drm_di_minor >= 1) { if (sv.drm_di_minor >= 1) {
/* /*
* Version 1.1 includes tying of DRM to specific device * Version 1.1 includes tying of DRM to specific device
...@@ -426,12 +326,11 @@ int DRM(setversion)(DRM_IOCTL_ARGS) ...@@ -426,12 +326,11 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
} }
if (sv.drm_dd_major != -1) { if (sv.drm_dd_major != -1) {
if (sv.drm_dd_major != DRIVER_MAJOR || sv.drm_dd_minor < 0) if (sv.drm_dd_major != DRIVER_MAJOR ||
return EINVAL; sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR)
if (sv.drm_dd_minor > DRIVER_MINOR)
return EINVAL; return EINVAL;
#ifdef DRIVER_SETVERSION #ifdef DRIVER_SETVERSION
DRIVER_SETVERSION(dev, sv); DRIVER_SETVERSION(dev, &sv);
#endif #endif
} }
return 0; return 0;
......
...@@ -48,6 +48,44 @@ ...@@ -48,6 +48,44 @@
#define DRM_IRQ_TYPE 0 #define DRM_IRQ_TYPE 0
#endif #endif
/**
* Get interrupt from bus id.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_irq_busid structure.
* \return zero on success or a negative number on failure.
*
* Finds the PCI device with the specified bus id and gets its IRQ number.
* This IOCTL is deprecated, and will now return EINVAL for any busid not equal
* to that of the device that this DRM instance attached to.
*/
int DRM(irq_by_busid)(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
drm_irq_busid_t p;
if (copy_from_user(&p, (drm_irq_busid_t *)arg, sizeof(p)))
return -EFAULT;
if ((p.busnum >> 8) != dev->pci_domain ||
(p.busnum & 0xff) != dev->pci_bus ||
p.devnum != dev->pci_slot ||
p.funcnum != dev->pci_func)
return -EINVAL;
p.irq = dev->irq;
DRM_DEBUG("%d:%d:%d => IRQ %d\n",
p.busnum, p.devnum, p.funcnum, p.irq);
if (copy_to_user((drm_irq_busid_t *)arg, &p, sizeof(p)))
return -EFAULT;
return 0;
}
#if __HAVE_IRQ #if __HAVE_IRQ
/** /**
...@@ -60,11 +98,11 @@ ...@@ -60,11 +98,11 @@
* \c DRM(driver_irq_preinstall)() and \c DRM(driver_irq_postinstall)() functions * \c DRM(driver_irq_preinstall)() and \c DRM(driver_irq_postinstall)() functions
* before and after the installation. * before and after the installation.
*/ */
int DRM(irq_install)( drm_device_t *dev, int irq ) int DRM(irq_install)( drm_device_t *dev )
{ {
int ret; int ret;
if ( !irq ) if ( dev->irq == 0 )
return -EINVAL; return -EINVAL;
down( &dev->struct_sem ); down( &dev->struct_sem );
...@@ -75,22 +113,20 @@ int DRM(irq_install)( drm_device_t *dev, int irq ) ...@@ -75,22 +113,20 @@ int DRM(irq_install)( drm_device_t *dev, int irq )
return -EINVAL; return -EINVAL;
} }
if ( dev->irq ) { if ( dev->irq_enabled ) {
up( &dev->struct_sem ); up( &dev->struct_sem );
return -EBUSY; return -EBUSY;
} }
dev->irq = irq; dev->irq_enabled = 1;
up( &dev->struct_sem ); up( &dev->struct_sem );
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, irq ); DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
dev->context_flag = 0;
dev->interrupt_flag = 0;
dev->dma_flag = 0;
#if __HAVE_DMA
dev->dma->next_buffer = NULL; dev->dma->next_buffer = NULL;
dev->dma->next_queue = NULL; dev->dma->next_queue = NULL;
dev->dma->this_buffer = NULL; dev->dma->this_buffer = NULL;
#endif
#if __HAVE_IRQ_BH #if __HAVE_IRQ_BH
INIT_WORK(&dev->work, DRM(irq_immediate_bh), dev); INIT_WORK(&dev->work, DRM(irq_immediate_bh), dev);
...@@ -114,7 +150,7 @@ int DRM(irq_install)( drm_device_t *dev, int irq ) ...@@ -114,7 +150,7 @@ int DRM(irq_install)( drm_device_t *dev, int irq )
DRM_IRQ_TYPE, dev->devname, dev ); DRM_IRQ_TYPE, dev->devname, dev );
if ( ret < 0 ) { if ( ret < 0 ) {
down( &dev->struct_sem ); down( &dev->struct_sem );
dev->irq = 0; dev->irq_enabled = 0;
up( &dev->struct_sem ); up( &dev->struct_sem );
return ret; return ret;
} }
...@@ -134,21 +170,21 @@ int DRM(irq_install)( drm_device_t *dev, int irq ) ...@@ -134,21 +170,21 @@ int DRM(irq_install)( drm_device_t *dev, int irq )
*/ */
int DRM(irq_uninstall)( drm_device_t *dev ) int DRM(irq_uninstall)( drm_device_t *dev )
{ {
int irq; int irq_enabled;
down( &dev->struct_sem ); down( &dev->struct_sem );
irq = dev->irq; irq_enabled = dev->irq_enabled;
dev->irq = 0; dev->irq_enabled = 0;
up( &dev->struct_sem ); up( &dev->struct_sem );
if ( !irq ) if ( !irq_enabled )
return -EINVAL; return -EINVAL;
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, irq ); DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
DRM(driver_irq_uninstall)( dev ); DRM(driver_irq_uninstall)( dev );
free_irq( irq, dev ); free_irq( dev->irq, dev );
return 0; return 0;
} }
...@@ -176,7 +212,10 @@ int DRM(control)( struct inode *inode, struct file *filp, ...@@ -176,7 +212,10 @@ int DRM(control)( struct inode *inode, struct file *filp,
switch ( ctl.func ) { switch ( ctl.func ) {
case DRM_INST_HANDLER: case DRM_INST_HANDLER:
return DRM(irq_install)( dev, ctl.irq ); if (dev->if_version < DRM_IF_VERSION(1, 2) &&
ctl.irq != dev->irq)
return -EINVAL;
return DRM(irq_install)( dev );
case DRM_UNINST_HANDLER: case DRM_UNINST_HANDLER:
return DRM(irq_uninstall)( dev ); return DRM(irq_uninstall)( dev );
default: default:
......
...@@ -661,7 +661,7 @@ int gamma_do_cleanup_dma( drm_device_t *dev ) ...@@ -661,7 +661,7 @@ int gamma_do_cleanup_dma( drm_device_t *dev )
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if ( dev->irq ) DRM(irq_uninstall)(dev); if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#endif #endif
if ( dev->dev_private ) { if ( dev->dev_private ) {
......
...@@ -237,7 +237,7 @@ int i810_dma_cleanup(drm_device_t *dev) ...@@ -237,7 +237,7 @@ int i810_dma_cleanup(drm_device_t *dev)
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if (dev->irq) DRM(irq_uninstall)(dev); if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#endif #endif
if (dev->dev_private) { if (dev->dev_private) {
......
...@@ -236,7 +236,7 @@ int i830_dma_cleanup(drm_device_t *dev) ...@@ -236,7 +236,7 @@ int i830_dma_cleanup(drm_device_t *dev)
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if (dev->irq) DRM(irq_uninstall)(dev); if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#endif #endif
if (dev->dev_private) { if (dev->dev_private) {
...@@ -1539,7 +1539,7 @@ int i830_getparam( struct inode *inode, struct file *filp, unsigned int cmd, ...@@ -1539,7 +1539,7 @@ int i830_getparam( struct inode *inode, struct file *filp, unsigned int cmd,
switch( param.param ) { switch( param.param ) {
case I830_PARAM_IRQ_ACTIVE: case I830_PARAM_IRQ_ACTIVE:
value = dev->irq ? 1 : 0; value = dev->irq_enabled;
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
...@@ -644,7 +644,7 @@ int mga_do_cleanup_dma( drm_device_t *dev ) ...@@ -644,7 +644,7 @@ int mga_do_cleanup_dma( drm_device_t *dev )
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if ( dev->irq ) DRM(irq_uninstall)(dev); if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#endif #endif
if ( dev->dev_private ) { if ( dev->dev_private ) {
......
...@@ -620,7 +620,7 @@ int r128_do_cleanup_cce( drm_device_t *dev ) ...@@ -620,7 +620,7 @@ int r128_do_cleanup_cce( drm_device_t *dev )
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if ( dev->irq ) DRM(irq_uninstall)(dev); if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#endif #endif
if ( dev->dev_private ) { if ( dev->dev_private ) {
......
...@@ -1287,7 +1287,7 @@ int radeon_do_cleanup_cp( drm_device_t *dev ) ...@@ -1287,7 +1287,7 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
* may not have been called from userspace and after dev_private * may not have been called from userspace and after dev_private
* is freed, it's too late. * is freed, it's too late.
*/ */
if ( dev->irq ) DRM(irq_uninstall)(dev); if ( dev->irq_enabled ) DRM(irq_uninstall)(dev);
#endif #endif
if ( dev->dev_private ) { if ( dev->dev_private ) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment