drm: remove usage of drm_pci_alloc/free
authorJoseph Kogut <joseph.kogut@gmail.com>
Fri, 23 Apr 2021 02:02:43 +0000 (19:02 -0700)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 26 Apr 2021 16:19:15 +0000 (18:19 +0200)
Remove usage of legacy dma-api abstraction in preparation for removal

Signed-off-by: Joseph Kogut <joseph.kogut@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210423020248.3427369-1-joseph.kogut@gmail.com
drivers/gpu/drm/drm_bufs.c
drivers/gpu/drm/drm_dma.c
drivers/gpu/drm/r128/ati_pcigart.c

index 410623f..311dbd3 100644 (file)
@@ -675,12 +675,17 @@ int drm_legacy_rmmap_ioctl(struct drm_device *dev, void *data,
 static void drm_cleanup_buf_error(struct drm_device *dev,
                                  struct drm_buf_entry *entry)
 {
+       drm_dma_handle_t *dmah;
        int i;
 
        if (entry->seg_count) {
                for (i = 0; i < entry->seg_count; i++) {
                        if (entry->seglist[i]) {
-                               drm_pci_free(dev, entry->seglist[i]);
+                               dmah = entry->seglist[i];
+                               dma_free_coherent(dev->dev,
+                                                 dmah->size,
+                                                 dmah->vaddr,
+                                                 dmah->busaddr);
                        }
                }
                kfree(entry->seglist);
@@ -979,10 +984,18 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
        page_count = 0;
 
        while (entry->buf_count < count) {
+               dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL);
+               if (!dmah)
+                       return -ENOMEM;
 
-               dmah = drm_pci_alloc(dev, PAGE_SIZE << page_order, 0x1000);
+               dmah->size = total;
+               dmah->vaddr = dma_alloc_coherent(dev->dev,
+                                                dmah->size,
+                                                &dmah->busaddr,
+                                                GFP_KERNEL);
+               if (!dmah->vaddr) {
+                       kfree(dmah);
 
-               if (!dmah) {
                        /* Set count correctly so we free the proper amount. */
                        entry->buf_count = count;
                        entry->seg_count = count;
index d07ba54..eb6b741 100644 (file)
@@ -81,6 +81,7 @@ int drm_legacy_dma_setup(struct drm_device *dev)
 void drm_legacy_dma_takedown(struct drm_device *dev)
 {
        struct drm_device_dma *dma = dev->dma;
+       drm_dma_handle_t *dmah;
        int i, j;
 
        if (!drm_core_check_feature(dev, DRIVER_HAVE_DMA) ||
@@ -100,7 +101,12 @@ void drm_legacy_dma_takedown(struct drm_device *dev)
                                  dma->bufs[i].seg_count);
                        for (j = 0; j < dma->bufs[i].seg_count; j++) {
                                if (dma->bufs[i].seglist[j]) {
-                                       drm_pci_free(dev, dma->bufs[i].seglist[j]);
+                                       dmah = dma->bufs[i].seglist[j];
+                                       dma_free_coherent(dev->dev,
+                                                         dmah->size,
+                                                         dmah->vaddr,
+                                                         dmah->busaddr);
+                                       kfree(dmah);
                                }
                        }
                        kfree(dma->bufs[i].seglist);
index 1234ec6..fbb0cfd 100644 (file)
 static int drm_ati_alloc_pcigart_table(struct drm_device *dev,
                                       struct drm_ati_pcigart_info *gart_info)
 {
-       gart_info->table_handle = drm_pci_alloc(dev, gart_info->table_size,
-                                               PAGE_SIZE);
-       if (gart_info->table_handle == NULL)
+       drm_dma_handle_t *dmah = kmalloc(sizeof(drm_dma_handle_t), GFP_KERNEL);
+
+       if (!dmah)
+               return -ENOMEM;
+
+       dmah->size = gart_info->table_size;
+       dmah->vaddr = dma_alloc_coherent(dev->dev,
+                                        dmah->size,
+                                        &dmah->busaddr,
+                                        GFP_KERNEL);
+
+       if (!dmah->vaddr) {
+               kfree(dmah);
                return -ENOMEM;
+       }
 
+       gart_info->table_handle = dmah;
        return 0;
 }
 
 static void drm_ati_free_pcigart_table(struct drm_device *dev,
                                       struct drm_ati_pcigart_info *gart_info)
 {
-       drm_pci_free(dev, gart_info->table_handle);
+       drm_dma_handle_t *dmah = gart_info->table_handle;
+
+       dma_free_coherent(dev->dev, dmah->size, dmah->vaddr, dmah->busaddr);
        gart_info->table_handle = NULL;
 }