Subclassing struct drm_device
Subsystems (6)
I was reminded on Monday that we'd like to be able to subclass struct drm_device so we don't have to always juggle between a pointer to a struct drm_device and its drv_private field to access everything we care about.
It'd be nicer for those two pointers to have the same value to avoid a few extra instructions pretty everywhere.
Turns out, there's a cheap way to go towards that goal, just make DRM core allocate enough space for drivers that want to subclass struct drm_device and have a transition path where dev_private points to the start of the structure.
I've converted i915 to do just that, seems to still boot. Of course, a number of nice refactoring are possible once dev == dev_priv, but that'd be for follow up patches on top.
Thoughts?
Signature · 1 line
Damien
PATCH 1/5 drm: Remove unnecessary dev_priv_size initializations to 0
Not specifying it makes it a bit easier to identify drivers that really need this field, and down the line, ease refactoring. This field doesn't make sense for KMS drivers anyway.
--- drivers/gpu/drm/ast/ast_drv.c | 1 - drivers/gpu/drm/qxl/qxl_drv.c | 1 - drivers/gpu/drm/radeon/radeon_drv.c | 1 - 3 files changed, 3 deletions(-)
drivers/gpu/drm/ast/ast_drv.c +0 -1
@@ -198,7 +198,6 @@ static const struct file_operations ast_fops = {static struct drm_driver driver = { .driver_features =DRIVER_MODESET |DRIVER_GEM , - .dev_priv_size =0 , .load = ast_driver_load, .unload = ast_driver_unload,
drivers/gpu/drm/qxl/qxl_drv.c +0 -1
@@ -214,7 +214,6 @@ static struct pci_driver qxl_pci_driver = {static struct drm_driver qxl_driver = { .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_HAVE_IRQ |DRIVER_IRQ_SHARED , - .dev_priv_size =0 , .load = qxl_driver_load, .unload = qxl_driver_unload,
drivers/gpu/drm/radeon/radeon_drv.c +0 -1
@@ -514,7 +514,6 @@ static struct drm_driver kms_driver = {DRIVER_USE_AGP |DRIVER_HAVE_IRQ |DRIVER_IRQ_SHARED |DRIVER_GEM | DRIVER_PRIME | DRIVER_RENDER, - .dev_priv_size = 0, .load = radeon_driver_load_kms, .open = radeon_driver_open_kms, .preclose = radeon_driver_preclose_kms,
Signature · 1 line
1.8.3.1
PATCH 2/5 drm: Remove dev_priv_size from struct drm_buf
In reply to Damien LespiauThis field is only used when creating a new buffer and can already be found in the drm_driver structure, so no need to duplicate the information for every buffer.
--- drivers/gpu/drm/drm_bufs.c | 13 ++++++------- include/drm/drmP.h | 1 - 2 files changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_bufs.c +6 -7
@@ -705,8 +705,8 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request) buf->pending =0 ; buf->file_priv =NULL ; - buf->dev_priv_size = dev->driver->dev_priv_size; - buf->dev_private =kzalloc (buf->dev_priv_size,GFP_KERNEL ); + buf->dev_private =kzalloc (dev->driver->dev_priv_size, +GFP_KERNEL );if (!buf->dev_private) {/* Set count correctly so we free the proper amount. */ entry->buf_count = count;
@@ -902,9 +902,8 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request) buf->pending =0 ; buf->file_priv =NULL ; - buf->dev_priv_size = dev->driver->dev_priv_size; - buf->dev_private =kzalloc (buf->dev_priv_size, -GFP_KERNEL ); + buf->dev_private =kzalloc (dev->driver->dev_priv_size, +GFP_KERNEL );if (!buf->dev_private) {/* Set count correctly so we free the proper amount. */ entry->buf_count = count;
@@ -1066,8 +1065,8 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request buf->pending =0 ; buf->file_priv =NULL ; - buf->dev_priv_size = dev->driver->dev_priv_size; - buf->dev_private =kzalloc (buf->dev_priv_size,GFP_KERNEL ); + buf->dev_private =kzalloc (dev->driver->dev_priv_size, +GFP_KERNEL );if (!buf->dev_private) {/* Set count correctly so we free the proper amount. */ entry->buf_count = count;
include/drm/drmP.h +0 -1
@@ -364,7 +364,6 @@ struct drm_buf { DRM_LIST_RECLAIM = 5 } list;/**< Which list we're on */ -int dev_priv_size;/**< Size of buffer private storage */ void *dev_private;/**< Per-buffer private storage */ };
Signature · 1 line
1.8.3.1
PATCH 3/5 drm: Rename dev_priv_size to buf_priv_size
In reply to Damien LespiauThis field is really the size of the per-driver private data attached to a struct drm_buf. Name it accordingly and add a comment so it doesn't get confused with, say, the size of the private data attatched to a struct drm_device.
--- drivers/gpu/drm/drm_bufs.c | 6 +++--- drivers/gpu/drm/i810/i810_drv.c | 2 +- drivers/gpu/drm/mga/mga_drv.c | 2 +- drivers/gpu/drm/r128/r128_drv.c | 2 +- drivers/gpu/drm/radeon/radeon_drv.c | 2 +- drivers/gpu/drm/savage/savage_drv.c | 2 +- include/drm/drmP.h | 3 ++- 7 files changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/drm_bufs.c +3 -3
@@ -705,7 +705,7 @@ int drm_addbufs_agp(struct drm_device * dev, struct drm_buf_desc * request) buf->pending =0 ; buf->file_priv =NULL ; - buf->dev_private =kzalloc (dev->driver->dev_priv_size, + buf->dev_private =kzalloc (dev->driver->buf_priv_size,GFP_KERNEL );if (!buf->dev_private) {/* Set count correctly so we free the proper amount. */
@@ -902,7 +902,7 @@ int drm_addbufs_pci(struct drm_device * dev, struct drm_buf_desc * request) buf->pending =0 ; buf->file_priv =NULL ; - buf->dev_private =kzalloc (dev->driver->dev_priv_size, + buf->dev_private =kzalloc (dev->driver->buf_priv_size,GFP_KERNEL );if (!buf->dev_private) {/* Set count correctly so we free the proper amount. */
@@ -1065,7 +1065,7 @@ static int drm_addbufs_sg(struct drm_device * dev, struct drm_buf_desc * request buf->pending =0 ; buf->file_priv =NULL ; - buf->dev_private =kzalloc (dev->driver->dev_priv_size, + buf->dev_private =kzalloc (dev->driver->buf_priv_size,GFP_KERNEL );if (!buf->dev_private) {/* Set count correctly so we free the proper amount. */
drivers/gpu/drm/i810/i810_drv.c +1 -1
@@ -59,7 +59,7 @@ static struct drm_driver driver = { .driver_features =DRIVER_USE_AGP | DRIVER_HAVE_DMA, - .dev_priv_size = sizeof(drm_i810_buf_priv_t), + .buf_priv_size = sizeof(drm_i810_buf_priv_t), .load = i810_driver_load, .lastclose = i810_driver_lastclose, .preclose = i810_driver_preclose,
drivers/gpu/drm/mga/mga_drv.c +1 -1
@@ -60,7 +60,7 @@ static struct drm_driver driver = { .driver_features =DRIVER_USE_AGP |DRIVER_PCI_DMA | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, - .dev_priv_size = sizeof(drm_mga_buf_priv_t), + .buf_priv_size = sizeof(drm_mga_buf_priv_t), .load = mga_driver_load, .unload = mga_driver_unload, .lastclose = mga_driver_lastclose,
drivers/gpu/drm/r128/r128_drv.c +1 -1
@@ -58,7 +58,7 @@ static struct drm_driver driver = { .driver_features =DRIVER_USE_AGP |DRIVER_PCI_DMA |DRIVER_SG | DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, - .dev_priv_size = sizeof(drm_r128_buf_priv_t), + .buf_priv_size = sizeof(drm_r128_buf_priv_t), .load = r128_driver_load, .preclose = r128_driver_preclose, .lastclose = r128_driver_lastclose,
drivers/gpu/drm/radeon/radeon_drv.c +1 -1
@@ -287,7 +287,7 @@ static struct drm_driver driver_old = { .driver_features =DRIVER_USE_AGP |DRIVER_PCI_DMA |DRIVER_SG | DRIVER_HAVE_IRQ | DRIVER_HAVE_DMA | DRIVER_IRQ_SHARED, - .dev_priv_size = sizeof(drm_radeon_buf_priv_t), + .buf_priv_size = sizeof(drm_radeon_buf_priv_t), .load = radeon_driver_load, .firstopen = radeon_driver_firstopen, .open = radeon_driver_open,
drivers/gpu/drm/savage/savage_drv.c +1 -1
@@ -51,7 +51,7 @@ static const struct file_operations savage_driver_fops = {static struct drm_driver driver = { .driver_features =DRIVER_USE_AGP |DRIVER_HAVE_DMA |DRIVER_PCI_DMA , - .dev_priv_size =sizeof (drm_savage_buf_priv_t), + .buf_priv_size =sizeof (drm_savage_buf_priv_t), .load = savage_driver_load, .firstopen = savage_driver_firstopen, .preclose = savage_reclaim_buffers,
include/drm/drmP.h +2 -1
@@ -994,7 +994,8 @@ struct drm_driver {char *date;u32 driver_features; -int dev_priv_size; +/* size of the private data attached to a struct drm_buf */ +int buf_priv_size;const struct drm_ioctl_desc *ioctls;int num_ioctls;const struct file_operations *fops;
Signature · 1 line
1.8.3.1
PATCH 4/5 drm: Add support for subclassing struct drm_device
In reply to Damien LespiauCurrently, drivers are expected to allocate private data and attach it to dev_private in struct drm_device.
This has the unfortunate property to require driver code to juggle between the pointer to struct drm_device and dev->dev_private instead of using the same pointer if they could embed the device structure.
This patch enables drivers to declare the size of the device structure they want DRM core to create for them.
--- drivers/gpu/drm/drm_stub.c | 8 +++++++- include/drm/drmP.h | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_stub.c +7 -1
@@ -433,8 +433,14 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, {struct drm_device *dev;int ret; +size_t device_struct_size; - dev =kzalloc (sizeof (*dev),GFP_KERNEL ); +if (driver->device_struct_size) + device_struct_size = driver->device_struct_size; +else + device_struct_size =sizeof (*dev); + + dev =kzalloc (device_struct_size,GFP_KERNEL );if (!dev)return NULL ;
include/drm/drmP.h +8 -0
@@ -996,6 +996,14 @@ struct drm_driver {u32 driver_features;/* size of the private data attached to a struct drm_buf */ int buf_priv_size; +/* +* DRM drivers can subclass struct drm_device to have their own device +* structure to store private data. In this case, they need to declare +* the size of the child structure (ie the structure embedding a struct +* drm_device as first field) for the DRM core to allocate a big +* enough device structure. +*/ +size_t device_struct_size;const struct drm_ioctl_desc *ioctls;int num_ioctls;const struct file_operations *fops;
Signature · 1 line
1.8.3.1
Re: [PATCH 4/5] drm: Add support for subclassing struct drm_device
Hi
Quoted 21 lines · Damien Lespiau
Currently, drivers are expected to allocate private data and attach it to
dev_privatein structdrm_device.This has the unfortunate property to require driver code to juggle between the pointer to struct
drm_deviceanddev->dev_privateinstead of using the same pointer if they could embed the device structure.This patch enables drivers to declare the size of the device structure they want DRM core to create for them.
Signed-off-by Damien Lespiau <[email protected]>--- drivers/gpu/drm/drm_stub.c | 8 +++++++- include/drm/drmP.h | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_stub.c +0
-0
drivers/gpu/drm/drm_stub.c struct drm_device *drm_dev_alloc(struct drm_driver *driver, · line 441
Quoted 10 lines
drivers/gpu/drm/drm_stub.c +5
-1@@ -433,8 +433,14 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, {struct drm_device *dev;int ret; +size_t device_struct_size; - dev =kzalloc (sizeof (*dev),GFP_KERNEL ); +if (driver->device_struct_size) + device_struct_size = driver->device_struct_size; +else + device_struct_size =sizeof (*dev);
How about a:WARN_ON(driver->device_struct_size < sizeof(*dev))
drivers/gpu/drm/drm_stub.c struct drm_device *drm_dev_alloc(struct drm_driver *driver, · line 443
Quoted 2 lines
drivers/gpu/drm/drm_stub.c +2
-0+ + dev =kzalloc (device_struct_size,GFP_KERNEL );
So the parent structure is expected to have "struct drm_device" at offset 0? I'd rather like to see a "drm_dev_init()" alongside drm_dev_alloc() similar to device_initialize().
Thanks
David
Quoted 29 lines
drivers/gpu/drm/drm_stub.c +0
-0if (!dev)return NULL ;include/drm/drmP.h +8
-1@@ -996,6 +996,14 @@ struct drm_driver {u32 driver_features;/* size of the private data attached to a struct drm_buf */ int buf_priv_size; +/* +* DRM drivers can subclass struct drm_device to have their own device +* structure to store private data. In this case, they need to declare +* the size of the child structure (ie the structure embedding a struct +* drm_device as first field) for the DRM core to allocate a big +* enough device structure. +*/ +size_t device_struct_size;const struct drm_ioctl_desc *ioctls;int num_ioctls;const struct file_operations *fops; --1.8.3.1
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/5] drm: Add support for subclassing struct drm_device
Quoted 38 lines · David Herrmann
Hi
Quoted 21 lines · Damien Lespiau
Currently, drivers are expected to allocate private data and attach it to
dev_privatein structdrm_device.This has the unfortunate property to require driver code to juggle between the pointer to struct
drm_deviceanddev->dev_privateinstead of using the same pointer if they could embed the device structure.This patch enables drivers to declare the size of the device structure they want DRM core to create for them.
Signed-off-by Damien Lespiau <[email protected]>--- drivers/gpu/drm/drm_stub.c | 8 +++++++- include/drm/drmP.h | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_stub.c +0
-0drivers/gpu/drm/drm_stub.c struct drm_device *drm_dev_alloc(struct drm_driver *driver, · line 441
Quoted 10 lines
drivers/gpu/drm/drm_stub.c +5
-1@@ -433,8 +433,14 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, {struct drm_device *dev;int ret; +size_t device_struct_size; - dev =kzalloc (sizeof (*dev),GFP_KERNEL ); +if (driver->device_struct_size) + device_struct_size = driver->device_struct_size; +else + device_struct_size =sizeof (*dev);How about a:
WARN_ON(driver->device_struct_size < sizeof(*dev))
Quoted 6 lines
drivers/gpu/drm/drm_stub.c struct drm_device *drm_dev_alloc(struct drm_driver *driver, · line 443
Quoted 2 lines
drivers/gpu/drm/drm_stub.c +2
-0+ + dev =kzalloc (device_struct_size,GFP_KERNEL );So the parent structure is expected to have "struct
drm_device" at offset 0? I'd rather like to see a "drm_dev_init()" alongsidedrm_dev_alloc()similar todevice_initialize().
Yeah, I think for subclassing we want drivers in charge to kmalloc the entire thing and embedded struct drm_device wherever they please to do so. Adding struct_size stuff all over the place still forces us through the midlayer ...
I'm trying to get there with my giant drm cleanup series (which contains some of the same dev_priv_size cleanups like yours). Dunno whether it's worth all to much to start embedding before we have that all ready since imo the big value in demidlayering is that it allows us to fix up the init/teardown sequence. That it also allows struct drm_device embedding is kinda neat, but not my main goal.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 4/5] drm: Add support for subclassing struct drm_device
Quoted 9 lines · Daniel Vetter
Quoted 3 lines
So the parent structure is expected to have "struct
drm_device" at offset 0? I'd rather like to see a "drm_dev_init()" alongsidedrm_dev_alloc()similar todevice_initialize().Yeah, I think for subclassing we want drivers in charge to kmalloc the entire thing and embedded struct
drm_devicewherever they please to do so. Addingstruct_sizestuff all over the place still forces us through the midlayer ...
Quoted 7 lines
I'm trying to get there with my giant drm cleanup series (which contains some of the same
dev_priv_sizecleanups like yours). Dunno whether it's worth all to much to start embedding before we have that all ready since imo the big value in demidlayering is that it allows us to fix up the init/teardown sequence. That it also allows structdrm_deviceembedding is kinda neat, but not my main goal.
-Daniel
I'm not sure why would people want struct drm_device at a non-0 offset, but in any case, if Daniel is already looking into this, let's scrap that series. At least we know that it doesn't have to be a long term plan and we can do it as soon as we want.
Signature · 1 line
Damien
Re: [PATCH 4/5] drm: Add support for subclassing struct drm_device
Hi
Quoted 18 lines · Damien Lespiau
Quoted 9 lines · Daniel Vetter
Quoted 3 lines
So the parent structure is expected to have "struct
drm_device" at offset 0? I'd rather like to see a "drm_dev_init()" alongsidedrm_dev_alloc()similar todevice_initialize().Yeah, I think for subclassing we want drivers in charge to kmalloc the entire thing and embedded struct
drm_devicewherever they please to do so. Addingstruct_sizestuff all over the place still forces us through the midlayer ...Quoted 7 lines
I'm trying to get there with my giant drm cleanup series (which contains some of the same
dev_priv_sizecleanups like yours). Dunno whether it's worth all to much to start embedding before we have that all ready since imo the big value in demidlayering is that it allows us to fix up the init/teardown sequence. That it also allows structdrm_deviceembedding is kinda neat, but not my main goal.
-Daniel
Quoted 4 lines
I'm not sure why would people want struct
drm_deviceat a non-0 offset, but in any case, if Daniel is already looking into this, let's scrap that series. At least we know that it doesn't have to be a long term plan and we can do it as soon as we want.
In case you embed multiple objects in your parent device and both have this requirement, you're screwed. Obviously, this only works if at most one of them has a ref-count, but see for instance the gem+ttm combinations, which embed both, gem_object and ttm_bo in their private bo.
Besides, it's more about clean code here than functionality. The code doesn't get more complicated if we remove the restriction so lets use the cleaner way similar to "struct device".
Thanks
David
PATCH 5/5 drm/i915: Make struct drm_i915_private a subclass of struct drm_device
In reply to Damien LespiauThis patch is the result of running:
sed -i -e 's/\([^&]\)dev_priv->dev\([^-]\)/\1\&dev_priv->dev\2/g' drivers/gpu/drm/i915/*.[ch] sed -i -e 's/dev_priv->dev->/dev_priv->dev./g' drivers/gpu/drm/i915/*.[ch]
and a minor correction in gem_context.c that the 2 regex above didn't catch.
In addition:
- struct drm_i915_private now embed a struct drm_device instead of just a pointer to it,
- The loading code had to be changed (i915_driver_load()) to not allocate the private structure,
- we need to specificy the size of struct drm_i915_private in our struct drm_driver definition for the DRM core to allocate enough space,
- to ease the transition, dev->dev_private is still valid and points to the start of the structure.
- don't kfree dev_private either in the _load() error path or the _unload() vfunc.
--- drivers/gpu/drm/i915/i915_debugfs.c | 2 +- drivers/gpu/drm/i915/i915_dma.c | 15 ++---- drivers/gpu/drm/i915/i915_drv.c | 3 +- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/i915_gem.c | 14 +++--- drivers/gpu/drm/i915/i915_gem_context.c | 6 +-- drivers/gpu/drm/i915/i915_gem_gtt.c | 6 +-- drivers/gpu/drm/i915/i915_gpu_error.c | 2 +- drivers/gpu/drm/i915/i915_irq.c | 30 +++++------ drivers/gpu/drm/i915/i915_sysfs.c | 8 +-- drivers/gpu/drm/i915/intel_bios.c | 6 +-- drivers/gpu/drm/i915/intel_ddi.c | 2 +- drivers/gpu/drm/i915/intel_display.c | 88 ++++++++++++++++----------------- drivers/gpu/drm/i915/intel_dp.c | 2 +- drivers/gpu/drm/i915/intel_hdmi.c | 2 +- drivers/gpu/drm/i915/intel_i2c.c | 14 +++--- drivers/gpu/drm/i915/intel_lvds.c | 2 +- drivers/gpu/drm/i915/intel_opregion.c | 2 +- drivers/gpu/drm/i915/intel_pm.c | 44 ++++++++--------- drivers/gpu/drm/i915/intel_uncore.c | 14 +++--- 20 files changed, 129 insertions(+), 135 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
@@ -3091,7 +3091,7 @@ i915_cache_sharing_get(void *data, u64 *val) snpcr =I915_READ (GEN6_MBCUNIT_SNPCR );intel_runtime_pm_put (dev_priv); -mutex_unlock (&dev_priv->dev->struct_mutex); +mutex_unlock (&dev_priv->dev.struct_mutex); *val = (snpcr &GEN6_MBC_SNPCR_MASK ) >>GEN6_MBC_SNPCR_SHIFT ;
drivers/gpu/drm/i915/i915_dma.c +4 -11
@@ -70,7 +70,7 @@static inline u32 intel_read_legacy_status_page (struct drm_i915_private *dev_priv,int reg) { -if (I915_NEED_GFX_HWS (dev_priv->dev)) +if (I915_NEED_GFX_HWS (&dev_priv->dev))return ioread32 (dev_priv->dri1.gfx_hws_cpu_addr + reg);else return intel_read_status_page (LP_RING (dev_priv), reg);
@@ -1417,7 +1417,7 @@ void i915_master_destroy(struct drm_device *dev, struct drm_master *master)static void i915_kick_out_firmware_fb (struct drm_i915_private *dev_priv) {struct apertures_struct *ap; -struct pci_dev *pdev = dev_priv->dev->pdev; +struct pci_dev *pdev = dev_priv->dev.pdev;bool primary; ap =alloc_apertures (1 );
@@ -1451,7 +1451,7 @@ static void i915_dump_device_info(struct drm_i915_private *dev_priv)DRM_DEBUG_DRIVER ("i915 device info: gen=%i, pciid=0x%04x flags=" DEV_INFO_FOR_EACH_FLAG (PRINT_S ,SEP_EMPTY ), info->gen, - dev_priv->dev->pdev->device, + dev_priv->dev.pdev->device,DEV_INFO_FOR_EACH_FLAG (PRINT_FLAG ,SEP_COMMA ));#undef PRINT_S#undef SEP_EMPTY
@@ -1490,12 +1490,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)if (!drm_core_check_feature (dev,DRIVER_MODESET ) && !dev->agp)return -EINVAL ; - dev_priv =kzalloc (sizeof (*dev_priv),GFP_KERNEL ); -if (dev_priv ==NULL ) -return -ENOMEM ; - - dev->dev_private = (void *)dev_priv; - dev_priv->dev = dev; + dev->dev_private = dev_priv = (void *)dev; dev_priv->info = info;spin_lock_init (&dev_priv->irq_lock);
@@ -1701,7 +1696,6 @@ put_bridge: free_priv:if (dev_priv->slab)kmem_cache_destroy (dev_priv->slab); -kfree (dev_priv);return ret; }
@@ -1804,7 +1798,6 @@ int i915_driver_unload(struct drm_device *dev)kmem_cache_destroy (dev_priv->slab);pci_dev_put (dev_priv->bridge_dev); -kfree (dev->dev_private);return 0 ; }
drivers/gpu/drm/i915/i915_drv.c +2 -1
@@ -597,7 +597,7 @@ void intel_console_resume(struct work_struct *work)struct drm_i915_private *dev_priv = container_of(work, struct drm_i915_private, console_resume_work); -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;console_lock ();intel_fbdev_set_suspend (dev,FBINFO_STATE_RUNNING );
@@ -985,6 +985,7 @@ static struct drm_driver driver = {DRIVER_USE_AGP |DRIVER_HAVE_IRQ |DRIVER_IRQ_SHARED |DRIVER_GEM |DRIVER_PRIME | DRIVER_RENDER, + .device_struct_size = sizeof(struct drm_i915_private), .load = i915_driver_load, .unload = i915_driver_unload, .open = i915_driver_open,
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -1357,7 +1357,7 @@ struct intel_pipe_crc { }; typedef struct drm_i915_private { - struct drm_device *dev; + struct drm_device dev; struct kmem_cache *slab; const struct intel_device_info *info;
drivers/gpu/drm/i915/i915_gem.c +7 -7
@@ -1839,7 +1839,7 @@ i915_gem_shrink_all(struct drm_i915_private *dev_priv)struct drm_i915_gem_object *obj, *next;long freed =0 ; -i915_gem_evict_everything (dev_priv->dev); +i915_gem_evict_everything (&dev_priv->dev);list_for_each_entry_safe (obj, next, &dev_priv->mm.unbound_list, global_list) {
@@ -2218,7 +2218,7 @@ int __i915_add_request(struct intel_ring_buffer *ring,queue_delayed_work (dev_priv->wq, &dev_priv->mm.retire_work,round_jiffies_up_relative (HZ )); -intel_mark_busy (dev_priv->dev); +intel_mark_busy (&dev_priv->dev); } }
@@ -2555,7 +2555,7 @@ i915_gem_retire_work_handler(struct work_struct *work) {struct drm_i915_private *dev_priv =container_of (work,typeof (*dev_priv), mm.retire_work.work); -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;bool idle;/* Come back later if the device is busy... */
@@ -2575,7 +2575,7 @@ i915_gem_idle_work_handler(struct work_struct *work)struct drm_i915_private *dev_priv =container_of (work,typeof (*dev_priv), mm.idle_work.work); -intel_mark_idle (dev_priv->dev); +intel_mark_idle (&dev_priv->dev); }/**
@@ -4623,7 +4623,7 @@ void i915_init_vm(struct drm_i915_private *dev_priv, {if (!i915_is_ggtt (vm))drm_mm_init (&vm->mm, vm->start, vm->total); - vm->dev = dev_priv->dev; + vm->dev = &dev_priv->dev;INIT_LIST_HEAD (&vm->active_list);INIT_LIST_HEAD (&vm->inactive_list);INIT_LIST_HEAD (&vm->global_link);
@@ -4955,7 +4955,7 @@ i915_gem_inactive_count(struct shrinker *shrinker, struct shrink_control *sc)container_of (shrinker, struct drm_i915_private, mm.inactive_shrinker); -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;struct drm_i915_gem_object *obj;bool unlock = true;unsigned long count;
@@ -5058,7 +5058,7 @@ i915_gem_inactive_scan(struct shrinker *shrinker, struct shrink_control *sc)container_of (shrinker, struct drm_i915_private, mm.inactive_shrinker); -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;unsigned long freed;bool unlock = true;
drivers/gpu/drm/i915/i915_gem_context.c +3 -3
@@ -444,7 +444,7 @@ int i915_gem_context_enable(struct drm_i915_private *dev_priv)struct intel_ring_buffer *ring;int ret, i; -if (!HAS_HW_CONTEXTS (dev_priv->dev)) +if (!HAS_HW_CONTEXTS (&dev_priv->dev))return 0 ;/* This is the only place the aliasing PPGTT gets enabled, which means
@@ -528,7 +528,7 @@ i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id) {struct i915_hw_context *ctx; -if (!HAS_HW_CONTEXTS (file_priv->dev_priv->dev)) +if (!HAS_HW_CONTEXTS (&file_priv->dev_priv->dev))return file_priv->private_default_ctx; ctx = (struct i915_hw_context *)idr_find (&file_priv->context_idr, id);
@@ -723,7 +723,7 @@ int i915_switch_context(struct intel_ring_buffer *ring, {struct drm_i915_private *dev_priv = ring->dev->dev_private; -WARN_ON (!mutex_is_locked (&dev_priv->dev->struct_mutex)); +WARN_ON (!mutex_is_locked (&dev_priv->dev.struct_mutex));BUG_ON (file && to ==NULL );
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -3
@@ -1033,7 +1033,7 @@ static bool do_idling(struct drm_i915_private *dev_priv)if (unlikely (dev_priv->gtt.do_idle_maps)) { dev_priv->mm.interruptible = false; -if (i915_gpu_idle (dev_priv->dev)) { +if (i915_gpu_idle (&dev_priv->dev)) {DRM_ERROR ("Couldn't idle GPU\n" );/* Wait a bit, in hopes it avoids the hang */ udelay (10 );
@@ -1716,7 +1716,7 @@ static int i915_gmch_probe(struct drm_device *dev,struct drm_i915_private *dev_priv = dev->dev_private;int ret; - ret =intel_gmch_probe (dev_priv->bridge_dev, dev_priv->dev->pdev,NULL ); + ret =intel_gmch_probe (dev_priv->bridge_dev, dev_priv->dev.pdev,NULL );if (!ret) {DRM_ERROR ("failed to set up gmch\n" );return -EIO ;
@@ -1724,7 +1724,7 @@ static int i915_gmch_probe(struct drm_device *dev,intel_gtt_get (gtt_total, stolen, mappable_base, mappable_end); - dev_priv->gtt.do_idle_maps =needs_idle_maps (dev_priv->dev); + dev_priv->gtt.do_idle_maps =needs_idle_maps (&dev_priv->dev); dev_priv->gtt.base.clear_range = i915_ggtt_clear_range;if (unlikely (dev_priv->gtt.do_idle_maps))
drivers/gpu/drm/i915/i915_gpu_error.c +1 -1
@@ -693,7 +693,7 @@ i915_error_first_batchbuffer(struct drm_i915_private *dev_priv,if (!ring->get_seqno)return NULL ; -if (HAS_BROKEN_CS_TLB (dev_priv->dev)) { +if (HAS_BROKEN_CS_TLB (&dev_priv->dev)) {u32 acthd =I915_READ (ACTHD );if (WARN_ON (ring->id !=RCS ))
drivers/gpu/drm/i915/i915_irq.c +15 -15
@@ -842,7 +842,7 @@ static void i915_hotplug_work_func(struct work_struct *work) {drm_i915_private_t *dev_priv =container_of (work, drm_i915_private_t, hotplug_work); -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;struct drm_mode_config *mode_config = &dev->mode_config;struct intel_connector *intel_connector;struct intel_encoder *intel_encoder;
@@ -1019,10 +1019,10 @@ static void gen6_pm_rps_work(struct work_struct *work) dev_priv->rps.min_delay, dev_priv->rps.max_delay); dev_priv->rps.last_adj = new_delay - dev_priv->rps.cur_delay; -if (IS_VALLEYVIEW (dev_priv->dev)) -valleyview_set_rps (dev_priv->dev, new_delay); +if (IS_VALLEYVIEW (&dev_priv->dev)) +valleyview_set_rps (&dev_priv->dev, new_delay);else -gen6_set_rps (dev_priv->dev, new_delay); +gen6_set_rps (&dev_priv->dev, new_delay);mutex_unlock (&dev_priv->rps.hw_lock); }
@@ -1051,7 +1051,7 @@ static void ivybridge_parity_work(struct work_struct *work)* In order to prevent a get/put style interface, acquire struct mutex * any time we access those registers. */ -mutex_lock (&dev_priv->dev->struct_mutex); +mutex_lock (&dev_priv->dev.struct_mutex);/* If we've screwed up tracking, just let the interrupt fire again */ if (WARN_ON (!dev_priv->l3_parity.which_slice))
@@ -1065,7 +1065,7 @@ static void ivybridge_parity_work(struct work_struct *work)u32 reg; slice--; -if (WARN_ON_ONCE (slice >=NUM_L3_SLICES (dev_priv->dev))) +if (WARN_ON_ONCE (slice >=NUM_L3_SLICES (&dev_priv->dev)))break ; dev_priv->l3_parity.which_slice &= ~(1 <<slice);
@@ -1087,7 +1087,7 @@ static void ivybridge_parity_work(struct work_struct *work) parity_event[4 ] =kasprintf (GFP_KERNEL ,"SLICE=%d" , slice); parity_event[5 ] =NULL ; -kobject_uevent_env (&dev_priv->dev->primary->kdev->kobj, +kobject_uevent_env (&dev_priv->dev.primary->kdev->kobj,KOBJ_CHANGE , parity_event); DRM_DEBUG("Parity error: Slice = %d, Row = %d, Bank = %d, Sub bank = %d.\n",
@@ -1104,10 +1104,10 @@ static void ivybridge_parity_work(struct work_struct *work) out:WARN_ON (dev_priv->l3_parity.which_slice);spin_lock_irqsave (&dev_priv->irq_lock, flags); -ilk_enable_gt_irq (dev_priv,GT_PARITY_ERROR (dev_priv->dev)); +ilk_enable_gt_irq (dev_priv,GT_PARITY_ERROR (&dev_priv->dev));spin_unlock_irqrestore (&dev_priv->irq_lock, flags); -mutex_unlock (&dev_priv->dev->struct_mutex); +mutex_unlock (&dev_priv->dev.struct_mutex); }static void ivybridge_parity_error_irq_handler (struct drm_device *dev,u32 iir)
@@ -1397,13 +1397,13 @@ static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir)queue_work (dev_priv->wq, &dev_priv->rps.work); } -if (HAS_VEBOX (dev_priv->dev)) { +if (HAS_VEBOX (&dev_priv->dev)) {if (pm_iir &PM_VEBOX_USER_INTERRUPT ) -notify_ring (dev_priv->dev, &dev_priv->ring[VECS ]); +notify_ring (&dev_priv->dev, &dev_priv->ring[VECS ]);if (pm_iir &PM_VEBOX_CS_ERROR_INTERRUPT ) {DRM_ERROR ("VEBOX CS error interrupt 0x%08x\n" , pm_iir); -i915_handle_error (dev_priv->dev, false); +i915_handle_error (&dev_priv->dev, false); } } }
@@ -1944,7 +1944,7 @@ static void i915_error_work_func(struct work_struct *work) work);drm_i915_private_t *dev_priv =container_of (error, drm_i915_private_t, gpu_error); -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;char *error_event[] = {I915_ERROR_UEVENT "=1" ,NULL };char *reset_event[] = {I915_RESET_UEVENT "=1" ,NULL };char *reset_done_event[] = {I915_ERROR_UEVENT "=0" ,NULL };
@@ -2949,7 +2949,7 @@ static void gen8_gt_irq_postinstall(struct drm_i915_private *dev_priv)static void gen8_de_irq_postinstall (struct drm_i915_private *dev_priv) { -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;uint32_t de_pipe_masked =GEN8_PIPE_FLIP_DONE |GEN8_PIPE_CDCLK_CRC_DONE | GEN8_PIPE_FIFO_UNDERRUN |
@@ -3746,7 +3746,7 @@ static void i965_irq_uninstall(struct drm_device * dev)static void i915_reenable_hotplug_timer_func (unsigned long data) {drm_i915_private_t *dev_priv = (drm_i915_private_t *)data; -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;struct drm_mode_config *mode_config = &dev->mode_config;unsigned long irqflags;int i;
drivers/gpu/drm/i915/i915_sysfs.c +4 -4
@@ -264,7 +264,7 @@ static ssize_t gt_cur_freq_mhz_show(struct device *kdev,flush_delayed_work (&dev_priv->rps.delayed_resume_work);mutex_lock (&dev_priv->rps.hw_lock); -if (IS_VALLEYVIEW (dev_priv->dev)) { +if (IS_VALLEYVIEW (&dev_priv->dev)) {u32 freq; freq =vlv_punit_read (dev_priv,PUNIT_REG_GPU_FREQ_STS ); ret =vlv_gpu_freq (dev_priv, (freq >>8 ) &0xff );
@@ -297,7 +297,7 @@ static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attributeflush_delayed_work (&dev_priv->rps.delayed_resume_work);mutex_lock (&dev_priv->rps.hw_lock); -if (IS_VALLEYVIEW (dev_priv->dev)) +if (IS_VALLEYVIEW (&dev_priv->dev)) ret =vlv_gpu_freq (dev_priv, dev_priv->rps.max_delay);else ret = dev_priv->rps.max_delay *GT_FREQUENCY_MULTIPLIER ;
@@ -324,7 +324,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev,mutex_lock (&dev_priv->rps.hw_lock); -if (IS_VALLEYVIEW (dev_priv->dev)) { +if (IS_VALLEYVIEW (&dev_priv->dev)) { val =vlv_freq_opcode (dev_priv, val); hw_max =valleyview_rps_max_freq (dev_priv);
@@ -373,7 +373,7 @@ static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attributeflush_delayed_work (&dev_priv->rps.delayed_resume_work);mutex_lock (&dev_priv->rps.hw_lock); -if (IS_VALLEYVIEW (dev_priv->dev)) +if (IS_VALLEYVIEW (&dev_priv->dev)) ret =vlv_gpu_freq (dev_priv, dev_priv->rps.min_delay);else ret = dev_priv->rps.min_delay *GT_FREQUENCY_MULTIPLIER ;
drivers/gpu/drm/i915/intel_bios.c +3 -3
@@ -368,7 +368,7 @@ static void parse_general_features(struct drm_i915_private *dev_priv, struct bdb_header *bdb) { - struct drm_device *dev = dev_priv->dev; + struct drm_device *dev = &dev_priv->dev;struct bdb_general_features *general; general =find_section (bdb,BDB_GENERAL_FEATURES );
@@ -716,7 +716,7 @@ static void parse_ddi_port(struct drm_i915_private *dev_priv, enum port port,static void parse_ddi_ports (struct drm_i915_private *dev_priv,struct bdb_header *bdb) { -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;enum port port;if (!HAS_DDI (dev))
@@ -800,7 +800,7 @@ parse_device_mapping(struct drm_i915_private *dev_priv,static void init_vbt_defaults (struct drm_i915_private *dev_priv) { -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;enum port port; dev_priv->vbt.crt_ddc_pin =GMBUS_PORT_VGADDC ;
drivers/gpu/drm/i915/intel_ddi.c +1 -1
@@ -1313,7 +1313,7 @@ static void intel_disable_ddi(struct intel_encoder *intel_encoder)int intel_ddi_get_cdclk_freq (struct drm_i915_private *dev_priv) { -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;uint32_t lcpll =I915_READ (LCPLL_CTL );uint32_t freq = lcpll &LCPLL_CLK_FREQ_MASK ;
drivers/gpu/drm/i915/intel_display.c +44 -44
348 lines not on this page · raw message
drivers/gpu/drm/i915/intel_dp.c +1 -1
@@ -1490,7 +1490,7 @@ static void intel_dp_get_config(struct intel_encoder *encoder, dotclock =intel_dotclock_calculate (pipe_config->port_clock, &pipe_config->dp_m_n); -if (HAS_PCH_SPLIT (dev_priv->dev) && port !=PORT_A ) +if (HAS_PCH_SPLIT (&dev_priv->dev) && port !=PORT_A )ironlake_check_encoder_dotclock (pipe_config, dotclock); pipe_config->adjusted_mode.crtc_clock = dotclock;
drivers/gpu/drm/i915/intel_hdmi.c +1 -1
@@ -734,7 +734,7 @@ static void intel_hdmi_get_config(struct intel_encoder *encoder,else dotclock = pipe_config->port_clock; -if (HAS_PCH_SPLIT (dev_priv->dev)) +if (HAS_PCH_SPLIT (&dev_priv->dev))ironlake_check_encoder_dotclock (pipe_config, dotclock); pipe_config->adjusted_mode.crtc_clock = dotclock;
drivers/gpu/drm/i915/intel_i2c.c +7 -7
@@ -84,7 +84,7 @@ static void gmbus_set_freq(struct drm_i915_private *dev_priv) {int vco, gmbus_freq =0 , cdclk_div; -BUG_ON (!IS_VALLEYVIEW (dev_priv->dev)); +BUG_ON (!IS_VALLEYVIEW (&dev_priv->dev)); vco =valleyview_get_vco (dev_priv);
@@ -126,7 +126,7 @@ static void intel_i2c_quirk_set(struct drm_i915_private *dev_priv, bool enable)u32 val;/* When using bit bashing for I2C, this bit needs to be set to 1 */ -if (!IS_PINEVIEW (dev_priv->dev)) +if (!IS_PINEVIEW (&dev_priv->dev))return ; val =I915_READ (DSPCLK_GATE_D );
@@ -140,7 +140,7 @@ static void intel_i2c_quirk_set(struct drm_i915_private *dev_priv, bool enable)static u32 get_reserved (struct intel_gmbus *bus) {struct drm_i915_private *dev_priv = bus->dev_priv; -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;u32 reserved =0 ;/* On most chips, these bits must be preserved in software. */
@@ -214,7 +214,7 @@ intel_gpio_pre_xfer(struct i2c_adapter *adapter) adapter);struct drm_i915_private *dev_priv = bus->dev_priv; -intel_i2c_reset (dev_priv->dev); +intel_i2c_reset (&dev_priv->dev);intel_i2c_quirk_set (dev_priv, true);set_data (bus,1 );set_clock (bus,1 );
@@ -275,7 +275,7 @@ gmbus_wait_hw_status(struct drm_i915_private *dev_priv,u32 gmbus2 =0 ;DEFINE_WAIT (wait); -if (!HAS_GMBUS_IRQ (dev_priv->dev)) +if (!HAS_GMBUS_IRQ (&dev_priv->dev)) gmbus4_irq_en =0 ;/* Important: The hw handles only the first bit, so set only one! Since
@@ -312,7 +312,7 @@ gmbus_wait_idle(struct drm_i915_private *dev_priv)#define C ((I915_READ_NOTRACE(GMBUS2 + reg_offset) & GMBUS_ACTIVE) == 0) -if (!HAS_GMBUS_IRQ (dev_priv->dev)) +if (!HAS_GMBUS_IRQ (&dev_priv->dev))return wait_for (C ,10 );/* Important: The hw handles only the first bit, so set only one! */
@@ -622,7 +622,7 @@ int intel_setup_gmbus(struct drm_device *dev) goto err; } -intel_i2c_reset (dev_priv->dev); +intel_i2c_reset (&dev_priv->dev);return 0 ;
drivers/gpu/drm/i915/intel_lvds.c +1 -1
@@ -120,7 +120,7 @@ static void intel_lvds_get_config(struct intel_encoder *encoder, dotclock = pipe_config->port_clock; -if (HAS_PCH_SPLIT (dev_priv->dev)) +if (HAS_PCH_SPLIT (&dev_priv->dev))ironlake_check_encoder_dotclock (pipe_config, dotclock); pipe_config->adjusted_mode.crtc_clock = dotclock;
drivers/gpu/drm/i915/intel_opregion.c +1 -1
@@ -509,7 +509,7 @@ static void asle_work(struct work_struct *work) container_of(work, struct intel_opregion, asle_work);struct drm_i915_private *dev_priv = container_of(opregion, struct drm_i915_private, opregion); -struct drm_device *dev = dev_priv->dev; +struct drm_device *dev = &dev_priv->dev;struct opregion_asle __iomem *asle = dev_priv->opregion.asle;u32 aslc_stat =0 ;u32 aslc_req;
drivers/gpu/drm/i915/intel_pm.c +22 -22
162 lines not on this page · raw message
drivers/gpu/drm/i915/intel_uncore.c +7 -7
@@ -45,7 +45,7 @@ static void __gen6_gt_wait_for_thread_c0(struct drm_i915_private *dev_priv) {u32 gt_thread_status_mask; -if (IS_HASWELL (dev_priv->dev)) +if (IS_HASWELL (&dev_priv->dev)) gt_thread_status_mask =GEN6_GT_THREAD_STATUS_CORE_MASK_HSW ;else gt_thread_status_mask =GEN6_GT_THREAD_STATUS_CORE_MASK ;
@@ -95,7 +95,7 @@ static void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv, {u32 forcewake_ack; -if (IS_HASWELL (dev_priv->dev) ||IS_GEN8 (dev_priv->dev)) +if (IS_HASWELL (&dev_priv->dev) ||IS_GEN8 (&dev_priv->dev)) forcewake_ack =FORCEWAKE_ACK_HSW ;else forcewake_ack =FORCEWAKE_MT_ACK ;
@@ -114,7 +114,7 @@ static void __gen6_gt_force_wake_mt_get(struct drm_i915_private *dev_priv,DRM_ERROR ("Timed out waiting for forcewake to ack request.\n" );/* WaRsForcewakeWaitTC0:ivb,hsw */ -if (INTEL_INFO (dev_priv->dev)->gen <8 ) +if (INTEL_INFO (&dev_priv->dev)->gen <8 )__gen6_gt_wait_for_thread_c0 (dev_priv); }
@@ -152,7 +152,7 @@ static int __gen6_gt_wait_for_fifo(struct drm_i915_private *dev_priv)/* On VLV, FIFO will be shared by both SW and HW. * So, we need to read the FREE_ENTRIES everytime */ -if (IS_VALLEYVIEW (dev_priv->dev)) +if (IS_VALLEYVIEW (&dev_priv->dev)) dev_priv->uncore.fifo_count =__raw_i915_read32 (dev_priv,GTFIFOCTL ) >_FIFO_FREE_ENTRIES_MASK ;
@@ -378,7 +378,7 @@ void gen6_gt_force_wake_get(struct drm_i915_private *dev_priv, int fw_engine)intel_runtime_pm_get (dev_priv);/* Redirect to VLV specific routine */ -if (IS_VALLEYVIEW (dev_priv->dev)) +if (IS_VALLEYVIEW (&dev_priv->dev))return vlv_force_wake_get (dev_priv, fw_engine);spin_lock_irqsave (&dev_priv->uncore.lock, irqflags);
@@ -398,7 +398,7 @@ void gen6_gt_force_wake_put(struct drm_i915_private *dev_priv, int fw_engine)return ;/* Redirect to VLV specific routine */ -if (IS_VALLEYVIEW (dev_priv->dev)) +if (IS_VALLEYVIEW (&dev_priv->dev))return vlv_force_wake_put (dev_priv, fw_engine);
@@ -449,7 +449,7 @@ hsw_unclaimed_reg_check(struct drm_i915_private *dev_priv, u32 reg)static void assert_device_not_suspended (struct drm_i915_private *dev_priv) { -WARN (HAS_RUNTIME_PM (dev_priv->dev) && dev_priv->pm.suspended, +WARN (HAS_RUNTIME_PM (&dev_priv->dev) && dev_priv->pm.suspended,"Device suspended\n" ); }
Signature · 1 line
1.8.3.1