summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2008-11-24 04:21:32 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2008-11-24 04:21:32 +0000
commit70726140b5f5aeb5d0261c046b8541c97ac47d29 (patch)
tree5a21cffaf0b6a31b5684bf0c6b83b9a5651ce246
parenta43cdb6fcb92bf96c215850a16e23b90fc13b585 (diff)
change drm_attach_mi to drm_attach_pci. we take the pci_attach_args, and
setup the drm_attach_args with the needed information. require interface version 1.1 libdrm has been requesting it for ages), which means that we can set the busid string at attach time. (generated in drm_attach_pci), also pass in the interrupt line and bst. Now we don't need dev->pa at all, so remove it, finally.
-rw-r--r--sys/dev/pci/drm/drmP.h18
-rw-r--r--sys/dev/pci/drm/drm_drv.c39
-rw-r--r--sys/dev/pci/drm/drm_ioctl.c105
-rw-r--r--sys/dev/pci/drm/drm_irq.c11
-rw-r--r--sys/dev/pci/drm/drm_memory.c2
-rw-r--r--sys/dev/pci/drm/i915_drv.c3
-rw-r--r--sys/dev/pci/drm/mach64_drv.c3
-rw-r--r--sys/dev/pci/drm/mga_drv.c3
-rw-r--r--sys/dev/pci/drm/r128_drv.c3
-rw-r--r--sys/dev/pci/drm/radeon_drv.c3
-rw-r--r--sys/dev/pci/drm/savage_drv.c3
-rw-r--r--sys/dev/pci/drm/sis_drv.c3
-rw-r--r--sys/dev/pci/drm/tdfx_drv.c2
13 files changed, 51 insertions, 147 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index d070ee8fa4c..107cf93653f 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -486,6 +486,7 @@ struct drm_device {
const struct drm_driver_info *driver;
bus_dma_tag_t dmat;
+ bus_space_tag_t bst;
char *unique; /* Unique identifier: e.g., busid */
int unique_len; /* Length of unique field */
@@ -518,12 +519,6 @@ struct drm_device {
/* Context support */
int irq; /* Interrupt used by board */
int irq_enabled; /* True if the irq handler is enabled */
- struct pci_attach_args pa;
-
- int pci_domain;
- int pci_bus;
- int pci_slot;
- int pci_func;
/* VBLANK support */
int num_crtcs; /* number of crtcs */
@@ -548,18 +543,20 @@ struct drm_device {
struct drm_attach_args {
const struct drm_driver_info *driver;
- struct pci_attach_args *pa;
- struct vga_pci_softc *vga;
+ char *busid;
bus_dma_tag_t dmat;
+ bus_space_tag_t bst;
+ size_t busid_len;
int is_agp;
+ u_int8_t irq;
};
extern int drm_debug_flag;
/* Device setup support (drm_drv.c) */
int drm_pciprobe(struct pci_attach_args *, drm_pci_id_list_t * );
-struct device *drm_attach_mi(const struct drm_driver_info *, bus_dma_tag_t,
- struct pci_attach_args *pa, int, struct device *);
+struct device *drm_attach_pci(const struct drm_driver_info *,
+ struct pci_attach_args *, int, struct device *);
dev_type_ioctl(drmioctl);
dev_type_open(drmopen);
dev_type_close(drmclose);
@@ -670,7 +667,6 @@ int drm_setversion(struct drm_device *, void *, struct drm_file *);
/* Misc. IOCTL support (drm_ioctl.c) */
int drm_irq_by_busid(struct drm_device *, void *, struct drm_file *);
int drm_getunique(struct drm_device *, void *, struct drm_file *);
-int drm_setunique(struct drm_device *, void *, struct drm_file *);
int drm_getmap(struct drm_device *, void *, struct drm_file *);
/* Context IOCTL support (drm_context.c) */
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index b9d292c113a..e385230dac8 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -56,16 +56,26 @@ int drm_activate(struct device *, enum devact);
int drmprint(void *, const char *);
struct device *
-drm_attach_mi(const struct drm_driver_info *driver, bus_dma_tag_t dmat,
- struct pci_attach_args *pa, int is_agp, struct device *dev)
+drm_attach_pci(const struct drm_driver_info *driver, struct pci_attach_args *pa,
+ int is_agp, struct device *dev)
{
struct drm_attach_args arg;
arg.driver = driver;
- arg.pa = pa;
- arg.dmat = dmat;
+ arg.dmat = pa->pa_dmat;
+ arg.bst = pa->pa_memt;
+ arg.irq = pa->pa_intrline;
arg.is_agp = is_agp;
+ arg.busid_len = 20;
+ arg.busid = malloc(arg.busid_len + 1, M_DRM, M_NOWAIT);
+ if (arg.busid == NULL) {
+ printf(": no memory for drm\n");
+ return (NULL);
+ }
+ snprintf(arg.busid, arg.busid_len, "pci:%04x:%02x:%02x.%1x",
+ pa->pa_domain, pa->pa_bus, pa->pa_device, pa->pa_function);
+
printf("\n");
return (config_found(dev, &arg, drmprint));
}
@@ -104,20 +114,14 @@ drm_attach(struct device *parent, struct device *self, void *aux)
{
struct drm_device *dev = (struct drm_device *)self;
struct drm_attach_args *da = aux;
- struct pci_attach_args *pa = da->pa;
dev->dev_private = parent;
dev->driver = da->driver;
- /* needed for pci_mapreg_* */
- memcpy(&dev->pa, pa, sizeof(dev->pa));
-
dev->dmat = da->dmat;
- dev->irq = pa->pa_intrline;
- dev->pci_domain = 0;
- dev->pci_bus = pa->pa_bus;
- dev->pci_slot = pa->pa_device;
- dev->pci_func = pa->pa_function;
+ dev->irq = da->irq;
+ dev->unique = da->busid;
+ dev->unique_len = da->busid_len;
rw_init(&dev->dev_lock, "drmdevlk");
mtx_init(&dev->drw_lock, IPL_NONE);
@@ -628,8 +632,6 @@ drmioctl(dev_t kdev, u_long cmd, caddr_t data, int flags,
return (drm_setversion(dev, data, file_priv));
case DRM_IOCTL_IRQ_BUSID:
return (drm_irq_by_busid(dev, data, file_priv));
- case DRM_IOCTL_SET_UNIQUE:
- return (drm_setunique(dev, data, file_priv));
case DRM_IOCTL_AUTH_MAGIC:
return (drm_authmagic(dev, data, file_priv));
case DRM_IOCTL_ADD_MAP:
@@ -666,6 +668,13 @@ drmioctl(dev_t kdev, u_long cmd, caddr_t data, int flags,
return (drm_sg_free(dev, data, file_priv));
case DRM_IOCTL_UPDATE_DRAW:
return (drm_update_draw(dev, data, file_priv));
+ case DRM_IOCTL_SET_UNIQUE:
+ /*
+ * Deprecated in DRM version 1.1, and will return EBUSY
+ * when setversion has
+ * requested version 1.1 or greater.
+ */
+ return (EBUSY);
}
}
if (dev->driver->ioctl != NULL)
diff --git a/sys/dev/pci/drm/drm_ioctl.c b/sys/dev/pci/drm/drm_ioctl.c
index 176d834223f..fc3215d1710 100644
--- a/sys/dev/pci/drm/drm_ioctl.c
+++ b/sys/dev/pci/drm/drm_ioctl.c
@@ -35,8 +35,6 @@
#include "drmP.h"
-int drm_set_busid(struct drm_device *);
-
/*
* Beginning in revision 1.1 of the DRM interface, getunique will return
* a unique in the form pci:oooo:bb:dd.f (o=domain, b=bus, d=device, f=function)
@@ -57,94 +55,6 @@ drm_getunique(struct drm_device *dev, void *data, struct drm_file *file_priv)
return 0;
}
-/* Deprecated in DRM version 1.1, and will return EBUSY when setversion has
- * requested version 1.1 or greater.
- */
-int
-drm_setunique(struct drm_device *dev, void *data, struct drm_file *file_priv)
-{
- struct drm_unique *u = data;
- char *busid;
- int domain, bus, slot, func, ret;
-#if defined (__NetBSD__)
- return EOPNOTSUPP;
-#endif
-
- /* Check and copy in the submitted Bus ID */
- if (!u->unique_len || u->unique_len > 1024)
- return EINVAL;
-
- busid = drm_alloc(u->unique_len + 1, DRM_MEM_DRIVER);
- if (busid == NULL)
- return ENOMEM;
-
- if (DRM_COPY_FROM_USER(busid, u->unique, u->unique_len)) {
- drm_free(busid, u->unique_len + 1, DRM_MEM_DRIVER);
- return EFAULT;
- }
- busid[u->unique_len] = '\0';
-
- /* Return error if the busid submitted doesn't match the device's actual
- * busid.
- */
-#ifdef __FreeBSD__
- ret = sscanf(busid, "PCI:%d:%d:%d", &bus, &slot, &func);
-#endif /* Net and Openbsd don't have sscanf in the kernel this is deprecated anyway. */
-
- if (ret != 3) {
- drm_free(busid, u->unique_len + 1, DRM_MEM_DRIVER);
- return EINVAL;
- }
- domain = bus >> 8;
- bus &= 0xff;
-
- if ((domain != dev->pci_domain) || (bus != dev->pci_bus) ||
- (slot != dev->pci_slot) || (func != dev->pci_func)) {
- drm_free(busid, u->unique_len + 1, DRM_MEM_DRIVER);
- return EINVAL;
- }
-
- /* Actually set the device's busid now. */
- DRM_LOCK();
- if (dev->unique_len || dev->unique) {
- DRM_UNLOCK();
- return EBUSY;
- }
-
- dev->unique_len = u->unique_len;
- dev->unique = busid;
- DRM_UNLOCK();
-
- return 0;
-}
-
-
-int
-drm_set_busid(struct drm_device *dev)
-{
-
- DRM_LOCK();
-
- if (dev->unique != NULL) {
- DRM_UNLOCK();
- return EBUSY;
- }
-
- dev->unique_len = 20;
- dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER);
- if (dev->unique == NULL) {
- DRM_UNLOCK();
- return ENOMEM;
- }
-
- snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%1x",
- dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func);
-
- DRM_UNLOCK();
-
- return 0;
-}
-
int
drm_getmap(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
@@ -199,28 +109,25 @@ drm_setversion(struct drm_device *dev, void *data, struct drm_file *file_priv)
sv->drm_dd_major = dev->driver->major;
sv->drm_dd_minor = dev->driver->minor;
+ /*
+ * We no longer support interface versions less than 1.1, so error
+ * out if the xserver is too old. 1.1 always ties the drm to a
+ * certain busid, this was done on attach
+ */
if (ver.drm_di_major != -1) {
- if (ver.drm_di_major != DRM_IF_MAJOR || ver.drm_di_minor < 0 ||
+ if (ver.drm_di_major != DRM_IF_MAJOR || ver.drm_di_minor < 1 ||
ver.drm_di_minor > DRM_IF_MINOR) {
return EINVAL;
}
if_version = DRM_IF_VERSION(ver.drm_di_major, ver.drm_dd_minor);
dev->if_version = DRM_MAX(if_version, dev->if_version);
- if (ver.drm_di_minor >= 1) {
- /*
- * Version 1.1 includes tying of DRM to specific device
- */
- drm_set_busid(dev);
- }
}
if (ver.drm_dd_major != -1) {
if (ver.drm_dd_major != dev->driver->major ||
ver.drm_dd_minor < 0 ||
ver.drm_dd_minor > dev->driver->minor)
- {
return EINVAL;
- }
}
return 0;
diff --git a/sys/dev/pci/drm/drm_irq.c b/sys/dev/pci/drm/drm_irq.c
index e4eaa8e1718..065ce7449d1 100644
--- a/sys/dev/pci/drm/drm_irq.c
+++ b/sys/dev/pci/drm/drm_irq.c
@@ -43,12 +43,11 @@ drm_irq_by_busid(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
struct drm_irq_busid *irq = data;
- if ((irq->busnum >> 8) != dev->pci_domain ||
- (irq->busnum & 0xff) != dev->pci_bus ||
- irq->devnum != dev->pci_slot ||
- irq->funcnum != dev->pci_func)
- return EINVAL;
-
+ /*
+ * This is only ever called by root as part of a stupid interface.
+ * just hand over the irq without checking the busid. If all clients
+ * can be forced to use interface 1.2 then this can die.
+ */
irq->irq = dev->irq;
DRM_DEBUG("%d:%d:%d => IRQ %d\n", irq->busnum, irq->devnum,
diff --git a/sys/dev/pci/drm/drm_memory.c b/sys/dev/pci/drm/drm_memory.c
index a6f46e0bb7d..fd53412b0dc 100644
--- a/sys/dev/pci/drm/drm_memory.c
+++ b/sys/dev/pci/drm/drm_memory.c
@@ -88,7 +88,7 @@ drm_ioremap(struct drm_device *dev, drm_local_map_t *map)
* to map it.
*/
DRM_DEBUG("AGP map\n");
- map->bst = dev->pa.pa_memt;
+ map->bst = dev->bst;
if (bus_space_map(map->bst, map->offset,
map->size, BUS_SPACE_MAP_LINEAR, &map->bsh)) {
DRM_ERROR("ioremap fail\n");
diff --git a/sys/dev/pci/drm/i915_drv.c b/sys/dev/pci/drm/i915_drv.c
index 43ab7c12fd1..c5cea77a6f1 100644
--- a/sys/dev/pci/drm/i915_drv.c
+++ b/sys/dev/pci/drm/i915_drv.c
@@ -164,8 +164,7 @@ inteldrm_attach(struct device *parent, struct device *self, void *aux)
mtx_init(&dev_priv->user_irq_lock, IPL_BIO);
/* All intel chipsets need to be treated as agp, so just pass one */
- dev_priv->drmdev = drm_attach_mi(&inteldrm_driver, pa->pa_dmat,
- pa, 1, self);
+ dev_priv->drmdev = drm_attach_pci(&inteldrm_driver, pa, 1, self);
}
int
diff --git a/sys/dev/pci/drm/mach64_drv.c b/sys/dev/pci/drm/mach64_drv.c
index 753b9c7c857..f1d6271ef08 100644
--- a/sys/dev/pci/drm/mach64_drv.c
+++ b/sys/dev/pci/drm/mach64_drv.c
@@ -127,8 +127,7 @@ machdrm_attach(struct device *parent, struct device *self, void *aux)
is_agp = pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP,
NULL, NULL);
- dev_priv->drmdev = drm_attach_mi(&machdrm_driver, pa->pa_dmat,
- pa, is_agp, self);
+ dev_priv->drmdev = drm_attach_pci(&machdrm_driver, pa, is_agp, self);
}
int
diff --git a/sys/dev/pci/drm/mga_drv.c b/sys/dev/pci/drm/mga_drv.c
index fbdcbebecbb..0d8580edfc2 100644
--- a/sys/dev/pci/drm/mga_drv.c
+++ b/sys/dev/pci/drm/mga_drv.c
@@ -168,8 +168,7 @@ mgadrm_attach(struct device *parent, struct device *self, void *aux)
return;
}
- dev_priv->drmdev = drm_attach_mi(&mga_driver, pa->pa_dmat, pa,
- is_agp, self);
+ dev_priv->drmdev = drm_attach_pci(&mga_driver, pa, is_agp, self);
}
int
diff --git a/sys/dev/pci/drm/r128_drv.c b/sys/dev/pci/drm/r128_drv.c
index 990858cae82..b84ecc77caf 100644
--- a/sys/dev/pci/drm/r128_drv.c
+++ b/sys/dev/pci/drm/r128_drv.c
@@ -144,8 +144,7 @@ ragedrm_attach(struct device *parent, struct device *self, void *aux)
is_agp = pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP,
NULL, NULL);
- dev_priv->drmdev = drm_attach_mi(&ragedrm_driver, pa->pa_dmat, pa,
- is_agp, self);
+ dev_priv->drmdev = drm_attach_pci(&ragedrm_driver, pa, is_agp, self);
}
int
diff --git a/sys/dev/pci/drm/radeon_drv.c b/sys/dev/pci/drm/radeon_drv.c
index 789eb6e9647..c5a412326a6 100644
--- a/sys/dev/pci/drm/radeon_drv.c
+++ b/sys/dev/pci/drm/radeon_drv.c
@@ -586,8 +586,7 @@ radeondrm_attach(struct device *parent, struct device *self, void *aux)
is_agp = pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP,
NULL, NULL);
- dev_priv->drmdev = drm_attach_mi(&radeondrm_driver, pa->pa_dmat,
- pa, is_agp, self);
+ dev_priv->drmdev = drm_attach_pci(&radeondrm_driver, pa, is_agp, self);
}
int
diff --git a/sys/dev/pci/drm/savage_drv.c b/sys/dev/pci/drm/savage_drv.c
index 55ef7ba25e6..cac31667265 100644
--- a/sys/dev/pci/drm/savage_drv.c
+++ b/sys/dev/pci/drm/savage_drv.c
@@ -174,8 +174,7 @@ savagedrm_attach(struct device *parent, struct device *self, void *aux)
is_agp = pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP,
NULL, NULL);
- dev_priv->drmdev = drm_attach_mi(&savagedrm_driver, pa->pa_dmat,
- pa, is_agp, self);
+ dev_priv->drmdev = drm_attach_pci(&savagedrm_driver, pa, is_agp, self);
}
int
diff --git a/sys/dev/pci/drm/sis_drv.c b/sys/dev/pci/drm/sis_drv.c
index 5eec111b76b..cdda6c78718 100644
--- a/sys/dev/pci/drm/sis_drv.c
+++ b/sys/dev/pci/drm/sis_drv.c
@@ -78,8 +78,7 @@ sisdrm_attach(struct device *parent, struct device *self, void *aux)
is_agp = pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP,
NULL, NULL);
- dev_priv->drmdev = drm_attach_mi(&sis_driver, pa->pa_dmat,
- pa, is_agp, self);
+ dev_priv->drmdev = drm_attach_pci(&sis_driver, pa, is_agp, self);
}
int
diff --git a/sys/dev/pci/drm/tdfx_drv.c b/sys/dev/pci/drm/tdfx_drv.c
index 46ab4a88e82..647a70f3b38 100644
--- a/sys/dev/pci/drm/tdfx_drv.c
+++ b/sys/dev/pci/drm/tdfx_drv.c
@@ -79,7 +79,7 @@ tdfxdrm_attach(struct device *parent, struct device *self, void *aux)
struct pci_attach_args *pa = aux;
/* never agp */
- dev_priv->drmdev = drm_attach_mi(&tdfxdrm_driver, pa->pa_dmat, pa, 0, self);
+ dev_priv->drmdev = drm_attach_pci(&tdfxdrm_driver, pa, 0, self);
}
struct cfattach tdfxdrm_ca = {