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
@@ -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),
|
||||
|
Reference in New Issue
Block a user