summaryrefslogtreecommitdiff
path: root/bsd-core/drm_dma.c
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2003-04-26 22:52:39 +0000
committerEric Anholt <anholt@freebsd.org>2003-04-26 22:52:39 +0000
commitce514e08aa8fdbdf52da2ac2cbdace68e0b25210 (patch)
tree4c7101a5f73d5fcface6aeee9b4f599d6a3be9ce /bsd-core/drm_dma.c
parentf2a0c5438dc83171de1007a68e4f98e35b5a8fbe (diff)
Add PCI DMA memory functions and make addbufs_pci and associated code use
it. To do this we need to save the bus address along with the virtual address in the seglist. Also fix some error handling and a few bits of whitespace.
Diffstat (limited to 'bsd-core/drm_dma.c')
-rw-r--r--bsd-core/drm_dma.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/bsd-core/drm_dma.c b/bsd-core/drm_dma.c
index 4ddf8b22..526faee2 100644
--- a/bsd-core/drm_dma.c
+++ b/bsd-core/drm_dma.c
@@ -70,6 +70,7 @@ void DRM(dma_takedown)(drm_device_t *dev)
/* Clear dma buffers */
for (i = 0; i <= DRM_MAX_ORDER; i++) {
+#if __HAVE_PCI_DMA
if (dma->bufs[i].seg_count) {
DRM_DEBUG("order %d: buf_count = %d,"
" seg_count = %d\n",
@@ -77,22 +78,27 @@ void DRM(dma_takedown)(drm_device_t *dev)
dma->bufs[i].buf_count,
dma->bufs[i].seg_count);
for (j = 0; j < dma->bufs[i].seg_count; j++) {
- DRM(free)((void *)dma->bufs[i].seglist[j],
- dma->bufs[i].buf_size,
- DRM_MEM_DMA);
+ if (dma->bufs[i].seglist[j] != NULL)
+ DRM(pci_free)(dev, dma->bufs[i].buf_size,
+ (void *)dma->bufs[i].seglist[j],
+ dma->bufs[i].seglist_bus[j]);
}
DRM(free)(dma->bufs[i].seglist,
dma->bufs[i].seg_count
* sizeof(*dma->bufs[0].seglist),
DRM_MEM_SEGS);
+ DRM(free)(dma->bufs[i].seglist_bus,
+ dma->bufs[i].seg_count
+ * sizeof(*dma->bufs[0].seglist_bus),
+ DRM_MEM_SEGS);
}
- if(dma->bufs[i].buf_count) {
- for(j = 0; j < dma->bufs[i].buf_count; j++) {
- if(dma->bufs[i].buflist[j].dev_private) {
- DRM(free)(dma->bufs[i].buflist[j].dev_private,
+#endif /* __HAVE_PCI_DMA */
+
+ if (dma->bufs[i].buf_count) {
+ for (j = 0; j < dma->bufs[i].buf_count; j++) {
+ DRM(free)(dma->bufs[i].buflist[j].dev_private,
dma->bufs[i].buflist[j].dev_priv_size,
DRM_MEM_BUFS);
- }
}
DRM(free)(dma->bufs[i].buflist,
dma->bufs[i].buf_count *
@@ -101,17 +107,10 @@ void DRM(dma_takedown)(drm_device_t *dev)
}
}
- if (dma->buflist) {
- DRM(free)(dma->buflist,
- dma->buf_count * sizeof(*dma->buflist),
- DRM_MEM_BUFS);
- }
-
- if (dma->pagelist) {
- DRM(free)(dma->pagelist,
- dma->page_count * sizeof(*dma->pagelist),
- DRM_MEM_PAGES);
- }
+ DRM(free)(dma->buflist, dma->buf_count * sizeof(*dma->buflist),
+ DRM_MEM_BUFS);
+ DRM(free)(dma->pagelist, dma->page_count * sizeof(*dma->pagelist),
+ DRM_MEM_PAGES);
DRM(free)(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER);
dev->dma = NULL;
}