summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2008-11-22 20:49:37 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2008-11-22 20:49:37 +0000
commite352ee055ffd21c59021f5da76de929ac5cd366e (patch)
treeebdf8fd97a71e024222c722d3aa3e147b8c34d11 /sys
parent1f7fa548404d88d6545729694cab86cd18ee7fec (diff)
Remove the driver->load callback and just do all the initialization in
the attach function. First step towards splitting drm off as it's own (bus independant) device, as it should be.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/drmP.h7
-rw-r--r--sys/dev/pci/drm/drm_drv.c19
-rw-r--r--sys/dev/pci/drm/i915_dma.c59
-rw-r--r--sys/dev/pci/drm/i915_drv.c75
-rw-r--r--sys/dev/pci/drm/i915_drv.h5
-rw-r--r--sys/dev/pci/drm/mach64_dma.c40
-rw-r--r--sys/dev/pci/drm/mach64_drv.c33
-rw-r--r--sys/dev/pci/drm/mga_dma.c112
-rw-r--r--sys/dev/pci/drm/mga_drv.c46
-rw-r--r--sys/dev/pci/drm/mga_drv.h2
-rw-r--r--sys/dev/pci/drm/r128_cce.c53
-rw-r--r--sys/dev/pci/drm/r128_drv.c42
-rw-r--r--sys/dev/pci/drm/r128_state.c9
-rw-r--r--sys/dev/pci/drm/radeon_cp.c56
-rw-r--r--sys/dev/pci/drm/radeon_drv.c75
-rw-r--r--sys/dev/pci/drm/radeon_drv.h2
-rw-r--r--sys/dev/pci/drm/radeon_state.c23
-rw-r--r--sys/dev/pci/drm/savage_bci.c24
-rw-r--r--sys/dev/pci/drm/savage_drv.c43
-rw-r--r--sys/dev/pci/drm/savage_drv.h2
-rw-r--r--sys/dev/pci/drm/sis_drv.c25
-rw-r--r--sys/dev/pci/drm/sis_mm.c18
-rw-r--r--sys/dev/pci/drm/tdfx_drv.c16
23 files changed, 371 insertions, 415 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index f4fad5ca95f..54c5da04555 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -442,7 +442,6 @@ struct drm_ati_pcigart_info {
};
struct drm_driver_info {
- int (*load)(struct drm_device *, unsigned long);
int (*firstopen)(struct drm_device *);
int (*open)(struct drm_device *, struct drm_file *);
int (*ioctl)(struct drm_device*, u_long, caddr_t,
@@ -450,7 +449,6 @@ struct drm_driver_info {
void (*preclose)(struct drm_device *, struct drm_file *);
void (*postclose)(struct drm_device *, struct drm_file *);
void (*lastclose)(struct drm_device *);
- int (*unload)(struct drm_device *);
void (*reclaim_buffers_locked)(struct drm_device *,
struct drm_file *);
int (*dma_ioctl)(struct drm_device *, void *, struct drm_file *);
@@ -581,8 +579,7 @@ extern int drm_debug_flag;
/* Device setup support (drm_drv.c) */
int drm_probe(struct pci_attach_args *, drm_pci_id_list_t * );
-void drm_attach(struct device *, struct device *,
- struct pci_attach_args *, drm_pci_id_list_t *);
+void drm_attach(struct device *, struct device *, struct pci_attach_args *);
int drm_detach(struct device *, int );
int drm_activate(struct device *, enum devact);
dev_type_ioctl(drmioctl);
@@ -593,6 +590,8 @@ dev_type_poll(drmpoll);
dev_type_mmap(drmmmap);
extern drm_local_map_t *drm_getsarea(struct drm_device *);
+drm_pci_id_list_t *drm_find_description(int , int , drm_pci_id_list_t *);
+
/* File operations helpers (drm_fops.c) */
struct drm_file *drm_find_file_by_minor(struct drm_device *, int);
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index f45f0962632..0e9fecb33b4 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -47,8 +47,6 @@ int drm_debug_flag = 1;
int drm_debug_flag = 0;
#endif
-drm_pci_id_list_t *drm_find_description(int , int ,
- drm_pci_id_list_t *);
int drm_firstopen(struct drm_device *);
int drm_lastclose(struct drm_device *);
@@ -80,11 +78,10 @@ drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist)
void
drm_attach(struct device *parent, struct device *kdev,
- struct pci_attach_args *pa, drm_pci_id_list_t *idlist)
+ struct pci_attach_args *pa)
{
int unit;
struct drm_device *dev;
- drm_pci_id_list_t *id_entry;
if (init_units) {
for (unit=0; unit<DRM_MAXUNITS; unit++)
@@ -118,9 +115,6 @@ drm_attach(struct device *parent, struct device *kdev,
mtx_init(&dev->drw_lock, IPL_NONE);
mtx_init(&dev->lock.spinlock, IPL_NONE);
- id_entry = drm_find_description(PCI_VENDOR(pa->pa_id),
- PCI_PRODUCT(pa->pa_id), idlist);
-
TAILQ_INIT(&dev->maplist);
drm_mem_init();
@@ -137,14 +131,6 @@ drm_attach(struct device *parent, struct device *kdev,
goto error;
}
- if (dev->driver->load != NULL) {
- int retcode;
-
- retcode = dev->driver->load(dev, id_entry->driver_private);
- if (retcode != 0)
- goto error;
- }
-
if (dev->driver->flags & DRIVER_AGP) {
if (drm_device_is_agp(dev))
dev->agp = drm_agp_init();
@@ -195,9 +181,6 @@ drm_detach(struct device *self, int flags)
dev->agp = NULL;
}
- if (dev->driver->unload != NULL)
- dev->driver->unload(dev);
-
drm_mem_uninit();
return 0;
}
diff --git a/sys/dev/pci/drm/i915_dma.c b/sys/dev/pci/drm/i915_dma.c
index 3c00381f23d..af8d4dca8e9 100644
--- a/sys/dev/pci/drm/i915_dma.c
+++ b/sys/dev/pci/drm/i915_dma.c
@@ -31,9 +31,6 @@
#include "i915_drm.h"
#include "i915_drv.h"
-int i915_init_phys_hws(drm_i915_private_t *, bus_dma_tag_t);
-void i915_free_hws(drm_i915_private_t *, bus_dma_tag_t);
-
/* Really want an OS-independent resettable timer. Would like to have
* this loop run for (eg) 3 sec, but have the timer reset every time
* the head pointer changes, so that EBUSY only happens if the ring
@@ -799,62 +796,6 @@ int i915_set_status_page(struct drm_device *dev, void *data,
return 0;
}
-int i915_driver_load(struct drm_device *dev, unsigned long flags)
-{
- struct drm_i915_private *dev_priv;
- struct vga_pci_bar *bar;
- int ret;
-
- dev_priv = drm_calloc(1, sizeof(drm_i915_private_t), DRM_MEM_DRIVER);
- if (dev_priv == NULL)
- return ENOMEM;
-
- dev->dev_private = (void *)dev_priv;
-
- dev_priv->flags = flags;
-
- /* Add register map (needed for suspend/resume) */
- bar = vga_pci_bar_info(dev->vga_softc, (IS_I9XX(dev_priv) ? 0 : 1));
- if (bar == NULL) {
- printf(": can't get BAR info\n");
- return (EINVAL);
- }
-
- dev_priv->regs = vga_pci_bar_map(dev->vga_softc,
- bar->addr, bar->size, 0);
- if (dev_priv->regs == NULL) {
- printf(": can't map mmio space\n");
- return (ENOMEM);
- }
-
- /* Init HWS */
- if (!I915_NEED_GFX_HWS(dev_priv)) {
- ret = i915_init_phys_hws(dev_priv, dev->pa.pa_dmat);
- if (ret != 0)
- return ret;
- }
-
- mtx_init(&dev_priv->user_irq_lock, IPL_BIO);
-
- return ret;
-}
-
-int i915_driver_unload(struct drm_device *dev)
-{
- struct drm_i915_private *dev_priv = dev->dev_private;
-
- i915_free_hws(dev_priv, dev->pa.pa_dmat);
-
- if (dev_priv->regs != NULL)
- vga_pci_bar_unmap(dev_priv->regs);
-
- DRM_SPINUNINIT(&dev_priv->user_irq_lock);
-
- drm_free(dev->dev_private, sizeof(drm_i915_private_t), DRM_MEM_DRIVER);
-
- return 0;
-}
-
void i915_driver_lastclose(struct drm_device * dev)
{
drm_i915_private_t *dev_priv = dev->dev_private;
diff --git a/sys/dev/pci/drm/i915_drv.c b/sys/dev/pci/drm/i915_drv.c
index 672a99fb214..e1bd5be9af2 100644
--- a/sys/dev/pci/drm/i915_drv.c
+++ b/sys/dev/pci/drm/i915_drv.c
@@ -34,11 +34,12 @@
#include "i915_drm.h"
#include "i915_drv.h"
-int i915drm_probe(struct device *, void *, void *);
-void i915drm_attach(struct device *, struct device *, void *);
+int inteldrm_probe(struct device *, void *, void *);
+void inteldrm_attach(struct device *, struct device *, void *);
+int inteldrm_detach(struct device *, int);
int inteldrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *);
-static drm_pci_id_list_t i915_pciidlist[] = {
+static drm_pci_id_list_t inteldrm_pciidlist[] = {
{PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82830M_IGD,
CHIP_I830|CHIP_M},
{PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82845G_IGD,
@@ -88,9 +89,8 @@ static drm_pci_id_list_t i915_pciidlist[] = {
{0, 0, 0}
};
-static const struct drm_driver_info i915_driver = {
+static const struct drm_driver_info inteldrm_driver = {
.buf_priv_size = 1, /* No dev_priv */
- .load = i915_driver_load,
.ioctl = inteldrm_ioctl,
.preclose = i915_driver_preclose,
.lastclose = i915_driver_lastclose,
@@ -115,25 +115,74 @@ static const struct drm_driver_info i915_driver = {
};
int
-i915drm_probe(struct device *parent, void *match, void *aux)
+inteldrm_probe(struct device *parent, void *match, void *aux)
{
- return drm_probe((struct pci_attach_args *)aux, i915_pciidlist);
+ return drm_probe((struct pci_attach_args *)aux, inteldrm_pciidlist);
}
void
-i915drm_attach(struct device *parent, struct device *self, void *aux)
+inteldrm_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct pci_attach_args *pa = aux;
+ struct drm_i915_private *dev_priv;
+ struct drm_device *dev = (struct drm_device *)self;
+ drm_pci_id_list_t *id_entry;
+ unsigned long base, size;
+ int ret = 0, mmio_bar = IS_I9XX(dev_priv) ? 0 : 1;
+
+ dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ if (dev_priv == NULL)
+ return;
+
+ dev->dev_private = (void *)dev_priv;
+
+ id_entry = drm_find_description(PCI_VENDOR(pa->pa_id),
+ PCI_PRODUCT(pa->pa_id), inteldrm_pciidlist);
+ dev_priv->flags = id_entry->driver_private;
+
+ /* Add register map (needed for suspend/resume) */
+ base = drm_get_resource_start(dev, mmio_bar);
+ size = drm_get_resource_len(dev, mmio_bar);
+
+ dev_priv->regs = vga_pci_bar_map(dev->vga_softc, base, size, 0);
+ if (dev_priv->regs == NULL)
+ return;
+
+ /* Init HWS */
+ if (!I915_NEED_GFX_HWS(dev_priv)) {
+ ret = i915_init_phys_hws(dev_priv, dev->pa.pa_dmat);
+ if (ret != 0)
+ return;
+ }
+
+ mtx_init(&dev_priv->user_irq_lock, IPL_BIO);
+
+ dev->driver = &inteldrm_driver;
+
+ drm_attach(parent, self, pa);
+}
+
+int
+inteldrm_detach(struct device *self, int flags)
{
- struct pci_attach_args *pa = aux;
struct drm_device *dev = (struct drm_device *)self;
+ struct drm_i915_private *dev_priv = dev->dev_private;
+
+ i915_free_hws(dev_priv, dev->pa.pa_dmat);
+
+ if (dev_priv->regs != NULL)
+ vga_pci_bar_unmap(dev_priv->regs);
+
+ DRM_SPINUNINIT(&dev_priv->user_irq_lock);
- dev->driver = &i915_driver;
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
- drm_attach(parent, self, pa, i915_pciidlist);
+ return (drm_detach(self, flags));
}
struct cfattach inteldrm_ca = {
- sizeof(struct drm_device), i915drm_probe, i915drm_attach,
- drm_detach, drm_activate
+ sizeof(struct drm_device), inteldrm_probe, inteldrm_attach,
+ inteldrm_detach, drm_activate
};
struct cfdriver inteldrm_cd = {
diff --git a/sys/dev/pci/drm/i915_drv.h b/sys/dev/pci/drm/i915_drv.h
index 0d2ebcdef4b..f4ff3e7407d 100644
--- a/sys/dev/pci/drm/i915_drv.h
+++ b/sys/dev/pci/drm/i915_drv.h
@@ -222,8 +222,6 @@ typedef struct drm_i915_private {
/* i915_dma.c */
extern void i915_kernel_lost_context(struct drm_device * dev);
-extern int i915_driver_load(struct drm_device *, unsigned long flags);
-extern int i915_driver_unload(struct drm_device *);
extern void i915_driver_lastclose(struct drm_device * dev);
extern void i915_driver_preclose(struct drm_device *dev,
struct drm_file *file_priv);
@@ -238,6 +236,9 @@ extern int i915_dispatch_batchbuffer(struct drm_device * dev,
drm_i915_batchbuffer_t * batch);
extern int i915_quiescent(struct drm_device *dev);
+int i915_init_phys_hws(drm_i915_private_t *, bus_dma_tag_t);
+void i915_free_hws(drm_i915_private_t *, bus_dma_tag_t);
+
/* i915_irq.c */
extern int i915_irq_emit(struct drm_device *dev, void *data,
struct drm_file *file_priv);
diff --git a/sys/dev/pci/drm/mach64_dma.c b/sys/dev/pci/drm/mach64_dma.c
index 5092fce4a70..7d5e8ad24ff 100644
--- a/sys/dev/pci/drm/mach64_dma.c
+++ b/sys/dev/pci/drm/mach64_dma.c
@@ -1006,10 +1006,6 @@ static int mach64_do_dma_init(struct drm_device * dev, drm_mach64_init_t * init)
DRM_DEBUG("\n");
- dev_priv = drm_calloc(1, sizeof(drm_mach64_private_t), DRM_MEM_DRIVER);
- if (dev_priv == NULL)
- return ENOMEM;
-
dev_priv->is_pci = init->is_pci;
dev_priv->fb_bpp = init->fb_bpp;
@@ -1039,21 +1035,18 @@ static int mach64_do_dma_init(struct drm_device * dev, drm_mach64_init_t * init)
dev_priv->sarea = drm_getsarea(dev);
if (!dev_priv->sarea) {
DRM_ERROR("can not find sarea!\n");
- dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma(dev);
return EINVAL;
}
dev_priv->fb = drm_core_findmap(dev, init->fb_offset);
if (!dev_priv->fb) {
DRM_ERROR("can not find frame buffer map!\n");
- dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma(dev);
return EINVAL;
}
dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset);
if (!dev_priv->mmio) {
DRM_ERROR("can not find mmio map!\n");
- dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma(dev);
return EINVAL;
}
@@ -1061,7 +1054,6 @@ static int mach64_do_dma_init(struct drm_device * dev, drm_mach64_init_t * init)
dev_priv->ring_map = drm_core_findmap(dev, init->ring_offset);
if (!dev_priv->ring_map) {
DRM_ERROR("can not find ring map!\n");
- dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma(dev);
return EINVAL;
}
@@ -1074,7 +1066,6 @@ static int mach64_do_dma_init(struct drm_device * dev, drm_mach64_init_t * init)
if (!dev_priv->ring_map->handle) {
DRM_ERROR("can not ioremap virtual address for"
" descriptor ring\n");
- dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma(dev);
return ENOMEM;
}
@@ -1082,7 +1073,6 @@ static int mach64_do_dma_init(struct drm_device * dev, drm_mach64_init_t * init)
drm_core_findmap(dev, init->buffers_offset);
if (!dev->agp_buffer_map) {
DRM_ERROR("can not find dma buffer map!\n");
- dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma(dev);
return EINVAL;
}
@@ -1094,7 +1084,6 @@ static int mach64_do_dma_init(struct drm_device * dev, drm_mach64_init_t * init)
if (!dev->agp_buffer_map->handle) {
DRM_ERROR("can not ioremap virtual address for"
" dma buffer\n");
- dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma(dev);
return ENOMEM;
}
@@ -1102,14 +1091,11 @@ static int mach64_do_dma_init(struct drm_device * dev, drm_mach64_init_t * init)
drm_core_findmap(dev, init->agp_textures_offset);
if (!dev_priv->agp_textures) {
DRM_ERROR("can not find agp texture region!\n");
- dev->dev_private = (void *)dev_priv;
mach64_do_cleanup_dma(dev);
return EINVAL;
}
}
- dev->dev_private = (void *)dev_priv;
-
dev_priv->driver_mode = init->dma_mode;
/* changing the FIFO size from the default causes problems with DMA */
@@ -1360,6 +1346,8 @@ int mach64_do_dispatch_pseudo_dma(drm_mach64_private_t *dev_priv)
int mach64_do_cleanup_dma(struct drm_device * dev)
{
+ drm_mach64_private_t *dev_priv = dev->dev_private;
+
DRM_DEBUG("\n");
/* Make sure interrupts are disabled here because the uninstall ioctl
@@ -1369,26 +1357,18 @@ int mach64_do_cleanup_dma(struct drm_device * dev)
if (dev->irq)
drm_irq_uninstall(dev);
- if (dev->dev_private) {
- drm_mach64_private_t *dev_priv = dev->dev_private;
-
- if (!dev_priv->is_pci) {
- if (dev_priv->ring_map)
- drm_core_ioremapfree(dev_priv->ring_map);
+ if (!dev_priv->is_pci) {
+ if (dev_priv->ring_map)
+ drm_core_ioremapfree(dev_priv->ring_map);
- if (dev->agp_buffer_map) {
- drm_core_ioremapfree(dev->agp_buffer_map);
- dev->agp_buffer_map = NULL;
- }
+ if (dev->agp_buffer_map) {
+ drm_core_ioremapfree(dev->agp_buffer_map);
+ dev->agp_buffer_map = NULL;
}
-
- mach64_destroy_freelist(dev);
-
- drm_free(dev_priv, sizeof(drm_mach64_private_t),
- DRM_MEM_DRIVER);
- dev->dev_private = NULL;
}
+ mach64_destroy_freelist(dev);
+
return 0;
}
diff --git a/sys/dev/pci/drm/mach64_drv.c b/sys/dev/pci/drm/mach64_drv.c
index 65e777a7780..0a4467f48bc 100644
--- a/sys/dev/pci/drm/mach64_drv.c
+++ b/sys/dev/pci/drm/mach64_drv.c
@@ -38,8 +38,9 @@
#include "mach64_drm.h"
#include "mach64_drv.h"
-int mach64drm_probe(struct device *, void *, void *);
-void mach64drm_attach(struct device *, struct device *, void *);
+int machdrm_probe(struct device *, void *, void *);
+void machdrm_attach(struct device *, struct device *, void *);
+int machdrm_detach(struct device *, int);
int machdrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *);
static drm_pci_id_list_t mach64_pciidlist[] = {
@@ -91,25 +92,43 @@ static const struct drm_driver_info mach64_driver = {
};
int
-mach64drm_probe(struct device *parent, void *match, void *aux)
+machdrm_probe(struct device *parent, void *match, void *aux)
{
return drm_probe((struct pci_attach_args *)aux, mach64_pciidlist);
}
void
-mach64drm_attach(struct device *parent, struct device *self, void *aux)
+machdrm_attach(struct device *parent, struct device *self, void *aux)
{
struct pci_attach_args *pa = aux;
struct drm_device *dev = (struct drm_device *)self;
+ drm_mach64_private_t *dev_priv;
+
+ dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ if (dev_priv == NULL)
+ return;
+ dev->dev_private = (void *)dev_priv;
dev->driver = &mach64_driver;
- return drm_attach(parent, self, pa, mach64_pciidlist);
+ return drm_attach(parent, self, pa);
+}
+
+int
+machdrm_detach(struct device *self, int flags)
+{
+ struct drm_device *dev = (struct drm_device *)self;
+ drm_mach64_private_t *dev_priv = dev->dev_private;
+
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+
+ return (drm_detach(self, flags));
}
struct cfattach machdrm_ca = {
- sizeof(struct drm_device), mach64drm_probe, mach64drm_attach,
- drm_detach, drm_activate
+ sizeof(struct drm_device), machdrm_probe, machdrm_attach,
+ machdrm_detach, drm_activate
};
struct cfdriver machdrm_cd = {
diff --git a/sys/dev/pci/drm/mga_dma.c b/sys/dev/pci/drm/mga_dma.c
index b7e729ceb72..f48091c336b 100644
--- a/sys/dev/pci/drm/mga_dma.c
+++ b/sys/dev/pci/drm/mga_dma.c
@@ -41,7 +41,6 @@
#include "mga_drm.h"
#include "mga_drv.h"
-#define MGA_DEFAULT_USEC_TIMEOUT 10000
#define MGA_FREELIST_DEBUG 0
#define MINIMAL_CLEANUP 0
@@ -391,25 +390,6 @@ int mga_freelist_put(struct drm_device * dev, struct drm_buf * buf)
* DMA initialization, cleanup
*/
-int mga_driver_load(struct drm_device *dev, unsigned long flags)
-{
- drm_mga_private_t *dev_priv;
-
- dev_priv = drm_calloc(1, sizeof(drm_mga_private_t), DRM_MEM_DRIVER);
- if (!dev_priv)
- return ENOMEM;
-
- dev->dev_private = (void *)dev_priv;
-
- dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
- dev_priv->chipset = flags;
-
- dev_priv->mmio_base = drm_get_resource_start(dev, 1);
- dev_priv->mmio_size = drm_get_resource_len(dev, 1);
-
- return 0;
-}
-
/**
* Bootstrap the driver for AGP DMA.
*
@@ -905,6 +885,7 @@ static int mga_do_init_dma(struct drm_device * dev, drm_mga_init_t * init)
static int mga_do_cleanup_dma(struct drm_device *dev, int full_cleanup)
{
+ drm_mga_private_t *dev_priv = dev->dev_private;
int err = 0;
DRM_DEBUG("\n");
@@ -915,61 +896,57 @@ static int mga_do_cleanup_dma(struct drm_device *dev, int full_cleanup)
if (dev->irq_enabled)
drm_irq_uninstall(dev);
- if (dev->dev_private) {
- drm_mga_private_t *dev_priv = dev->dev_private;
- if ((dev_priv->warp != NULL)
- && (dev_priv->warp->type != _DRM_CONSISTENT))
- drm_core_ioremapfree(dev_priv->warp);
+ if ((dev_priv->warp != NULL)
+ && (dev_priv->warp->type != _DRM_CONSISTENT))
+ drm_core_ioremapfree(dev_priv->warp);
- if ((dev_priv->primary != NULL)
- && (dev_priv->primary->type != _DRM_CONSISTENT))
- drm_core_ioremapfree(dev_priv->primary);
+ if ((dev_priv->primary != NULL)
+ && (dev_priv->primary->type != _DRM_CONSISTENT))
+ drm_core_ioremapfree(dev_priv->primary);
- if (dev->agp_buffer_map != NULL)
- drm_core_ioremapfree(dev->agp_buffer_map);
+ if (dev->agp_buffer_map != NULL)
+ drm_core_ioremapfree(dev->agp_buffer_map);
- if (dev_priv->used_new_dma_init) {
- if (dev_priv->agp_handle != 0) {
- struct drm_agp_binding unbind_req;
- struct drm_agp_buffer free_req;
+ if (dev_priv->used_new_dma_init) {
+ if (dev_priv->agp_handle != 0) {
+ struct drm_agp_binding unbind_req;
+ struct drm_agp_buffer free_req;
- unbind_req.handle = dev_priv->agp_handle;
- drm_agp_unbind(dev, &unbind_req);
+ unbind_req.handle = dev_priv->agp_handle;
+ drm_agp_unbind(dev, &unbind_req);
- free_req.handle = dev_priv->agp_handle;
- drm_agp_free(dev, &free_req);
+ free_req.handle = dev_priv->agp_handle;
+ drm_agp_free(dev, &free_req);
- dev_priv->agp_textures = NULL;
- dev_priv->agp_size = 0;
- dev_priv->agp_handle = 0;
- }
+ dev_priv->agp_textures = NULL;
+ dev_priv->agp_size = 0;
+ dev_priv->agp_handle = 0;
+ }
- if ((dev->agp != NULL) && dev->agp->acquired) {
- err = drm_agp_release(dev);
- }
+ if ((dev->agp != NULL) && dev->agp->acquired) {
+ err = drm_agp_release(dev);
}
+ }
- dev_priv->warp = NULL;
- dev_priv->primary = NULL;
- dev_priv->sarea = NULL;
- dev_priv->sarea_priv = NULL;
- dev->agp_buffer_map = NULL;
+ dev_priv->warp = NULL;
+ dev_priv->primary = NULL;
+ dev_priv->sarea = NULL;
+ dev_priv->sarea_priv = NULL;
+ dev->agp_buffer_map = NULL;
- if (full_cleanup) {
- dev_priv->mmio = NULL;
- dev_priv->status = NULL;
- dev_priv->used_new_dma_init = 0;
- }
+ if (full_cleanup) {
+ dev_priv->mmio = NULL;
+ dev_priv->status = NULL;
+ dev_priv->used_new_dma_init = 0;
+ }
- memset(&dev_priv->prim, 0, sizeof(dev_priv->prim));
- dev_priv->warp_pipe = 0;
- memset(dev_priv->warp_pipe_phys, 0,
- sizeof(dev_priv->warp_pipe_phys));
+ memset(&dev_priv->prim, 0, sizeof(dev_priv->prim));
+ dev_priv->warp_pipe = 0;
+ memset(dev_priv->warp_pipe_phys, 0, sizeof(dev_priv->warp_pipe_phys));
- if (dev_priv->head != NULL) {
- mga_freelist_cleanup(dev);
- }
+ if (dev_priv->head != NULL) {
+ mga_freelist_cleanup(dev);
}
return err;
@@ -1111,17 +1088,6 @@ int mga_dma_buffers(struct drm_device *dev, void *data,
}
/**
- * Called just before the module is unloaded.
- */
-int mga_driver_unload(struct drm_device * dev)
-{
- drm_free(dev->dev_private, sizeof(drm_mga_private_t), DRM_MEM_DRIVER);
- dev->dev_private = NULL;
-
- return 0;
-}
-
-/**
* Called when the last opener of the device is closed.
*/
void mga_driver_lastclose(struct drm_device * dev)
diff --git a/sys/dev/pci/drm/mga_drv.c b/sys/dev/pci/drm/mga_drv.c
index 19d4f799179..ec4c9ce66a9 100644
--- a/sys/dev/pci/drm/mga_drv.c
+++ b/sys/dev/pci/drm/mga_drv.c
@@ -38,10 +38,13 @@
int mgadrm_probe(struct device *, void *, void *);
void mgadrm_attach(struct device *, struct device *, void *);
+int mgadrm_detach(struct device *, int);
int mga_driver_device_is_agp(struct drm_device * );
int mgadrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *);
-static drm_pci_id_list_t mga_pciidlist[] = {
+#define MGA_DEFAULT_USEC_TIMEOUT 10000
+
+static drm_pci_id_list_t mgadrm_pciidlist[] = {
{PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_MILL_II_G200_PCI,
MGA_CARD_TYPE_G200},
{PCI_VENDOR_MATROX, PCI_PRODUCT_MATROX_MILL_II_G200_AGP,
@@ -101,8 +104,6 @@ mga_driver_device_is_agp(struct drm_device * dev)
static const struct drm_driver_info mga_driver = {
.buf_priv_size = sizeof(drm_mga_buf_priv_t),
- .load = mga_driver_load,
- .unload = mga_driver_unload,
.ioctl = mgadrm_ioctl,
.lastclose = mga_driver_lastclose,
.enable_vblank = mga_enable_vblank,
@@ -130,22 +131,51 @@ static const struct drm_driver_info mga_driver = {
int
mgadrm_probe(struct device *parent, void *match, void *aux)
{
- return drm_probe((struct pci_attach_args *)aux, mga_pciidlist);
+ return drm_probe((struct pci_attach_args *)aux, mgadrm_pciidlist);
}
void
mgadrm_attach(struct device *parent, struct device *self, void *aux)
{
- struct pci_attach_args *pa = aux;
- struct drm_device *dev = (struct drm_device *)self;
+ struct pci_attach_args *pa = aux;
+ struct drm_device *dev = (struct drm_device *)self;
+ drm_mga_private_t *dev_priv;
+ drm_pci_id_list_t *id_entry;
+
+ dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ if (!dev_priv)
+ return;
+
+ dev->dev_private = (void *)dev_priv;
+
+ dev_priv->usec_timeout = MGA_DEFAULT_USEC_TIMEOUT;
+
+ id_entry = drm_find_description(PCI_VENDOR(pa->pa_id),
+ PCI_PRODUCT(pa->pa_id), mgadrm_pciidlist);
+ dev_priv->chipset = id_entry->driver_private;
+
+ dev_priv->mmio_base = drm_get_resource_start(dev, 1);
+ dev_priv->mmio_size = drm_get_resource_len(dev, 1);
dev->driver = &mga_driver;
- return drm_attach(parent, self, pa, mga_pciidlist);
+ return drm_attach(parent, self, pa);
+}
+
+int
+mgadrm_detach(struct device *self, int flags)
+{
+ struct drm_device *dev = (struct drm_device *)self;
+ drm_mga_private_t *dev_priv = dev->dev_private;
+
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+
+ return (drm_detach(self, flags));
}
struct cfattach mgadrm_ca = {
sizeof(struct drm_device), mgadrm_probe, mgadrm_attach,
- drm_detach, drm_activate
+ mgadrm_detach, drm_activate
};
struct cfdriver mgadrm_cd = {
diff --git a/sys/dev/pci/drm/mga_drv.h b/sys/dev/pci/drm/mga_drv.h
index 74d23a554bd..59f770c28e8 100644
--- a/sys/dev/pci/drm/mga_drv.h
+++ b/sys/dev/pci/drm/mga_drv.h
@@ -160,8 +160,6 @@ extern int mga_dma_reset(struct drm_device *dev, void *data,
struct drm_file *file_priv);
extern int mga_dma_buffers(struct drm_device *dev, void *data,
struct drm_file *file_priv);
-extern int mga_driver_load(struct drm_device *dev, unsigned long flags);
-extern int mga_driver_unload(struct drm_device * dev);
extern void mga_driver_lastclose(struct drm_device * dev);
extern int mga_driver_dma_quiescent(struct drm_device * dev);
extern int mga_dma_swap(struct drm_device *, void *, struct drm_file *);
diff --git a/sys/dev/pci/drm/r128_cce.c b/sys/dev/pci/drm/r128_cce.c
index d41d089ddea..381eb993a1f 100644
--- a/sys/dev/pci/drm/r128_cce.c
+++ b/sys/dev/pci/drm/r128_cce.c
@@ -353,9 +353,6 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
DRM_DEBUG("\n");
- dev_priv = drm_calloc(1, sizeof(drm_r128_private_t), DRM_MEM_DRIVER);
- if (dev_priv == NULL)
- return ENOMEM;
dev_priv->is_pci = init->is_pci;
@@ -457,7 +454,6 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
dev_priv->sarea = drm_getsarea(dev);
if (!dev_priv->sarea) {
DRM_ERROR("could not find sarea!\n");
- dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce(dev);
return EINVAL;
}
@@ -465,28 +461,24 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
dev_priv->mmio = drm_core_findmap(dev, init->mmio_offset);
if (!dev_priv->mmio) {
DRM_ERROR("could not find mmio region!\n");
- dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce(dev);
return EINVAL;
}
dev_priv->cce_ring = drm_core_findmap(dev, init->ring_offset);
if (!dev_priv->cce_ring) {
DRM_ERROR("could not find cce ring region!\n");
- dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce(dev);
return EINVAL;
}
dev_priv->ring_rptr = drm_core_findmap(dev, init->ring_rptr_offset);
if (!dev_priv->ring_rptr) {
DRM_ERROR("could not find ring read pointer!\n");
- dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce(dev);
return EINVAL;
}
dev->agp_buffer_map = drm_core_findmap(dev, init->buffers_offset);
if (!dev->agp_buffer_map) {
DRM_ERROR("could not find dma buffer region!\n");
- dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce(dev);
return EINVAL;
}
@@ -496,7 +488,6 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
drm_core_findmap(dev, init->agp_textures_offset);
if (!dev_priv->agp_textures) {
DRM_ERROR("could not find agp texture region!\n");
- dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce(dev);
return EINVAL;
}
@@ -515,7 +506,6 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
!dev_priv->ring_rptr->handle ||
!dev->agp_buffer_map->handle) {
DRM_ERROR("Could not ioremap agp regions!\n");
- dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce(dev);
return ENOMEM;
}
@@ -563,7 +553,6 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
dev_priv->gart_info.gart_reg_if = DRM_ATI_GART_PCI;
if (!drm_ati_pcigart_init(dev, &dev_priv->gart_info)) {
DRM_ERROR("failed to init PCI GART!\n");
- dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce(dev);
return ENOMEM;
}
@@ -575,8 +564,6 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
r128_cce_init_ring_buffer(dev, dev_priv);
r128_cce_load_microcode(dev_priv);
- dev->dev_private = (void *)dev_priv;
-
r128_do_engine_reset(dev);
return 0;
@@ -584,38 +571,30 @@ static int r128_do_init_cce(struct drm_device * dev, drm_r128_init_t * init)
int r128_do_cleanup_cce(struct drm_device * dev)
{
+ drm_r128_private_t *dev_priv = dev->dev_private;
/* Make sure interrupts are disabled here because the uninstall ioctl
- * may not have been called from userspace and after dev_private
- * is freed, it's too late.
+ * may not have been called from userspace
*/
if (dev->irq_enabled)
drm_irq_uninstall(dev);
- if (dev->dev_private) {
- drm_r128_private_t *dev_priv = dev->dev_private;
-
#if __OS_HAS_AGP
- if (!dev_priv->is_pci) {
- if (dev_priv->cce_ring != NULL)
- drm_core_ioremapfree(dev_priv->cce_ring);
- if (dev_priv->ring_rptr != NULL)
- drm_core_ioremapfree(dev_priv->ring_rptr);
- if (dev->agp_buffer_map != NULL) {
- drm_core_ioremapfree(dev->agp_buffer_map);
- dev->agp_buffer_map = NULL;
- }
- } else
-#endif
- {
- if (dev_priv->gart_info.bus_addr)
- if (!drm_ati_pcigart_cleanup(dev, &dev_priv->gart_info))
- DRM_ERROR("failed to cleanup PCI GART!\n");
+ if (!dev_priv->is_pci) {
+ if (dev_priv->cce_ring != NULL)
+ drm_core_ioremapfree(dev_priv->cce_ring);
+ if (dev_priv->ring_rptr != NULL)
+ drm_core_ioremapfree(dev_priv->ring_rptr);
+ if (dev->agp_buffer_map != NULL) {
+ drm_core_ioremapfree(dev->agp_buffer_map);
+ dev->agp_buffer_map = NULL;
}
-
- drm_free(dev->dev_private, sizeof(drm_r128_private_t),
- DRM_MEM_DRIVER);
- dev->dev_private = NULL;
+ } else
+#endif
+ {
+ if (dev_priv->gart_info.bus_addr)
+ if (!drm_ati_pcigart_cleanup(dev, &dev_priv->gart_info))
+ DRM_ERROR("failed to cleanup PCI GART!\n");
}
return 0;
diff --git a/sys/dev/pci/drm/r128_drv.c b/sys/dev/pci/drm/r128_drv.c
index 37a91a9074c..aa0911303a8 100644
--- a/sys/dev/pci/drm/r128_drv.c
+++ b/sys/dev/pci/drm/r128_drv.c
@@ -36,11 +36,12 @@
#include "r128_drm.h"
#include "r128_drv.h"
-int r128drm_probe(struct device *, void *, void *);
-void r128drm_attach(struct device *, struct device *, void *);
+int ragedrm_probe(struct device *, void *, void *);
+void ragedrm_attach(struct device *, struct device *, void *);
+int ragedrm_detach(struct device *, int);
int ragedrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *);
-static drm_pci_id_list_t r128_pciidlist[] = {
+static drm_pci_id_list_t ragedrm_pciidlist[] = {
{PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE128_LE},
{PCI_VENDOR_ATI, PCI_PRODUCT_ATI_MOBILITY_M3},
{PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RAGE128_MF},
@@ -81,7 +82,7 @@ static drm_pci_id_list_t r128_pciidlist[] = {
{0, 0, 0}
};
-static const struct drm_driver_info r128_driver = {
+static const struct drm_driver_info ragedrm_driver = {
.buf_priv_size = sizeof(drm_r128_buf_priv_t),
.ioctl = ragedrm_ioctl,
.preclose = r128_driver_preclose,
@@ -107,24 +108,43 @@ static const struct drm_driver_info r128_driver = {
};
int
-r128drm_probe(struct device *parent, void *match, void *aux)
+ragedrm_probe(struct device *parent, void *match, void *aux)
{
- return drm_probe((struct pci_attach_args *)aux, r128_pciidlist);
+ return drm_probe((struct pci_attach_args *)aux, ragedrm_pciidlist);
}
void
-r128drm_attach(struct device *parent, struct device *self, void *aux)
+ragedrm_attach(struct device *parent, struct device *self, void *aux)
{
struct pci_attach_args *pa = aux;
struct drm_device *dev = (struct drm_device *)self;
+ drm_r128_private_t *dev_priv;
- dev->driver = &r128_driver;
- return drm_attach(parent, self, pa, r128_pciidlist);
+ dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ if (dev_priv == NULL)
+ return;
+ dev->dev_private = (void *)dev_priv;
+
+ dev->driver = &ragedrm_driver;
+ return drm_attach(parent, self, pa);
+}
+
+int
+ragedrm_detach(struct device *self, int flags)
+{
+ struct drm_device *dev = (struct drm_device *)self;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+
+ drm_free(dev_priv, sizeof(*dev_priv),
+ DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+
+ return (drm_detach(self, flags));
}
struct cfattach ragedrm_ca = {
- sizeof(struct drm_device), r128drm_probe, r128drm_attach,
- drm_detach, drm_activate
+ sizeof(struct drm_device), ragedrm_probe, ragedrm_attach,
+ ragedrm_detach, drm_activate
};
struct cfdriver ragedrm_cd = {
diff --git a/sys/dev/pci/drm/r128_state.c b/sys/dev/pci/drm/r128_state.c
index 11f8e152c37..47657c6f79c 100644
--- a/sys/dev/pci/drm/r128_state.c
+++ b/sys/dev/pci/drm/r128_state.c
@@ -1645,11 +1645,10 @@ int r128_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv
void r128_driver_preclose(struct drm_device * dev, struct drm_file *file_priv)
{
- if (dev->dev_private) {
- drm_r128_private_t *dev_priv = dev->dev_private;
- if (dev_priv->page_flipping) {
- r128_do_cleanup_pageflip(dev);
- }
+ drm_r128_private_t *dev_priv = dev->dev_private;
+
+ if (dev_priv->page_flipping) {
+ r128_do_cleanup_pageflip(dev);
}
}
diff --git a/sys/dev/pci/drm/radeon_cp.c b/sys/dev/pci/drm/radeon_cp.c
index a8d78d7b882..ab153bf40cb 100644
--- a/sys/dev/pci/drm/radeon_cp.c
+++ b/sys/dev/pci/drm/radeon_cp.c
@@ -1714,51 +1714,6 @@ int radeon_cp_buffers(struct drm_device *dev, void *data, struct drm_file *file_
return ret;
}
-int radeon_driver_load(struct drm_device *dev, unsigned long flags)
-{
- drm_radeon_private_t *dev_priv;
- int ret = 0;
-
- dev_priv = drm_calloc(1, sizeof(drm_radeon_private_t), DRM_MEM_DRIVER);
- if (dev_priv == NULL)
- return ENOMEM;
-
- dev->dev_private = (void *)dev_priv;
- dev_priv->flags = flags;
-
- switch (flags & RADEON_FAMILY_MASK) {
- case CHIP_R100:
- case CHIP_RV200:
- case CHIP_R200:
- case CHIP_R300:
- case CHIP_R350:
- case CHIP_R420:
- case CHIP_R423:
- case CHIP_RV410:
- case CHIP_RV515:
- case CHIP_R520:
- case CHIP_RV570:
- case CHIP_R580:
- dev_priv->flags |= RADEON_HAS_HIERZ;
- break;
- default:
- /* all other chips have no hierarchical z buffer */
- break;
- }
-
- dev_priv->chip_family = flags & RADEON_FAMILY_MASK;
- if (drm_device_is_agp(dev))
- dev_priv->flags |= RADEON_IS_AGP;
- else if (drm_device_is_pcie(dev))
- dev_priv->flags |= RADEON_IS_PCIE;
- else
- dev_priv->flags |= RADEON_IS_PCI;
-
- DRM_DEBUG("%s card detected\n",
- ((dev_priv->flags & RADEON_IS_AGP) ? "AGP" : (((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI"))));
- return ret;
-}
-
/* Create mappings for registers and framebuffer so userland doesn't necessarily
* have to find them.
*/
@@ -1785,14 +1740,3 @@ int radeon_driver_firstopen(struct drm_device *dev)
return 0;
}
-
-int radeon_driver_unload(struct drm_device *dev)
-{
- drm_radeon_private_t *dev_priv = dev->dev_private;
-
- DRM_DEBUG("\n");
- drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
-
- dev->dev_private = NULL;
- return 0;
-}
diff --git a/sys/dev/pci/drm/radeon_drv.c b/sys/dev/pci/drm/radeon_drv.c
index 486ad58be1f..eea48415803 100644
--- a/sys/dev/pci/drm/radeon_drv.c
+++ b/sys/dev/pci/drm/radeon_drv.c
@@ -36,11 +36,12 @@
int radeondrm_probe(struct device *, void *, void *);
void radeondrm_attach(struct device *, struct device *, void *);
+int radeondrm_detach(struct device *, int);
int radeondrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *);
int radeon_no_wb;
-static drm_pci_id_list_t radeon_pciidlist[] = {
+static drm_pci_id_list_t radeondrm_pciidlist[] = {
{PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_M241P,
CHIP_RV380|RADEON_IS_MOBILITY},
{PCI_VENDOR_ATI, PCI_PRODUCT_ATI_RADEON_X300M24,
@@ -475,10 +476,8 @@ static drm_pci_id_list_t radeon_pciidlist[] = {
{0, 0, 0}
};
-static const struct drm_driver_info radeon_driver = {
+static const struct drm_driver_info radeondrm_driver = {
.buf_priv_size = sizeof(drm_radeon_buf_priv_t),
- .load = radeon_driver_load,
- .unload = radeon_driver_unload,
.firstopen = radeon_driver_firstopen,
.open = radeon_driver_open,
.ioctl = radeondrm_ioctl,
@@ -508,22 +507,80 @@ static const struct drm_driver_info radeon_driver = {
int
radeondrm_probe(struct device *parent, void *match, void *aux)
{
- return drm_probe((struct pci_attach_args *)aux, radeon_pciidlist);
+ return drm_probe((struct pci_attach_args *)aux, radeondrm_pciidlist);
}
void
radeondrm_attach(struct device *parent, struct device *self, void *aux)
{
- struct pci_attach_args *pa = aux;
+ struct pci_attach_args *pa = aux;
+ struct drm_device *dev = (struct drm_device *)self;
+ drm_radeon_private_t *dev_priv;
+ drm_pci_id_list_t *id_entry;
+
+ dev_priv = drm_calloc(1, sizeof(drm_radeon_private_t), DRM_MEM_DRIVER);
+ if (dev_priv == NULL)
+ return;
+
+ dev->dev_private = (void *)dev_priv;
+
+ id_entry = drm_find_description(PCI_VENDOR(pa->pa_id),
+ PCI_PRODUCT(pa->pa_id), radeondrm_pciidlist);
+ dev_priv->flags = id_entry->driver_private;
+
+ switch (dev_priv->flags & RADEON_FAMILY_MASK) {
+ case CHIP_R100:
+ case CHIP_RV200:
+ case CHIP_R200:
+ case CHIP_R300:
+ case CHIP_R350:
+ case CHIP_R420:
+ case CHIP_R423:
+ case CHIP_RV410:
+ case CHIP_RV515:
+ case CHIP_R520:
+ case CHIP_RV570:
+ case CHIP_R580:
+ dev_priv->flags |= RADEON_HAS_HIERZ;
+ break;
+ default:
+ /* all other chips have no hierarchical z buffer */
+ break;
+ }
+
+ dev_priv->chip_family = dev_priv->flags & RADEON_FAMILY_MASK;
+ if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP, NULL, NULL))
+ dev_priv->flags |= RADEON_IS_AGP;
+ else if (pci_get_capability(pa->pa_pc, pa->pa_tag,
+ PCI_CAP_PCIEXPRESS, NULL, NULL))
+ dev_priv->flags |= RADEON_IS_PCIE;
+ else
+ dev_priv->flags |= RADEON_IS_PCI;
+
+ DRM_DEBUG("%s card detected\n",
+ ((dev_priv->flags & RADEON_IS_AGP) ? "AGP" :
+ (((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI"))));
+
+ dev->driver = &radeondrm_driver;
+ return drm_attach(parent, self, pa);
+}
+
+int
+radeondrm_detach(struct device *self, int flags)
+{
struct drm_device *dev = (struct drm_device *)self;
+ drm_radeon_private_t *dev_priv = dev->dev_private;
+
+ DRM_DEBUG("\n");
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
- dev->driver = &radeon_driver;
- return drm_attach(parent, self, pa, radeon_pciidlist);
+ dev->dev_private = NULL;
+ return (drm_detach(self, flags));
}
struct cfattach radeondrm_ca = {
sizeof (struct drm_device), radeondrm_probe, radeondrm_attach,
- drm_detach, drm_activate
+ radeondrm_detach, drm_activate
};
struct cfdriver radeondrm_cd = {
diff --git a/sys/dev/pci/drm/radeon_drv.h b/sys/dev/pci/drm/radeon_drv.h
index a1324f95995..4fffaac7f49 100644
--- a/sys/dev/pci/drm/radeon_drv.h
+++ b/sys/dev/pci/drm/radeon_drv.h
@@ -402,8 +402,6 @@ extern void radeon_driver_irq_uninstall(struct drm_device * dev);
extern int radeon_vblank_crtc_get(struct drm_device *dev);
extern int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value);
-extern int radeon_driver_load(struct drm_device *dev, unsigned long flags);
-extern int radeon_driver_unload(struct drm_device *dev);
extern int radeon_driver_firstopen(struct drm_device *dev);
extern void radeon_driver_preclose(struct drm_device * dev,
struct drm_file *file_priv);
diff --git a/sys/dev/pci/drm/radeon_state.c b/sys/dev/pci/drm/radeon_state.c
index a6556c79081..21edebce63a 100644
--- a/sys/dev/pci/drm/radeon_state.c
+++ b/sys/dev/pci/drm/radeon_state.c
@@ -3180,24 +3180,21 @@ int radeon_cp_setparam(struct drm_device *dev, void *data, struct drm_file *file
void radeon_driver_preclose(struct drm_device *dev,
struct drm_file *file_priv)
{
- if (dev->dev_private) {
- drm_radeon_private_t *dev_priv = dev->dev_private;
- dev_priv->page_flipping = 0;
- radeon_mem_release(file_priv, dev_priv->gart_heap);
- radeon_mem_release(file_priv, dev_priv->fb_heap);
- radeon_surfaces_release(file_priv, dev_priv);
- }
+ drm_radeon_private_t *dev_priv = dev->dev_private;
+
+ dev_priv->page_flipping = 0;
+ radeon_mem_release(file_priv, dev_priv->gart_heap);
+ radeon_mem_release(file_priv, dev_priv->fb_heap);
+ radeon_surfaces_release(file_priv, dev_priv);
}
void radeon_driver_lastclose(struct drm_device *dev)
{
- if (dev->dev_private) {
- drm_radeon_private_t *dev_priv = dev->dev_private;
+ drm_radeon_private_t *dev_priv = dev->dev_private;
- if (dev_priv->sarea_priv &&
- dev_priv->sarea_priv->pfCurrentPage != 0)
- radeon_cp_dispatch_flip(dev);
- }
+ if (dev_priv->sarea_priv &&
+ dev_priv->sarea_priv->pfCurrentPage != 0)
+ radeon_cp_dispatch_flip(dev);
radeon_do_release(dev);
}
diff --git a/sys/dev/pci/drm/savage_bci.c b/sys/dev/pci/drm/savage_bci.c
index 638c83eae8c..481c448ef29 100644
--- a/sys/dev/pci/drm/savage_bci.c
+++ b/sys/dev/pci/drm/savage_bci.c
@@ -535,21 +535,6 @@ static void savage_fake_dma_flush(drm_savage_private_t *dev_priv)
dev_priv->first_dma_page = dev_priv->current_dma_page = 0;
}
-int savage_driver_load(struct drm_device *dev, unsigned long chipset)
-{
- drm_savage_private_t *dev_priv;
-
- dev_priv = drm_calloc(1, sizeof(drm_savage_private_t), DRM_MEM_DRIVER);
- if (dev_priv == NULL)
- return ENOMEM;
-
- dev->dev_private = (void *)dev_priv;
-
- dev_priv->chipset = (enum savage_family)chipset;
-
- return 0;
-}
-
/*
* Initalize mappings. On Savage4 and SavageIX the alignment
* and size of the aperture is not suitable for automatic MTRR setup
@@ -665,15 +650,6 @@ void savage_driver_lastclose(struct drm_device *dev)
dev_priv->mtrr[i].size, DRM_MTRR_WC);
}
-int savage_driver_unload(struct drm_device *dev)
-{
- drm_savage_private_t *dev_priv = dev->dev_private;
-
- drm_free(dev_priv, sizeof(drm_savage_private_t), DRM_MEM_DRIVER);
-
- return 0;
-}
-
static int savage_do_init_bci(struct drm_device *dev, drm_savage_init_t *init)
{
drm_savage_private_t *dev_priv = dev->dev_private;
diff --git a/sys/dev/pci/drm/savage_drv.c b/sys/dev/pci/drm/savage_drv.c
index 3b2e3076459..e26e8eebd8e 100644
--- a/sys/dev/pci/drm/savage_drv.c
+++ b/sys/dev/pci/drm/savage_drv.c
@@ -33,9 +33,10 @@
int savagedrm_probe(struct device *, void *, void *);
void savagedrm_attach(struct device *, struct device *, void *);
+int savagedrm_detach(struct device *, int);
int savagedrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *);
-static drm_pci_id_list_t savage_pciidlist[] = {
+static drm_pci_id_list_t savagedrm_pciidlist[] = {
{PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE3D, S3_SAVAGE3D},
{PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE3D_M, S3_SAVAGE3D},
{PCI_VENDOR_S3, PCI_PRODUCT_S3_SAVAGE4, S3_SAVAGE4},
@@ -62,12 +63,10 @@ static drm_pci_id_list_t savage_pciidlist[] = {
{0, 0, 0}
};
-static const struct drm_driver_info savage_driver = {
+static const struct drm_driver_info savagedrm_driver = {
.buf_priv_size = sizeof(drm_savage_buf_priv_t),
- .load = savage_driver_load,
.firstopen = savage_driver_firstopen,
.lastclose = savage_driver_lastclose,
- .unload = savage_driver_unload,
.reclaim_buffers_locked = savage_reclaim_buffers,
.dma_ioctl = savage_bci_buffers,
@@ -85,22 +84,46 @@ static const struct drm_driver_info savage_driver = {
int
savagedrm_probe(struct device *parent, void *match, void *aux)
{
- return drm_probe((struct pci_attach_args *)aux, savage_pciidlist);
+ return drm_probe((struct pci_attach_args *)aux, savagedrm_pciidlist);
}
void
savagedrm_attach(struct device *parent, struct device *self, void *aux)
{
- struct pci_attach_args *pa = aux;
- struct drm_device *dev = (struct drm_device *)self;
+ struct pci_attach_args *pa = aux;
+ struct drm_device *dev = (struct drm_device *)self;
+ drm_pci_id_list_t *id_entry;
+ drm_savage_private_t *dev_priv;
- dev->driver = &savage_driver;
- return drm_attach(parent, self, pa, savage_pciidlist);
+ dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ if (dev_priv == NULL)
+ return;
+
+ dev->dev_private = (void *)dev_priv;
+
+ id_entry = drm_find_description(PCI_VENDOR(pa->pa_id),
+ PCI_PRODUCT(pa->pa_id), savagedrm_pciidlist);
+ dev_priv->chipset = (enum savage_family)id_entry->driver_private;
+
+ dev->driver = &savagedrm_driver;
+ return drm_attach(parent, self, pa);
+}
+
+int
+savagedrm_detach(struct device *self, int flags)
+{
+ struct drm_device *dev = (struct drm_device *)self;
+ drm_savage_private_t *dev_priv = dev->dev_private;
+
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+
+ return (drm_detach(self, flags));
}
struct cfattach savagedrm_ca = {
sizeof(struct drm_device), savagedrm_probe, savagedrm_attach,
- drm_detach, drm_activate
+ savagedrm_detach, drm_activate
};
struct cfdriver savagedrm_cd = {
diff --git a/sys/dev/pci/drm/savage_drv.h b/sys/dev/pci/drm/savage_drv.h
index 0ff36178178..574ce2231cb 100644
--- a/sys/dev/pci/drm/savage_drv.h
+++ b/sys/dev/pci/drm/savage_drv.h
@@ -208,10 +208,8 @@ extern void savage_dma_reset(drm_savage_private_t *dev_priv);
extern void savage_dma_wait(drm_savage_private_t *dev_priv, unsigned int page);
extern uint32_t *savage_dma_alloc(drm_savage_private_t *dev_priv,
unsigned int n);
-extern int savage_driver_load(struct drm_device *dev, unsigned long chipset);
extern int savage_driver_firstopen(struct drm_device *dev);
extern void savage_driver_lastclose(struct drm_device *dev);
-extern int savage_driver_unload(struct drm_device *dev);
extern void savage_reclaim_buffers(struct drm_device *dev,
struct drm_file *file_priv);
diff --git a/sys/dev/pci/drm/sis_drv.c b/sys/dev/pci/drm/sis_drv.c
index c430e4e0206..f847a80ef19 100644
--- a/sys/dev/pci/drm/sis_drv.c
+++ b/sys/dev/pci/drm/sis_drv.c
@@ -32,6 +32,7 @@
int sisdrm_probe(struct device *, void *, void *);
void sisdrm_attach(struct device *, struct device *, void *);
+int sisdrm_detach(struct device *, int);
int sisdrm_ioctl(struct drm_device *, u_long, caddr_t, struct drm_file *);
static drm_pci_id_list_t sis_pciidlist[] = {
@@ -40,10 +41,8 @@ static drm_pci_id_list_t sis_pciidlist[] = {
{PCI_VENDOR_SIS, PCI_PRODUCT_SIS_6300},
{PCI_VENDOR_SIS, PCI_PRODUCT_SIS_6330},
{PCI_VENDOR_SIS, PCI_PRODUCT_SIS_7300},
- {PCI_VENDOR_XGI, PCI_PRODUCT_XGI_VOLARI_V3XT},
-#if 0 /* do these actually EXIST? */
{PCI_VENDOR_XGI, 0x0042, SIS_CHIP_315},
-#endif
+ {PCI_VENDOR_XGI, PCI_PRODUCT_XGI_VOLARI_V3XT},
{0, 0, 0}
};
@@ -74,14 +73,30 @@ sisdrm_attach(struct device *parent, struct device *self, void *aux)
{
struct pci_attach_args *pa = aux;
struct drm_device *dev = (struct drm_device *)self;
+ drm_sis_private_t *dev_priv = dev->dev_private;
+
+ dev_priv = drm_calloc(1, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ dev->dev_private = dev_priv;
dev->driver = &sis_driver;
- return drm_attach(parent, self, pa, sis_pciidlist);
+ return drm_attach(parent, self, pa);
+}
+
+int
+sisdrm_detach(struct device *self, int flags)
+{
+ struct drm_device *dev = (struct drm_device *)self;
+ drm_sis_private_t *dev_priv = dev->dev_private;
+
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+
+ return (drm_detach(self, flags));
}
struct cfattach sisdrm_ca = {
sizeof(struct drm_device), sisdrm_probe, sisdrm_attach,
- drm_detach, drm_activate
+ sisdrm_detach, drm_activate
};
struct cfdriver sisdrm_cd = {
diff --git a/sys/dev/pci/drm/sis_mm.c b/sys/dev/pci/drm/sis_mm.c
index 5f4412cb34c..07f3f575f45 100644
--- a/sys/dev/pci/drm/sis_mm.c
+++ b/sys/dev/pci/drm/sis_mm.c
@@ -88,16 +88,8 @@ int sis_fb_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_fb_t *fb = data;
- if (dev_priv == NULL) {
- dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
- DRM_MEM_DRIVER);
- dev_priv = dev->dev_private;
- if (dev_priv == NULL)
- return ENOMEM;
- }
-
if (dev_priv->FBHeap != NULL)
- return EINVAL;
+ return (EINVAL);
dev_priv->FBHeap = mmInit(fb->offset, fb->size);
@@ -164,14 +156,6 @@ int sis_ioctl_agp_init(struct drm_device *dev, void *data, struct drm_file *file
drm_sis_private_t *dev_priv = dev->dev_private;
drm_sis_agp_t *agp = data;
- if (dev_priv == NULL) {
- dev->dev_private = drm_calloc(1, sizeof(drm_sis_private_t),
- DRM_MEM_DRIVER);
- dev_priv = dev->dev_private;
- if (dev_priv == NULL)
- return ENOMEM;
- }
-
if (dev_priv->AGPHeap != NULL)
return EINVAL;
diff --git a/sys/dev/pci/drm/tdfx_drv.c b/sys/dev/pci/drm/tdfx_drv.c
index 4456a7bf99e..660eac5ac42 100644
--- a/sys/dev/pci/drm/tdfx_drv.c
+++ b/sys/dev/pci/drm/tdfx_drv.c
@@ -35,7 +35,10 @@
#include "tdfx_drv.h"
#include "drmP.h"
-static drm_pci_id_list_t tdfx_pciidlist[] = {
+int tdfxdrm_probe(struct device *, void *, void *);
+void tdfxdrm_attach(struct device *, struct device *, void *);
+
+static drm_pci_id_list_t tdfxdrm_pciidlist[] = {
{PCI_VENDOR_3DFX, PCI_PRODUCT_3DFX_BANSHEE},
{PCI_VENDOR_3DFX, PCI_PRODUCT_3DFX_VOODOO32000},
{PCI_VENDOR_3DFX, PCI_PRODUCT_3DFX_VOODOO3},
@@ -45,7 +48,7 @@ static drm_pci_id_list_t tdfx_pciidlist[] = {
{0, 0, 0}
};
-static const struct drm_driver_info tdfx_driver = {
+static const struct drm_driver_info tdfxdrm_driver = {
.buf_priv_size = 1, /* No dev_priv */
.name = DRIVER_NAME,
@@ -58,13 +61,10 @@ static const struct drm_driver_info tdfx_driver = {
.flags = DRIVER_MTRR,
};
-int tdfxdrm_probe(struct device *, void *, void *);
-void tdfxdrm_attach(struct device *, struct device *, void *);
-
int
tdfxdrm_probe(struct device *parent, void *match, void *aux)
{
- return drm_probe((struct pci_attach_args *)aux, tdfx_pciidlist);
+ return drm_probe((struct pci_attach_args *)aux, tdfxdrm_pciidlist);
}
void
@@ -73,8 +73,8 @@ tdfxdrm_attach(struct device *parent, struct device *self, void *aux)
struct pci_attach_args *pa = aux;
struct drm_device *dev = (struct drm_device *)self;
- dev->driver = &tdfx_driver;
- return drm_attach(parent, self, pa, tdfx_pciidlist);
+ dev->driver = &tdfxdrm_driver;
+ return drm_attach(parent, self, pa);
}
struct cfattach tdfxdrm_ca = {