Commit 83c00f55 authored by Imre Deak's avatar Imre Deak Committed by Daniel Vetter

drm/i915: prepare for multiple power wells

In the future we'll need to support multiple power wells, so prepare for
that here. Create a new power domains struct which contains all
power domain/well specific fields. Since we'll have one lock protecting
all power wells, move power_well->lock to the new struct too.

No functional change.
Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Reviewed-by: default avatarPaulo Zanoni <paulo.zanoni@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 8c7b72f2
...@@ -909,12 +909,18 @@ struct intel_ilk_power_mgmt { ...@@ -909,12 +909,18 @@ struct intel_ilk_power_mgmt {
/* Power well structure for haswell */ /* Power well structure for haswell */
struct i915_power_well { struct i915_power_well {
struct drm_device *device; struct drm_device *device;
struct mutex lock;
/* power well enable/disable usage count */ /* power well enable/disable usage count */
int count; int count;
int i915_request; int i915_request;
}; };
#define I915_MAX_POWER_WELLS 1
struct i915_power_domains {
struct mutex lock;
struct i915_power_well power_wells[I915_MAX_POWER_WELLS];
};
struct i915_dri1_state { struct i915_dri1_state {
unsigned allow_batchbuffer : 1; unsigned allow_batchbuffer : 1;
u32 __iomem *gfx_hws_cpu_addr; u32 __iomem *gfx_hws_cpu_addr;
...@@ -1410,8 +1416,7 @@ typedef struct drm_i915_private { ...@@ -1410,8 +1416,7 @@ typedef struct drm_i915_private {
* mchdev_lock in intel_pm.c */ * mchdev_lock in intel_pm.c */
struct intel_ilk_power_mgmt ips; struct intel_ilk_power_mgmt ips;
/* Haswell power well */ struct i915_power_domains power_domains;
struct i915_power_well power_well;
struct i915_psr psr; struct i915_psr psr;
......
...@@ -5598,7 +5598,7 @@ void intel_display_power_get(struct drm_device *dev, ...@@ -5598,7 +5598,7 @@ void intel_display_power_get(struct drm_device *dev,
enum intel_display_power_domain domain) enum intel_display_power_domain domain)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct i915_power_well *power_well = &dev_priv->power_well; struct i915_power_domains *power_domains;
if (!HAS_POWER_WELL(dev)) if (!HAS_POWER_WELL(dev))
return; return;
...@@ -5606,16 +5606,18 @@ void intel_display_power_get(struct drm_device *dev, ...@@ -5606,16 +5606,18 @@ void intel_display_power_get(struct drm_device *dev,
if (is_always_on_power_domain(dev, domain)) if (is_always_on_power_domain(dev, domain))
return; return;
mutex_lock(&power_well->lock); power_domains = &dev_priv->power_domains;
__intel_power_well_get(power_well);
mutex_unlock(&power_well->lock); mutex_lock(&power_domains->lock);
__intel_power_well_get(&power_domains->power_wells[0]);
mutex_unlock(&power_domains->lock);
} }
void intel_display_power_put(struct drm_device *dev, void intel_display_power_put(struct drm_device *dev,
enum intel_display_power_domain domain) enum intel_display_power_domain domain)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct i915_power_well *power_well = &dev_priv->power_well; struct i915_power_domains *power_domains;
if (!HAS_POWER_WELL(dev)) if (!HAS_POWER_WELL(dev))
return; return;
...@@ -5623,12 +5625,14 @@ void intel_display_power_put(struct drm_device *dev, ...@@ -5623,12 +5625,14 @@ void intel_display_power_put(struct drm_device *dev,
if (is_always_on_power_domain(dev, domain)) if (is_always_on_power_domain(dev, domain))
return; return;
mutex_lock(&power_well->lock); power_domains = &dev_priv->power_domains;
__intel_power_well_put(power_well);
mutex_unlock(&power_well->lock); mutex_lock(&power_domains->lock);
__intel_power_well_put(&power_domains->power_wells[0]);
mutex_unlock(&power_domains->lock);
} }
static struct i915_power_well *hsw_pwr; static struct i915_power_domains *hsw_pwr;
/* Display audio driver power well request */ /* Display audio driver power well request */
void i915_request_power_well(void) void i915_request_power_well(void)
...@@ -5637,7 +5641,7 @@ void i915_request_power_well(void) ...@@ -5637,7 +5641,7 @@ void i915_request_power_well(void)
return; return;
mutex_lock(&hsw_pwr->lock); mutex_lock(&hsw_pwr->lock);
__intel_power_well_get(hsw_pwr); __intel_power_well_get(&hsw_pwr->power_wells[0]);
mutex_unlock(&hsw_pwr->lock); mutex_unlock(&hsw_pwr->lock);
} }
EXPORT_SYMBOL_GPL(i915_request_power_well); EXPORT_SYMBOL_GPL(i915_request_power_well);
...@@ -5649,7 +5653,7 @@ void i915_release_power_well(void) ...@@ -5649,7 +5653,7 @@ void i915_release_power_well(void)
return; return;
mutex_lock(&hsw_pwr->lock); mutex_lock(&hsw_pwr->lock);
__intel_power_well_put(hsw_pwr); __intel_power_well_put(&hsw_pwr->power_wells[0]);
mutex_unlock(&hsw_pwr->lock); mutex_unlock(&hsw_pwr->lock);
} }
EXPORT_SYMBOL_GPL(i915_release_power_well); EXPORT_SYMBOL_GPL(i915_release_power_well);
...@@ -5657,12 +5661,15 @@ EXPORT_SYMBOL_GPL(i915_release_power_well); ...@@ -5657,12 +5661,15 @@ EXPORT_SYMBOL_GPL(i915_release_power_well);
int i915_init_power_well(struct drm_device *dev) int i915_init_power_well(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct i915_power_domains *power_domains = &dev_priv->power_domains;
struct i915_power_well *power_well;
hsw_pwr = &dev_priv->power_well; mutex_init(&power_domains->lock);
hsw_pwr = power_domains;
hsw_pwr->device = dev; power_well = &power_domains->power_wells[0];
mutex_init(&hsw_pwr->lock); power_well->device = dev;
hsw_pwr->count = 0; power_well->count = 0;
return 0; return 0;
} }
...@@ -5675,7 +5682,8 @@ void i915_remove_power_well(struct drm_device *dev) ...@@ -5675,7 +5682,8 @@ void i915_remove_power_well(struct drm_device *dev)
void intel_set_power_well(struct drm_device *dev, bool enable) void intel_set_power_well(struct drm_device *dev, bool enable)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct i915_power_well *power_well = &dev_priv->power_well; struct i915_power_domains *power_domains = &dev_priv->power_domains;
struct i915_power_well *power_well;
if (!HAS_POWER_WELL(dev)) if (!HAS_POWER_WELL(dev))
return; return;
...@@ -5683,8 +5691,9 @@ void intel_set_power_well(struct drm_device *dev, bool enable) ...@@ -5683,8 +5691,9 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
if (!i915_disable_power_well && !enable) if (!i915_disable_power_well && !enable)
return; return;
mutex_lock(&power_well->lock); mutex_lock(&power_domains->lock);
power_well = &power_domains->power_wells[0];
/* /*
* This function will only ever contribute one * This function will only ever contribute one
* to the power well reference count. i915_request * to the power well reference count. i915_request
...@@ -5702,20 +5711,24 @@ void intel_set_power_well(struct drm_device *dev, bool enable) ...@@ -5702,20 +5711,24 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
__intel_power_well_put(power_well); __intel_power_well_put(power_well);
out: out:
mutex_unlock(&power_well->lock); mutex_unlock(&power_domains->lock);
} }
static void intel_resume_power_well(struct drm_device *dev) static void intel_resume_power_well(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct i915_power_well *power_well = &dev_priv->power_well; struct i915_power_domains *power_domains = &dev_priv->power_domains;
struct i915_power_well *power_well;
if (!HAS_POWER_WELL(dev)) if (!HAS_POWER_WELL(dev))
return; return;
mutex_lock(&power_well->lock); mutex_lock(&power_domains->lock);
power_well = &power_domains->power_wells[0];
__intel_set_power_well(dev, power_well->count > 0); __intel_set_power_well(dev, power_well->count > 0);
mutex_unlock(&power_well->lock);
mutex_unlock(&power_domains->lock);
} }
/* /*
......
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