Commit 8e4ff9b5 authored by Chris Wilson's avatar Chris Wilson

drm: Remove the dma_alloc_coherent wrapper for internal usage

Internally for "consistent" maps, we create a temporary struct
drm_dma_handle in order to use our own dma_alloc_coherent wrapper then
destroy the temporary wrap. Simplify our logic by removing the temporary
wrapper!
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200202171635.4039044-2-chris@chris-wilson.co.uk
parent ea36ec86
...@@ -149,7 +149,6 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset, ...@@ -149,7 +149,6 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset,
{ {
struct drm_local_map *map; struct drm_local_map *map;
struct drm_map_list *list; struct drm_map_list *list;
drm_dma_handle_t *dmah;
unsigned long user_token; unsigned long user_token;
int ret; int ret;
...@@ -324,14 +323,14 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset, ...@@ -324,14 +323,14 @@ static int drm_addmap_core(struct drm_device *dev, resource_size_t offset,
* As we're limiting the address to 2^32-1 (or less), * As we're limiting the address to 2^32-1 (or less),
* casting it down to 32 bits is no problem, but we * casting it down to 32 bits is no problem, but we
* need to point to a 64bit variable first. */ * need to point to a 64bit variable first. */
dmah = drm_pci_alloc(dev, map->size, map->size); map->handle = dma_alloc_coherent(&dev->pdev->dev,
if (!dmah) { map->size,
&map->offset,
GFP_KERNEL);
if (!map->handle) {
kfree(map); kfree(map);
return -ENOMEM; return -ENOMEM;
} }
map->handle = dmah->vaddr;
map->offset = (unsigned long)dmah->busaddr;
kfree(dmah);
break; break;
default: default:
kfree(map); kfree(map);
...@@ -513,7 +512,6 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data, ...@@ -513,7 +512,6 @@ int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
int drm_legacy_rmmap_locked(struct drm_device *dev, struct drm_local_map *map) int drm_legacy_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
{ {
struct drm_map_list *r_list = NULL, *list_t; struct drm_map_list *r_list = NULL, *list_t;
drm_dma_handle_t dmah;
int found = 0; int found = 0;
struct drm_master *master; struct drm_master *master;
...@@ -554,10 +552,10 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, struct drm_local_map *map) ...@@ -554,10 +552,10 @@ int drm_legacy_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
case _DRM_SCATTER_GATHER: case _DRM_SCATTER_GATHER:
break; break;
case _DRM_CONSISTENT: case _DRM_CONSISTENT:
dmah.vaddr = map->handle; dma_free_coherent(&dev->pdev->dev,
dmah.busaddr = map->offset; map->size,
dmah.size = map->size; map->handle,
__drm_legacy_pci_free(dev, &dmah); map->offset);
break; break;
} }
kfree(map); kfree(map);
......
...@@ -78,18 +78,6 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali ...@@ -78,18 +78,6 @@ drm_dma_handle_t *drm_pci_alloc(struct drm_device * dev, size_t size, size_t ali
EXPORT_SYMBOL(drm_pci_alloc); EXPORT_SYMBOL(drm_pci_alloc);
/*
* Free a PCI consistent memory block without freeing its descriptor.
*
* This function is for internal use in the Linux-specific DRM core code.
*/
void __drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
{
if (dmah->vaddr)
dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
dmah->busaddr);
}
/** /**
* drm_pci_free - Free a PCI consistent memory block * drm_pci_free - Free a PCI consistent memory block
* @dev: DRM device * @dev: DRM device
...@@ -100,7 +88,8 @@ void __drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) ...@@ -100,7 +88,8 @@ void __drm_legacy_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
*/ */
void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah) void drm_pci_free(struct drm_device * dev, drm_dma_handle_t * dmah)
{ {
__drm_legacy_pci_free(dev, dmah); dma_free_coherent(&dev->pdev->dev, dmah->size, dmah->vaddr,
dmah->busaddr);
kfree(dmah); kfree(dmah);
} }
......
...@@ -269,8 +269,6 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) ...@@ -269,8 +269,6 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
} }
if (!found_maps) { if (!found_maps) {
drm_dma_handle_t dmah;
switch (map->type) { switch (map->type) {
case _DRM_REGISTERS: case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER: case _DRM_FRAME_BUFFER:
...@@ -284,10 +282,10 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) ...@@ -284,10 +282,10 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
case _DRM_SCATTER_GATHER: case _DRM_SCATTER_GATHER:
break; break;
case _DRM_CONSISTENT: case _DRM_CONSISTENT:
dmah.vaddr = map->handle; dma_free_coherent(&dev->pdev->dev,
dmah.busaddr = map->offset; map->size,
dmah.size = map->size; map->handle,
__drm_legacy_pci_free(dev, &dmah); map->offset);
break; break;
} }
kfree(map); kfree(map);
......
...@@ -194,17 +194,11 @@ void drm_legacy_idlelock_release(struct drm_lock_data *lock); ...@@ -194,17 +194,11 @@ void drm_legacy_idlelock_release(struct drm_lock_data *lock);
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
void __drm_legacy_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); int drm_legacy_pci_init(struct drm_driver *driver, struct pci_driver *pdriver);
void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); void drm_legacy_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver);
#else #else
static inline void __drm_legacy_pci_free(struct drm_device *dev,
drm_dma_handle_t *dmah)
{
}
static inline int drm_legacy_pci_init(struct drm_driver *driver, static inline int drm_legacy_pci_init(struct drm_driver *driver,
struct pci_driver *pdriver) struct pci_driver *pdriver)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment