2020-11-07 05:49:32 +08:00
|
|
|
/*
|
2005-09-25 12:28:13 +08:00
|
|
|
* \file ati_pcigart.c
|
2005-04-17 06:20:36 +08:00
|
|
|
* ATI PCI GART support
|
|
|
|
*
|
|
|
|
* \author Gareth Hughes <gareth@valinux.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Created: Wed Dec 13 21:52:19 2000 by gareth@valinux.com
|
|
|
|
*
|
|
|
|
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2011-08-31 06:16:33 +08:00
|
|
|
#include <linux/export.h>
|
2020-04-03 19:06:10 +08:00
|
|
|
#include <linux/pci.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2019-05-27 01:35:35 +08:00
|
|
|
#include <drm/drm_device.h>
|
2020-04-03 19:06:10 +08:00
|
|
|
#include <drm/drm_legacy.h>
|
2019-05-27 01:35:35 +08:00
|
|
|
#include <drm/drm_print.h>
|
2014-09-10 16:23:07 +08:00
|
|
|
|
2019-11-19 18:05:36 +08:00
|
|
|
#include "ati_pcigart.h"
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
# define ATI_PCIGART_PAGE_SIZE 4096 /**< PCI GART page size */
|
|
|
|
|
2008-03-17 08:24:24 +08:00
|
|
|
static int drm_ati_alloc_pcigart_table(struct drm_device *dev,
|
|
|
|
struct drm_ati_pcigart_info *gart_info)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2021-04-23 10:02:43 +08:00
|
|
|
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);
|
2008-03-17 08:24:24 +08:00
|
|
|
return -ENOMEM;
|
2021-04-23 10:02:43 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2021-04-23 10:02:43 +08:00
|
|
|
gart_info->table_handle = dmah;
|
2008-03-17 08:24:24 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-03-17 08:24:24 +08:00
|
|
|
static void drm_ati_free_pcigart_table(struct drm_device *dev,
|
|
|
|
struct drm_ati_pcigart_info *gart_info)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2021-04-23 10:02:43 +08:00
|
|
|
drm_dma_handle_t *dmah = gart_info->table_handle;
|
|
|
|
|
|
|
|
dma_free_coherent(dev->dev, dmah->size, dmah->vaddr, dmah->busaddr);
|
2021-05-19 05:28:59 +08:00
|
|
|
kfree(dmah);
|
|
|
|
|
2008-03-17 08:24:24 +08:00
|
|
|
gart_info->table_handle = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-07-11 14:53:40 +08:00
|
|
|
int drm_ati_pcigart_cleanup(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-07-11 14:53:40 +08:00
|
|
|
struct drm_sg_mem *entry = dev->sg;
|
2021-05-02 18:49:49 +08:00
|
|
|
struct pci_dev *pdev = to_pci_dev(dev->dev);
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long pages;
|
|
|
|
int i;
|
2008-03-17 08:24:24 +08:00
|
|
|
int max_pages;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* we need to support large memory configurations */
|
2005-09-25 12:28:13 +08:00
|
|
|
if (!entry) {
|
|
|
|
DRM_ERROR("no scatter/gather memory!\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-09-11 18:28:11 +08:00
|
|
|
if (gart_info->bus_addr) {
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-05-08 13:19:23 +08:00
|
|
|
max_pages = (gart_info->table_size / sizeof(u32));
|
|
|
|
pages = (entry->pages <= max_pages)
|
|
|
|
? entry->pages : max_pages;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
for (i = 0; i < pages; i++) {
|
|
|
|
if (!entry->busaddr[i])
|
|
|
|
break;
|
drm/r128: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below.
It has been compile tested.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/46ccdd7bffdba1273a1ebb3d6cd2fbe186e0795a.1629667572.git.christophe.jaillet@wanadoo.fr
2021-08-23 05:27:10 +08:00
|
|
|
dma_unmap_page(&pdev->dev, entry->busaddr[i],
|
|
|
|
PAGE_SIZE, DMA_BIDIRECTIONAL);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-09-25 12:28:13 +08:00
|
|
|
|
|
|
|
if (gart_info->gart_table_location == DRM_ATI_GART_MAIN)
|
|
|
|
gart_info->bus_addr = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2008-03-17 08:24:24 +08:00
|
|
|
if (gart_info->gart_table_location == DRM_ATI_GART_MAIN &&
|
|
|
|
gart_info->table_handle) {
|
|
|
|
drm_ati_free_pcigart_table(dev, gart_info);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-07-11 14:53:40 +08:00
|
|
|
int drm_ati_pcigart_init(struct drm_device *dev, struct drm_ati_pcigart_info *gart_info)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-02-12 18:15:27 +08:00
|
|
|
struct drm_local_map *map = &gart_info->mapping;
|
2007-07-11 14:53:40 +08:00
|
|
|
struct drm_sg_mem *entry = dev->sg;
|
2021-05-02 18:49:49 +08:00
|
|
|
struct pci_dev *pdev = to_pci_dev(dev->dev);
|
2006-01-02 14:18:39 +08:00
|
|
|
void *address = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long pages;
|
2009-02-26 08:13:47 +08:00
|
|
|
u32 *pci_gart = NULL, page_base, gart_idx;
|
2008-03-17 08:24:24 +08:00
|
|
|
dma_addr_t bus_address = 0;
|
2018-12-17 15:03:44 +08:00
|
|
|
int i, j, ret = -ENOMEM;
|
2009-02-15 17:08:07 +08:00
|
|
|
int max_ati_pages, max_real_pages;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
if (!entry) {
|
|
|
|
DRM_ERROR("no scatter/gather memory!\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
|
2005-09-11 18:28:11 +08:00
|
|
|
DRM_DEBUG("PCI: no table in VRAM: using normal RAM\n");
|
2005-09-25 12:28:13 +08:00
|
|
|
|
drm/r128: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below.
It has been compile tested.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/46ccdd7bffdba1273a1ebb3d6cd2fbe186e0795a.1629667572.git.christophe.jaillet@wanadoo.fr
2021-08-23 05:27:10 +08:00
|
|
|
if (dma_set_mask(&pdev->dev, gart_info->table_mask)) {
|
2010-01-05 11:25:05 +08:00
|
|
|
DRM_ERROR("fail to set dma mask to 0x%Lx\n",
|
2010-02-03 06:40:33 +08:00
|
|
|
(unsigned long long)gart_info->table_mask);
|
2018-12-17 15:03:44 +08:00
|
|
|
ret = -EFAULT;
|
2010-01-05 11:25:05 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2008-03-17 08:24:24 +08:00
|
|
|
ret = drm_ati_alloc_pcigart_table(dev, gart_info);
|
|
|
|
if (ret) {
|
2005-09-25 12:28:13 +08:00
|
|
|
DRM_ERROR("cannot allocate PCI GART page!\n");
|
2005-09-11 18:28:11 +08:00
|
|
|
goto done;
|
|
|
|
}
|
2005-09-25 12:28:13 +08:00
|
|
|
|
2009-02-26 08:13:47 +08:00
|
|
|
pci_gart = gart_info->table_handle->vaddr;
|
2008-03-17 08:24:24 +08:00
|
|
|
address = gart_info->table_handle->vaddr;
|
|
|
|
bus_address = gart_info->table_handle->busaddr;
|
2005-09-25 12:28:13 +08:00
|
|
|
} else {
|
2005-09-11 18:28:11 +08:00
|
|
|
address = gart_info->addr;
|
|
|
|
bus_address = gart_info->bus_addr;
|
2008-03-29 05:15:49 +08:00
|
|
|
DRM_DEBUG("PCI: Gart Table: VRAM %08LX mapped at %08lX\n",
|
|
|
|
(unsigned long long)bus_address,
|
|
|
|
(unsigned long)address);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-15 17:08:07 +08:00
|
|
|
max_ati_pages = (gart_info->table_size / sizeof(u32));
|
|
|
|
max_real_pages = max_ati_pages / (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE);
|
|
|
|
pages = (entry->pages <= max_real_pages)
|
|
|
|
? entry->pages : max_real_pages;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-02-12 18:15:27 +08:00
|
|
|
if (gart_info->gart_table_location == DRM_ATI_GART_MAIN) {
|
2009-02-15 17:08:07 +08:00
|
|
|
memset(pci_gart, 0, max_ati_pages * sizeof(u32));
|
2009-02-12 18:15:27 +08:00
|
|
|
} else {
|
2009-02-26 08:13:47 +08:00
|
|
|
memset_io((void __iomem *)map->handle, 0, max_ati_pages * sizeof(u32));
|
2009-02-12 18:15:27 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-02-12 18:15:27 +08:00
|
|
|
gart_idx = 0;
|
2005-09-25 12:28:13 +08:00
|
|
|
for (i = 0; i < pages; i++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* we need to support large memory configurations */
|
drm/r128: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away.
The patch has been generated with the coccinelle script below.
It has been compile tested.
@@
@@
- PCI_DMA_BIDIRECTIONAL
+ DMA_BIDIRECTIONAL
@@
@@
- PCI_DMA_TODEVICE
+ DMA_TO_DEVICE
@@
@@
- PCI_DMA_FROMDEVICE
+ DMA_FROM_DEVICE
@@
@@
- PCI_DMA_NONE
+ DMA_NONE
@@
expression e1, e2, e3;
@@
- pci_alloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3;
@@
- pci_zalloc_consistent(e1, e2, e3)
+ dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
@@
expression e1, e2, e3, e4;
@@
- pci_free_consistent(e1, e2, e3, e4)
+ dma_free_coherent(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_single(e1, e2, e3, e4)
+ dma_map_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_single(e1, e2, e3, e4)
+ dma_unmap_single(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4, e5;
@@
- pci_map_page(e1, e2, e3, e4, e5)
+ dma_map_page(&e1->dev, e2, e3, e4, e5)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_page(e1, e2, e3, e4)
+ dma_unmap_page(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_map_sg(e1, e2, e3, e4)
+ dma_map_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_unmap_sg(e1, e2, e3, e4)
+ dma_unmap_sg(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+ dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_single_for_device(e1, e2, e3, e4)
+ dma_sync_single_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+ dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
@@
expression e1, e2, e3, e4;
@@
- pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+ dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
@@
expression e1, e2;
@@
- pci_dma_mapping_error(e1, e2)
+ dma_mapping_error(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_dma_mask(e1, e2)
+ dma_set_mask(&e1->dev, e2)
@@
expression e1, e2;
@@
- pci_set_consistent_dma_mask(e1, e2)
+ dma_set_coherent_mask(&e1->dev, e2)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/46ccdd7bffdba1273a1ebb3d6cd2fbe186e0795a.1629667572.git.christophe.jaillet@wanadoo.fr
2021-08-23 05:27:10 +08:00
|
|
|
entry->busaddr[i] = dma_map_page(&pdev->dev, entry->pagelist[i],
|
|
|
|
0, PAGE_SIZE, DMA_BIDIRECTIONAL);
|
|
|
|
if (dma_mapping_error(&pdev->dev, entry->busaddr[i])) {
|
2005-09-25 12:28:13 +08:00
|
|
|
DRM_ERROR("unable to map PCIGART pages!\n");
|
2005-09-11 18:28:11 +08:00
|
|
|
drm_ati_pcigart_cleanup(dev, gart_info);
|
2006-01-02 14:18:39 +08:00
|
|
|
address = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
bus_address = 0;
|
2018-12-17 15:03:44 +08:00
|
|
|
ret = -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
page_base = (u32) entry->busaddr[i];
|
|
|
|
|
|
|
|
for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
|
2019-07-19 00:15:00 +08:00
|
|
|
u32 offset;
|
2009-02-12 18:15:27 +08:00
|
|
|
u32 val;
|
|
|
|
|
2007-05-08 13:19:23 +08:00
|
|
|
switch(gart_info->gart_reg_if) {
|
|
|
|
case DRM_ATI_GART_IGP:
|
2009-02-12 18:15:27 +08:00
|
|
|
val = page_base | 0xc;
|
2007-05-08 13:19:23 +08:00
|
|
|
break;
|
|
|
|
case DRM_ATI_GART_PCIE:
|
2009-02-12 18:15:27 +08:00
|
|
|
val = (page_base >> 8) | 0xc;
|
2007-05-08 13:19:23 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case DRM_ATI_GART_PCI:
|
2009-02-12 18:15:27 +08:00
|
|
|
val = page_base;
|
2007-05-08 13:19:23 +08:00
|
|
|
break;
|
|
|
|
}
|
2009-02-12 18:15:27 +08:00
|
|
|
if (gart_info->gart_table_location ==
|
2019-07-19 00:15:00 +08:00
|
|
|
DRM_ATI_GART_MAIN) {
|
2009-02-12 18:15:27 +08:00
|
|
|
pci_gart[gart_idx] = cpu_to_le32(val);
|
2019-07-19 00:15:00 +08:00
|
|
|
} else {
|
|
|
|
offset = gart_idx * sizeof(u32);
|
|
|
|
writel(val, (void __iomem *)map->handle + offset);
|
|
|
|
}
|
2009-02-12 18:15:27 +08:00
|
|
|
gart_idx++;
|
2005-04-17 06:20:36 +08:00
|
|
|
page_base += ATI_PCIGART_PAGE_SIZE;
|
|
|
|
}
|
|
|
|
}
|
2018-12-17 15:03:44 +08:00
|
|
|
ret = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2021-10-11 16:00:06 +08:00
|
|
|
#ifdef CONFIG_X86
|
2005-04-17 06:20:36 +08:00
|
|
|
wbinvd();
|
|
|
|
#else
|
|
|
|
mb();
|
|
|
|
#endif
|
|
|
|
|
2005-09-25 12:28:13 +08:00
|
|
|
done:
|
2005-09-11 18:28:11 +08:00
|
|
|
gart_info->addr = address;
|
2005-09-25 12:28:13 +08:00
|
|
|
gart_info->bus_addr = bus_address;
|
2005-04-17 06:20:36 +08:00
|
|
|
return ret;
|
|
|
|
}
|