[1/2] drm/i915/pm: Unconstify power_domain_str

Submitted by Daniel Stone on Nov. 19, 2015, 5:59 p.m.

Details

Message ID 1447955951-19170-1-git-send-email-daniels@collabora.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Intel GFX

Not browsing as part of any series.

Commit Message

Daniel Stone Nov. 19, 2015, 5:59 p.m.
Let us print human-parseable values from the power domain code; upcoming
display code also wants to use it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 67 +------------------------------------
 drivers/gpu/drm/i915/i915_drv.h     | 66 ++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 66 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 411a9c6..b28da6f 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2685,71 +2685,6 @@  static int i915_runtime_pm_status(struct seq_file *m, void *unused)
 	return 0;
 }
 
-static const char *power_domain_str(enum intel_display_power_domain domain)
-{
-	switch (domain) {
-	case POWER_DOMAIN_PIPE_A:
-		return "PIPE_A";
-	case POWER_DOMAIN_PIPE_B:
-		return "PIPE_B";
-	case POWER_DOMAIN_PIPE_C:
-		return "PIPE_C";
-	case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
-		return "PIPE_A_PANEL_FITTER";
-	case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
-		return "PIPE_B_PANEL_FITTER";
-	case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
-		return "PIPE_C_PANEL_FITTER";
-	case POWER_DOMAIN_TRANSCODER_A:
-		return "TRANSCODER_A";
-	case POWER_DOMAIN_TRANSCODER_B:
-		return "TRANSCODER_B";
-	case POWER_DOMAIN_TRANSCODER_C:
-		return "TRANSCODER_C";
-	case POWER_DOMAIN_TRANSCODER_EDP:
-		return "TRANSCODER_EDP";
-	case POWER_DOMAIN_PORT_DDI_A_LANES:
-		return "PORT_DDI_A_LANES";
-	case POWER_DOMAIN_PORT_DDI_B_LANES:
-		return "PORT_DDI_B_LANES";
-	case POWER_DOMAIN_PORT_DDI_C_LANES:
-		return "PORT_DDI_C_LANES";
-	case POWER_DOMAIN_PORT_DDI_D_LANES:
-		return "PORT_DDI_D_LANES";
-	case POWER_DOMAIN_PORT_DDI_E_LANES:
-		return "PORT_DDI_E_LANES";
-	case POWER_DOMAIN_PORT_DSI:
-		return "PORT_DSI";
-	case POWER_DOMAIN_PORT_CRT:
-		return "PORT_CRT";
-	case POWER_DOMAIN_PORT_OTHER:
-		return "PORT_OTHER";
-	case POWER_DOMAIN_VGA:
-		return "VGA";
-	case POWER_DOMAIN_AUDIO:
-		return "AUDIO";
-	case POWER_DOMAIN_PLLS:
-		return "PLLS";
-	case POWER_DOMAIN_AUX_A:
-		return "AUX_A";
-	case POWER_DOMAIN_AUX_B:
-		return "AUX_B";
-	case POWER_DOMAIN_AUX_C:
-		return "AUX_C";
-	case POWER_DOMAIN_AUX_D:
-		return "AUX_D";
-	case POWER_DOMAIN_GMBUS:
-		return "GMBUS";
-	case POWER_DOMAIN_MODESET:
-		return "MODESET";
-	case POWER_DOMAIN_INIT:
-		return "INIT";
-	default:
-		MISSING_CASE(domain);
-		return "?";
-	}
-}
-
 static int i915_power_domain_info(struct seq_file *m, void *unused)
 {
 	struct drm_info_node *node = m->private;
@@ -2775,7 +2710,7 @@  static int i915_power_domain_info(struct seq_file *m, void *unused)
 				continue;
 
 			seq_printf(m, "  %-23s %d\n",
-				 power_domain_str(power_domain),
+				 intel_display_power_domain_str(power_domain),
 				 power_domains->domain_use_count[power_domain]);
 		}
 	}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a47e0f4..854e678 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -209,6 +209,72 @@  enum intel_display_power_domain {
 	((tran) == TRANSCODER_EDP ? POWER_DOMAIN_TRANSCODER_EDP : \
 	 (tran) + POWER_DOMAIN_TRANSCODER_A)
 
+static inline const char *
+intel_display_power_domain_str(enum intel_display_power_domain domain)
+{
+	switch (domain) {
+	case POWER_DOMAIN_PIPE_A:
+		return "PIPE_A";
+	case POWER_DOMAIN_PIPE_B:
+		return "PIPE_B";
+	case POWER_DOMAIN_PIPE_C:
+		return "PIPE_C";
+	case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
+		return "PIPE_A_PANEL_FITTER";
+	case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
+		return "PIPE_B_PANEL_FITTER";
+	case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
+		return "PIPE_C_PANEL_FITTER";
+	case POWER_DOMAIN_TRANSCODER_A:
+		return "TRANSCODER_A";
+	case POWER_DOMAIN_TRANSCODER_B:
+		return "TRANSCODER_B";
+	case POWER_DOMAIN_TRANSCODER_C:
+		return "TRANSCODER_C";
+	case POWER_DOMAIN_TRANSCODER_EDP:
+		return "TRANSCODER_EDP";
+	case POWER_DOMAIN_PORT_DDI_A_LANES:
+		return "PORT_DDI_A_LANES";
+	case POWER_DOMAIN_PORT_DDI_B_LANES:
+		return "PORT_DDI_B_LANES";
+	case POWER_DOMAIN_PORT_DDI_C_LANES:
+		return "PORT_DDI_C_LANES";
+	case POWER_DOMAIN_PORT_DDI_D_LANES:
+		return "PORT_DDI_D_LANES";
+	case POWER_DOMAIN_PORT_DDI_E_LANES:
+		return "PORT_DDI_E_LANES";
+	case POWER_DOMAIN_PORT_DSI:
+		return "PORT_DSI";
+	case POWER_DOMAIN_PORT_CRT:
+		return "PORT_CRT";
+	case POWER_DOMAIN_PORT_OTHER:
+		return "PORT_OTHER";
+	case POWER_DOMAIN_VGA:
+		return "VGA";
+	case POWER_DOMAIN_AUDIO:
+		return "AUDIO";
+	case POWER_DOMAIN_PLLS:
+		return "PLLS";
+	case POWER_DOMAIN_AUX_A:
+		return "AUX_A";
+	case POWER_DOMAIN_AUX_B:
+		return "AUX_B";
+	case POWER_DOMAIN_AUX_C:
+		return "AUX_C";
+	case POWER_DOMAIN_AUX_D:
+		return "AUX_D";
+	case POWER_DOMAIN_GMBUS:
+		return "GMBUS";
+	case POWER_DOMAIN_INIT:
+		return "INIT";
+	case POWER_DOMAIN_MODESET:
+		return "MODESET";
+	default:
+		MISSING_CASE(domain);
+		return "?";
+	}
+}
+
 enum hpd_pin {
 	HPD_NONE = 0,
 	HPD_TV = HPD_NONE,     /* TV is known to be unreliable */

Comments

On Thu, Nov 19, 2015 at 05:59:10PM +0000, Daniel Stone wrote:
> Let us print human-parseable values from the power domain code; upcoming
> display code also wants to use it.
> 
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c | 67 +------------------------------------
>  drivers/gpu/drm/i915/i915_drv.h     | 66 ++++++++++++++++++++++++++++++++++++
>  2 files changed, 67 insertions(+), 66 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 411a9c6..b28da6f 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -2685,71 +2685,6 @@ static int i915_runtime_pm_status(struct seq_file *m, void *unused)
>  	return 0;
>  }
>  
> -static const char *power_domain_str(enum intel_display_power_domain domain)
> -{
> -	switch (domain) {
> -	case POWER_DOMAIN_PIPE_A:
> -		return "PIPE_A";
> -	case POWER_DOMAIN_PIPE_B:
> -		return "PIPE_B";
> -	case POWER_DOMAIN_PIPE_C:
> -		return "PIPE_C";
> -	case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
> -		return "PIPE_A_PANEL_FITTER";
> -	case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
> -		return "PIPE_B_PANEL_FITTER";
> -	case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
> -		return "PIPE_C_PANEL_FITTER";
> -	case POWER_DOMAIN_TRANSCODER_A:
> -		return "TRANSCODER_A";
> -	case POWER_DOMAIN_TRANSCODER_B:
> -		return "TRANSCODER_B";
> -	case POWER_DOMAIN_TRANSCODER_C:
> -		return "TRANSCODER_C";
> -	case POWER_DOMAIN_TRANSCODER_EDP:
> -		return "TRANSCODER_EDP";
> -	case POWER_DOMAIN_PORT_DDI_A_LANES:
> -		return "PORT_DDI_A_LANES";
> -	case POWER_DOMAIN_PORT_DDI_B_LANES:
> -		return "PORT_DDI_B_LANES";
> -	case POWER_DOMAIN_PORT_DDI_C_LANES:
> -		return "PORT_DDI_C_LANES";
> -	case POWER_DOMAIN_PORT_DDI_D_LANES:
> -		return "PORT_DDI_D_LANES";
> -	case POWER_DOMAIN_PORT_DDI_E_LANES:
> -		return "PORT_DDI_E_LANES";
> -	case POWER_DOMAIN_PORT_DSI:
> -		return "PORT_DSI";
> -	case POWER_DOMAIN_PORT_CRT:
> -		return "PORT_CRT";
> -	case POWER_DOMAIN_PORT_OTHER:
> -		return "PORT_OTHER";
> -	case POWER_DOMAIN_VGA:
> -		return "VGA";
> -	case POWER_DOMAIN_AUDIO:
> -		return "AUDIO";
> -	case POWER_DOMAIN_PLLS:
> -		return "PLLS";
> -	case POWER_DOMAIN_AUX_A:
> -		return "AUX_A";
> -	case POWER_DOMAIN_AUX_B:
> -		return "AUX_B";
> -	case POWER_DOMAIN_AUX_C:
> -		return "AUX_C";
> -	case POWER_DOMAIN_AUX_D:
> -		return "AUX_D";
> -	case POWER_DOMAIN_GMBUS:
> -		return "GMBUS";
> -	case POWER_DOMAIN_MODESET:
> -		return "MODESET";
> -	case POWER_DOMAIN_INIT:
> -		return "INIT";
> -	default:
> -		MISSING_CASE(domain);
> -		return "?";
> -	}
> -}
> -
>  static int i915_power_domain_info(struct seq_file *m, void *unused)
>  {
>  	struct drm_info_node *node = m->private;
> @@ -2775,7 +2710,7 @@ static int i915_power_domain_info(struct seq_file *m, void *unused)
>  				continue;
>  
>  			seq_printf(m, "  %-23s %d\n",
> -				 power_domain_str(power_domain),
> +				 intel_display_power_domain_str(power_domain),
>  				 power_domains->domain_use_count[power_domain]);
>  		}
>  	}
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index a47e0f4..854e678 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -209,6 +209,72 @@ enum intel_display_power_domain {
>  	((tran) == TRANSCODER_EDP ? POWER_DOMAIN_TRANSCODER_EDP : \
>  	 (tran) + POWER_DOMAIN_TRANSCODER_A)
>  
> +static inline const char *
> +intel_display_power_domain_str(enum intel_display_power_domain domain)

It's still const. And I assume now we end up duplicating these strings
in every object file that calls this. Why don't you just remove the
"static" from the original?

> +{
> +	switch (domain) {
> +	case POWER_DOMAIN_PIPE_A:
> +		return "PIPE_A";
> +	case POWER_DOMAIN_PIPE_B:
> +		return "PIPE_B";
> +	case POWER_DOMAIN_PIPE_C:
> +		return "PIPE_C";
> +	case POWER_DOMAIN_PIPE_A_PANEL_FITTER:
> +		return "PIPE_A_PANEL_FITTER";
> +	case POWER_DOMAIN_PIPE_B_PANEL_FITTER:
> +		return "PIPE_B_PANEL_FITTER";
> +	case POWER_DOMAIN_PIPE_C_PANEL_FITTER:
> +		return "PIPE_C_PANEL_FITTER";
> +	case POWER_DOMAIN_TRANSCODER_A:
> +		return "TRANSCODER_A";
> +	case POWER_DOMAIN_TRANSCODER_B:
> +		return "TRANSCODER_B";
> +	case POWER_DOMAIN_TRANSCODER_C:
> +		return "TRANSCODER_C";
> +	case POWER_DOMAIN_TRANSCODER_EDP:
> +		return "TRANSCODER_EDP";
> +	case POWER_DOMAIN_PORT_DDI_A_LANES:
> +		return "PORT_DDI_A_LANES";
> +	case POWER_DOMAIN_PORT_DDI_B_LANES:
> +		return "PORT_DDI_B_LANES";
> +	case POWER_DOMAIN_PORT_DDI_C_LANES:
> +		return "PORT_DDI_C_LANES";
> +	case POWER_DOMAIN_PORT_DDI_D_LANES:
> +		return "PORT_DDI_D_LANES";
> +	case POWER_DOMAIN_PORT_DDI_E_LANES:
> +		return "PORT_DDI_E_LANES";
> +	case POWER_DOMAIN_PORT_DSI:
> +		return "PORT_DSI";
> +	case POWER_DOMAIN_PORT_CRT:
> +		return "PORT_CRT";
> +	case POWER_DOMAIN_PORT_OTHER:
> +		return "PORT_OTHER";
> +	case POWER_DOMAIN_VGA:
> +		return "VGA";
> +	case POWER_DOMAIN_AUDIO:
> +		return "AUDIO";
> +	case POWER_DOMAIN_PLLS:
> +		return "PLLS";
> +	case POWER_DOMAIN_AUX_A:
> +		return "AUX_A";
> +	case POWER_DOMAIN_AUX_B:
> +		return "AUX_B";
> +	case POWER_DOMAIN_AUX_C:
> +		return "AUX_C";
> +	case POWER_DOMAIN_AUX_D:
> +		return "AUX_D";
> +	case POWER_DOMAIN_GMBUS:
> +		return "GMBUS";
> +	case POWER_DOMAIN_INIT:
> +		return "INIT";
> +	case POWER_DOMAIN_MODESET:
> +		return "MODESET";
> +	default:
> +		MISSING_CASE(domain);
> +		return "?";
> +	}
> +}
> +
>  enum hpd_pin {
>  	HPD_NONE = 0,
>  	HPD_TV = HPD_NONE,     /* TV is known to be unreliable */
> -- 
> 2.5.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hey,

On 19 November 2015 at 18:24, Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
> On Thu, Nov 19, 2015 at 05:59:10PM +0000, Daniel Stone wrote:
>> +static inline const char *
>> +intel_display_power_domain_str(enum intel_display_power_domain domain)
>
> It's still const. And I assume now we end up duplicating these strings
> in every object file that calls this. Why don't you just remove the
> "static" from the original?

Right, 'unstatic' is what I meant. Dropping const wouldn't have been
very clever.

Surely gcc's DCE pass will trivially eliminate this? I put it so it
could lie next to the enum definition itself, but if you'd prefer,
I'll happily move the definition to intel_runtime_pm.c (or whatever
shed colour is deemed appropriate) instead.

Cheers,
Daniel
On Thu, Nov 19, 2015 at 06:26:23PM +0000, Daniel Stone wrote:
> Hey,
> 
> On 19 November 2015 at 18:24, Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> > On Thu, Nov 19, 2015 at 05:59:10PM +0000, Daniel Stone wrote:
> >> +static inline const char *
> >> +intel_display_power_domain_str(enum intel_display_power_domain domain)
> >
> > It's still const. And I assume now we end up duplicating these strings
> > in every object file that calls this. Why don't you just remove the
> > "static" from the original?
> 
> Right, 'unstatic' is what I meant. Dropping const wouldn't have been
> very clever.
> 
> Surely gcc's DCE pass will trivially eliminate this?

Dunno. But I rather dislike having code in headers anyway.

> I put it so it
> could lie next to the enum definition itself, but if you'd prefer,
> I'll happily move the definition to intel_runtime_pm.c (or whatever
> shed colour is deemed appropriate) instead.
> 
> Cheers,
> Daniel
On Thu, 19 Nov 2015, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> On Thu, Nov 19, 2015 at 06:26:23PM +0000, Daniel Stone wrote:
>> Hey,
>> 
>> On 19 November 2015 at 18:24, Ville Syrjälä
>> <ville.syrjala@linux.intel.com> wrote:
>> > On Thu, Nov 19, 2015 at 05:59:10PM +0000, Daniel Stone wrote:
>> >> +static inline const char *
>> >> +intel_display_power_domain_str(enum intel_display_power_domain domain)
>> >
>> > It's still const. And I assume now we end up duplicating these strings
>> > in every object file that calls this. Why don't you just remove the
>> > "static" from the original?
>> 
>> Right, 'unstatic' is what I meant. Dropping const wouldn't have been
>> very clever.
>> 
>> Surely gcc's DCE pass will trivially eliminate this?
>
> Dunno. But I rather dislike having code in headers anyway.

Agreed, particularly for long ones like this. Please just drop the
static.

BR,
Jani.
On 20 November 2015 at 08:21, Jani Nikula <jani.nikula@linux.intel.com> wrote:
> On Thu, 19 Nov 2015, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
>> On Thu, Nov 19, 2015 at 06:26:23PM +0000, Daniel Stone wrote:
>>> Surely gcc's DCE pass will trivially eliminate this?
>>
>> Dunno. But I rather dislike having code in headers anyway.
>
> Agreed, particularly for long ones like this. Please just drop the
> static.

Purple it is; re-sent. Augmented commit message explains why it can't
live in i915_debugfs.c.

Cheers,
Daniel