提交 ad49f501 编写于 作者: D Dave Airlie 提交者: Dave Airlie

drm/ttm/radeon: add dma32 support.

This add support for using dma32 memory on gpus that really need it.

Currently IGPs are left without DMA32 but we might need to change
that unless we can fix rs690.
Signed-off-by: NDave Airlie <airlied@redhat.com>
上级 61b576db
...@@ -624,6 +624,7 @@ struct radeon_device { ...@@ -624,6 +624,7 @@ struct radeon_device {
bool gpu_lockup; bool gpu_lockup;
bool shutdown; bool shutdown;
bool suspend; bool suspend;
bool need_dma32;
}; };
int radeon_device_init(struct radeon_device *rdev, int radeon_device_init(struct radeon_device *rdev,
......
...@@ -450,6 +450,7 @@ int radeon_device_init(struct radeon_device *rdev, ...@@ -450,6 +450,7 @@ int radeon_device_init(struct radeon_device *rdev,
uint32_t flags) uint32_t flags)
{ {
int r, ret; int r, ret;
int dma_bits;
DRM_INFO("radeon: Initializing kernel modesetting.\n"); DRM_INFO("radeon: Initializing kernel modesetting.\n");
rdev->shutdown = false; rdev->shutdown = false;
...@@ -492,8 +493,20 @@ int radeon_device_init(struct radeon_device *rdev, ...@@ -492,8 +493,20 @@ int radeon_device_init(struct radeon_device *rdev,
return r; return r;
} }
/* Report DMA addressing limitation */ /* set DMA mask + need_dma32 flags.
r = pci_set_dma_mask(rdev->pdev, DMA_BIT_MASK(32)); * PCIE - can handle 40-bits.
* IGP - can handle 40-bits (in theory)
* AGP - generally dma32 is safest
* PCI - only dma32
*/
rdev->need_dma32 = false;
if (rdev->flags & RADEON_IS_AGP)
rdev->need_dma32 = true;
if (rdev->flags & RADEON_IS_PCI)
rdev->need_dma32 = true;
dma_bits = rdev->need_dma32 ? 32 : 40;
r = pci_set_dma_mask(rdev->pdev, DMA_BIT_MASK(dma_bits));
if (r) { if (r) {
printk(KERN_WARNING "radeon: No suitable DMA available.\n"); printk(KERN_WARNING "radeon: No suitable DMA available.\n");
} }
......
...@@ -442,7 +442,8 @@ int radeon_ttm_init(struct radeon_device *rdev) ...@@ -442,7 +442,8 @@ int radeon_ttm_init(struct radeon_device *rdev)
/* No others user of address space so set it to 0 */ /* No others user of address space so set it to 0 */
r = ttm_bo_device_init(&rdev->mman.bdev, r = ttm_bo_device_init(&rdev->mman.bdev,
rdev->mman.mem_global_ref.object, rdev->mman.mem_global_ref.object,
&radeon_bo_driver, DRM_FILE_PAGE_OFFSET); &radeon_bo_driver, DRM_FILE_PAGE_OFFSET,
rdev->need_dma32);
if (r) { if (r) {
DRM_ERROR("failed initializing buffer object driver(%d).\n", r); DRM_ERROR("failed initializing buffer object driver(%d).\n", r);
return r; return r;
......
...@@ -224,6 +224,9 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc) ...@@ -224,6 +224,9 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)
TTM_ASSERT_LOCKED(&bo->mutex); TTM_ASSERT_LOCKED(&bo->mutex);
bo->ttm = NULL; bo->ttm = NULL;
if (bdev->need_dma32)
page_flags |= TTM_PAGE_FLAG_DMA32;
switch (bo->type) { switch (bo->type) {
case ttm_bo_type_device: case ttm_bo_type_device:
if (zero_alloc) if (zero_alloc)
...@@ -1332,7 +1335,8 @@ EXPORT_SYMBOL(ttm_bo_device_release); ...@@ -1332,7 +1335,8 @@ EXPORT_SYMBOL(ttm_bo_device_release);
int ttm_bo_device_init(struct ttm_bo_device *bdev, int ttm_bo_device_init(struct ttm_bo_device *bdev,
struct ttm_mem_global *mem_glob, struct ttm_mem_global *mem_glob,
struct ttm_bo_driver *driver, uint64_t file_page_offset) struct ttm_bo_driver *driver, uint64_t file_page_offset,
bool need_dma32)
{ {
int ret = -EINVAL; int ret = -EINVAL;
...@@ -1369,6 +1373,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, ...@@ -1369,6 +1373,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
INIT_LIST_HEAD(&bdev->ddestroy); INIT_LIST_HEAD(&bdev->ddestroy);
INIT_LIST_HEAD(&bdev->swap_lru); INIT_LIST_HEAD(&bdev->swap_lru);
bdev->dev_mapping = NULL; bdev->dev_mapping = NULL;
bdev->need_dma32 = need_dma32;
ttm_mem_init_shrink(&bdev->shrink, ttm_bo_swapout); ttm_mem_init_shrink(&bdev->shrink, ttm_bo_swapout);
ret = ttm_mem_register_shrink(mem_glob, &bdev->shrink); ret = ttm_mem_register_shrink(mem_glob, &bdev->shrink);
if (unlikely(ret != 0)) { if (unlikely(ret != 0)) {
......
...@@ -131,10 +131,15 @@ static void ttm_tt_free_page_directory(struct ttm_tt *ttm) ...@@ -131,10 +131,15 @@ static void ttm_tt_free_page_directory(struct ttm_tt *ttm)
static struct page *ttm_tt_alloc_page(unsigned page_flags) static struct page *ttm_tt_alloc_page(unsigned page_flags)
{ {
gfp_t gfp_flags = GFP_HIGHUSER;
if (page_flags & TTM_PAGE_FLAG_ZERO_ALLOC) if (page_flags & TTM_PAGE_FLAG_ZERO_ALLOC)
return alloc_page(GFP_HIGHUSER | __GFP_ZERO); gfp_flags |= __GFP_ZERO;
if (page_flags & TTM_PAGE_FLAG_DMA32)
gfp_flags |= __GFP_DMA32;
return alloc_page(GFP_HIGHUSER); return alloc_page(gfp_flags);
} }
static void ttm_tt_free_user_pages(struct ttm_tt *ttm) static void ttm_tt_free_user_pages(struct ttm_tt *ttm)
......
...@@ -121,6 +121,7 @@ struct ttm_backend { ...@@ -121,6 +121,7 @@ struct ttm_backend {
#define TTM_PAGE_FLAG_SWAPPED (1 << 4) #define TTM_PAGE_FLAG_SWAPPED (1 << 4)
#define TTM_PAGE_FLAG_PERSISTANT_SWAP (1 << 5) #define TTM_PAGE_FLAG_PERSISTANT_SWAP (1 << 5)
#define TTM_PAGE_FLAG_ZERO_ALLOC (1 << 6) #define TTM_PAGE_FLAG_ZERO_ALLOC (1 << 6)
#define TTM_PAGE_FLAG_DMA32 (1 << 7)
enum ttm_caching_state { enum ttm_caching_state {
tt_uncached, tt_uncached,
...@@ -429,6 +430,8 @@ struct ttm_bo_device { ...@@ -429,6 +430,8 @@ struct ttm_bo_device {
*/ */
struct delayed_work wq; struct delayed_work wq;
bool need_dma32;
}; };
/** /**
...@@ -648,7 +651,7 @@ extern int ttm_bo_device_release(struct ttm_bo_device *bdev); ...@@ -648,7 +651,7 @@ extern int ttm_bo_device_release(struct ttm_bo_device *bdev);
extern int ttm_bo_device_init(struct ttm_bo_device *bdev, extern int ttm_bo_device_init(struct ttm_bo_device *bdev,
struct ttm_mem_global *mem_glob, struct ttm_mem_global *mem_glob,
struct ttm_bo_driver *driver, struct ttm_bo_driver *driver,
uint64_t file_page_offset); uint64_t file_page_offset, bool need_dma32);
/** /**
* ttm_bo_reserve: * ttm_bo_reserve:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册