diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-11-22 14:42:37 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-11-22 14:42:37 +0000 |
commit | a714fd2e735156d99ef7b116ecd1a2fdf32cdadb (patch) | |
tree | 5dc1408fac391297810faebdba47591d39f9ed56 /sys/dev/pci | |
parent | 74c8fafc99a7d1c884138462d4f8df03656fbb87 (diff) |
reduce the dependancy of drm_pci_alloc upon the drm device softc. Just
pass in the dma tag
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/drm/ati_pcigart.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/drm/drmP.h | 6 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_bufs.c | 11 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_dma.c | 2 | ||||
-rw-r--r-- | sys/dev/pci/drm/drm_pci.c | 26 | ||||
-rw-r--r-- | sys/dev/pci/drm/i915_dma.c | 24 | ||||
-rw-r--r-- | sys/dev/pci/drm/mach64_dma.c | 14 | ||||
-rw-r--r-- | sys/dev/pci/drm/mga_dma.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/drm/r128_cce.c | 6 | ||||
-rw-r--r-- | sys/dev/pci/drm/radeon_cp.c | 8 | ||||
-rw-r--r-- | sys/dev/pci/drm/savage_bci.c | 4 |
11 files changed, 56 insertions, 57 deletions
diff --git a/sys/dev/pci/drm/ati_pcigart.c b/sys/dev/pci/drm/ati_pcigart.c index a4627413b21..7ef8a44802e 100644 --- a/sys/dev/pci/drm/ati_pcigart.c +++ b/sys/dev/pci/drm/ati_pcigart.c @@ -48,8 +48,8 @@ int drm_ati_alloc_pcigart_table(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info) { - dev->sg->dmah = drm_pci_alloc(dev, gart_info->table_size, PAGE_SIZE, - gart_info->table_mask); + dev->sg->dmah = drm_pci_alloc(dev->pa.pa_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, dev->sg->dmah); + drm_pci_free(dev->pa.pa_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 e36c4aae466..f4fad5ca95f 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -752,9 +752,9 @@ int drm_sg_alloc_ioctl(struct drm_device *, void *, struct drm_file *); int drm_sg_free(struct drm_device *, void *, struct drm_file *); /* consistent PCI memory functions (drm_pci.c) */ -drm_dma_handle_t *drm_pci_alloc(struct drm_device *, size_t, size_t, +drm_dma_handle_t *drm_pci_alloc(bus_dma_tag_t, size_t, size_t, dma_addr_t); -void drm_pci_free(struct drm_device *, drm_dma_handle_t *); +void drm_pci_free(bus_dma_tag_t, drm_dma_handle_t *); /* Inline replacements for DRM_IOREMAP macros */ #define drm_core_ioremap_wc drm_core_ioremap @@ -762,7 +762,7 @@ static __inline__ void drm_core_ioremap(struct drm_local_map *map, struct drm_de { map->handle = drm_ioremap(dev, map); } -static __inline__ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev) +static __inline__ void drm_core_ioremapfree(struct drm_local_map *map) { if ( map->handle && map->size ) drm_ioremapfree(map); diff --git a/sys/dev/pci/drm/drm_bufs.c b/sys/dev/pci/drm/drm_bufs.c index 94208d556b2..9403bdf22cd 100644 --- a/sys/dev/pci/drm/drm_bufs.c +++ b/sys/dev/pci/drm/drm_bufs.c @@ -250,7 +250,8 @@ 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, map->size, align, 0xfffffffful); + map->dmah = drm_pci_alloc(dev->pa.pa_dmat, map->size, align, + 0xfffffffful); if (map->dmah == NULL) { drm_free(map, sizeof(*map), DRM_MEM_MAPS); return (ENOMEM); @@ -262,7 +263,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, map->dmah); + drm_pci_free(dev->pa.pa_dmat, map->dmah); drm_free(map, sizeof(*map), DRM_MEM_MAPS); return (EBUSY); } @@ -348,7 +349,7 @@ drm_rmmap_locked(struct drm_device *dev, drm_local_map_t *map) break; case _DRM_SHM: case _DRM_CONSISTENT: - drm_pci_free(dev, map->dmah); + drm_pci_free(dev->pa.pa_dmat, map->dmah); break; default: DRM_ERROR("Bad map type %d\n", map->type); @@ -594,8 +595,8 @@ 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, size, alignment, - 0xfffffffful); + drm_dma_handle_t *dmah = drm_pci_alloc(dev->pa.pa_dmat, size, + alignment, 0xfffffffful); if (dmah == NULL) { /* Set count correctly so we free the proper amount. */ entry->buf_count = count; diff --git a/sys/dev/pci/drm/drm_dma.c b/sys/dev/pci/drm/drm_dma.c index 06e2684ee3c..4100fb0c221 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, entry->seglist[i]); + drm_pci_free(dev->pa.pa_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_pci.c b/sys/dev/pci/drm/drm_pci.c index 8404297d169..cba243f001b 100644 --- a/sys/dev/pci/drm/drm_pci.c +++ b/sys/dev/pci/drm/drm_pci.c @@ -28,7 +28,7 @@ * memory block. */ drm_dma_handle_t * -drm_pci_alloc(struct drm_device *dev, size_t size, size_t align, +drm_pci_alloc(bus_dma_tag_t dmat, size_t size, size_t align, dma_addr_t maxaddr) { drm_dma_handle_t *dmah; @@ -45,11 +45,11 @@ drm_pci_alloc(struct drm_device *dev, size_t size, size_t align, if (dmah == NULL) return NULL; - if (bus_dmamap_create(dev->pa.pa_dmat, size, 1, size, 0, + if (bus_dmamap_create(dmat, size, 1, size, 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &dmah->dmamap) != 0) goto dmahfree; - if (bus_dmamem_alloc(dev->pa.pa_dmat, size, align, 0, + if (bus_dmamem_alloc(dmat, size, align, 0, &dmah->seg, 1, &nsegs, BUS_DMA_NOWAIT) != 0) { DRM_ERROR("bus_dmamem_alloc(%zd, %zd) returned %d\n", size, align, ret); @@ -61,13 +61,13 @@ drm_pci_alloc(struct drm_device *dev, size_t size, size_t align, goto free; } - if (bus_dmamem_map(dev->pa.pa_dmat, &dmah->seg, 1, size, + if (bus_dmamem_map(dmat, &dmah->seg, 1, size, (caddr_t*)&dmah->addr, BUS_DMA_NOWAIT) != 0) { DRM_ERROR("bus_dmamem_map() failed %d\n", ret); goto free; } - if (bus_dmamap_load(dev->pa.pa_dmat, dmah->dmamap, dmah->addr, size, + if (bus_dmamap_load(dmat, dmah->dmamap, dmah->addr, size, NULL, BUS_DMA_NOWAIT) != 0) goto unmap; @@ -78,11 +78,11 @@ drm_pci_alloc(struct drm_device *dev, size_t size, size_t align, return dmah; unmap: - bus_dmamem_unmap(dev->pa.pa_dmat, dmah->addr, size); + bus_dmamem_unmap(dmat, dmah->addr, size); free: - bus_dmamem_free(dev->pa.pa_dmat, &dmah->seg, 1); + bus_dmamem_free(dmat, &dmah->seg, 1); destroy: - bus_dmamap_destroy(dev->pa.pa_dmat, dmah->dmamap); + bus_dmamap_destroy(dmat, dmah->dmamap); dmahfree: drm_free(dmah, sizeof(*dmah), DRM_MEM_DMA); @@ -94,15 +94,15 @@ dmahfree: * Free a DMA-accessible consistent memory block. */ void -drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah) +drm_pci_free(bus_dma_tag_t dmat, drm_dma_handle_t *dmah) { if (dmah == NULL) return; - bus_dmamap_unload(dev->pa.pa_dmat, dmah->dmamap); - bus_dmamem_unmap(dev->pa.pa_dmat, dmah->vaddr, dmah->size); - bus_dmamem_free(dev->pa.pa_dmat, &dmah->seg, 1); - bus_dmamap_destroy(dev->pa.pa_dmat, dmah->dmamap); + bus_dmamap_unload(dmat, dmah->dmamap); + bus_dmamem_unmap(dmat, dmah->vaddr, dmah->size); + bus_dmamem_free(dmat, &dmah->seg, 1); + bus_dmamap_destroy(dmat, dmah->dmamap); drm_free(dmah, sizeof(*dmah), DRM_MEM_DMA); } diff --git a/sys/dev/pci/drm/i915_dma.c b/sys/dev/pci/drm/i915_dma.c index 01852eb901a..3c00381f23d 100644 --- a/sys/dev/pci/drm/i915_dma.c +++ b/sys/dev/pci/drm/i915_dma.c @@ -31,8 +31,8 @@ #include "i915_drm.h" #include "i915_drv.h" -int i915_init_phys_hws(struct drm_device *); -void i915_free_hws(struct drm_device *); +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 @@ -76,12 +76,11 @@ int i915_wait_ring(struct drm_device * dev, int n, const char *caller) * Sets up the hardware status page for devices that need a physical address * in the register. */ -int i915_init_phys_hws(struct drm_device *dev) +int i915_init_phys_hws(drm_i915_private_t *dev_priv, bus_dma_tag_t dmat) { - drm_i915_private_t *dev_priv = dev->dev_private; /* Program Hardware Status Page */ dev_priv->status_page_dmah = - drm_pci_alloc(dev, PAGE_SIZE, PAGE_SIZE, 0xffffffff); + drm_pci_alloc(dmat, PAGE_SIZE, PAGE_SIZE, 0xffffffff); if (!dev_priv->status_page_dmah) { DRM_ERROR("Can not allocate hardware status page\n"); @@ -101,17 +100,16 @@ int i915_init_phys_hws(struct drm_device *dev) * Frees the hardware status page, whether it's a physical address of a virtual * address set up by the X Server. */ -void i915_free_hws(struct drm_device *dev) +void i915_free_hws(drm_i915_private_t *dev_priv, bus_dma_tag_t dmat) { - drm_i915_private_t *dev_priv = dev->dev_private; if (dev_priv->status_page_dmah) { - drm_pci_free(dev, dev_priv->status_page_dmah); + drm_pci_free(dmat, dev_priv->status_page_dmah); dev_priv->status_page_dmah = NULL; } if (dev_priv->status_gfx_addr) { dev_priv->status_gfx_addr = 0; - drm_core_ioremapfree(&dev_priv->hws_map, dev); + drm_core_ioremapfree(&dev_priv->hws_map); } /* Need to rewrite hardware status page */ @@ -141,7 +139,7 @@ static int i915_dma_cleanup(struct drm_device * dev) drm_irq_uninstall(dev); if (dev_priv->ring.virtual_start) { - drm_core_ioremapfree(&dev_priv->ring.map, dev); + drm_core_ioremapfree(&dev_priv->ring.map); dev_priv->ring.virtual_start = NULL; dev_priv->ring.map.handle = NULL; dev_priv->ring.map.size = 0; @@ -149,7 +147,7 @@ static int i915_dma_cleanup(struct drm_device * dev) /* Clear the HWS virtual address at teardown */ if (I915_NEED_GFX_HWS(dev_priv)) - i915_free_hws(dev); + i915_free_hws(dev_priv, dev->pa.pa_dmat); return 0; } @@ -831,7 +829,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) /* Init HWS */ if (!I915_NEED_GFX_HWS(dev_priv)) { - ret = i915_init_phys_hws(dev); + ret = i915_init_phys_hws(dev_priv, dev->pa.pa_dmat); if (ret != 0) return ret; } @@ -845,7 +843,7 @@ int i915_driver_unload(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; - i915_free_hws(dev); + i915_free_hws(dev_priv, dev->pa.pa_dmat); if (dev_priv->regs != NULL) vga_pci_bar_unmap(dev_priv->regs); diff --git a/sys/dev/pci/drm/mach64_dma.c b/sys/dev/pci/drm/mach64_dma.c index f0c58f8bc0f..5092fce4a70 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, 0x1000, 0x1000, 0xfffffffful); + drm_pci_alloc(dev->pa.pa_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, cpu_addr_dmah); + drm_pci_free(dev->pa.pa_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, cpu_addr_dmah); + drm_pci_free(dev->pa.pa_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, cpu_addr_dmah); + drm_pci_free(dev->pa.pa_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, cpu_addr_dmah); + drm_pci_free(dev->pa.pa_dmat, cpu_addr_dmah); DRM_DEBUG("returning ...\n"); return failed; @@ -1374,10 +1374,10 @@ int mach64_do_cleanup_dma(struct drm_device * dev) if (!dev_priv->is_pci) { if (dev_priv->ring_map) - drm_core_ioremapfree(dev_priv->ring_map, dev); + drm_core_ioremapfree(dev_priv->ring_map); if (dev->agp_buffer_map) { - drm_core_ioremapfree(dev->agp_buffer_map, dev); + drm_core_ioremapfree(dev->agp_buffer_map); dev->agp_buffer_map = NULL; } } diff --git a/sys/dev/pci/drm/mga_dma.c b/sys/dev/pci/drm/mga_dma.c index a7a941af2c2..b7e729ceb72 100644 --- a/sys/dev/pci/drm/mga_dma.c +++ b/sys/dev/pci/drm/mga_dma.c @@ -920,14 +920,14 @@ static int mga_do_cleanup_dma(struct drm_device *dev, int full_cleanup) if ((dev_priv->warp != NULL) && (dev_priv->warp->type != _DRM_CONSISTENT)) - drm_core_ioremapfree(dev_priv->warp, dev); + drm_core_ioremapfree(dev_priv->warp); if ((dev_priv->primary != NULL) && (dev_priv->primary->type != _DRM_CONSISTENT)) - drm_core_ioremapfree(dev_priv->primary, dev); + drm_core_ioremapfree(dev_priv->primary); if (dev->agp_buffer_map != NULL) - drm_core_ioremapfree(dev->agp_buffer_map, dev); + drm_core_ioremapfree(dev->agp_buffer_map); if (dev_priv->used_new_dma_init) { if (dev_priv->agp_handle != 0) { diff --git a/sys/dev/pci/drm/r128_cce.c b/sys/dev/pci/drm/r128_cce.c index d000b24cac2..d41d089ddea 100644 --- a/sys/dev/pci/drm/r128_cce.c +++ b/sys/dev/pci/drm/r128_cce.c @@ -598,11 +598,11 @@ int r128_do_cleanup_cce(struct drm_device * dev) #if __OS_HAS_AGP if (!dev_priv->is_pci) { if (dev_priv->cce_ring != NULL) - drm_core_ioremapfree(dev_priv->cce_ring, dev); + drm_core_ioremapfree(dev_priv->cce_ring); if (dev_priv->ring_rptr != NULL) - drm_core_ioremapfree(dev_priv->ring_rptr, dev); + drm_core_ioremapfree(dev_priv->ring_rptr); if (dev->agp_buffer_map != NULL) { - drm_core_ioremapfree(dev->agp_buffer_map, dev); + drm_core_ioremapfree(dev->agp_buffer_map); dev->agp_buffer_map = NULL; } } else diff --git a/sys/dev/pci/drm/radeon_cp.c b/sys/dev/pci/drm/radeon_cp.c index 78d356689a0..a8d78d7b882 100644 --- a/sys/dev/pci/drm/radeon_cp.c +++ b/sys/dev/pci/drm/radeon_cp.c @@ -1240,15 +1240,15 @@ static int radeon_do_cleanup_cp(struct drm_device * dev) #if __OS_HAS_AGP if (dev_priv->flags & RADEON_IS_AGP) { if (dev_priv->cp_ring != NULL) { - drm_core_ioremapfree(dev_priv->cp_ring, dev); + drm_core_ioremapfree(dev_priv->cp_ring); dev_priv->cp_ring = NULL; } if (dev_priv->ring_rptr != NULL) { - drm_core_ioremapfree(dev_priv->ring_rptr, dev); + drm_core_ioremapfree(dev_priv->ring_rptr); dev_priv->ring_rptr = NULL; } if (dev->agp_buffer_map != NULL) { - drm_core_ioremapfree(dev->agp_buffer_map, dev); + drm_core_ioremapfree(dev->agp_buffer_map); dev->agp_buffer_map = NULL; } } else @@ -1264,7 +1264,7 @@ static int radeon_do_cleanup_cp(struct drm_device * dev) if (dev_priv->gart_info.gart_table_location == DRM_ATI_GART_FB) { - drm_core_ioremapfree(&dev_priv->gart_info.mapping, dev); + drm_core_ioremapfree(&dev_priv->gart_info.mapping); dev_priv->gart_info.addr = 0; } } diff --git a/sys/dev/pci/drm/savage_bci.c b/sys/dev/pci/drm/savage_bci.c index 14aad7b0342..638c83eae8c 100644 --- a/sys/dev/pci/drm/savage_bci.c +++ b/sys/dev/pci/drm/savage_bci.c @@ -906,11 +906,11 @@ static int savage_do_cleanup_bci(struct drm_device *dev) } else if (dev_priv->cmd_dma && dev_priv->cmd_dma->handle && dev_priv->cmd_dma->type == _DRM_AGP && dev_priv->dma_type == SAVAGE_DMA_AGP) - drm_core_ioremapfree(dev_priv->cmd_dma, dev); + drm_core_ioremapfree(dev_priv->cmd_dma); if (dev_priv->dma_type == SAVAGE_DMA_AGP && dev->agp_buffer_map && dev->agp_buffer_map->handle) { - drm_core_ioremapfree(dev->agp_buffer_map, dev); + drm_core_ioremapfree(dev->agp_buffer_map); /* make sure the next instance (which may be running * in PCI mode) doesn't try to use an old * agp_buffer_map. */ |