Commit cbdded7f authored by Gabriel Krisman Bertazi's avatar Gabriel Krisman Bertazi Committed by Gerd Hoffmann

drm: qxl: Embed drm_device into driver structure

This is the recommended way to create the drm_device structure,
according to DRM documentation.
Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@collabora.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/20170127010548.27970-4-krisman@collabora.co.ukSigned-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent d74d74ae
...@@ -133,8 +133,8 @@ int qxl_debugfs_add_files(struct qxl_device *qdev, ...@@ -133,8 +133,8 @@ int qxl_debugfs_add_files(struct qxl_device *qdev,
qdev->debugfs_count = i; qdev->debugfs_count = i;
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
drm_debugfs_create_files(files, nfiles, drm_debugfs_create_files(files, nfiles,
qdev->ddev->primary->debugfs_root, qdev->ddev.primary->debugfs_root,
qdev->ddev->primary); qdev->ddev.primary);
#endif #endif
return 0; return 0;
} }
...@@ -147,7 +147,7 @@ void qxl_debugfs_remove_files(struct qxl_device *qdev) ...@@ -147,7 +147,7 @@ void qxl_debugfs_remove_files(struct qxl_device *qdev)
for (i = 0; i < qdev->debugfs_count; i++) { for (i = 0; i < qdev->debugfs_count; i++) {
drm_debugfs_remove_files(qdev->debugfs[i].files, drm_debugfs_remove_files(qdev->debugfs[i].files,
qdev->debugfs[i].num_files, qdev->debugfs[i].num_files,
qdev->ddev->primary); qdev->ddev.primary);
} }
#endif #endif
} }
...@@ -136,7 +136,7 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev) ...@@ -136,7 +136,7 @@ static int qxl_display_copy_rom_client_monitors_config(struct qxl_device *qdev)
static void qxl_update_offset_props(struct qxl_device *qdev) static void qxl_update_offset_props(struct qxl_device *qdev)
{ {
struct drm_device *dev = qdev->ddev; struct drm_device *dev = &qdev->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct qxl_output *output; struct qxl_output *output;
struct qxl_head *head; struct qxl_head *head;
...@@ -156,7 +156,7 @@ static void qxl_update_offset_props(struct qxl_device *qdev) ...@@ -156,7 +156,7 @@ static void qxl_update_offset_props(struct qxl_device *qdev)
void qxl_display_read_client_monitors_config(struct qxl_device *qdev) void qxl_display_read_client_monitors_config(struct qxl_device *qdev)
{ {
struct drm_device *dev = qdev->ddev; struct drm_device *dev = &qdev->ddev;
int status; int status;
status = qxl_display_copy_rom_client_monitors_config(qdev); status = qxl_display_copy_rom_client_monitors_config(qdev);
...@@ -174,10 +174,10 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev) ...@@ -174,10 +174,10 @@ void qxl_display_read_client_monitors_config(struct qxl_device *qdev)
drm_modeset_lock_all(dev); drm_modeset_lock_all(dev);
qxl_update_offset_props(qdev); qxl_update_offset_props(qdev);
drm_modeset_unlock_all(dev); drm_modeset_unlock_all(dev);
if (!drm_helper_hpd_irq_event(qdev->ddev)) { if (!drm_helper_hpd_irq_event(dev)) {
/* notify that the monitor configuration changed, to /* notify that the monitor configuration changed, to
adjust at the arbitrary resolution */ adjust at the arbitrary resolution */
drm_kms_helper_hotplug_event(qdev->ddev); drm_kms_helper_hotplug_event(dev);
} }
} }
...@@ -1036,7 +1036,7 @@ static int qxl_mode_create_hotplug_mode_update_property(struct qxl_device *qdev) ...@@ -1036,7 +1036,7 @@ static int qxl_mode_create_hotplug_mode_update_property(struct qxl_device *qdev)
return 0; return 0;
qdev->hotplug_mode_update_property = qdev->hotplug_mode_update_property =
drm_property_create_range(qdev->ddev, DRM_MODE_PROP_IMMUTABLE, drm_property_create_range(&qdev->ddev, DRM_MODE_PROP_IMMUTABLE,
"hotplug_mode_update", 0, 1); "hotplug_mode_update", 0, 1);
return 0; return 0;
...@@ -1175,28 +1175,28 @@ int qxl_modeset_init(struct qxl_device *qdev) ...@@ -1175,28 +1175,28 @@ int qxl_modeset_init(struct qxl_device *qdev)
int i; int i;
int ret; int ret;
drm_mode_config_init(qdev->ddev); drm_mode_config_init(&qdev->ddev);
ret = qxl_create_monitors_object(qdev); ret = qxl_create_monitors_object(qdev);
if (ret) if (ret)
return ret; return ret;
qdev->ddev->mode_config.funcs = (void *)&qxl_mode_funcs; qdev->ddev.mode_config.funcs = (void *)&qxl_mode_funcs;
/* modes will be validated against the framebuffer size */ /* modes will be validated against the framebuffer size */
qdev->ddev->mode_config.min_width = 320; qdev->ddev.mode_config.min_width = 320;
qdev->ddev->mode_config.min_height = 200; qdev->ddev.mode_config.min_height = 200;
qdev->ddev->mode_config.max_width = 8192; qdev->ddev.mode_config.max_width = 8192;
qdev->ddev->mode_config.max_height = 8192; qdev->ddev.mode_config.max_height = 8192;
qdev->ddev->mode_config.fb_base = qdev->vram_base; qdev->ddev.mode_config.fb_base = qdev->vram_base;
drm_mode_create_suggested_offset_properties(qdev->ddev); drm_mode_create_suggested_offset_properties(&qdev->ddev);
qxl_mode_create_hotplug_mode_update_property(qdev); qxl_mode_create_hotplug_mode_update_property(qdev);
for (i = 0 ; i < qxl_num_crtc; ++i) { for (i = 0 ; i < qxl_num_crtc; ++i) {
qdev_crtc_init(qdev->ddev, i); qdev_crtc_init(&qdev->ddev, i);
qdev_output_init(qdev->ddev, i); qdev_output_init(&qdev->ddev, i);
} }
qdev->mode_info.mode_config_initialized = true; qdev->mode_info.mode_config_initialized = true;
...@@ -1214,7 +1214,7 @@ void qxl_modeset_fini(struct qxl_device *qdev) ...@@ -1214,7 +1214,7 @@ void qxl_modeset_fini(struct qxl_device *qdev)
qxl_destroy_monitors_object(qdev); qxl_destroy_monitors_object(qdev);
if (qdev->mode_info.mode_config_initialized) { if (qdev->mode_info.mode_config_initialized) {
drm_mode_config_cleanup(qdev->ddev); drm_mode_config_cleanup(&qdev->ddev);
qdev->mode_info.mode_config_initialized = false; qdev->mode_info.mode_config_initialized = false;
} }
} }
...@@ -62,7 +62,6 @@ static struct pci_driver qxl_pci_driver; ...@@ -62,7 +62,6 @@ static struct pci_driver qxl_pci_driver;
static int static int
qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
struct drm_device *drm;
struct qxl_device *qdev; struct qxl_device *qdev;
int ret; int ret;
...@@ -72,29 +71,19 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -72,29 +71,19 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
return -EINVAL; /* TODO: ENODEV ? */ return -EINVAL; /* TODO: ENODEV ? */
} }
drm = drm_dev_alloc(&qxl_driver, &pdev->dev);
if (IS_ERR(drm))
return -ENOMEM;
qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL); qdev = kzalloc(sizeof(struct qxl_device), GFP_KERNEL);
if (!qdev) { if (!qdev)
ret = -ENOMEM; return -ENOMEM;
goto free_drm_device;
}
ret = pci_enable_device(pdev); ret = pci_enable_device(pdev);
if (ret) if (ret)
goto free_drm_device; goto free_dev;
drm->pdev = pdev;
pci_set_drvdata(pdev, drm);
drm->dev_private = qdev;
ret = qxl_device_init(qdev, drm, pdev, ent->driver_data); ret = qxl_device_init(qdev, &qxl_driver, pdev, ent->driver_data);
if (ret) if (ret)
goto disable_pci; goto disable_pci;
ret = drm_vblank_init(drm, 1); ret = drm_vblank_init(&qdev->ddev, 1);
if (ret) if (ret)
goto unload; goto unload;
...@@ -102,10 +91,10 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -102,10 +91,10 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret) if (ret)
goto vblank_cleanup; goto vblank_cleanup;
drm_kms_helper_poll_init(qdev->ddev); drm_kms_helper_poll_init(&qdev->ddev);
/* Complete initialization. */ /* Complete initialization. */
ret = drm_dev_register(drm, ent->driver_data); ret = drm_dev_register(&qdev->ddev, ent->driver_data);
if (ret) if (ret)
goto modeset_cleanup; goto modeset_cleanup;
...@@ -114,14 +103,13 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -114,14 +103,13 @@ qxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
modeset_cleanup: modeset_cleanup:
qxl_modeset_fini(qdev); qxl_modeset_fini(qdev);
vblank_cleanup: vblank_cleanup:
drm_vblank_cleanup(drm); drm_vblank_cleanup(&qdev->ddev);
unload: unload:
qxl_device_fini(qdev); qxl_device_fini(qdev);
disable_pci: disable_pci:
pci_disable_device(pdev); pci_disable_device(pdev);
free_drm_device: free_dev:
kfree(qdev); kfree(qdev);
kfree(drm);
return ret; return ret;
} }
......
...@@ -242,7 +242,7 @@ void qxl_debugfs_remove_files(struct qxl_device *qdev); ...@@ -242,7 +242,7 @@ void qxl_debugfs_remove_files(struct qxl_device *qdev);
struct qxl_device; struct qxl_device;
struct qxl_device { struct qxl_device {
struct drm_device *ddev; struct drm_device ddev;
unsigned long flags; unsigned long flags;
resource_size_t vram_base, vram_size; resource_size_t vram_base, vram_size;
...@@ -334,7 +334,7 @@ __printf(2,3) void qxl_io_log(struct qxl_device *qdev, const char *fmt, ...); ...@@ -334,7 +334,7 @@ __printf(2,3) void qxl_io_log(struct qxl_device *qdev, const char *fmt, ...);
extern const struct drm_ioctl_desc qxl_ioctls[]; extern const struct drm_ioctl_desc qxl_ioctls[];
extern int qxl_max_ioctl; extern int qxl_max_ioctl;
int qxl_device_init(struct qxl_device *qdev, struct drm_device *ddev, int qxl_device_init(struct qxl_device *qdev, struct drm_driver *drv,
struct pci_dev *pdev, unsigned long flags); struct pci_dev *pdev, unsigned long flags);
void qxl_device_fini(struct qxl_device *qdev); void qxl_device_fini(struct qxl_device *qdev);
......
...@@ -268,7 +268,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev, ...@@ -268,7 +268,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
info->par = qfbdev; info->par = qfbdev;
qxl_framebuffer_init(qdev->ddev, &qfbdev->qfb, &mode_cmd, gobj, qxl_framebuffer_init(&qdev->ddev, &qfbdev->qfb, &mode_cmd, gobj,
&qxlfb_fb_funcs); &qxlfb_fb_funcs);
fb = &qfbdev->qfb.base; fb = &qfbdev->qfb.base;
...@@ -297,7 +297,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev, ...@@ -297,7 +297,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
sizes->fb_height); sizes->fb_height);
/* setup aperture base/size for vesafb takeover */ /* setup aperture base/size for vesafb takeover */
info->apertures->ranges[0].base = qdev->ddev->mode_config.fb_base; info->apertures->ranges[0].base = qdev->ddev.mode_config.fb_base;
info->apertures->ranges[0].size = qdev->vram_size; info->apertures->ranges[0].size = qdev->vram_size;
info->fix.mmio_start = 0; info->fix.mmio_start = 0;
...@@ -395,10 +395,10 @@ int qxl_fbdev_init(struct qxl_device *qdev) ...@@ -395,10 +395,10 @@ int qxl_fbdev_init(struct qxl_device *qdev)
spin_lock_init(&qfbdev->delayed_ops_lock); spin_lock_init(&qfbdev->delayed_ops_lock);
INIT_LIST_HEAD(&qfbdev->delayed_ops); INIT_LIST_HEAD(&qfbdev->delayed_ops);
drm_fb_helper_prepare(qdev->ddev, &qfbdev->helper, drm_fb_helper_prepare(&qdev->ddev, &qfbdev->helper,
&qxl_fb_helper_funcs); &qxl_fb_helper_funcs);
ret = drm_fb_helper_init(qdev->ddev, &qfbdev->helper, ret = drm_fb_helper_init(&qdev->ddev, &qfbdev->helper,
qxl_num_crtc, qxl_num_crtc,
QXLFB_CONN_LIMIT); QXLFB_CONN_LIMIT);
if (ret) if (ret)
...@@ -426,7 +426,7 @@ void qxl_fbdev_fini(struct qxl_device *qdev) ...@@ -426,7 +426,7 @@ void qxl_fbdev_fini(struct qxl_device *qdev)
if (!qdev->mode_info.qfbdev) if (!qdev->mode_info.qfbdev)
return; return;
qxl_fbdev_destroy(qdev->ddev, qdev->mode_info.qfbdev); qxl_fbdev_destroy(&qdev->ddev, qdev->mode_info.qfbdev);
kfree(qdev->mode_info.qfbdev); kfree(qdev->mode_info.qfbdev);
qdev->mode_info.qfbdev = NULL; qdev->mode_info.qfbdev = NULL;
} }
......
...@@ -64,7 +64,7 @@ static int qxl_map_ioctl(struct drm_device *dev, void *data, ...@@ -64,7 +64,7 @@ static int qxl_map_ioctl(struct drm_device *dev, void *data,
struct qxl_device *qdev = dev->dev_private; struct qxl_device *qdev = dev->dev_private;
struct drm_qxl_map *qxl_map = data; struct drm_qxl_map *qxl_map = data;
return qxl_mode_dumb_mmap(file_priv, qdev->ddev, qxl_map->handle, return qxl_mode_dumb_mmap(file_priv, &qdev->ddev, qxl_map->handle,
&qxl_map->offset); &qxl_map->offset);
} }
......
...@@ -90,7 +90,7 @@ int qxl_irq_init(struct qxl_device *qdev) ...@@ -90,7 +90,7 @@ int qxl_irq_init(struct qxl_device *qdev)
atomic_set(&qdev->irq_received_cursor, 0); atomic_set(&qdev->irq_received_cursor, 0);
atomic_set(&qdev->irq_received_io_cmd, 0); atomic_set(&qdev->irq_received_io_cmd, 0);
qdev->irq_received_error = 0; qdev->irq_received_error = 0;
ret = drm_irq_install(qdev->ddev, qdev->ddev->pdev->irq); ret = drm_irq_install(&qdev->ddev, qdev->ddev.pdev->irq);
qdev->ram_header->int_mask = QXL_INTERRUPT_MASK; qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
if (unlikely(ret != 0)) { if (unlikely(ret != 0)) {
DRM_ERROR("Failed installing irq: %d\n", ret); DRM_ERROR("Failed installing irq: %d\n", ret);
......
...@@ -116,13 +116,20 @@ static void qxl_gc_work(struct work_struct *work) ...@@ -116,13 +116,20 @@ static void qxl_gc_work(struct work_struct *work)
} }
int qxl_device_init(struct qxl_device *qdev, int qxl_device_init(struct qxl_device *qdev,
struct drm_device *ddev, struct drm_driver *drv,
struct pci_dev *pdev, struct pci_dev *pdev,
unsigned long flags) unsigned long flags)
{ {
int r, sb; int r, sb;
qdev->ddev = ddev; r = drm_dev_init(&qdev->ddev, drv, &pdev->dev);
if (r)
return r;
qdev->ddev.pdev = pdev;
pci_set_drvdata(pdev, &qdev->ddev);
qdev->ddev.dev_private = qdev;
qdev->flags = flags; qdev->flags = flags;
mutex_init(&qdev->gem.mutex); mutex_init(&qdev->gem.mutex);
......
...@@ -93,7 +93,7 @@ int qxl_bo_create(struct qxl_device *qdev, ...@@ -93,7 +93,7 @@ int qxl_bo_create(struct qxl_device *qdev,
if (bo == NULL) if (bo == NULL)
return -ENOMEM; return -ENOMEM;
size = roundup(size, PAGE_SIZE); size = roundup(size, PAGE_SIZE);
r = drm_gem_object_init(qdev->ddev, &bo->gem_base, size); r = drm_gem_object_init(&qdev->ddev, &bo->gem_base, size);
if (unlikely(r)) { if (unlikely(r)) {
kfree(bo); kfree(bo);
return r; return r;
...@@ -113,7 +113,7 @@ int qxl_bo_create(struct qxl_device *qdev, ...@@ -113,7 +113,7 @@ int qxl_bo_create(struct qxl_device *qdev,
NULL, NULL, &qxl_ttm_bo_destroy); NULL, NULL, &qxl_ttm_bo_destroy);
if (unlikely(r != 0)) { if (unlikely(r != 0)) {
if (r != -ERESTARTSYS) if (r != -ERESTARTSYS)
dev_err(qdev->ddev->dev, dev_err(qdev->ddev.dev,
"object_init failed for (%lu, 0x%08X)\n", "object_init failed for (%lu, 0x%08X)\n",
size, domain); size, domain);
return r; return r;
...@@ -270,9 +270,9 @@ void qxl_bo_force_delete(struct qxl_device *qdev) ...@@ -270,9 +270,9 @@ void qxl_bo_force_delete(struct qxl_device *qdev)
if (list_empty(&qdev->gem.objects)) if (list_empty(&qdev->gem.objects))
return; return;
dev_err(qdev->ddev->dev, "Userspace still has active objects !\n"); dev_err(qdev->ddev.dev, "Userspace still has active objects !\n");
list_for_each_entry_safe(bo, n, &qdev->gem.objects, list) { list_for_each_entry_safe(bo, n, &qdev->gem.objects, list) {
dev_err(qdev->ddev->dev, "%p %p %lu %lu force free\n", dev_err(qdev->ddev.dev, "%p %p %lu %lu force free\n",
&bo->gem_base, bo, (unsigned long)bo->gem_base.size, &bo->gem_base, bo, (unsigned long)bo->gem_base.size,
*((unsigned long *)&bo->gem_base.refcount)); *((unsigned long *)&bo->gem_base.refcount));
mutex_lock(&qdev->gem.mutex); mutex_lock(&qdev->gem.mutex);
......
...@@ -408,7 +408,7 @@ int qxl_ttm_init(struct qxl_device *qdev) ...@@ -408,7 +408,7 @@ int qxl_ttm_init(struct qxl_device *qdev)
r = ttm_bo_device_init(&qdev->mman.bdev, r = ttm_bo_device_init(&qdev->mman.bdev,
qdev->mman.bo_global_ref.ref.object, qdev->mman.bo_global_ref.ref.object,
&qxl_bo_driver, &qxl_bo_driver,
qdev->ddev->anon_inode->i_mapping, qdev->ddev.anon_inode->i_mapping,
DRM_FILE_PAGE_OFFSET, 0); DRM_FILE_PAGE_OFFSET, 0);
if (r) { if (r) {
DRM_ERROR("failed initializing buffer object driver(%d).\n", r); DRM_ERROR("failed initializing buffer object driver(%d).\n", r);
......
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