drm/vram-helper: Remove BO device from public interface
TTM is an implementation detail of the VRAM helpers and therefore shouldn't be exposed to the callers. There's only one correct value for the BO device anyway, which is the one stored in the DRM device. So remove struct ttm_bo_device from the VRAM-helper interface and use the device's VRAM manager unconditionally. The GEM initializer function fails if the VRAM manager has not been initialized. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Sam Ravnborg <sam@ravnborg.org> Link: https://patchwork.freedesktop.org/patch/msgid/20200106125745.13797-8-tzimmermann@suse.de
This commit is contained in:
parent
ebe9428b3f
commit
a4d46a8e26
|
@ -1144,8 +1144,7 @@ static int ast_cursor_init(struct drm_device *dev)
|
|||
size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) {
|
||||
gbo = drm_gem_vram_create(dev, &dev->vram_mm->bdev,
|
||||
size, 0);
|
||||
gbo = drm_gem_vram_create(dev, size, 0);
|
||||
if (IS_ERR(gbo)) {
|
||||
ret = PTR_ERR(gbo);
|
||||
goto err_drm_gem_vram_put;
|
||||
|
|
|
@ -92,13 +92,18 @@ static void drm_gem_vram_placement(struct drm_gem_vram_object *gbo,
|
|||
}
|
||||
|
||||
static int drm_gem_vram_init(struct drm_device *dev,
|
||||
struct ttm_bo_device *bdev,
|
||||
struct drm_gem_vram_object *gbo,
|
||||
size_t size, unsigned long pg_align)
|
||||
{
|
||||
struct drm_vram_mm *vmm = dev->vram_mm;
|
||||
struct ttm_bo_device *bdev;
|
||||
int ret;
|
||||
size_t acc_size;
|
||||
|
||||
if (WARN_ONCE(!vmm, "VRAM MM not initialized"))
|
||||
return -EINVAL;
|
||||
bdev = &vmm->bdev;
|
||||
|
||||
gbo->bo.base.funcs = &drm_gem_vram_object_funcs;
|
||||
|
||||
ret = drm_gem_object_init(dev, &gbo->bo.base, size);
|
||||
|
@ -126,7 +131,6 @@ err_drm_gem_object_release:
|
|||
/**
|
||||
* drm_gem_vram_create() - Creates a VRAM-backed GEM object
|
||||
* @dev: the DRM device
|
||||
* @bdev: the TTM BO device backing the object
|
||||
* @size: the buffer size in bytes
|
||||
* @pg_align: the buffer's alignment in multiples of the page size
|
||||
*
|
||||
|
@ -135,7 +139,6 @@ err_drm_gem_object_release:
|
|||
* an ERR_PTR()-encoded error code otherwise.
|
||||
*/
|
||||
struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
|
||||
struct ttm_bo_device *bdev,
|
||||
size_t size,
|
||||
unsigned long pg_align)
|
||||
{
|
||||
|
@ -146,7 +149,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
|
|||
if (!gbo)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
ret = drm_gem_vram_init(dev, bdev, gbo, size, pg_align);
|
||||
ret = drm_gem_vram_init(dev, gbo, size, pg_align);
|
||||
if (ret < 0)
|
||||
goto err_kfree;
|
||||
|
||||
|
@ -480,7 +483,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
|
|||
Helper for implementing &struct drm_driver.dumb_create
|
||||
* @file: the DRM file
|
||||
* @dev: the DRM device
|
||||
* @bdev: the TTM BO device managing the buffer object
|
||||
* @pg_align: the buffer's alignment in multiples of the page size
|
||||
* @pitch_align: the scanline's alignment in powers of 2
|
||||
* @args: the arguments as provided to \
|
||||
|
@ -497,7 +499,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
|
|||
*/
|
||||
int drm_gem_vram_fill_create_dumb(struct drm_file *file,
|
||||
struct drm_device *dev,
|
||||
struct ttm_bo_device *bdev,
|
||||
unsigned long pg_align,
|
||||
unsigned long pitch_align,
|
||||
struct drm_mode_create_dumb *args)
|
||||
|
@ -519,7 +520,7 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
|
|||
if (!size)
|
||||
return -EINVAL;
|
||||
|
||||
gbo = drm_gem_vram_create(dev, bdev, size, pg_align);
|
||||
gbo = drm_gem_vram_create(dev, size, pg_align);
|
||||
if (IS_ERR(gbo))
|
||||
return PTR_ERR(gbo);
|
||||
|
||||
|
@ -614,8 +615,7 @@ int drm_gem_vram_driver_dumb_create(struct drm_file *file,
|
|||
if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized"))
|
||||
return -EINVAL;
|
||||
|
||||
return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev,
|
||||
0, 0, args);
|
||||
return drm_gem_vram_fill_create_dumb(file, dev, 0, 0, args);
|
||||
}
|
||||
EXPORT_SYMBOL(drm_gem_vram_driver_dumb_create);
|
||||
|
||||
|
|
|
@ -50,8 +50,7 @@ void hibmc_mm_fini(struct hibmc_drm_private *hibmc)
|
|||
int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
|
||||
struct drm_mode_create_dumb *args)
|
||||
{
|
||||
return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev,
|
||||
0, 16, args);
|
||||
return drm_gem_vram_fill_create_dumb(file, dev, 0, 16, args);
|
||||
}
|
||||
|
||||
const struct drm_mode_config_funcs hibmc_mode_funcs = {
|
||||
|
|
|
@ -208,8 +208,7 @@ int mgag200_cursor_init(struct mga_device *mdev)
|
|||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < ncursors; ++i) {
|
||||
gbo = drm_gem_vram_create(dev, &dev->vram_mm->bdev,
|
||||
size, 0);
|
||||
gbo = drm_gem_vram_create(dev, size, 0);
|
||||
if (IS_ERR(gbo)) {
|
||||
ret = PTR_ERR(gbo);
|
||||
goto err_drm_gem_vram_put;
|
||||
|
|
|
@ -120,8 +120,7 @@ int mgag200_driver_dumb_create(struct drm_file *file,
|
|||
if (mgag200_pin_bo_at_0(mdev))
|
||||
pg_align = PFN_UP(mdev->mc.vram_size);
|
||||
|
||||
return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev,
|
||||
pg_align, 0, args);
|
||||
return drm_gem_vram_fill_create_dumb(file, dev, pg_align, 0, args);
|
||||
}
|
||||
|
||||
static struct drm_driver driver = {
|
||||
|
|
|
@ -93,7 +93,6 @@ static inline struct drm_gem_vram_object *drm_gem_vram_of_gem(
|
|||
}
|
||||
|
||||
struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
|
||||
struct ttm_bo_device *bdev,
|
||||
size_t size,
|
||||
unsigned long pg_align);
|
||||
void drm_gem_vram_put(struct drm_gem_vram_object *gbo);
|
||||
|
@ -109,7 +108,6 @@ void drm_gem_vram_vunmap(struct drm_gem_vram_object *gbo, void *vaddr);
|
|||
|
||||
int drm_gem_vram_fill_create_dumb(struct drm_file *file,
|
||||
struct drm_device *dev,
|
||||
struct ttm_bo_device *bdev,
|
||||
unsigned long pg_align,
|
||||
unsigned long pitch_align,
|
||||
struct drm_mode_create_dumb *args);
|
||||
|
|
Loading…
Reference in New Issue