diff options
author | Dave Airlie <airlied@linux.ie> | 2006-03-19 02:56:12 -0500 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2006-03-19 02:56:12 -0500 |
commit | ddf19b973be5a96d77c8467f657fe5bd7d126e0f (patch) | |
tree | e7b003b3dad82014b364acde5681956011e67b58 /drivers/char/drm/drm_bufs.c | |
parent | 60a6dc55b93b3321afa52f650a149fb7e87fa85a (diff) |
drm: fixup PCI DMA support
This patch makes the PCI support use the correct Linux interfaces finally.
Tested in DRM CVS on PCI MGA card.
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_bufs.c')
-rw-r--r-- | drivers/char/drm/drm_bufs.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c index e2637b4d51de..8a9cf12e6183 100644 --- a/drivers/char/drm/drm_bufs.c +++ b/drivers/char/drm/drm_bufs.c | |||
@@ -474,8 +474,7 @@ static void drm_cleanup_buf_error(drm_device_t * dev, drm_buf_entry_t * entry) | |||
474 | if (entry->seg_count) { | 474 | if (entry->seg_count) { |
475 | for (i = 0; i < entry->seg_count; i++) { | 475 | for (i = 0; i < entry->seg_count; i++) { |
476 | if (entry->seglist[i]) { | 476 | if (entry->seglist[i]) { |
477 | drm_free_pages(entry->seglist[i], | 477 | drm_pci_free(dev, entry->seglist[i]); |
478 | entry->page_order, DRM_MEM_DMA); | ||
479 | } | 478 | } |
480 | } | 479 | } |
481 | drm_free(entry->seglist, | 480 | drm_free(entry->seglist, |
@@ -678,7 +677,7 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request) | |||
678 | int total; | 677 | int total; |
679 | int page_order; | 678 | int page_order; |
680 | drm_buf_entry_t *entry; | 679 | drm_buf_entry_t *entry; |
681 | unsigned long page; | 680 | drm_dma_handle_t *dmah; |
682 | drm_buf_t *buf; | 681 | drm_buf_t *buf; |
683 | int alignment; | 682 | int alignment; |
684 | unsigned long offset; | 683 | unsigned long offset; |
@@ -781,8 +780,10 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request) | |||
781 | page_count = 0; | 780 | page_count = 0; |
782 | 781 | ||
783 | while (entry->buf_count < count) { | 782 | while (entry->buf_count < count) { |
784 | page = drm_alloc_pages(page_order, DRM_MEM_DMA); | 783 | |
785 | if (!page) { | 784 | dmah = drm_pci_alloc(dev, PAGE_SIZE << page_order, 0x1000, 0xfffffffful); |
785 | |||
786 | if (!dmah) { | ||
786 | /* Set count correctly so we free the proper amount. */ | 787 | /* Set count correctly so we free the proper amount. */ |
787 | entry->buf_count = count; | 788 | entry->buf_count = count; |
788 | entry->seg_count = count; | 789 | entry->seg_count = count; |
@@ -794,13 +795,13 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request) | |||
794 | atomic_dec(&dev->buf_alloc); | 795 | atomic_dec(&dev->buf_alloc); |
795 | return -ENOMEM; | 796 | return -ENOMEM; |
796 | } | 797 | } |
797 | entry->seglist[entry->seg_count++] = page; | 798 | entry->seglist[entry->seg_count++] = dmah; |
798 | for (i = 0; i < (1 << page_order); i++) { | 799 | for (i = 0; i < (1 << page_order); i++) { |
799 | DRM_DEBUG("page %d @ 0x%08lx\n", | 800 | DRM_DEBUG("page %d @ 0x%08lx\n", |
800 | dma->page_count + page_count, | 801 | dma->page_count + page_count, |
801 | page + PAGE_SIZE * i); | 802 | (unsigned long)dmah->vaddr + PAGE_SIZE * i); |
802 | temp_pagelist[dma->page_count + page_count++] | 803 | temp_pagelist[dma->page_count + page_count++] |
803 | = page + PAGE_SIZE * i; | 804 | = (unsigned long)dmah->vaddr + PAGE_SIZE * i; |
804 | } | 805 | } |
805 | for (offset = 0; | 806 | for (offset = 0; |
806 | offset + size <= total && entry->buf_count < count; | 807 | offset + size <= total && entry->buf_count < count; |
@@ -811,7 +812,8 @@ int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request) | |||
811 | buf->order = order; | 812 | buf->order = order; |
812 | buf->used = 0; | 813 | buf->used = 0; |
813 | buf->offset = (dma->byte_count + byte_count + offset); | 814 | buf->offset = (dma->byte_count + byte_count + offset); |
814 | buf->address = (void *)(page + offset); | 815 | buf->address = (void *)(dmah->vaddr + offset); |
816 | buf->bus_address = dmah->busaddr + offset; | ||
815 | buf->next = NULL; | 817 | buf->next = NULL; |
816 | buf->waiting = 0; | 818 | buf->waiting = 0; |
817 | buf->pending = 0; | 819 | buf->pending = 0; |