summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2008-11-23 22:56:03 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2008-11-23 22:56:03 +0000
commit1d7e5147d3dc81330b16094ced38b06c932348c5 (patch)
tree1724295808d749af180f138b4829bada8188ae1d /sys/dev/pci/drm
parentc791069d8055cb759d9d899b60dcc500533efd9c (diff)
pass in the dmat when we attach the drm driver. reduces pci dependancy.
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r--sys/dev/pci/drm/ati_pcigart.c4
-rw-r--r--sys/dev/pci/drm/drmP.h5
-rw-r--r--sys/dev/pci/drm/drm_bufs.c8
-rw-r--r--sys/dev/pci/drm/drm_dma.c2
-rw-r--r--sys/dev/pci/drm/drm_drv.c6
-rw-r--r--sys/dev/pci/drm/drm_scatter.c22
-rw-r--r--sys/dev/pci/drm/drm_vm.c4
-rw-r--r--sys/dev/pci/drm/i915_drv.c2
-rw-r--r--sys/dev/pci/drm/mach64_dma.c10
-rw-r--r--sys/dev/pci/drm/mach64_drv.c2
-rw-r--r--sys/dev/pci/drm/mga_drv.c2
-rw-r--r--sys/dev/pci/drm/r128_drv.c2
-rw-r--r--sys/dev/pci/drm/radeon_drv.c2
-rw-r--r--sys/dev/pci/drm/savage_drv.c2
-rw-r--r--sys/dev/pci/drm/sis_drv.c2
-rw-r--r--sys/dev/pci/drm/tdfx_drv.c2
16 files changed, 41 insertions, 36 deletions
diff --git a/sys/dev/pci/drm/ati_pcigart.c b/sys/dev/pci/drm/ati_pcigart.c
index 7ef8a44802e..2de7d9ea041 100644
--- a/sys/dev/pci/drm/ati_pcigart.c
+++ b/sys/dev/pci/drm/ati_pcigart.c
@@ -48,7 +48,7 @@ int
drm_ati_alloc_pcigart_table(struct drm_device *dev,
struct drm_ati_pcigart_info *gart_info)
{
- dev->sg->dmah = drm_pci_alloc(dev->pa.pa_dmat, gart_info->table_size,
+ dev->sg->dmah = drm_pci_alloc(dev->dmat, gart_info->table_size,
PAGE_SIZE, gart_info->table_mask);
if (dev->sg->dmah == NULL)
return ENOMEM;
@@ -60,7 +60,7 @@ void
drm_ati_free_pcigart_table(struct drm_device *dev,
struct drm_ati_pcigart_info *gart_info)
{
- drm_pci_free(dev->pa.pa_dmat, dev->sg->dmah);
+ drm_pci_free(dev->dmat, dev->sg->dmah);
dev->sg->dmah = NULL;
}
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 987c7a00a83..ca929f091e3 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -498,6 +498,8 @@ struct drm_device {
const struct drm_driver_info *driver;
+ bus_dma_tag_t dmat;
+
char *unique; /* Unique identifier: e.g., busid */
int unique_len; /* Length of unique field */
@@ -561,13 +563,14 @@ struct drm_attach_args {
const struct drm_driver_info *driver;
struct pci_attach_args *pa;
struct vga_pci_softc *vga;
+ bus_dma_tag_t dmat;
};
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 *,
+struct device *drm_attach_mi(const struct drm_driver_info *, bus_dma_tag_t,
struct pci_attach_args *pa, struct device *);
dev_type_ioctl(drmioctl);
dev_type_open(drmopen);
diff --git a/sys/dev/pci/drm/drm_bufs.c b/sys/dev/pci/drm/drm_bufs.c
index bd0c74ad8c6..58488b9668c 100644
--- a/sys/dev/pci/drm/drm_bufs.c
+++ b/sys/dev/pci/drm/drm_bufs.c
@@ -206,7 +206,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
align = map->size;
if ((align & (align - 1)) != 0)
align = PAGE_SIZE;
- map->dmah = drm_pci_alloc(dev->pa.pa_dmat, map->size, align,
+ map->dmah = drm_pci_alloc(dev->dmat, map->size, align,
0xfffffffful);
if (map->dmah == NULL) {
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
@@ -219,7 +219,7 @@ drm_addmap(struct drm_device * dev, unsigned long offset, unsigned long size,
/* Prevent a 2nd X Server from creating a 2nd lock */
if (dev->lock.hw_lock != NULL) {
DRM_UNLOCK();
- drm_pci_free(dev->pa.pa_dmat, map->dmah);
+ drm_pci_free(dev->dmat, map->dmah);
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
return (EBUSY);
}
@@ -306,7 +306,7 @@ drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map)
case _DRM_SHM:
/* FALLTHROUGH */
case _DRM_CONSISTENT:
- drm_pci_free(dev->pa.pa_dmat, map->dmah);
+ drm_pci_free(dev->dmat, map->dmah);
break;
default:
DRM_ERROR("Bad map type %d\n", map->type);
@@ -552,7 +552,7 @@ drm_do_addbufs_pci(struct drm_device *dev, struct drm_buf_desc *request)
page_count = 0;
while (entry->buf_count < count) {
- drm_dma_handle_t *dmah = drm_pci_alloc(dev->pa.pa_dmat, size,
+ drm_dma_handle_t *dmah = drm_pci_alloc(dev->dmat, size,
alignment, 0xfffffffful);
if (dmah == NULL) {
/* Set count correctly so we free the proper amount. */
diff --git a/sys/dev/pci/drm/drm_dma.c b/sys/dev/pci/drm/drm_dma.c
index 4100fb0c221..88334924a6f 100644
--- a/sys/dev/pci/drm/drm_dma.c
+++ b/sys/dev/pci/drm/drm_dma.c
@@ -60,7 +60,7 @@ drm_cleanup_buf(struct drm_device *dev, drm_buf_entry_t *entry)
if (entry->seg_count) {
for (i = 0; i < entry->seg_count; i++)
- drm_pci_free(dev->pa.pa_dmat, entry->seglist[i]);
+ drm_pci_free(dev->dmat, entry->seglist[i]);
drm_free(entry->seglist, entry->seg_count *
sizeof(*entry->seglist), DRM_MEM_BUFS);
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index a855a3a61e8..6026a95ee19 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -56,13 +56,14 @@ int drm_activate(struct device *, enum devact);
int drmprint(void *, const char *);
struct device *
-drm_attach_mi(const struct drm_driver_info *driver, struct pci_attach_args *pa,
- struct device *dev)
+drm_attach_mi(const struct drm_driver_info *driver, bus_dma_tag_t dmat,
+ struct pci_attach_args *pa, struct device *dev)
{
struct drm_attach_args arg;
arg.driver = driver;
arg.pa = pa;
+ arg.dmat = dmat;
printf("\n");
return (config_found(dev, &arg, drmprint));
@@ -110,6 +111,7 @@ drm_attach(struct device *parent, struct device *self, void *aux)
/* 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;
diff --git a/sys/dev/pci/drm/drm_scatter.c b/sys/dev/pci/drm/drm_scatter.c
index 0def5031699..a34ae5f9533 100644
--- a/sys/dev/pci/drm/drm_scatter.c
+++ b/sys/dev/pci/drm/drm_scatter.c
@@ -35,7 +35,7 @@
*/
#include "drmP.h"
-struct drm_sg_dmamem *drm_sg_dmamem_alloc(struct drm_device *, size_t);
+struct drm_sg_dmamem *drm_sg_dmamem_alloc(bus_dma_tag_t, size_t);
void drm_sg_dmamem_free(struct drm_sg_dmamem *);
void
@@ -76,7 +76,7 @@ drm_sg_alloc(struct drm_device * dev, struct drm_scatter_gather *request)
return ENOMEM;
}
- if ((entry->mem = drm_sg_dmamem_alloc(dev, pages)) == NULL) {
+ if ((entry->mem = drm_sg_dmamem_alloc(dev->dmat, pages)) == NULL) {
drm_sg_cleanup(entry);
return ENOMEM;
}
@@ -142,7 +142,7 @@ drm_sg_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
* scatter/gather
*/
struct drm_sg_dmamem*
-drm_sg_dmamem_alloc(struct drm_device *dev, size_t pages)
+drm_sg_dmamem_alloc(bus_dma_tag_t dmat, size_t pages)
{
struct drm_sg_dmamem *dsd = NULL;
bus_size_t size = pages << PAGE_SHIFT;
@@ -157,22 +157,22 @@ drm_sg_dmamem_alloc(struct drm_device *dev, size_t pages)
if (dsd->sg_segs == NULL)
goto dsdfree;
- dsd->sg_tag = dev->pa.pa_dmat;
+ dsd->sg_tag = dmat;
dsd->sg_size = size;
- if (bus_dmamap_create(dev->pa.pa_dmat, size, pages, PAGE_SIZE, 0,
+ if (bus_dmamap_create(dmat, size, pages, PAGE_SIZE, 0,
BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &dsd->sg_map) != 0)
goto segsfree;
- if ((ret = bus_dmamem_alloc(dev->pa.pa_dmat, size, PAGE_SIZE, 0,
+ if ((ret = bus_dmamem_alloc(dmat, size, PAGE_SIZE, 0,
dsd->sg_segs, pages, &dsd->sg_nsegs, BUS_DMA_NOWAIT)) != 0)
goto destroy;
- if (bus_dmamem_map(dev->pa.pa_dmat, dsd->sg_segs, dsd->sg_nsegs, size,
+ if (bus_dmamem_map(dmat, dsd->sg_segs, dsd->sg_nsegs, size,
&dsd->sg_kva, BUS_DMA_NOWAIT) != 0)
goto free;
- if (bus_dmamap_load(dev->pa.pa_dmat, dsd->sg_map, dsd->sg_kva, size,
+ if (bus_dmamap_load(dmat, dsd->sg_map, dsd->sg_kva, size,
NULL, BUS_DMA_NOWAIT) != 0)
goto unmap;
@@ -181,11 +181,11 @@ drm_sg_dmamem_alloc(struct drm_device *dev, size_t pages)
return (dsd);
unmap:
- bus_dmamem_unmap(dev->pa.pa_dmat, dsd->sg_kva, size);
+ bus_dmamem_unmap(dmat, dsd->sg_kva, size);
free:
- bus_dmamem_free(dev->pa.pa_dmat, dsd->sg_segs, dsd->sg_nsegs);
+ bus_dmamem_free(dmat, dsd->sg_segs, dsd->sg_nsegs);
destroy:
- bus_dmamap_destroy(dev->pa.pa_dmat, dsd->sg_map);
+ bus_dmamap_destroy(dmat, dsd->sg_map);
segsfree:
drm_free(dsd->sg_segs, sizeof(*dsd->sg_segs) * pages, DRM_MEM_SGLISTS);
diff --git a/sys/dev/pci/drm/drm_vm.c b/sys/dev/pci/drm/drm_vm.c
index f9d3d13da7c..a459f3a9e2d 100644
--- a/sys/dev/pci/drm/drm_vm.c
+++ b/sys/dev/pci/drm/drm_vm.c
@@ -102,12 +102,12 @@ drmmmap(dev_t kdev, off_t offset, int prot)
break;
/* XXX unify all the bus_dmamem_mmap bits */
case _DRM_SCATTER_GATHER:
- return (bus_dmamem_mmap(dev->pa.pa_dmat, dev->sg->mem->sg_segs,
+ return (bus_dmamem_mmap(dev->dmat, dev->sg->mem->sg_segs,
dev->sg->mem->sg_nsegs, map->offset - dev->sg->handle +
offset, prot, BUS_DMA_NOWAIT));
case _DRM_SHM:
case _DRM_CONSISTENT:
- return (bus_dmamem_mmap(dev->pa.pa_dmat, &map->dmah->seg, 1,
+ return (bus_dmamem_mmap(dev->dmat, &map->dmah->seg, 1,
offset, prot, BUS_DMA_NOWAIT));
default:
DRM_ERROR("bad map type %d\n", type);
diff --git a/sys/dev/pci/drm/i915_drv.c b/sys/dev/pci/drm/i915_drv.c
index 830b068629e..d70d273115d 100644
--- a/sys/dev/pci/drm/i915_drv.c
+++ b/sys/dev/pci/drm/i915_drv.c
@@ -164,7 +164,7 @@ inteldrm_attach(struct device *parent, struct device *self, void *aux)
mtx_init(&dev_priv->user_irq_lock, IPL_BIO);
- dev_priv->drmdev = drm_attach_mi(&inteldrm_driver, pa, self);
+ dev_priv->drmdev = drm_attach_mi(&inteldrm_driver, pa->pa_dmat, pa, self);
}
int
diff --git a/sys/dev/pci/drm/mach64_dma.c b/sys/dev/pci/drm/mach64_dma.c
index f93f4474211..9d752b757c7 100644
--- a/sys/dev/pci/drm/mach64_dma.c
+++ b/sys/dev/pci/drm/mach64_dma.c
@@ -835,7 +835,7 @@ static int mach64_bm_dma_test(struct drm_device * dev)
/* FIXME: get a dma buffer from the freelist here */
DRM_DEBUG("Allocating data memory ...\n");
cpu_addr_dmah =
- drm_pci_alloc(dev->pa.pa_dmat, 0x1000, 0x1000, 0xfffffffful);
+ drm_pci_alloc(dev->dmat, 0x1000, 0x1000, 0xfffffffful);
if (!cpu_addr_dmah) {
DRM_INFO("data-memory allocation failed!\n");
return ENOMEM;
@@ -869,7 +869,7 @@ static int mach64_bm_dma_test(struct drm_device * dev)
DRM_INFO("resetting engine ...\n");
mach64_do_engine_reset(dev_priv);
DRM_INFO("freeing data buffer memory.\n");
- drm_pci_free(dev->pa.pa_dmat, cpu_addr_dmah);
+ drm_pci_free(dev->dmat, cpu_addr_dmah);
return EIO;
}
}
@@ -924,7 +924,7 @@ static int mach64_bm_dma_test(struct drm_device * dev)
MACH64_WRITE(MACH64_PAT_REG0, pat_reg0);
MACH64_WRITE(MACH64_PAT_REG1, pat_reg1);
DRM_INFO("freeing data buffer memory.\n");
- drm_pci_free(dev->pa.pa_dmat, cpu_addr_dmah);
+ drm_pci_free(dev->dmat, cpu_addr_dmah);
return i;
}
DRM_DEBUG("waiting for idle...done\n");
@@ -960,7 +960,7 @@ static int mach64_bm_dma_test(struct drm_device * dev)
MACH64_WRITE(MACH64_PAT_REG0, pat_reg0);
MACH64_WRITE(MACH64_PAT_REG1, pat_reg1);
DRM_INFO("freeing data buffer memory.\n");
- drm_pci_free(dev->pa.pa_dmat, cpu_addr_dmah);
+ drm_pci_free(dev->dmat, cpu_addr_dmah);
return i;
}
@@ -988,7 +988,7 @@ static int mach64_bm_dma_test(struct drm_device * dev)
MACH64_WRITE(MACH64_PAT_REG1, pat_reg1);
DRM_DEBUG("freeing data buffer memory.\n");
- drm_pci_free(dev->pa.pa_dmat, cpu_addr_dmah);
+ drm_pci_free(dev->dmat, cpu_addr_dmah);
DRM_DEBUG("returning ...\n");
return failed;
diff --git a/sys/dev/pci/drm/mach64_drv.c b/sys/dev/pci/drm/mach64_drv.c
index dc29df381ec..ea92e429252 100644
--- a/sys/dev/pci/drm/mach64_drv.c
+++ b/sys/dev/pci/drm/mach64_drv.c
@@ -123,7 +123,7 @@ machdrm_attach(struct device *parent, struct device *self, void *aux)
return;
}
- dev_priv->drmdev = drm_attach_mi(&machdrm_driver, pa, self);
+ dev_priv->drmdev = drm_attach_mi(&machdrm_driver, pa->pa_dmat, pa, self);
}
int
diff --git a/sys/dev/pci/drm/mga_drv.c b/sys/dev/pci/drm/mga_drv.c
index cd548590644..59911938323 100644
--- a/sys/dev/pci/drm/mga_drv.c
+++ b/sys/dev/pci/drm/mga_drv.c
@@ -168,7 +168,7 @@ mgadrm_attach(struct device *parent, struct device *self, void *aux)
return;
}
- dev_priv->drmdev = drm_attach_mi(&mga_driver, pa, self);
+ dev_priv->drmdev = drm_attach_mi(&mga_driver, pa->pa_dmat, pa, self);
}
int
diff --git a/sys/dev/pci/drm/r128_drv.c b/sys/dev/pci/drm/r128_drv.c
index 97bd7908e72..f4042a2864a 100644
--- a/sys/dev/pci/drm/r128_drv.c
+++ b/sys/dev/pci/drm/r128_drv.c
@@ -140,7 +140,7 @@ ragedrm_attach(struct device *parent, struct device *self, void *aux)
return;
}
- dev_priv->drmdev = drm_attach_mi(&ragedrm_driver, pa, self);
+ dev_priv->drmdev = drm_attach_mi(&ragedrm_driver, pa->pa_dmat, pa, self);
}
int
diff --git a/sys/dev/pci/drm/radeon_drv.c b/sys/dev/pci/drm/radeon_drv.c
index 22fdf1cf55e..994183f194f 100644
--- a/sys/dev/pci/drm/radeon_drv.c
+++ b/sys/dev/pci/drm/radeon_drv.c
@@ -582,7 +582,7 @@ radeondrm_attach(struct device *parent, struct device *self, void *aux)
((dev_priv->flags & RADEON_IS_AGP) ? "AGP" :
(((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI"))));
- dev_priv->drmdev = drm_attach_mi(&radeondrm_driver, pa, self);
+ dev_priv->drmdev = drm_attach_mi(&radeondrm_driver, pa->pa_dmat, pa, self);
}
int
diff --git a/sys/dev/pci/drm/savage_drv.c b/sys/dev/pci/drm/savage_drv.c
index 8fd23aa8f7c..8c0ec5866ca 100644
--- a/sys/dev/pci/drm/savage_drv.c
+++ b/sys/dev/pci/drm/savage_drv.c
@@ -168,7 +168,7 @@ savagedrm_attach(struct device *parent, struct device *self, void *aux)
}
dev_priv->bst = pa->pa_memt;
- dev_priv->drmdev = drm_attach_mi(&savagedrm_driver, pa, self);
+ dev_priv->drmdev = drm_attach_mi(&savagedrm_driver, pa->pa_dmat, pa, self);
}
int
diff --git a/sys/dev/pci/drm/sis_drv.c b/sys/dev/pci/drm/sis_drv.c
index baa30c04d40..5a8be935eb0 100644
--- a/sys/dev/pci/drm/sis_drv.c
+++ b/sys/dev/pci/drm/sis_drv.c
@@ -74,7 +74,7 @@ sisdrm_attach(struct device *parent, struct device *self, void *aux)
drm_sis_private_t *dev_priv = (drm_sis_private_t *)self;
struct pci_attach_args *pa = aux;
- dev_priv->drmdev = drm_attach_mi(&sis_driver, pa, self);
+ dev_priv->drmdev = drm_attach_mi(&sis_driver, pa->pa_dmat, pa, self);
}
int
diff --git a/sys/dev/pci/drm/tdfx_drv.c b/sys/dev/pci/drm/tdfx_drv.c
index 31cb3f156f6..ae739197ae4 100644
--- a/sys/dev/pci/drm/tdfx_drv.c
+++ b/sys/dev/pci/drm/tdfx_drv.c
@@ -78,7 +78,7 @@ tdfxdrm_attach(struct device *parent, struct device *self, void *aux)
struct tdfxdrm_softc *dev_priv = (struct tdfxdrm_softc *)self;
struct pci_attach_args *pa = aux;
- dev_priv->drmdev = drm_attach_mi(&tdfxdrm_driver, pa, self);
+ dev_priv->drmdev = drm_attach_mi(&tdfxdrm_driver, pa->pa_dmat, pa, self);
}
struct cfattach tdfxdrm_ca = {