Commit 40f5cf99 authored by Alex Deucher's avatar Alex Deucher Committed by Dave Airlie

drm/radeon: add PRIME support (v2)

This adds prime->fd and fd->prime support to radeon.
It passes the sg object to ttm and then populates
the gart entries using it.

Compile tested only.

v2: stub kmap + use new helpers + add reimporting
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarJerome Glisse <jglisse@redhat.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 1286ff73
...@@ -72,7 +72,7 @@ radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \ ...@@ -72,7 +72,7 @@ radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
evergreen.o evergreen_cs.o evergreen_blit_shaders.o evergreen_blit_kms.o \ evergreen.o evergreen_cs.o evergreen_blit_shaders.o evergreen_blit_kms.o \
evergreen_hdmi.o radeon_trace_points.o ni.o cayman_blit_shaders.o \ evergreen_hdmi.o radeon_trace_points.o ni.o cayman_blit_shaders.o \
atombios_encoders.o radeon_semaphore.o radeon_sa.o atombios_i2c.o si.o \ atombios_encoders.o radeon_semaphore.o radeon_sa.o atombios_i2c.o si.o \
si_blit_shaders.o si_blit_shaders.o radeon_prime.o
radeon-$(CONFIG_COMPAT) += radeon_ioc32.o radeon-$(CONFIG_COMPAT) += radeon_ioc32.o
radeon-$(CONFIG_VGA_SWITCHEROO) += radeon_atpx_handler.o radeon-$(CONFIG_VGA_SWITCHEROO) += radeon_atpx_handler.o
......
...@@ -668,7 +668,7 @@ int evergreen_blit_init(struct radeon_device *rdev) ...@@ -668,7 +668,7 @@ int evergreen_blit_init(struct radeon_device *rdev)
obj_size = ALIGN(obj_size, 256); obj_size = ALIGN(obj_size, 256);
r = radeon_bo_create(rdev, obj_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, r = radeon_bo_create(rdev, obj_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
&rdev->r600_blit.shader_obj); NULL, &rdev->r600_blit.shader_obj);
if (r) { if (r) {
DRM_ERROR("evergreen failed to allocate shader\n"); DRM_ERROR("evergreen failed to allocate shader\n");
return r; return r;
......
...@@ -1231,7 +1231,7 @@ int r600_vram_scratch_init(struct radeon_device *rdev) ...@@ -1231,7 +1231,7 @@ int r600_vram_scratch_init(struct radeon_device *rdev)
if (rdev->vram_scratch.robj == NULL) { if (rdev->vram_scratch.robj == NULL) {
r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE,
PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
&rdev->vram_scratch.robj); NULL, &rdev->vram_scratch.robj);
if (r) { if (r) {
return r; return r;
} }
...@@ -2769,7 +2769,7 @@ int r600_ih_ring_alloc(struct radeon_device *rdev) ...@@ -2769,7 +2769,7 @@ int r600_ih_ring_alloc(struct radeon_device *rdev)
r = radeon_bo_create(rdev, rdev->ih.ring_size, r = radeon_bo_create(rdev, rdev->ih.ring_size,
PAGE_SIZE, true, PAGE_SIZE, true,
RADEON_GEM_DOMAIN_GTT, RADEON_GEM_DOMAIN_GTT,
&rdev->ih.ring_obj); NULL, &rdev->ih.ring_obj);
if (r) { if (r) {
DRM_ERROR("radeon: failed to create ih ring buffer (%d).\n", r); DRM_ERROR("radeon: failed to create ih ring buffer (%d).\n", r);
return r; return r;
......
...@@ -552,7 +552,7 @@ int r600_blit_init(struct radeon_device *rdev) ...@@ -552,7 +552,7 @@ int r600_blit_init(struct radeon_device *rdev)
obj_size = ALIGN(obj_size, 256); obj_size = ALIGN(obj_size, 256);
r = radeon_bo_create(rdev, obj_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, r = radeon_bo_create(rdev, obj_size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
&rdev->r600_blit.shader_obj); NULL, &rdev->r600_blit.shader_obj);
if (r) { if (r) {
DRM_ERROR("r600 failed to allocate shader\n"); DRM_ERROR("r600 failed to allocate shader\n");
return r; return r;
......
...@@ -103,7 +103,7 @@ static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size, ...@@ -103,7 +103,7 @@ static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size,
int time; int time;
n = RADEON_BENCHMARK_ITERATIONS; n = RADEON_BENCHMARK_ITERATIONS;
r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, &sobj); r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, NULL, &sobj);
if (r) { if (r) {
goto out_cleanup; goto out_cleanup;
} }
...@@ -115,7 +115,7 @@ static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size, ...@@ -115,7 +115,7 @@ static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size,
if (r) { if (r) {
goto out_cleanup; goto out_cleanup;
} }
r = radeon_bo_create(rdev, size, PAGE_SIZE, true, ddomain, &dobj); r = radeon_bo_create(rdev, size, PAGE_SIZE, true, ddomain, NULL, &dobj);
if (r) { if (r) {
goto out_cleanup; goto out_cleanup;
} }
......
...@@ -193,7 +193,7 @@ int radeon_wb_init(struct radeon_device *rdev) ...@@ -193,7 +193,7 @@ int radeon_wb_init(struct radeon_device *rdev)
if (rdev->wb.wb_obj == NULL) { if (rdev->wb.wb_obj == NULL) {
r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true, r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true,
RADEON_GEM_DOMAIN_GTT, &rdev->wb.wb_obj); RADEON_GEM_DOMAIN_GTT, NULL, &rdev->wb.wb_obj);
if (r) { if (r) {
dev_warn(rdev->dev, "(%d) create WB bo failed\n", r); dev_warn(rdev->dev, "(%d) create WB bo failed\n", r);
return r; return r;
......
...@@ -105,6 +105,11 @@ int radeon_mode_dumb_create(struct drm_file *file_priv, ...@@ -105,6 +105,11 @@ int radeon_mode_dumb_create(struct drm_file *file_priv,
int radeon_mode_dumb_destroy(struct drm_file *file_priv, int radeon_mode_dumb_destroy(struct drm_file *file_priv,
struct drm_device *dev, struct drm_device *dev,
uint32_t handle); uint32_t handle);
struct dma_buf *radeon_gem_prime_export(struct drm_device *dev,
struct drm_gem_object *obj,
int flags);
struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev,
struct dma_buf *dma_buf);
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
int radeon_debugfs_init(struct drm_minor *minor); int radeon_debugfs_init(struct drm_minor *minor);
...@@ -333,7 +338,8 @@ static const struct file_operations radeon_driver_kms_fops = { ...@@ -333,7 +338,8 @@ static const struct file_operations radeon_driver_kms_fops = {
static struct drm_driver kms_driver = { static struct drm_driver kms_driver = {
.driver_features = .driver_features =
DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG | DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | DRIVER_GEM, DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED | DRIVER_GEM |
DRIVER_PRIME,
.dev_priv_size = 0, .dev_priv_size = 0,
.load = radeon_driver_load_kms, .load = radeon_driver_load_kms,
.firstopen = radeon_driver_firstopen_kms, .firstopen = radeon_driver_firstopen_kms,
...@@ -368,6 +374,12 @@ static struct drm_driver kms_driver = { ...@@ -368,6 +374,12 @@ static struct drm_driver kms_driver = {
.dumb_map_offset = radeon_mode_dumb_mmap, .dumb_map_offset = radeon_mode_dumb_mmap,
.dumb_destroy = radeon_mode_dumb_destroy, .dumb_destroy = radeon_mode_dumb_destroy,
.fops = &radeon_driver_kms_fops, .fops = &radeon_driver_kms_fops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_export = radeon_gem_prime_export,
.gem_prime_import = radeon_gem_prime_import,
.name = DRIVER_NAME, .name = DRIVER_NAME,
.desc = DRIVER_DESC, .desc = DRIVER_DESC,
.date = DRIVER_DATE, .date = DRIVER_DATE,
......
...@@ -80,7 +80,7 @@ int radeon_gart_table_vram_alloc(struct radeon_device *rdev) ...@@ -80,7 +80,7 @@ int radeon_gart_table_vram_alloc(struct radeon_device *rdev)
if (rdev->gart.robj == NULL) { if (rdev->gart.robj == NULL) {
r = radeon_bo_create(rdev, rdev->gart.table_size, r = radeon_bo_create(rdev, rdev->gart.table_size,
PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
&rdev->gart.robj); NULL, &rdev->gart.robj);
if (r) { if (r) {
return r; return r;
} }
......
...@@ -42,6 +42,8 @@ void radeon_gem_object_free(struct drm_gem_object *gobj) ...@@ -42,6 +42,8 @@ void radeon_gem_object_free(struct drm_gem_object *gobj)
struct radeon_bo *robj = gem_to_radeon_bo(gobj); struct radeon_bo *robj = gem_to_radeon_bo(gobj);
if (robj) { if (robj) {
if (robj->gem_base.import_attach)
drm_prime_gem_destroy(&robj->gem_base, robj->tbo.sg);
radeon_bo_unref(&robj); radeon_bo_unref(&robj);
} }
} }
...@@ -59,7 +61,7 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size, ...@@ -59,7 +61,7 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size,
if (alignment < PAGE_SIZE) { if (alignment < PAGE_SIZE) {
alignment = PAGE_SIZE; alignment = PAGE_SIZE;
} }
r = radeon_bo_create(rdev, size, alignment, kernel, initial_domain, &robj); r = radeon_bo_create(rdev, size, alignment, kernel, initial_domain, NULL, &robj);
if (r) { if (r) {
if (r != -ERESTARTSYS) if (r != -ERESTARTSYS)
DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n", DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n",
......
...@@ -104,7 +104,7 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain) ...@@ -104,7 +104,7 @@ void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 domain)
int radeon_bo_create(struct radeon_device *rdev, int radeon_bo_create(struct radeon_device *rdev,
unsigned long size, int byte_align, bool kernel, u32 domain, unsigned long size, int byte_align, bool kernel, u32 domain,
struct radeon_bo **bo_ptr) struct sg_table *sg, struct radeon_bo **bo_ptr)
{ {
struct radeon_bo *bo; struct radeon_bo *bo;
enum ttm_bo_type type; enum ttm_bo_type type;
...@@ -120,6 +120,8 @@ int radeon_bo_create(struct radeon_device *rdev, ...@@ -120,6 +120,8 @@ int radeon_bo_create(struct radeon_device *rdev,
} }
if (kernel) { if (kernel) {
type = ttm_bo_type_kernel; type = ttm_bo_type_kernel;
} else if (sg) {
type = ttm_bo_type_sg;
} else { } else {
type = ttm_bo_type_device; type = ttm_bo_type_device;
} }
...@@ -155,7 +157,7 @@ int radeon_bo_create(struct radeon_device *rdev, ...@@ -155,7 +157,7 @@ int radeon_bo_create(struct radeon_device *rdev,
mutex_lock(&rdev->vram_mutex); mutex_lock(&rdev->vram_mutex);
r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type, r = ttm_bo_init(&rdev->mman.bdev, &bo->tbo, size, type,
&bo->placement, page_align, 0, !kernel, NULL, &bo->placement, page_align, 0, !kernel, NULL,
acc_size, NULL, &radeon_ttm_bo_destroy); acc_size, sg, &radeon_ttm_bo_destroy);
mutex_unlock(&rdev->vram_mutex); mutex_unlock(&rdev->vram_mutex);
if (unlikely(r != 0)) { if (unlikely(r != 0)) {
if (r != -ERESTARTSYS) { if (r != -ERESTARTSYS) {
......
...@@ -111,9 +111,10 @@ extern int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type, ...@@ -111,9 +111,10 @@ extern int radeon_bo_wait(struct radeon_bo *bo, u32 *mem_type,
bool no_wait); bool no_wait);
extern int radeon_bo_create(struct radeon_device *rdev, extern int radeon_bo_create(struct radeon_device *rdev,
unsigned long size, int byte_align, unsigned long size, int byte_align,
bool kernel, u32 domain, bool kernel, u32 domain,
struct radeon_bo **bo_ptr); struct sg_table *sg,
struct radeon_bo **bo_ptr);
extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr); extern int radeon_bo_kmap(struct radeon_bo *bo, void **ptr);
extern void radeon_bo_kunmap(struct radeon_bo *bo); extern void radeon_bo_kunmap(struct radeon_bo *bo);
extern void radeon_bo_unref(struct radeon_bo **bo); extern void radeon_bo_unref(struct radeon_bo **bo);
......
/*
* Copyright 2012 Advanced Micro Devices, Inc.
*
* 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 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
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
*
* based on nouveau_prime.c
*
* Authors: Alex Deucher
*/
#include "drmP.h"
#include "drm.h"
#include "radeon.h"
#include "radeon_drm.h"
#include <linux/dma-buf.h>
static struct sg_table *radeon_gem_map_dma_buf(struct dma_buf_attachment *attachment,
enum dma_data_direction dir)
{
struct radeon_bo *bo = attachment->dmabuf->priv;
struct drm_device *dev = bo->rdev->ddev;
int npages = bo->tbo.num_pages;
struct sg_table *sg;
int nents;
mutex_lock(&dev->struct_mutex);
sg = drm_prime_pages_to_sg(bo->tbo.ttm->pages, npages);
nents = dma_map_sg(attachment->dev, sg->sgl, sg->nents, dir);
mutex_unlock(&dev->struct_mutex);
return sg;
}
static void radeon_gem_unmap_dma_buf(struct dma_buf_attachment *attachment,
struct sg_table *sg, enum dma_data_direction dir)
{
dma_unmap_sg(attachment->dev, sg->sgl, sg->nents, dir);
sg_free_table(sg);
kfree(sg);
}
static void radeon_gem_dmabuf_release(struct dma_buf *dma_buf)
{
struct radeon_bo *bo = dma_buf->priv;
if (bo->gem_base.export_dma_buf == dma_buf) {
DRM_ERROR("unreference dmabuf %p\n", &bo->gem_base);
bo->gem_base.export_dma_buf = NULL;
drm_gem_object_unreference_unlocked(&bo->gem_base);
}
}
static void *radeon_gem_kmap_atomic(struct dma_buf *dma_buf, unsigned long page_num)
{
return NULL;
}
static void radeon_gem_kunmap_atomic(struct dma_buf *dma_buf, unsigned long page_num, void *addr)
{
}
static void *radeon_gem_kmap(struct dma_buf *dma_buf, unsigned long page_num)
{
return NULL;
}
static void radeon_gem_kunmap(struct dma_buf *dma_buf, unsigned long page_num, void *addr)
{
}
struct dma_buf_ops radeon_dmabuf_ops = {
.map_dma_buf = radeon_gem_map_dma_buf,
.unmap_dma_buf = radeon_gem_unmap_dma_buf,
.release = radeon_gem_dmabuf_release,
.kmap = radeon_gem_kmap,
.kmap_atomic = radeon_gem_kmap_atomic,
.kunmap = radeon_gem_kunmap,
.kunmap_atomic = radeon_gem_kunmap_atomic,
};
static int radeon_prime_create(struct drm_device *dev,
size_t size,
struct sg_table *sg,
struct radeon_bo **pbo)
{
struct radeon_device *rdev = dev->dev_private;
struct radeon_bo *bo;
int ret;
ret = radeon_bo_create(rdev, size, PAGE_SIZE, false,
RADEON_GEM_DOMAIN_GTT, sg, pbo);
if (ret)
return ret;
bo = *pbo;
bo->gem_base.driver_private = bo;
mutex_lock(&rdev->gem.mutex);
list_add_tail(&bo->list, &rdev->gem.objects);
mutex_unlock(&rdev->gem.mutex);
return 0;
}
struct dma_buf *radeon_gem_prime_export(struct drm_device *dev,
struct drm_gem_object *obj,
int flags)
{
struct radeon_bo *bo = gem_to_radeon_bo(obj);
int ret = 0;
/* pin buffer into GTT */
ret = radeon_bo_pin(bo, RADEON_GEM_DOMAIN_GTT, NULL);
if (ret)
return ERR_PTR(ret);
return dma_buf_export(bo, &radeon_dmabuf_ops, obj->size, flags);
}
struct drm_gem_object *radeon_gem_prime_import(struct drm_device *dev,
struct dma_buf *dma_buf)
{
struct dma_buf_attachment *attach;
struct sg_table *sg;
struct radeon_bo *bo;
int ret;
if (dma_buf->ops == &radeon_dmabuf_ops) {
bo = dma_buf->priv;
if (bo->gem_base.dev == dev) {
drm_gem_object_reference(&bo->gem_base);
return &bo->gem_base;
}
}
/* need to attach */
attach = dma_buf_attach(dma_buf, dev->dev);
if (IS_ERR(attach))
return ERR_CAST(attach);
sg = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL);
if (IS_ERR(sg)) {
ret = PTR_ERR(sg);
goto fail_detach;
}
ret = radeon_prime_create(dev, dma_buf->size, sg, &bo);
if (ret)
goto fail_unmap;
bo->gem_base.import_attach = attach;
return &bo->gem_base;
fail_unmap:
dma_buf_unmap_attachment(attach, sg, DMA_BIDIRECTIONAL);
fail_detach:
dma_buf_detach(dma_buf, attach);
return ERR_PTR(ret);
}
...@@ -390,8 +390,8 @@ int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsig ...@@ -390,8 +390,8 @@ int radeon_ring_init(struct radeon_device *rdev, struct radeon_ring *ring, unsig
/* Allocate ring buffer */ /* Allocate ring buffer */
if (ring->ring_obj == NULL) { if (ring->ring_obj == NULL) {
r = radeon_bo_create(rdev, ring->ring_size, PAGE_SIZE, true, r = radeon_bo_create(rdev, ring->ring_size, PAGE_SIZE, true,
RADEON_GEM_DOMAIN_GTT, RADEON_GEM_DOMAIN_GTT,
&ring->ring_obj); NULL, &ring->ring_obj);
if (r) { if (r) {
dev_err(rdev->dev, "(%d) ring create failed\n", r); dev_err(rdev->dev, "(%d) ring create failed\n", r);
return r; return r;
......
...@@ -65,7 +65,7 @@ int radeon_sa_bo_manager_init(struct radeon_device *rdev, ...@@ -65,7 +65,7 @@ int radeon_sa_bo_manager_init(struct radeon_device *rdev,
} }
r = radeon_bo_create(rdev, size, RADEON_GPU_PAGE_SIZE, true, r = radeon_bo_create(rdev, size, RADEON_GPU_PAGE_SIZE, true,
RADEON_GEM_DOMAIN_CPU, &sa_manager->bo); RADEON_GEM_DOMAIN_CPU, NULL, &sa_manager->bo);
if (r) { if (r) {
dev_err(rdev->dev, "(%d) failed to allocate bo for manager\n", r); dev_err(rdev->dev, "(%d) failed to allocate bo for manager\n", r);
return r; return r;
......
...@@ -59,7 +59,7 @@ void radeon_test_moves(struct radeon_device *rdev) ...@@ -59,7 +59,7 @@ void radeon_test_moves(struct radeon_device *rdev)
} }
r = radeon_bo_create(rdev, size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM, r = radeon_bo_create(rdev, size, PAGE_SIZE, true, RADEON_GEM_DOMAIN_VRAM,
&vram_obj); NULL, &vram_obj);
if (r) { if (r) {
DRM_ERROR("Failed to create VRAM object\n"); DRM_ERROR("Failed to create VRAM object\n");
goto out_cleanup; goto out_cleanup;
...@@ -78,7 +78,7 @@ void radeon_test_moves(struct radeon_device *rdev) ...@@ -78,7 +78,7 @@ void radeon_test_moves(struct radeon_device *rdev)
void **vram_start, **vram_end; void **vram_start, **vram_end;
r = radeon_bo_create(rdev, size, PAGE_SIZE, true, r = radeon_bo_create(rdev, size, PAGE_SIZE, true,
RADEON_GEM_DOMAIN_GTT, gtt_obj + i); RADEON_GEM_DOMAIN_GTT, NULL, gtt_obj + i);
if (r) { if (r) {
DRM_ERROR("Failed to create GTT object %d\n", i); DRM_ERROR("Failed to create GTT object %d\n", i);
goto out_cleanup; goto out_cleanup;
......
...@@ -611,10 +611,18 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) ...@@ -611,10 +611,18 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm)
struct radeon_ttm_tt *gtt = (void *)ttm; struct radeon_ttm_tt *gtt = (void *)ttm;
unsigned i; unsigned i;
int r; int r;
bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
if (ttm->state != tt_unpopulated) if (ttm->state != tt_unpopulated)
return 0; return 0;
if (slave && ttm->sg) {
drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,
gtt->ttm.dma_address, ttm->num_pages);
ttm->state = tt_unbound;
return 0;
}
rdev = radeon_get_rdev(ttm->bdev); rdev = radeon_get_rdev(ttm->bdev);
#if __OS_HAS_AGP #if __OS_HAS_AGP
if (rdev->flags & RADEON_IS_AGP) { if (rdev->flags & RADEON_IS_AGP) {
...@@ -655,6 +663,10 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) ...@@ -655,6 +663,10 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm)
struct radeon_device *rdev; struct radeon_device *rdev;
struct radeon_ttm_tt *gtt = (void *)ttm; struct radeon_ttm_tt *gtt = (void *)ttm;
unsigned i; unsigned i;
bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);
if (slave)
return;
rdev = radeon_get_rdev(ttm->bdev); rdev = radeon_get_rdev(ttm->bdev);
#if __OS_HAS_AGP #if __OS_HAS_AGP
...@@ -726,8 +738,8 @@ int radeon_ttm_init(struct radeon_device *rdev) ...@@ -726,8 +738,8 @@ int radeon_ttm_init(struct radeon_device *rdev)
return r; return r;
} }
r = radeon_bo_create(rdev, 256 * 1024, PAGE_SIZE, true, r = radeon_bo_create(rdev, 256 * 1024, PAGE_SIZE, true,
RADEON_GEM_DOMAIN_VRAM, RADEON_GEM_DOMAIN_VRAM,
&rdev->stollen_vga_memory); NULL, &rdev->stollen_vga_memory);
if (r) { if (r) {
return r; return r;
} }
......
...@@ -2976,7 +2976,8 @@ int si_rlc_init(struct radeon_device *rdev) ...@@ -2976,7 +2976,8 @@ int si_rlc_init(struct radeon_device *rdev)
/* save restore block */ /* save restore block */
if (rdev->rlc.save_restore_obj == NULL) { if (rdev->rlc.save_restore_obj == NULL) {
r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true, r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true,
RADEON_GEM_DOMAIN_VRAM, &rdev->rlc.save_restore_obj); RADEON_GEM_DOMAIN_VRAM, NULL,
&rdev->rlc.save_restore_obj);
if (r) { if (r) {
dev_warn(rdev->dev, "(%d) create RLC sr bo failed\n", r); dev_warn(rdev->dev, "(%d) create RLC sr bo failed\n", r);
return r; return r;
...@@ -3000,7 +3001,8 @@ int si_rlc_init(struct radeon_device *rdev) ...@@ -3000,7 +3001,8 @@ int si_rlc_init(struct radeon_device *rdev)
/* clear state block */ /* clear state block */
if (rdev->rlc.clear_state_obj == NULL) { if (rdev->rlc.clear_state_obj == NULL) {
r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true, r = radeon_bo_create(rdev, RADEON_GPU_PAGE_SIZE, PAGE_SIZE, true,
RADEON_GEM_DOMAIN_VRAM, &rdev->rlc.clear_state_obj); RADEON_GEM_DOMAIN_VRAM, NULL,
&rdev->rlc.clear_state_obj);
if (r) { if (r) {
dev_warn(rdev->dev, "(%d) create RLC c bo failed\n", r); dev_warn(rdev->dev, "(%d) create RLC c bo failed\n", r);
si_rlc_fini(rdev); si_rlc_fini(rdev);
......
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