mirror of
https://github.com/ukui/kernel.git
synced 2026-03-09 10:07:04 -07:00
drm/ttm: initialize globals during device init (v2)
Make sure that the global BO state is always correctly initialized. This allows removing all the device code to initialize it. v2: fix up vbox (Alex) Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
62b53b37e4
commit
a64f784bb1
@@ -61,56 +61,6 @@ static int amdgpu_map_buffer(struct ttm_buffer_object *bo,
|
||||
static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev);
|
||||
static void amdgpu_ttm_debugfs_fini(struct amdgpu_device *adev);
|
||||
|
||||
/*
|
||||
* Global memory.
|
||||
*/
|
||||
|
||||
/**
|
||||
* amdgpu_ttm_global_init - Initialize global TTM memory reference structures.
|
||||
*
|
||||
* @adev: AMDGPU device for which the global structures need to be registered.
|
||||
*
|
||||
* This is called as part of the AMDGPU ttm init from amdgpu_ttm_init()
|
||||
* during bring up.
|
||||
*/
|
||||
static int amdgpu_ttm_global_init(struct amdgpu_device *adev)
|
||||
{
|
||||
struct drm_global_reference *global_ref;
|
||||
int r;
|
||||
|
||||
/* ensure reference is false in case init fails */
|
||||
adev->mman.mem_global_referenced = false;
|
||||
|
||||
global_ref = &adev->mman.bo_global_ref.ref;
|
||||
global_ref->global_type = DRM_GLOBAL_TTM_BO;
|
||||
global_ref->size = sizeof(struct ttm_bo_global);
|
||||
global_ref->init = &ttm_bo_global_ref_init;
|
||||
global_ref->release = &ttm_bo_global_ref_release;
|
||||
r = drm_global_item_ref(global_ref);
|
||||
if (r) {
|
||||
DRM_ERROR("Failed setting up TTM BO subsystem.\n");
|
||||
goto error_bo;
|
||||
}
|
||||
|
||||
mutex_init(&adev->mman.gtt_window_lock);
|
||||
|
||||
adev->mman.mem_global_referenced = true;
|
||||
|
||||
return 0;
|
||||
|
||||
error_bo:
|
||||
return r;
|
||||
}
|
||||
|
||||
static void amdgpu_ttm_global_fini(struct amdgpu_device *adev)
|
||||
{
|
||||
if (adev->mman.mem_global_referenced) {
|
||||
mutex_destroy(&adev->mman.gtt_window_lock);
|
||||
drm_global_item_unref(&adev->mman.bo_global_ref.ref);
|
||||
adev->mman.mem_global_referenced = false;
|
||||
}
|
||||
}
|
||||
|
||||
static int amdgpu_invalidate_caches(struct ttm_bo_device *bdev, uint32_t flags)
|
||||
{
|
||||
return 0;
|
||||
@@ -1714,14 +1664,10 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
|
||||
int r;
|
||||
u64 vis_vram_limit;
|
||||
|
||||
/* initialize global references for vram/gtt */
|
||||
r = amdgpu_ttm_global_init(adev);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
mutex_init(&adev->mman.gtt_window_lock);
|
||||
|
||||
/* No others user of address space so set it to 0 */
|
||||
r = ttm_bo_device_init(&adev->mman.bdev,
|
||||
adev->mman.bo_global_ref.ref.object,
|
||||
&amdgpu_bo_driver,
|
||||
adev->ddev->anon_inode->i_mapping,
|
||||
DRM_FILE_PAGE_OFFSET,
|
||||
@@ -1878,7 +1824,6 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)
|
||||
ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_GWS);
|
||||
ttm_bo_clean_mm(&adev->mman.bdev, AMDGPU_PL_OA);
|
||||
ttm_bo_device_release(&adev->mman.bdev);
|
||||
amdgpu_ttm_global_fini(adev);
|
||||
adev->mman.initialized = false;
|
||||
DRM_INFO("amdgpu: ttm finalized\n");
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#define AMDGPU_GTT_NUM_TRANSFER_WINDOWS 2
|
||||
|
||||
struct amdgpu_mman {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
struct ttm_bo_device bdev;
|
||||
bool mem_global_referenced;
|
||||
bool initialized;
|
||||
|
||||
@@ -104,7 +104,6 @@ struct ast_private {
|
||||
int fb_mtrr;
|
||||
|
||||
struct {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
struct ttm_bo_device bdev;
|
||||
} ttm;
|
||||
|
||||
|
||||
@@ -36,35 +36,6 @@ ast_bdev(struct ttm_bo_device *bd)
|
||||
return container_of(bd, struct ast_private, ttm.bdev);
|
||||
}
|
||||
|
||||
static int ast_ttm_global_init(struct ast_private *ast)
|
||||
{
|
||||
struct drm_global_reference *global_ref;
|
||||
int r;
|
||||
|
||||
global_ref = &ast->ttm.bo_global_ref.ref;
|
||||
global_ref->global_type = DRM_GLOBAL_TTM_BO;
|
||||
global_ref->size = sizeof(struct ttm_bo_global);
|
||||
global_ref->init = &ttm_bo_global_ref_init;
|
||||
global_ref->release = &ttm_bo_global_ref_release;
|
||||
r = drm_global_item_ref(global_ref);
|
||||
if (r != 0) {
|
||||
DRM_ERROR("Failed setting up TTM BO subsystem.\n");
|
||||
return r;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ast_ttm_global_release(struct ast_private *ast)
|
||||
{
|
||||
if (ast->ttm.bo_global_ref.ref.release == NULL)
|
||||
return;
|
||||
|
||||
drm_global_item_unref(&ast->ttm.bo_global_ref.ref);
|
||||
ast->ttm.bo_global_ref.ref.release = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void ast_bo_ttm_destroy(struct ttm_buffer_object *tbo)
|
||||
{
|
||||
struct ast_bo *bo;
|
||||
@@ -204,12 +175,7 @@ int ast_mm_init(struct ast_private *ast)
|
||||
struct drm_device *dev = ast->dev;
|
||||
struct ttm_bo_device *bdev = &ast->ttm.bdev;
|
||||
|
||||
ret = ast_ttm_global_init(ast);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ttm_bo_device_init(&ast->ttm.bdev,
|
||||
ast->ttm.bo_global_ref.ref.object,
|
||||
&ast_bo_driver,
|
||||
dev->anon_inode->i_mapping,
|
||||
DRM_FILE_PAGE_OFFSET,
|
||||
@@ -240,8 +206,6 @@ void ast_mm_fini(struct ast_private *ast)
|
||||
|
||||
ttm_bo_device_release(&ast->ttm.bdev);
|
||||
|
||||
ast_ttm_global_release(ast);
|
||||
|
||||
arch_phys_wc_del(ast->fb_mtrr);
|
||||
arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
|
||||
pci_resource_len(dev->pdev, 0));
|
||||
|
||||
@@ -76,7 +76,6 @@ struct bochs_device {
|
||||
|
||||
/* ttm */
|
||||
struct {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
struct ttm_bo_device bdev;
|
||||
bool initialized;
|
||||
} ttm;
|
||||
|
||||
@@ -16,35 +16,6 @@ static inline struct bochs_device *bochs_bdev(struct ttm_bo_device *bd)
|
||||
return container_of(bd, struct bochs_device, ttm.bdev);
|
||||
}
|
||||
|
||||
static int bochs_ttm_global_init(struct bochs_device *bochs)
|
||||
{
|
||||
struct drm_global_reference *global_ref;
|
||||
int r;
|
||||
|
||||
global_ref = &bochs->ttm.bo_global_ref.ref;
|
||||
global_ref->global_type = DRM_GLOBAL_TTM_BO;
|
||||
global_ref->size = sizeof(struct ttm_bo_global);
|
||||
global_ref->init = &ttm_bo_global_ref_init;
|
||||
global_ref->release = &ttm_bo_global_ref_release;
|
||||
r = drm_global_item_ref(global_ref);
|
||||
if (r != 0) {
|
||||
DRM_ERROR("Failed setting up TTM BO subsystem.\n");
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bochs_ttm_global_release(struct bochs_device *bochs)
|
||||
{
|
||||
if (bochs->ttm.bo_global_ref.ref.release == NULL)
|
||||
return;
|
||||
|
||||
drm_global_item_unref(&bochs->ttm.bo_global_ref.ref);
|
||||
bochs->ttm.bo_global_ref.ref.release = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void bochs_bo_ttm_destroy(struct ttm_buffer_object *tbo)
|
||||
{
|
||||
struct bochs_bo *bo;
|
||||
@@ -182,12 +153,7 @@ int bochs_mm_init(struct bochs_device *bochs)
|
||||
struct ttm_bo_device *bdev = &bochs->ttm.bdev;
|
||||
int ret;
|
||||
|
||||
ret = bochs_ttm_global_init(bochs);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ttm_bo_device_init(&bochs->ttm.bdev,
|
||||
bochs->ttm.bo_global_ref.ref.object,
|
||||
&bochs_bo_driver,
|
||||
bochs->dev->anon_inode->i_mapping,
|
||||
DRM_FILE_PAGE_OFFSET,
|
||||
@@ -214,7 +180,6 @@ void bochs_mm_fini(struct bochs_device *bochs)
|
||||
return;
|
||||
|
||||
ttm_bo_device_release(&bochs->ttm.bdev);
|
||||
bochs_ttm_global_release(bochs);
|
||||
bochs->ttm.initialized = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,6 @@ struct cirrus_device {
|
||||
int fb_mtrr;
|
||||
|
||||
struct {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
struct ttm_bo_device bdev;
|
||||
} ttm;
|
||||
bool mm_inited;
|
||||
|
||||
@@ -36,35 +36,6 @@ cirrus_bdev(struct ttm_bo_device *bd)
|
||||
return container_of(bd, struct cirrus_device, ttm.bdev);
|
||||
}
|
||||
|
||||
static int cirrus_ttm_global_init(struct cirrus_device *cirrus)
|
||||
{
|
||||
struct drm_global_reference *global_ref;
|
||||
int r;
|
||||
|
||||
global_ref = &cirrus->ttm.bo_global_ref.ref;
|
||||
global_ref->global_type = DRM_GLOBAL_TTM_BO;
|
||||
global_ref->size = sizeof(struct ttm_bo_global);
|
||||
global_ref->init = &ttm_bo_global_ref_init;
|
||||
global_ref->release = &ttm_bo_global_ref_release;
|
||||
r = drm_global_item_ref(global_ref);
|
||||
if (r != 0) {
|
||||
DRM_ERROR("Failed setting up TTM BO subsystem.\n");
|
||||
return r;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
cirrus_ttm_global_release(struct cirrus_device *cirrus)
|
||||
{
|
||||
if (cirrus->ttm.bo_global_ref.ref.release == NULL)
|
||||
return;
|
||||
|
||||
drm_global_item_unref(&cirrus->ttm.bo_global_ref.ref);
|
||||
cirrus->ttm.bo_global_ref.ref.release = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void cirrus_bo_ttm_destroy(struct ttm_buffer_object *tbo)
|
||||
{
|
||||
struct cirrus_bo *bo;
|
||||
@@ -204,12 +175,7 @@ int cirrus_mm_init(struct cirrus_device *cirrus)
|
||||
struct drm_device *dev = cirrus->dev;
|
||||
struct ttm_bo_device *bdev = &cirrus->ttm.bdev;
|
||||
|
||||
ret = cirrus_ttm_global_init(cirrus);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ttm_bo_device_init(&cirrus->ttm.bdev,
|
||||
cirrus->ttm.bo_global_ref.ref.object,
|
||||
&cirrus_bo_driver,
|
||||
dev->anon_inode->i_mapping,
|
||||
DRM_FILE_PAGE_OFFSET,
|
||||
@@ -245,8 +211,6 @@ void cirrus_mm_fini(struct cirrus_device *cirrus)
|
||||
|
||||
ttm_bo_device_release(&cirrus->ttm.bdev);
|
||||
|
||||
cirrus_ttm_global_release(cirrus);
|
||||
|
||||
arch_phys_wc_del(cirrus->fb_mtrr);
|
||||
cirrus->fb_mtrr = 0;
|
||||
arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
|
||||
|
||||
@@ -49,7 +49,6 @@ struct hibmc_drm_private {
|
||||
bool mode_config_initialized;
|
||||
|
||||
/* ttm */
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
struct ttm_bo_device bdev;
|
||||
bool initialized;
|
||||
|
||||
|
||||
@@ -29,32 +29,6 @@ hibmc_bdev(struct ttm_bo_device *bd)
|
||||
return container_of(bd, struct hibmc_drm_private, bdev);
|
||||
}
|
||||
|
||||
static int hibmc_ttm_global_init(struct hibmc_drm_private *hibmc)
|
||||
{
|
||||
int ret;
|
||||
|
||||
hibmc->bo_global_ref.ref.global_type = DRM_GLOBAL_TTM_BO;
|
||||
hibmc->bo_global_ref.ref.size = sizeof(struct ttm_bo_global);
|
||||
hibmc->bo_global_ref.ref.init = &ttm_bo_global_ref_init;
|
||||
hibmc->bo_global_ref.ref.release = &ttm_bo_global_ref_release;
|
||||
ret = drm_global_item_ref(&hibmc->bo_global_ref.ref);
|
||||
if (ret) {
|
||||
DRM_ERROR("failed setting up TTM BO subsystem: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
hibmc_ttm_global_release(struct hibmc_drm_private *hibmc)
|
||||
{
|
||||
if (hibmc->bo_global_ref.ref.release == NULL)
|
||||
return;
|
||||
|
||||
drm_global_item_unref(&hibmc->bo_global_ref.ref);
|
||||
hibmc->bo_global_ref.ref.release = NULL;
|
||||
}
|
||||
|
||||
static void hibmc_bo_ttm_destroy(struct ttm_buffer_object *tbo)
|
||||
{
|
||||
struct hibmc_bo *bo = container_of(tbo, struct hibmc_bo, bo);
|
||||
@@ -214,18 +188,12 @@ int hibmc_mm_init(struct hibmc_drm_private *hibmc)
|
||||
struct drm_device *dev = hibmc->dev;
|
||||
struct ttm_bo_device *bdev = &hibmc->bdev;
|
||||
|
||||
ret = hibmc_ttm_global_init(hibmc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ttm_bo_device_init(&hibmc->bdev,
|
||||
hibmc->bo_global_ref.ref.object,
|
||||
&hibmc_bo_driver,
|
||||
dev->anon_inode->i_mapping,
|
||||
DRM_FILE_PAGE_OFFSET,
|
||||
true);
|
||||
if (ret) {
|
||||
hibmc_ttm_global_release(hibmc);
|
||||
DRM_ERROR("error initializing bo driver: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -233,7 +201,6 @@ int hibmc_mm_init(struct hibmc_drm_private *hibmc)
|
||||
ret = ttm_bo_init_mm(bdev, TTM_PL_VRAM,
|
||||
hibmc->fb_size >> PAGE_SHIFT);
|
||||
if (ret) {
|
||||
hibmc_ttm_global_release(hibmc);
|
||||
DRM_ERROR("failed ttm VRAM init: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
@@ -248,7 +215,6 @@ void hibmc_mm_fini(struct hibmc_drm_private *hibmc)
|
||||
return;
|
||||
|
||||
ttm_bo_device_release(&hibmc->bdev);
|
||||
hibmc_ttm_global_release(hibmc);
|
||||
hibmc->mm_inited = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -212,7 +212,6 @@ struct mga_device {
|
||||
int fb_mtrr;
|
||||
|
||||
struct {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
struct ttm_bo_device bdev;
|
||||
} ttm;
|
||||
|
||||
|
||||
@@ -36,35 +36,6 @@ mgag200_bdev(struct ttm_bo_device *bd)
|
||||
return container_of(bd, struct mga_device, ttm.bdev);
|
||||
}
|
||||
|
||||
static int mgag200_ttm_global_init(struct mga_device *ast)
|
||||
{
|
||||
struct drm_global_reference *global_ref;
|
||||
int r;
|
||||
|
||||
global_ref = &ast->ttm.bo_global_ref.ref;
|
||||
global_ref->global_type = DRM_GLOBAL_TTM_BO;
|
||||
global_ref->size = sizeof(struct ttm_bo_global);
|
||||
global_ref->init = &ttm_bo_global_ref_init;
|
||||
global_ref->release = &ttm_bo_global_ref_release;
|
||||
r = drm_global_item_ref(global_ref);
|
||||
if (r != 0) {
|
||||
DRM_ERROR("Failed setting up TTM BO subsystem.\n");
|
||||
return r;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
mgag200_ttm_global_release(struct mga_device *ast)
|
||||
{
|
||||
if (ast->ttm.bo_global_ref.ref.release == NULL)
|
||||
return;
|
||||
|
||||
drm_global_item_unref(&ast->ttm.bo_global_ref.ref);
|
||||
ast->ttm.bo_global_ref.ref.release = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void mgag200_bo_ttm_destroy(struct ttm_buffer_object *tbo)
|
||||
{
|
||||
struct mgag200_bo *bo;
|
||||
@@ -204,12 +175,7 @@ int mgag200_mm_init(struct mga_device *mdev)
|
||||
struct drm_device *dev = mdev->dev;
|
||||
struct ttm_bo_device *bdev = &mdev->ttm.bdev;
|
||||
|
||||
ret = mgag200_ttm_global_init(mdev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ttm_bo_device_init(&mdev->ttm.bdev,
|
||||
mdev->ttm.bo_global_ref.ref.object,
|
||||
&mgag200_bo_driver,
|
||||
dev->anon_inode->i_mapping,
|
||||
DRM_FILE_PAGE_OFFSET,
|
||||
@@ -240,8 +206,6 @@ void mgag200_mm_fini(struct mga_device *mdev)
|
||||
|
||||
ttm_bo_device_release(&mdev->ttm.bdev);
|
||||
|
||||
mgag200_ttm_global_release(mdev);
|
||||
|
||||
arch_io_free_memtype_wc(pci_resource_start(dev->pdev, 0),
|
||||
pci_resource_len(dev->pdev, 0));
|
||||
arch_phys_wc_del(mdev->fb_mtrr);
|
||||
|
||||
@@ -146,7 +146,6 @@ struct nouveau_drm {
|
||||
|
||||
/* TTM interface support */
|
||||
struct {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
struct ttm_bo_device bdev;
|
||||
atomic_t validate_sequence;
|
||||
int (*move)(struct nouveau_channel *,
|
||||
|
||||
@@ -174,38 +174,6 @@ nouveau_ttm_mmap(struct file *filp, struct vm_area_struct *vma)
|
||||
return ttm_bo_mmap(filp, vma, &drm->ttm.bdev);
|
||||
}
|
||||
|
||||
int
|
||||
nouveau_ttm_global_init(struct nouveau_drm *drm)
|
||||
{
|
||||
struct drm_global_reference *global_ref;
|
||||
int ret;
|
||||
|
||||
global_ref = &drm->ttm.bo_global_ref.ref;
|
||||
global_ref->global_type = DRM_GLOBAL_TTM_BO;
|
||||
global_ref->size = sizeof(struct ttm_bo_global);
|
||||
global_ref->init = &ttm_bo_global_ref_init;
|
||||
global_ref->release = &ttm_bo_global_ref_release;
|
||||
|
||||
ret = drm_global_item_ref(global_ref);
|
||||
if (unlikely(ret != 0)) {
|
||||
DRM_ERROR("Failed setting up TTM BO subsystem\n");
|
||||
drm->ttm.bo_global_ref.ref.release = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
nouveau_ttm_global_release(struct nouveau_drm *drm)
|
||||
{
|
||||
if (drm->ttm.bo_global_ref.ref.release == NULL)
|
||||
return;
|
||||
|
||||
drm_global_item_unref(&drm->ttm.bo_global_ref.ref);
|
||||
drm->ttm.bo_global_ref.ref.release = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)
|
||||
{
|
||||
@@ -268,12 +236,7 @@ nouveau_ttm_init(struct nouveau_drm *drm)
|
||||
drm->agp.cma = pci->agp.cma;
|
||||
}
|
||||
|
||||
ret = nouveau_ttm_global_init(drm);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = ttm_bo_device_init(&drm->ttm.bdev,
|
||||
drm->ttm.bo_global_ref.ref.object,
|
||||
&nouveau_bo_driver,
|
||||
dev->anon_inode->i_mapping,
|
||||
DRM_FILE_PAGE_OFFSET,
|
||||
@@ -328,8 +291,6 @@ nouveau_ttm_fini(struct nouveau_drm *drm)
|
||||
|
||||
ttm_bo_device_release(&drm->ttm.bdev);
|
||||
|
||||
nouveau_ttm_global_release(drm);
|
||||
|
||||
arch_phys_wc_del(drm->ttm.mtrr);
|
||||
drm->ttm.mtrr = 0;
|
||||
arch_io_free_memtype_wc(device->func->resource_addr(device, 1),
|
||||
|
||||
@@ -127,8 +127,6 @@ struct qxl_output {
|
||||
#define drm_encoder_to_qxl_output(x) container_of(x, struct qxl_output, enc)
|
||||
|
||||
struct qxl_mman {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
bool mem_global_referenced;
|
||||
struct ttm_bo_device bdev;
|
||||
};
|
||||
|
||||
|
||||
@@ -46,34 +46,6 @@ static struct qxl_device *qxl_get_qdev(struct ttm_bo_device *bdev)
|
||||
return qdev;
|
||||
}
|
||||
|
||||
static int qxl_ttm_global_init(struct qxl_device *qdev)
|
||||
{
|
||||
struct drm_global_reference *global_ref;
|
||||
int r;
|
||||
|
||||
global_ref = &qdev->mman.bo_global_ref.ref;
|
||||
global_ref->global_type = DRM_GLOBAL_TTM_BO;
|
||||
global_ref->size = sizeof(struct ttm_bo_global);
|
||||
global_ref->init = &ttm_bo_global_ref_init;
|
||||
global_ref->release = &ttm_bo_global_ref_release;
|
||||
r = drm_global_item_ref(global_ref);
|
||||
if (r != 0) {
|
||||
DRM_ERROR("Failed setting up TTM BO subsystem.\n");
|
||||
return r;
|
||||
}
|
||||
|
||||
qdev->mman.mem_global_referenced = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void qxl_ttm_global_fini(struct qxl_device *qdev)
|
||||
{
|
||||
if (qdev->mman.mem_global_referenced) {
|
||||
drm_global_item_unref(&qdev->mman.bo_global_ref.ref);
|
||||
qdev->mman.mem_global_referenced = false;
|
||||
}
|
||||
}
|
||||
|
||||
static struct vm_operations_struct qxl_ttm_vm_ops;
|
||||
static const struct vm_operations_struct *ttm_vm_ops;
|
||||
|
||||
@@ -345,12 +317,8 @@ int qxl_ttm_init(struct qxl_device *qdev)
|
||||
int r;
|
||||
int num_io_pages; /* != rom->num_io_pages, we include surface0 */
|
||||
|
||||
r = qxl_ttm_global_init(qdev);
|
||||
if (r)
|
||||
return r;
|
||||
/* No others user of address space so set it to 0 */
|
||||
r = ttm_bo_device_init(&qdev->mman.bdev,
|
||||
qdev->mman.bo_global_ref.ref.object,
|
||||
&qxl_bo_driver,
|
||||
qdev->ddev.anon_inode->i_mapping,
|
||||
DRM_FILE_PAGE_OFFSET, 0);
|
||||
@@ -386,7 +354,6 @@ void qxl_ttm_fini(struct qxl_device *qdev)
|
||||
ttm_bo_clean_mm(&qdev->mman.bdev, TTM_PL_VRAM);
|
||||
ttm_bo_clean_mm(&qdev->mman.bdev, TTM_PL_PRIV);
|
||||
ttm_bo_device_release(&qdev->mman.bdev);
|
||||
qxl_ttm_global_fini(qdev);
|
||||
DRM_INFO("qxl: ttm finalized\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -448,9 +448,7 @@ struct radeon_surface_reg {
|
||||
* TTM.
|
||||
*/
|
||||
struct radeon_mman {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
struct ttm_bo_device bdev;
|
||||
bool mem_global_referenced;
|
||||
bool initialized;
|
||||
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
|
||||
@@ -60,39 +60,6 @@ static struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
|
||||
return rdev;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Global memory.
|
||||
*/
|
||||
static int radeon_ttm_global_init(struct radeon_device *rdev)
|
||||
{
|
||||
struct drm_global_reference *global_ref;
|
||||
int r;
|
||||
|
||||
rdev->mman.mem_global_referenced = false;
|
||||
global_ref = &rdev->mman.bo_global_ref.ref;
|
||||
global_ref->global_type = DRM_GLOBAL_TTM_BO;
|
||||
global_ref->size = sizeof(struct ttm_bo_global);
|
||||
global_ref->init = &ttm_bo_global_ref_init;
|
||||
global_ref->release = &ttm_bo_global_ref_release;
|
||||
r = drm_global_item_ref(global_ref);
|
||||
if (r != 0) {
|
||||
DRM_ERROR("Failed setting up TTM BO subsystem.\n");
|
||||
return r;
|
||||
}
|
||||
|
||||
rdev->mman.mem_global_referenced = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void radeon_ttm_global_fini(struct radeon_device *rdev)
|
||||
{
|
||||
if (rdev->mman.mem_global_referenced) {
|
||||
drm_global_item_unref(&rdev->mman.bo_global_ref.ref);
|
||||
rdev->mman.mem_global_referenced = false;
|
||||
}
|
||||
}
|
||||
|
||||
static int radeon_invalidate_caches(struct ttm_bo_device *bdev, uint32_t flags)
|
||||
{
|
||||
return 0;
|
||||
@@ -821,13 +788,8 @@ int radeon_ttm_init(struct radeon_device *rdev)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = radeon_ttm_global_init(rdev);
|
||||
if (r) {
|
||||
return r;
|
||||
}
|
||||
/* No others user of address space so set it to 0 */
|
||||
r = ttm_bo_device_init(&rdev->mman.bdev,
|
||||
rdev->mman.bo_global_ref.ref.object,
|
||||
&radeon_bo_driver,
|
||||
rdev->ddev->anon_inode->i_mapping,
|
||||
DRM_FILE_PAGE_OFFSET,
|
||||
@@ -899,7 +861,6 @@ void radeon_ttm_fini(struct radeon_device *rdev)
|
||||
ttm_bo_clean_mm(&rdev->mman.bdev, TTM_PL_TT);
|
||||
ttm_bo_device_release(&rdev->mman.bdev);
|
||||
radeon_gart_fini(rdev);
|
||||
radeon_ttm_global_fini(rdev);
|
||||
rdev->mman.initialized = false;
|
||||
DRM_INFO("radeon: ttm finalized\n");
|
||||
}
|
||||
|
||||
@@ -1530,7 +1530,7 @@ static void ttm_bo_global_kobj_release(struct kobject *kobj)
|
||||
kfree(glob);
|
||||
}
|
||||
|
||||
void ttm_bo_global_release(void)
|
||||
static void ttm_bo_global_release(void)
|
||||
{
|
||||
struct ttm_bo_global *glob = &ttm_bo_glob;
|
||||
|
||||
@@ -1544,9 +1544,8 @@ void ttm_bo_global_release(void)
|
||||
out:
|
||||
mutex_unlock(&ttm_global_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL(ttm_bo_global_release);
|
||||
|
||||
int ttm_bo_global_init(void)
|
||||
static int ttm_bo_global_init(void)
|
||||
{
|
||||
struct ttm_bo_global *glob = &ttm_bo_glob;
|
||||
int ret = 0;
|
||||
@@ -1583,8 +1582,6 @@ out:
|
||||
mutex_unlock(&ttm_global_mutex);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(ttm_bo_global_init);
|
||||
|
||||
|
||||
int ttm_bo_device_release(struct ttm_bo_device *bdev)
|
||||
{
|
||||
@@ -1623,18 +1620,25 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
|
||||
|
||||
drm_vma_offset_manager_destroy(&bdev->vma_manager);
|
||||
|
||||
if (!ret)
|
||||
ttm_bo_global_release();
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(ttm_bo_device_release);
|
||||
|
||||
int ttm_bo_device_init(struct ttm_bo_device *bdev,
|
||||
struct ttm_bo_global *glob,
|
||||
struct ttm_bo_driver *driver,
|
||||
struct address_space *mapping,
|
||||
uint64_t file_page_offset,
|
||||
bool need_dma32)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
struct ttm_bo_global *glob = &ttm_bo_glob;
|
||||
int ret;
|
||||
|
||||
ret = ttm_bo_global_init();
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
bdev->driver = driver;
|
||||
|
||||
@@ -1661,6 +1665,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
|
||||
|
||||
return 0;
|
||||
out_no_sys:
|
||||
ttm_bo_global_release();
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(ttm_bo_device_init);
|
||||
|
||||
@@ -142,8 +142,6 @@ struct virtio_gpu_fbdev {
|
||||
};
|
||||
|
||||
struct virtio_gpu_mman {
|
||||
struct ttm_bo_global_ref bo_global_ref;
|
||||
bool mem_global_referenced;
|
||||
struct ttm_bo_device bdev;
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user