Commit 01648890 authored by Hans de Goede's avatar Hans de Goede Committed by Greg Kroah-Hartman

staging: vboxvideo: 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 avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d4670909
...@@ -51,35 +51,31 @@ MODULE_DEVICE_TABLE(pci, pciidlist); ...@@ -51,35 +51,31 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
struct vbox_private *vbox = NULL; struct vbox_private *vbox;
struct drm_device *dev = NULL;
int ret = 0; int ret = 0;
if (!vbox_check_supported(VBE_DISPI_ID_HGSMI)) if (!vbox_check_supported(VBE_DISPI_ID_HGSMI))
return -ENODEV; return -ENODEV;
dev = drm_dev_alloc(&driver, &pdev->dev); vbox = kzalloc(sizeof(*vbox), GFP_KERNEL);
if (IS_ERR(dev)) if (!vbox)
return PTR_ERR(dev); return -ENOMEM;
ret = pci_enable_device(pdev); ret = drm_dev_init(&vbox->ddev, &driver, &pdev->dev);
if (ret) if (ret) {
goto err_dev_put; kfree(vbox);
return ret;
dev->pdev = pdev;
pci_set_drvdata(pdev, dev);
vbox = devm_kzalloc(&pdev->dev, sizeof(*vbox), GFP_KERNEL);
if (!vbox) {
ret = -ENOMEM;
goto err_pci_disable;
} }
dev->dev_private = vbox; vbox->ddev.pdev = pdev;
vbox->dev = dev; vbox->ddev.dev_private = vbox;
pci_set_drvdata(pdev, vbox);
mutex_init(&vbox->hw_mutex); mutex_init(&vbox->hw_mutex);
ret = pci_enable_device(pdev);
if (ret)
goto err_dev_put;
ret = vbox_hw_init(vbox); ret = vbox_hw_init(vbox);
if (ret) if (ret)
goto err_pci_disable; goto err_pci_disable;
...@@ -88,7 +84,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -88,7 +84,7 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret) if (ret)
goto err_hw_fini; goto err_hw_fini;
ret = vbox_mode_init(dev); ret = vbox_mode_init(vbox);
if (ret) if (ret)
goto err_mm_fini; goto err_mm_fini;
...@@ -96,22 +92,22 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -96,22 +92,22 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ret) if (ret)
goto err_mode_fini; goto err_mode_fini;
ret = vbox_fbdev_init(dev); ret = vbox_fbdev_init(vbox);
if (ret) if (ret)
goto err_irq_fini; goto err_irq_fini;
ret = drm_dev_register(dev, 0); ret = drm_dev_register(&vbox->ddev, 0);
if (ret) if (ret)
goto err_fbdev_fini; goto err_fbdev_fini;
return 0; return 0;
err_fbdev_fini: err_fbdev_fini:
vbox_fbdev_fini(dev); vbox_fbdev_fini(vbox);
err_irq_fini: err_irq_fini:
vbox_irq_fini(vbox); vbox_irq_fini(vbox);
err_mode_fini: err_mode_fini:
vbox_mode_fini(dev); vbox_mode_fini(vbox);
err_mm_fini: err_mm_fini:
vbox_mm_fini(vbox); vbox_mm_fini(vbox);
err_hw_fini: err_hw_fini:
...@@ -119,110 +115,100 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -119,110 +115,100 @@ static int vbox_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
err_pci_disable: err_pci_disable:
pci_disable_device(pdev); pci_disable_device(pdev);
err_dev_put: err_dev_put:
drm_dev_put(dev); drm_dev_put(&vbox->ddev);
return ret; return ret;
} }
static void vbox_pci_remove(struct pci_dev *pdev) static void vbox_pci_remove(struct pci_dev *pdev)
{ {
struct drm_device *dev = pci_get_drvdata(pdev); struct vbox_private *vbox = pci_get_drvdata(pdev);
struct vbox_private *vbox = dev->dev_private;
drm_dev_unregister(dev); drm_dev_unregister(&vbox->ddev);
vbox_fbdev_fini(dev); vbox_fbdev_fini(vbox);
vbox_irq_fini(vbox); vbox_irq_fini(vbox);
vbox_mode_fini(dev); vbox_mode_fini(vbox);
vbox_mm_fini(vbox); vbox_mm_fini(vbox);
vbox_hw_fini(vbox); vbox_hw_fini(vbox);
drm_dev_put(dev); drm_dev_put(&vbox->ddev);
} }
static int vbox_drm_freeze(struct drm_device *dev) static int vbox_drm_freeze(struct vbox_private *vbox)
{ {
struct vbox_private *vbox = dev->dev_private; drm_kms_helper_poll_disable(&vbox->ddev);
drm_kms_helper_poll_disable(dev);
pci_save_state(dev->pdev); pci_save_state(vbox->ddev.pdev);
drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, true); drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, true);
return 0; return 0;
} }
static int vbox_drm_thaw(struct drm_device *dev) static int vbox_drm_thaw(struct vbox_private *vbox)
{ {
struct vbox_private *vbox = dev->dev_private; drm_mode_config_reset(&vbox->ddev);
drm_helper_resume_force_mode(&vbox->ddev);
drm_mode_config_reset(dev);
drm_helper_resume_force_mode(dev);
drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, false); drm_fb_helper_set_suspend_unlocked(&vbox->fbdev->helper, false);
return 0; return 0;
} }
static int vbox_drm_resume(struct drm_device *dev) static int vbox_drm_resume(struct vbox_private *vbox)
{ {
int ret; int ret;
if (pci_enable_device(dev->pdev)) if (pci_enable_device(vbox->ddev.pdev))
return -EIO; return -EIO;
ret = vbox_drm_thaw(dev); ret = vbox_drm_thaw(vbox);
if (ret) if (ret)
return ret; return ret;
drm_kms_helper_poll_enable(dev); drm_kms_helper_poll_enable(&vbox->ddev);
return 0; return 0;
} }
static int vbox_pm_suspend(struct device *dev) static int vbox_pm_suspend(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct vbox_private *vbox = dev_get_drvdata(dev);
struct drm_device *ddev = pci_get_drvdata(pdev);
int error; int error;
error = vbox_drm_freeze(ddev); error = vbox_drm_freeze(vbox);
if (error) if (error)
return error; return error;
pci_disable_device(pdev); pci_disable_device(vbox->ddev.pdev);
pci_set_power_state(pdev, PCI_D3hot); pci_set_power_state(vbox->ddev.pdev, PCI_D3hot);
return 0; return 0;
} }
static int vbox_pm_resume(struct device *dev) static int vbox_pm_resume(struct device *dev)
{ {
struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); struct vbox_private *vbox = dev_get_drvdata(dev);
return vbox_drm_resume(ddev); return vbox_drm_resume(vbox);
} }
static int vbox_pm_freeze(struct device *dev) static int vbox_pm_freeze(struct device *dev)
{ {
struct pci_dev *pdev = to_pci_dev(dev); struct vbox_private *vbox = dev_get_drvdata(dev);
struct drm_device *ddev = pci_get_drvdata(pdev);
if (!ddev || !ddev->dev_private)
return -ENODEV;
return vbox_drm_freeze(ddev); return vbox_drm_freeze(vbox);
} }
static int vbox_pm_thaw(struct device *dev) static int vbox_pm_thaw(struct device *dev)
{ {
struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); struct vbox_private *vbox = dev_get_drvdata(dev);
return vbox_drm_thaw(ddev); return vbox_drm_thaw(vbox);
} }
static int vbox_pm_poweroff(struct device *dev) static int vbox_pm_poweroff(struct device *dev)
{ {
struct drm_device *ddev = pci_get_drvdata(to_pci_dev(dev)); struct vbox_private *vbox = dev_get_drvdata(dev);
return vbox_drm_freeze(ddev); return vbox_drm_freeze(vbox);
} }
static const struct dev_pm_ops vbox_pm_ops = { static const struct dev_pm_ops vbox_pm_ops = {
......
...@@ -75,7 +75,8 @@ ...@@ -75,7 +75,8 @@
struct vbox_fbdev; struct vbox_fbdev;
struct vbox_private { struct vbox_private {
struct drm_device *dev; /* Must be first; or we must define our own release callback */
struct drm_device ddev;
u8 __iomem *guest_heap; u8 __iomem *guest_heap;
u8 __iomem *vbva_buffers; u8 __iomem *vbva_buffers;
...@@ -179,8 +180,8 @@ bool vbox_check_supported(u16 id); ...@@ -179,8 +180,8 @@ bool vbox_check_supported(u16 id);
int vbox_hw_init(struct vbox_private *vbox); int vbox_hw_init(struct vbox_private *vbox);
void vbox_hw_fini(struct vbox_private *vbox); void vbox_hw_fini(struct vbox_private *vbox);
int vbox_mode_init(struct drm_device *dev); int vbox_mode_init(struct vbox_private *vbox);
void vbox_mode_fini(struct drm_device *dev); void vbox_mode_fini(struct vbox_private *vbox);
#define DRM_MODE_FB_CMD drm_mode_fb_cmd2 #define DRM_MODE_FB_CMD drm_mode_fb_cmd2
#define CRTC_FB(crtc) ((crtc)->primary->fb) #define CRTC_FB(crtc) ((crtc)->primary->fb)
...@@ -193,13 +194,13 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, ...@@ -193,13 +194,13 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb,
struct drm_clip_rect *rects, struct drm_clip_rect *rects,
unsigned int num_rects); unsigned int num_rects);
int vbox_framebuffer_init(struct drm_device *dev, int vbox_framebuffer_init(struct vbox_private *vbox,
struct vbox_framebuffer *vbox_fb, struct vbox_framebuffer *vbox_fb,
const struct DRM_MODE_FB_CMD *mode_cmd, const struct DRM_MODE_FB_CMD *mode_cmd,
struct drm_gem_object *obj); struct drm_gem_object *obj);
int vbox_fbdev_init(struct drm_device *dev); int vbox_fbdev_init(struct vbox_private *vbox);
void vbox_fbdev_fini(struct drm_device *dev); void vbox_fbdev_fini(struct vbox_private *vbox);
void vbox_fbdev_set_base(struct vbox_private *vbox, unsigned long gpu_addr); void vbox_fbdev_set_base(struct vbox_private *vbox, unsigned long gpu_addr);
struct vbox_bo { struct vbox_bo {
...@@ -234,10 +235,10 @@ int vbox_dumb_mmap_offset(struct drm_file *file, ...@@ -234,10 +235,10 @@ int vbox_dumb_mmap_offset(struct drm_file *file,
int vbox_mm_init(struct vbox_private *vbox); int vbox_mm_init(struct vbox_private *vbox);
void vbox_mm_fini(struct vbox_private *vbox); void vbox_mm_fini(struct vbox_private *vbox);
int vbox_bo_create(struct drm_device *dev, int size, int align, int vbox_bo_create(struct vbox_private *vbox, int size, int align,
u32 flags, struct vbox_bo **pvboxbo); u32 flags, struct vbox_bo **pvboxbo);
int vbox_gem_create(struct drm_device *dev, int vbox_gem_create(struct vbox_private *vbox,
u32 size, bool iskernel, struct drm_gem_object **obj); u32 size, bool iskernel, struct drm_gem_object **obj);
int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag, u64 *gpu_addr); int vbox_bo_pin(struct vbox_bo *bo, u32 pl_flag, u64 *gpu_addr);
......
...@@ -71,7 +71,9 @@ static int vboxfb_create(struct drm_fb_helper *helper, ...@@ -71,7 +71,9 @@ static int vboxfb_create(struct drm_fb_helper *helper,
{ {
struct vbox_fbdev *fbdev = struct vbox_fbdev *fbdev =
container_of(helper, struct vbox_fbdev, helper); container_of(helper, struct vbox_fbdev, helper);
struct drm_device *dev = fbdev->helper.dev; struct vbox_private *vbox = container_of(fbdev->helper.dev,
struct vbox_private, ddev);
struct pci_dev *pdev = vbox->ddev.pdev;
struct DRM_MODE_FB_CMD mode_cmd; struct DRM_MODE_FB_CMD mode_cmd;
struct drm_framebuffer *fb; struct drm_framebuffer *fb;
struct fb_info *info; struct fb_info *info;
...@@ -89,13 +91,13 @@ static int vboxfb_create(struct drm_fb_helper *helper, ...@@ -89,13 +91,13 @@ static int vboxfb_create(struct drm_fb_helper *helper,
size = pitch * mode_cmd.height; size = pitch * mode_cmd.height;
ret = vbox_gem_create(fbdev->helper.dev, size, true, &gobj); ret = vbox_gem_create(vbox, size, true, &gobj);
if (ret) { if (ret) {
DRM_ERROR("failed to create fbcon backing object %d\n", ret); DRM_ERROR("failed to create fbcon backing object %d\n", ret);
return ret; return ret;
} }
ret = vbox_framebuffer_init(dev, &fbdev->afb, &mode_cmd, gobj); ret = vbox_framebuffer_init(vbox, &fbdev->afb, &mode_cmd, gobj);
if (ret) if (ret)
return ret; return ret;
...@@ -143,8 +145,8 @@ static int vboxfb_create(struct drm_fb_helper *helper, ...@@ -143,8 +145,8 @@ static int vboxfb_create(struct drm_fb_helper *helper,
* This seems to be done for safety checking that the framebuffer * This seems to be done for safety checking that the framebuffer
* is not registered twice by different drivers. * is not registered twice by different drivers.
*/ */
info->apertures->ranges[0].base = pci_resource_start(dev->pdev, 0); info->apertures->ranges[0].base = pci_resource_start(pdev, 0);
info->apertures->ranges[0].size = pci_resource_len(dev->pdev, 0); info->apertures->ranges[0].size = pci_resource_len(pdev, 0);
drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth); drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
drm_fb_helper_fill_var(info, &fbdev->helper, sizes->fb_width, drm_fb_helper_fill_var(info, &fbdev->helper, sizes->fb_width,
...@@ -169,9 +171,8 @@ static struct drm_fb_helper_funcs vbox_fb_helper_funcs = { ...@@ -169,9 +171,8 @@ static struct drm_fb_helper_funcs vbox_fb_helper_funcs = {
.fb_probe = vboxfb_create, .fb_probe = vboxfb_create,
}; };
void vbox_fbdev_fini(struct drm_device *dev) void vbox_fbdev_fini(struct vbox_private *vbox)
{ {
struct vbox_private *vbox = dev->dev_private;
struct vbox_fbdev *fbdev = vbox->fbdev; struct vbox_fbdev *fbdev = vbox->fbdev;
struct vbox_framebuffer *afb = &fbdev->afb; struct vbox_framebuffer *afb = &fbdev->afb;
...@@ -205,9 +206,9 @@ void vbox_fbdev_fini(struct drm_device *dev) ...@@ -205,9 +206,9 @@ void vbox_fbdev_fini(struct drm_device *dev)
drm_framebuffer_cleanup(&afb->base); drm_framebuffer_cleanup(&afb->base);
} }
int vbox_fbdev_init(struct drm_device *dev) int vbox_fbdev_init(struct vbox_private *vbox)
{ {
struct vbox_private *vbox = dev->dev_private; struct drm_device *dev = &vbox->ddev;
struct vbox_fbdev *fbdev; struct vbox_fbdev *fbdev;
int ret; int ret;
......
...@@ -123,7 +123,7 @@ static void validate_or_set_position_hints(struct vbox_private *vbox) ...@@ -123,7 +123,7 @@ static void validate_or_set_position_hints(struct vbox_private *vbox)
*/ */
static void vbox_update_mode_hints(struct vbox_private *vbox) static void vbox_update_mode_hints(struct vbox_private *vbox)
{ {
struct drm_device *dev = vbox->dev; struct drm_device *dev = &vbox->ddev;
struct drm_connector *connector; struct drm_connector *connector;
struct vbox_connector *vbox_conn; struct vbox_connector *vbox_conn;
struct vbva_modehint *hints; struct vbva_modehint *hints;
...@@ -179,7 +179,7 @@ static void vbox_hotplug_worker(struct work_struct *work) ...@@ -179,7 +179,7 @@ static void vbox_hotplug_worker(struct work_struct *work)
hotplug_work); hotplug_work);
vbox_update_mode_hints(vbox); vbox_update_mode_hints(vbox);
drm_kms_helper_hotplug_event(vbox->dev); drm_kms_helper_hotplug_event(&vbox->ddev);
} }
int vbox_irq_init(struct vbox_private *vbox) int vbox_irq_init(struct vbox_private *vbox)
...@@ -187,11 +187,11 @@ int vbox_irq_init(struct vbox_private *vbox) ...@@ -187,11 +187,11 @@ int vbox_irq_init(struct vbox_private *vbox)
INIT_WORK(&vbox->hotplug_work, vbox_hotplug_worker); INIT_WORK(&vbox->hotplug_work, vbox_hotplug_worker);
vbox_update_mode_hints(vbox); vbox_update_mode_hints(vbox);
return drm_irq_install(vbox->dev, vbox->dev->pdev->irq); return drm_irq_install(&vbox->ddev, vbox->ddev.pdev->irq);
} }
void vbox_irq_fini(struct vbox_private *vbox) void vbox_irq_fini(struct vbox_private *vbox)
{ {
drm_irq_uninstall(vbox->dev); drm_irq_uninstall(&vbox->ddev);
flush_work(&vbox->hotplug_work); flush_work(&vbox->hotplug_work);
} }
...@@ -155,16 +155,16 @@ static const struct drm_framebuffer_funcs vbox_fb_funcs = { ...@@ -155,16 +155,16 @@ static const struct drm_framebuffer_funcs vbox_fb_funcs = {
.dirty = vbox_user_framebuffer_dirty, .dirty = vbox_user_framebuffer_dirty,
}; };
int vbox_framebuffer_init(struct drm_device *dev, int vbox_framebuffer_init(struct vbox_private *vbox,
struct vbox_framebuffer *vbox_fb, struct vbox_framebuffer *vbox_fb,
const struct DRM_MODE_FB_CMD *mode_cmd, const struct DRM_MODE_FB_CMD *mode_cmd,
struct drm_gem_object *obj) struct drm_gem_object *obj)
{ {
int ret; int ret;
drm_helper_mode_fill_fb_struct(dev, &vbox_fb->base, mode_cmd); drm_helper_mode_fill_fb_struct(&vbox->ddev, &vbox_fb->base, mode_cmd);
vbox_fb->obj = obj; vbox_fb->obj = obj;
ret = drm_framebuffer_init(dev, &vbox_fb->base, &vbox_fb_funcs); ret = drm_framebuffer_init(&vbox->ddev, &vbox_fb->base, &vbox_fb_funcs);
if (ret) { if (ret) {
DRM_ERROR("framebuffer init failed %d\n", ret); DRM_ERROR("framebuffer init failed %d\n", ret);
return ret; return ret;
...@@ -177,7 +177,7 @@ static int vbox_accel_init(struct vbox_private *vbox) ...@@ -177,7 +177,7 @@ static int vbox_accel_init(struct vbox_private *vbox)
{ {
unsigned int i; unsigned int i;
vbox->vbva_info = devm_kcalloc(vbox->dev->dev, vbox->num_crtcs, vbox->vbva_info = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs,
sizeof(*vbox->vbva_info), GFP_KERNEL); sizeof(*vbox->vbva_info), GFP_KERNEL);
if (!vbox->vbva_info) if (!vbox->vbva_info)
return -ENOMEM; return -ENOMEM;
...@@ -185,7 +185,7 @@ static int vbox_accel_init(struct vbox_private *vbox) ...@@ -185,7 +185,7 @@ static int vbox_accel_init(struct vbox_private *vbox)
/* Take a command buffer for each screen from the end of usable VRAM. */ /* Take a command buffer for each screen from the end of usable VRAM. */
vbox->available_vram_size -= vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE; vbox->available_vram_size -= vbox->num_crtcs * VBVA_MIN_BUFFER_SIZE;
vbox->vbva_buffers = pci_iomap_range(vbox->dev->pdev, 0, vbox->vbva_buffers = pci_iomap_range(vbox->ddev.pdev, 0,
vbox->available_vram_size, vbox->available_vram_size,
vbox->num_crtcs * vbox->num_crtcs *
VBVA_MIN_BUFFER_SIZE); VBVA_MIN_BUFFER_SIZE);
...@@ -204,7 +204,7 @@ static int vbox_accel_init(struct vbox_private *vbox) ...@@ -204,7 +204,7 @@ static int vbox_accel_init(struct vbox_private *vbox)
static void vbox_accel_fini(struct vbox_private *vbox) static void vbox_accel_fini(struct vbox_private *vbox)
{ {
vbox_disable_accel(vbox); vbox_disable_accel(vbox);
pci_iounmap(vbox->dev->pdev, vbox->vbva_buffers); pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers);
} }
/** Do we support the 4.3 plus mode hint reporting interface? */ /** Do we support the 4.3 plus mode hint reporting interface? */
...@@ -253,7 +253,7 @@ int vbox_hw_init(struct vbox_private *vbox) ...@@ -253,7 +253,7 @@ int vbox_hw_init(struct vbox_private *vbox)
/* Map guest-heap at end of vram */ /* Map guest-heap at end of vram */
vbox->guest_heap = vbox->guest_heap =
pci_iomap_range(vbox->dev->pdev, 0, GUEST_HEAP_OFFSET(vbox), pci_iomap_range(vbox->ddev.pdev, 0, GUEST_HEAP_OFFSET(vbox),
GUEST_HEAP_SIZE); GUEST_HEAP_SIZE);
if (!vbox->guest_heap) if (!vbox->guest_heap)
return -ENOMEM; return -ENOMEM;
...@@ -288,7 +288,7 @@ int vbox_hw_init(struct vbox_private *vbox) ...@@ -288,7 +288,7 @@ int vbox_hw_init(struct vbox_private *vbox)
goto err_destroy_guest_pool; goto err_destroy_guest_pool;
} }
vbox->last_mode_hints = devm_kcalloc(vbox->dev->dev, vbox->num_crtcs, vbox->last_mode_hints = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs,
sizeof(struct vbva_modehint), sizeof(struct vbva_modehint),
GFP_KERNEL); GFP_KERNEL);
if (!vbox->last_mode_hints) { if (!vbox->last_mode_hints) {
...@@ -305,7 +305,7 @@ int vbox_hw_init(struct vbox_private *vbox) ...@@ -305,7 +305,7 @@ int vbox_hw_init(struct vbox_private *vbox)
err_destroy_guest_pool: err_destroy_guest_pool:
gen_pool_destroy(vbox->guest_pool); gen_pool_destroy(vbox->guest_pool);
err_unmap_guest_heap: err_unmap_guest_heap:
pci_iounmap(vbox->dev->pdev, vbox->guest_heap); pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
return ret; return ret;
} }
...@@ -313,7 +313,7 @@ void vbox_hw_fini(struct vbox_private *vbox) ...@@ -313,7 +313,7 @@ void vbox_hw_fini(struct vbox_private *vbox)
{ {
vbox_accel_fini(vbox); vbox_accel_fini(vbox);
gen_pool_destroy(vbox->guest_pool); gen_pool_destroy(vbox->guest_pool);
pci_iounmap(vbox->dev->pdev, vbox->guest_heap); pci_iounmap(vbox->ddev.pdev, vbox->guest_heap);
} }
/** /**
...@@ -328,7 +328,7 @@ void vbox_driver_lastclose(struct drm_device *dev) ...@@ -328,7 +328,7 @@ void vbox_driver_lastclose(struct drm_device *dev)
drm_fb_helper_restore_fbdev_mode_unlocked(&vbox->fbdev->helper); drm_fb_helper_restore_fbdev_mode_unlocked(&vbox->fbdev->helper);
} }
int vbox_gem_create(struct drm_device *dev, int vbox_gem_create(struct vbox_private *vbox,
u32 size, bool iskernel, struct drm_gem_object **obj) u32 size, bool iskernel, struct drm_gem_object **obj)
{ {
struct vbox_bo *vboxbo; struct vbox_bo *vboxbo;
...@@ -340,7 +340,7 @@ int vbox_gem_create(struct drm_device *dev, ...@@ -340,7 +340,7 @@ int vbox_gem_create(struct drm_device *dev,
if (size == 0) if (size == 0)
return -EINVAL; return -EINVAL;
ret = vbox_bo_create(dev, size, 0, 0, &vboxbo); ret = vbox_bo_create(vbox, size, 0, 0, &vboxbo);
if (ret) { if (ret) {
if (ret != -ERESTARTSYS) if (ret != -ERESTARTSYS)
DRM_ERROR("failed to allocate GEM object\n"); DRM_ERROR("failed to allocate GEM object\n");
...@@ -355,14 +355,16 @@ int vbox_gem_create(struct drm_device *dev, ...@@ -355,14 +355,16 @@ int vbox_gem_create(struct drm_device *dev,
int vbox_dumb_create(struct drm_file *file, int vbox_dumb_create(struct drm_file *file,
struct drm_device *dev, struct drm_mode_create_dumb *args) struct drm_device *dev, struct drm_mode_create_dumb *args)
{ {
int ret; struct vbox_private *vbox =
container_of(dev, struct vbox_private, ddev);
struct drm_gem_object *gobj; struct drm_gem_object *gobj;
u32 handle; u32 handle;
int ret;
args->pitch = args->width * ((args->bpp + 7) / 8); args->pitch = args->width * ((args->bpp + 7) / 8);
args->size = args->pitch * args->height; args->size = args->pitch * args->height;
ret = vbox_gem_create(dev, args->size, false, &gobj); ret = vbox_gem_create(vbox, args->size, false, &gobj);
if (ret) if (ret)
return ret; return ret;
......
...@@ -179,7 +179,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) ...@@ -179,7 +179,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox)
* If so then screen layout can be deduced from the crtc offsets. * If so then screen layout can be deduced from the crtc offsets.
* Same fall-back if this is the fbdev frame-buffer. * Same fall-back if this is the fbdev frame-buffer.
*/ */
list_for_each_entry(crtci, &vbox->dev->mode_config.crtc_list, head) { list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, head) {
if (!fb1) { if (!fb1) {
fb1 = CRTC_FB(crtci); fb1 = CRTC_FB(crtci);
if (to_vbox_framebuffer(fb1) == &vbox->fbdev->afb) if (to_vbox_framebuffer(fb1) == &vbox->fbdev->afb)
...@@ -189,7 +189,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) ...@@ -189,7 +189,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox)
} }
} }
if (single_framebuffer) { if (single_framebuffer) {
list_for_each_entry(crtci, &vbox->dev->mode_config.crtc_list, list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
head) { head) {
if (to_vbox_crtc(crtci)->crtc_id != 0) if (to_vbox_crtc(crtci)->crtc_id != 0)
continue; continue;
...@@ -202,7 +202,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) ...@@ -202,7 +202,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox)
} }
} }
/* Otherwise calculate the total span of all screens. */ /* Otherwise calculate the total span of all screens. */
list_for_each_entry(connectori, &vbox->dev->mode_config.connector_list, list_for_each_entry(connectori, &vbox->ddev.mode_config.connector_list,
head) { head) {
struct vbox_connector *vbox_connector = struct vbox_connector *vbox_connector =
to_vbox_connector(connectori); to_vbox_connector(connectori);
...@@ -285,7 +285,7 @@ static int vbox_crtc_set_base_and_mode(struct drm_crtc *crtc, ...@@ -285,7 +285,7 @@ static int vbox_crtc_set_base_and_mode(struct drm_crtc *crtc,
if (mode && vbox_set_up_input_mapping(vbox)) { if (mode && vbox_set_up_input_mapping(vbox)) {
struct drm_crtc *crtci; struct drm_crtc *crtci;
list_for_each_entry(crtci, &vbox->dev->mode_config.crtc_list, list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
head) { head) {
if (crtci == crtc) if (crtci == crtc)
continue; continue;
...@@ -324,8 +324,6 @@ static int vbox_crtc_page_flip(struct drm_crtc *crtc, ...@@ -324,8 +324,6 @@ static int vbox_crtc_page_flip(struct drm_crtc *crtc,
uint32_t page_flip_flags, uint32_t page_flip_flags,
struct drm_modeset_acquire_ctx *ctx) struct drm_modeset_acquire_ctx *ctx)
{ {
struct vbox_private *vbox = crtc->dev->dev_private;
struct drm_device *drm = vbox->dev;
unsigned long flags; unsigned long flags;
int rc; int rc;
...@@ -333,12 +331,12 @@ static int vbox_crtc_page_flip(struct drm_crtc *crtc, ...@@ -333,12 +331,12 @@ static int vbox_crtc_page_flip(struct drm_crtc *crtc,
if (rc) if (rc)
return rc; return rc;
spin_lock_irqsave(&drm->event_lock, flags); spin_lock_irqsave(&crtc->dev->event_lock, flags);
if (event) if (event)
drm_crtc_send_vblank_event(crtc, event); drm_crtc_send_vblank_event(crtc, event);
spin_unlock_irqrestore(&drm->event_lock, flags); spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
return 0; return 0;
} }
...@@ -593,19 +591,19 @@ static int vbox_get_modes(struct drm_connector *connector) ...@@ -593,19 +591,19 @@ static int vbox_get_modes(struct drm_connector *connector)
if (vbox_connector->vbox_crtc->x_hint != -1) if (vbox_connector->vbox_crtc->x_hint != -1)
drm_object_property_set_value(&connector->base, drm_object_property_set_value(&connector->base,
vbox->dev->mode_config.suggested_x_property, vbox->ddev.mode_config.suggested_x_property,
vbox_connector->vbox_crtc->x_hint); vbox_connector->vbox_crtc->x_hint);
else else
drm_object_property_set_value(&connector->base, drm_object_property_set_value(&connector->base,
vbox->dev->mode_config.suggested_x_property, 0); vbox->ddev.mode_config.suggested_x_property, 0);
if (vbox_connector->vbox_crtc->y_hint != -1) if (vbox_connector->vbox_crtc->y_hint != -1)
drm_object_property_set_value(&connector->base, drm_object_property_set_value(&connector->base,
vbox->dev->mode_config.suggested_y_property, vbox->ddev.mode_config.suggested_y_property,
vbox_connector->vbox_crtc->y_hint); vbox_connector->vbox_crtc->y_hint);
else else
drm_object_property_set_value(&connector->base, drm_object_property_set_value(&connector->base,
vbox->dev->mode_config.suggested_y_property, 0); vbox->ddev.mode_config.suggested_y_property, 0);
return num_modes; return num_modes;
} }
...@@ -701,6 +699,8 @@ static struct drm_framebuffer *vbox_user_framebuffer_create( ...@@ -701,6 +699,8 @@ static struct drm_framebuffer *vbox_user_framebuffer_create(
struct drm_file *filp, struct drm_file *filp,
const struct drm_mode_fb_cmd2 *mode_cmd) const struct drm_mode_fb_cmd2 *mode_cmd)
{ {
struct vbox_private *vbox =
container_of(dev, struct vbox_private, ddev);
struct drm_gem_object *obj; struct drm_gem_object *obj;
struct vbox_framebuffer *vbox_fb; struct vbox_framebuffer *vbox_fb;
int ret = -ENOMEM; int ret = -ENOMEM;
...@@ -713,7 +713,7 @@ static struct drm_framebuffer *vbox_user_framebuffer_create( ...@@ -713,7 +713,7 @@ static struct drm_framebuffer *vbox_user_framebuffer_create(
if (!vbox_fb) if (!vbox_fb)
goto err_unref_obj; goto err_unref_obj;
ret = vbox_framebuffer_init(dev, vbox_fb, mode_cmd, obj); ret = vbox_framebuffer_init(vbox, vbox_fb, mode_cmd, obj);
if (ret) if (ret)
goto err_free_vbox_fb; goto err_free_vbox_fb;
...@@ -730,9 +730,9 @@ static const struct drm_mode_config_funcs vbox_mode_funcs = { ...@@ -730,9 +730,9 @@ static const struct drm_mode_config_funcs vbox_mode_funcs = {
.fb_create = vbox_user_framebuffer_create, .fb_create = vbox_user_framebuffer_create,
}; };
int vbox_mode_init(struct drm_device *dev) int vbox_mode_init(struct vbox_private *vbox)
{ {
struct vbox_private *vbox = dev->dev_private; struct drm_device *dev = &vbox->ddev;
struct drm_encoder *encoder; struct drm_encoder *encoder;
struct vbox_crtc *vbox_crtc; struct vbox_crtc *vbox_crtc;
unsigned int i; unsigned int i;
...@@ -771,9 +771,9 @@ int vbox_mode_init(struct drm_device *dev) ...@@ -771,9 +771,9 @@ int vbox_mode_init(struct drm_device *dev)
return ret; return ret;
} }
void vbox_mode_fini(struct drm_device *dev) void vbox_mode_fini(struct vbox_private *vbox)
{ {
drm_mode_config_cleanup(dev); drm_mode_config_cleanup(&vbox->ddev);
/* vbox_cursor_fini(dev); */ /* vbox_cursor_fini(dev); */
} }
...@@ -824,7 +824,7 @@ static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv, ...@@ -824,7 +824,7 @@ static int vbox_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
/* Hide cursor. */ /* Hide cursor. */
vbox_crtc->cursor_enabled = false; vbox_crtc->cursor_enabled = false;
list_for_each_entry(crtci, &vbox->dev->mode_config.crtc_list, list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list,
head) { head) {
if (to_vbox_crtc(crtci)->cursor_enabled) if (to_vbox_crtc(crtci)->cursor_enabled)
cursor_enabled = true; cursor_enabled = true;
......
...@@ -169,7 +169,7 @@ static int vbox_ttm_io_mem_reserve(struct ttm_bo_device *bdev, ...@@ -169,7 +169,7 @@ static int vbox_ttm_io_mem_reserve(struct ttm_bo_device *bdev,
return 0; return 0;
case TTM_PL_VRAM: case TTM_PL_VRAM:
mem->bus.offset = mem->start << PAGE_SHIFT; mem->bus.offset = mem->start << PAGE_SHIFT;
mem->bus.base = pci_resource_start(vbox->dev->pdev, 0); mem->bus.base = pci_resource_start(vbox->ddev.pdev, 0);
mem->bus.is_iomem = true; mem->bus.is_iomem = true;
break; break;
default: default:
...@@ -224,7 +224,7 @@ static struct ttm_bo_driver vbox_bo_driver = { ...@@ -224,7 +224,7 @@ static struct ttm_bo_driver vbox_bo_driver = {
int vbox_mm_init(struct vbox_private *vbox) int vbox_mm_init(struct vbox_private *vbox)
{ {
int ret; int ret;
struct drm_device *dev = vbox->dev; struct drm_device *dev = &vbox->ddev;
struct ttm_bo_device *bdev = &vbox->ttm.bdev; struct ttm_bo_device *bdev = &vbox->ttm.bdev;
ret = vbox_ttm_global_init(vbox); ret = vbox_ttm_global_init(vbox);
...@@ -269,8 +269,8 @@ void vbox_mm_fini(struct vbox_private *vbox) ...@@ -269,8 +269,8 @@ void vbox_mm_fini(struct vbox_private *vbox)
{ {
#ifdef DRM_MTRR_WC #ifdef DRM_MTRR_WC
drm_mtrr_del(vbox->fb_mtrr, drm_mtrr_del(vbox->fb_mtrr,
pci_resource_start(vbox->dev->pdev, 0), pci_resource_start(vbox->ddev.pdev, 0),
pci_resource_len(vbox->dev->pdev, 0), DRM_MTRR_WC); pci_resource_len(vbox->ddev.pdev, 0), DRM_MTRR_WC);
#else #else
arch_phys_wc_del(vbox->fb_mtrr); arch_phys_wc_del(vbox->fb_mtrr);
#endif #endif
...@@ -305,10 +305,9 @@ void vbox_ttm_placement(struct vbox_bo *bo, int domain) ...@@ -305,10 +305,9 @@ void vbox_ttm_placement(struct vbox_bo *bo, int domain)
} }
} }
int vbox_bo_create(struct drm_device *dev, int size, int align, int vbox_bo_create(struct vbox_private *vbox, int size, int align,
u32 flags, struct vbox_bo **pvboxbo) u32 flags, struct vbox_bo **pvboxbo)
{ {
struct vbox_private *vbox = dev->dev_private;
struct vbox_bo *vboxbo; struct vbox_bo *vboxbo;
size_t acc_size; size_t acc_size;
int ret; int ret;
...@@ -317,7 +316,7 @@ int vbox_bo_create(struct drm_device *dev, int size, int align, ...@@ -317,7 +316,7 @@ int vbox_bo_create(struct drm_device *dev, int size, int align,
if (!vboxbo) if (!vboxbo)
return -ENOMEM; return -ENOMEM;
ret = drm_gem_object_init(dev, &vboxbo->gem, size); ret = drm_gem_object_init(&vbox->ddev, &vboxbo->gem, size);
if (ret) if (ret)
goto err_free_vboxbo; goto err_free_vboxbo;
......
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