Commit 5c969aa7 authored by Damien Lespiau's avatar Damien Lespiau Committed by Daniel Vetter

drm/i915: Make the intel_device_info structure kept in dev_priv writable

Turns out it'd be nice to change some device information at run-time or simply
have some code to fill in the info struct instead of having to declare the
values in 30+ structures.

What prompted this change is handling fused out display/pipe and tweaking
num_pipes at run-time, but I'm quite sure we'll find other flags/limits to
stick into dev_priv->info.

Most of the changes were done with a sed:
sed -i -e 's/dev_priv->info->/dev_priv->info./g' drivers/gpu/drm/i915/*[ch]

with a few tweaks to make it all work:
- Change the field definition in struct drm_i915_private
- adjust i915_dump_device_info()
- adjust i915_driver_load()
- adjust the INTEL_INFO() macro

v2: cast the info pointer returned by INTEL_INFO() to be const to catch
    uses that would modify the structure post-initialization.
    (Ville Syrjälä)

v3: Redo the patch onto latest drm-nightly,
    Keep the info field const to catch post initialization writes
    instead of the v2 solution,
    Use a direct structure copy for the initial info initialization to
    use the compiler type safety (Ville Syrjälä)

Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com> (for v2)
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> (for v2)
Signed-off-by: default avatarDamien Lespiau <damien.lespiau@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 3d13ef2e
...@@ -1442,7 +1442,7 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv) ...@@ -1442,7 +1442,7 @@ static void i915_kick_out_firmware_fb(struct drm_i915_private *dev_priv)
static void i915_dump_device_info(struct drm_i915_private *dev_priv) static void i915_dump_device_info(struct drm_i915_private *dev_priv)
{ {
const struct intel_device_info *info = dev_priv->info; const struct intel_device_info *info = &dev_priv->info;
#define PRINT_S(name) "%s" #define PRINT_S(name) "%s"
#define SEP_EMPTY #define SEP_EMPTY
...@@ -1473,7 +1473,7 @@ static void i915_dump_device_info(struct drm_i915_private *dev_priv) ...@@ -1473,7 +1473,7 @@ static void i915_dump_device_info(struct drm_i915_private *dev_priv)
int i915_driver_load(struct drm_device *dev, unsigned long flags) int i915_driver_load(struct drm_device *dev, unsigned long flags)
{ {
struct drm_i915_private *dev_priv; struct drm_i915_private *dev_priv;
struct intel_device_info *info; struct intel_device_info *info, *device_info;
int ret = 0, mmio_bar, mmio_size; int ret = 0, mmio_bar, mmio_size;
uint32_t aperture_size; uint32_t aperture_size;
...@@ -1496,7 +1496,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) ...@@ -1496,7 +1496,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
dev->dev_private = (void *)dev_priv; dev->dev_private = (void *)dev_priv;
dev_priv->dev = dev; dev_priv->dev = dev;
dev_priv->info = info;
/* copy initial configuration to dev_priv->info */
device_info = (struct intel_device_info *)&dev_priv->info;
*device_info = *info;
spin_lock_init(&dev_priv->irq_lock); spin_lock_init(&dev_priv->irq_lock);
spin_lock_init(&dev_priv->gpu_error.lock); spin_lock_init(&dev_priv->gpu_error.lock);
......
...@@ -1390,7 +1390,7 @@ typedef struct drm_i915_private { ...@@ -1390,7 +1390,7 @@ typedef struct drm_i915_private {
struct drm_device *dev; struct drm_device *dev;
struct kmem_cache *slab; struct kmem_cache *slab;
const struct intel_device_info *info; const struct intel_device_info info;
int relative_constants_mode; int relative_constants_mode;
...@@ -1799,7 +1799,7 @@ struct drm_i915_file_private { ...@@ -1799,7 +1799,7 @@ struct drm_i915_file_private {
atomic_t rps_wait_boost; atomic_t rps_wait_boost;
}; };
#define INTEL_INFO(dev) (to_i915(dev)->info) #define INTEL_INFO(dev) (&to_i915(dev)->info)
#define IS_I830(dev) ((dev)->pdev->device == 0x3577) #define IS_I830(dev) ((dev)->pdev->device == 0x3577)
#define IS_845G(dev) ((dev)->pdev->device == 0x2562) #define IS_845G(dev) ((dev)->pdev->device == 0x2562)
......
This diff is collapsed.
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