Commit a4d46a8e authored by Thomas Zimmermann's avatar Thomas Zimmermann

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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200106125745.13797-8-tzimmermann@suse.de
parent ebe9428b
...@@ -1144,8 +1144,7 @@ static int ast_cursor_init(struct drm_device *dev) ...@@ -1144,8 +1144,7 @@ static int ast_cursor_init(struct drm_device *dev)
size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE); size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE);
for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) { for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) {
gbo = drm_gem_vram_create(dev, &dev->vram_mm->bdev, gbo = drm_gem_vram_create(dev, size, 0);
size, 0);
if (IS_ERR(gbo)) { if (IS_ERR(gbo)) {
ret = PTR_ERR(gbo); ret = PTR_ERR(gbo);
goto err_drm_gem_vram_put; goto err_drm_gem_vram_put;
......
...@@ -92,13 +92,18 @@ static void drm_gem_vram_placement(struct drm_gem_vram_object *gbo, ...@@ -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, static int drm_gem_vram_init(struct drm_device *dev,
struct ttm_bo_device *bdev,
struct drm_gem_vram_object *gbo, struct drm_gem_vram_object *gbo,
size_t size, unsigned long pg_align) size_t size, unsigned long pg_align)
{ {
struct drm_vram_mm *vmm = dev->vram_mm;
struct ttm_bo_device *bdev;
int ret; int ret;
size_t acc_size; 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; gbo->bo.base.funcs = &drm_gem_vram_object_funcs;
ret = drm_gem_object_init(dev, &gbo->bo.base, size); ret = drm_gem_object_init(dev, &gbo->bo.base, size);
...@@ -126,7 +131,6 @@ static int drm_gem_vram_init(struct drm_device *dev, ...@@ -126,7 +131,6 @@ static int drm_gem_vram_init(struct drm_device *dev,
/** /**
* drm_gem_vram_create() - Creates a VRAM-backed GEM object * drm_gem_vram_create() - Creates a VRAM-backed GEM object
* @dev: the DRM device * @dev: the DRM device
* @bdev: the TTM BO device backing the object
* @size: the buffer size in bytes * @size: the buffer size in bytes
* @pg_align: the buffer's alignment in multiples of the page size * @pg_align: the buffer's alignment in multiples of the page size
* *
...@@ -135,7 +139,6 @@ static int drm_gem_vram_init(struct drm_device *dev, ...@@ -135,7 +139,6 @@ static int drm_gem_vram_init(struct drm_device *dev,
* an ERR_PTR()-encoded error code otherwise. * an ERR_PTR()-encoded error code otherwise.
*/ */
struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev, struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
struct ttm_bo_device *bdev,
size_t size, size_t size,
unsigned long pg_align) unsigned long pg_align)
{ {
...@@ -146,7 +149,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev, ...@@ -146,7 +149,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
if (!gbo) if (!gbo)
return ERR_PTR(-ENOMEM); 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) if (ret < 0)
goto err_kfree; goto err_kfree;
...@@ -480,7 +483,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap); ...@@ -480,7 +483,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
Helper for implementing &struct drm_driver.dumb_create Helper for implementing &struct drm_driver.dumb_create
* @file: the DRM file * @file: the DRM file
* @dev: the DRM device * @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 * @pg_align: the buffer's alignment in multiples of the page size
* @pitch_align: the scanline's alignment in powers of 2 * @pitch_align: the scanline's alignment in powers of 2
* @args: the arguments as provided to \ * @args: the arguments as provided to \
...@@ -497,7 +499,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap); ...@@ -497,7 +499,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
*/ */
int drm_gem_vram_fill_create_dumb(struct drm_file *file, int drm_gem_vram_fill_create_dumb(struct drm_file *file,
struct drm_device *dev, struct drm_device *dev,
struct ttm_bo_device *bdev,
unsigned long pg_align, unsigned long pg_align,
unsigned long pitch_align, unsigned long pitch_align,
struct drm_mode_create_dumb *args) struct drm_mode_create_dumb *args)
...@@ -519,7 +520,7 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file, ...@@ -519,7 +520,7 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
if (!size) if (!size)
return -EINVAL; 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)) if (IS_ERR(gbo))
return PTR_ERR(gbo); return PTR_ERR(gbo);
...@@ -614,8 +615,7 @@ int drm_gem_vram_driver_dumb_create(struct drm_file *file, ...@@ -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")) if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized"))
return -EINVAL; return -EINVAL;
return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev, return drm_gem_vram_fill_create_dumb(file, dev, 0, 0, args);
0, 0, args);
} }
EXPORT_SYMBOL(drm_gem_vram_driver_dumb_create); EXPORT_SYMBOL(drm_gem_vram_driver_dumb_create);
......
...@@ -50,8 +50,7 @@ void hibmc_mm_fini(struct hibmc_drm_private *hibmc) ...@@ -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, int hibmc_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args) struct drm_mode_create_dumb *args)
{ {
return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev, return drm_gem_vram_fill_create_dumb(file, dev, 0, 16, args);
0, 16, args);
} }
const struct drm_mode_config_funcs hibmc_mode_funcs = { const struct drm_mode_config_funcs hibmc_mode_funcs = {
......
...@@ -208,8 +208,7 @@ int mgag200_cursor_init(struct mga_device *mdev) ...@@ -208,8 +208,7 @@ int mgag200_cursor_init(struct mga_device *mdev)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < ncursors; ++i) { for (i = 0; i < ncursors; ++i) {
gbo = drm_gem_vram_create(dev, &dev->vram_mm->bdev, gbo = drm_gem_vram_create(dev, size, 0);
size, 0);
if (IS_ERR(gbo)) { if (IS_ERR(gbo)) {
ret = PTR_ERR(gbo); ret = PTR_ERR(gbo);
goto err_drm_gem_vram_put; goto err_drm_gem_vram_put;
......
...@@ -120,8 +120,7 @@ int mgag200_driver_dumb_create(struct drm_file *file, ...@@ -120,8 +120,7 @@ int mgag200_driver_dumb_create(struct drm_file *file,
if (mgag200_pin_bo_at_0(mdev)) if (mgag200_pin_bo_at_0(mdev))
pg_align = PFN_UP(mdev->mc.vram_size); pg_align = PFN_UP(mdev->mc.vram_size);
return drm_gem_vram_fill_create_dumb(file, dev, &dev->vram_mm->bdev, return drm_gem_vram_fill_create_dumb(file, dev, pg_align, 0, args);
pg_align, 0, args);
} }
static struct drm_driver driver = { static struct drm_driver driver = {
......
...@@ -93,7 +93,6 @@ static inline struct drm_gem_vram_object *drm_gem_vram_of_gem( ...@@ -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 drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
struct ttm_bo_device *bdev,
size_t size, size_t size,
unsigned long pg_align); unsigned long pg_align);
void drm_gem_vram_put(struct drm_gem_vram_object *gbo); 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); ...@@ -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, int drm_gem_vram_fill_create_dumb(struct drm_file *file,
struct drm_device *dev, struct drm_device *dev,
struct ttm_bo_device *bdev,
unsigned long pg_align, unsigned long pg_align,
unsigned long pitch_align, unsigned long pitch_align,
struct drm_mode_create_dumb *args); struct drm_mode_create_dumb *args);
......
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