Re: [Intel-gfx] [PATCH] drm/i915: prefer INTEL_GEN(dev_priv) to INTEL_INFO(dev)->gen

2016-09-14 Thread Dave Gordon

On 14/09/16 13:32, Dave Gordon wrote:

On 13/09/16 10:10, Jani Nikula wrote:

On Sat, 10 Sep 2016, Dave Gordon  wrote:

Thanks, the other things I was thinking of fixing in the remaining files
were generally things like

   if (INTEL_INFO(dev)->gen < 5 || IS_G33(dev))


Is that a real or a made up example? IS_G33() would be redundant. But
I'd like to see the semantic patch to fix that! ;)

BR,
Jani.


That particular one was made up. The full series is now on the list in
three patches. Part 1 is this one and already has Chris' R-b, part 2 is
all the nontrivial ones such as the above and part 3 is intel_display.c
all on its own 'cos it's the biggest file and the biggest user of this
construct. Both of the latter have various boolean combinations of
INTEL_GEN() with IS_X() or HAS_X() so it might be worth checking them
for redundancies.


I should have pointed out that the full series is not part of this 
thread, it's a separate patchset beginning with


[PATCH 0/3] drm/i915: use INTEL_GEN(dev_priv) wherever possible​

https://lists.freedesktop.org/archives/intel-gfx/2016-September/106338.html

.Dave.


If you make up a table of redundant comparisons I'm sure it can be
turned into a Cocci script :)

.Dave.
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: prefer INTEL_GEN(dev_priv) to INTEL_INFO(dev)->gen

2016-09-14 Thread Dave Gordon

On 13/09/16 10:10, Jani Nikula wrote:

On Sat, 10 Sep 2016, Dave Gordon  wrote:

Thanks, the other things I was thinking of fixing in the remaining files
were generally things like

   if (INTEL_INFO(dev)->gen < 5 || IS_G33(dev))


Is that a real or a made up example? IS_G33() would be redundant. But
I'd like to see the semantic patch to fix that! ;)

BR,
Jani.


That particular one was made up. The full series is now on the list in 
three patches. Part 1 is this one and already has Chris' R-b, part 2 is 
all the nontrivial ones such as the above and part 3 is intel_display.c 
all on its own 'cos it's the biggest file and the biggest user of this 
construct. Both of the latter have various boolean combinations of 
INTEL_GEN() with IS_X() or HAS_X() so it might be worth checking them 
for redundancies.


If you make up a table of redundant comparisons I'm sure it can be 
turned into a Cocci script :)


.Dave.
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: prefer INTEL_GEN(dev_priv) to INTEL_INFO(dev)->gen

2016-09-13 Thread Jani Nikula
On Sat, 10 Sep 2016, Dave Gordon  wrote:
> Thanks, the other things I was thinking of fixing in the remaining files 
> were generally things like
>
>if (INTEL_INFO(dev)->gen < 5 || IS_G33(dev))

Is that a real or a made up example? IS_G33() would be redundant. But
I'd like to see the semantic patch to fix that! ;)

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: prefer INTEL_GEN(dev_priv) to INTEL_INFO(dev)->gen

2016-09-09 Thread Dave Gordon

On 09/09/16 22:58, Chris Wilson wrote:

On Fri, Sep 09, 2016 at 10:37:46PM +0100, Dave Gordon wrote:

More Coccinellery ...

Wherever we find "INTEL_INFO(dev)->gen", and have a suitable
"dev_priv" in scope, replace it with "INTEL_GEN(dev_priv)",
which is the preferred wasy to access this device property.

This patch covers all the files that contained only relatively
few instances, and where no manual fixup was required. A few
more complex instances may be updated in a later patch.

@dev_priv_param@
function FUNC;
idexpression struct drm_device *DEV;


Oh. That's how you catch those.


identifier DEV_PRIV;
@@
FUNC(..., struct drm_i915_private *DEV_PRIV, ...)
{
<...
-   INTEL_INFO(DEV)->gen
+   INTEL_GEN(DEV_PRIV)
...>
}

@dev_priv_local@
idexpression struct drm_device *DEV;
identifier DEV_PRIV;
expression E;
@@
{
...
(
struct drm_i915_private *DEV_PRIV;
|
struct drm_i915_private *DEV_PRIV = E;
)
<...
-   INTEL_INFO(DEV)->gen
+   INTEL_GEN(DEV_PRIV)
...>
}


Looks good, will have to wait until just after another merge point so
that we can apply to dinq (as well as applies to nightly).

Nothing appeared out-of-place running this against intel_display.c, just
a residual unused struct drm_dev.

Reviewed-by: Chris Wilson 
-Chris


Thanks, the other things I was thinking of fixing in the remaining files 
were generally things like


  if (INTEL_INFO(dev)->gen < 5 || IS_G33(dev))

where the Cocci script spotted the first half but left a reference to 
'dev' in the IS_X() call, which might be worth changing at the same time 
in these specific cases. Of course I've got a Coccinelle script to 
convert all the IS_X() macros too but that does produce rather too much 
churn for one patch!


.Dave.
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: prefer INTEL_GEN(dev_priv) to INTEL_INFO(dev)->gen

2016-09-09 Thread Chris Wilson
On Fri, Sep 09, 2016 at 10:37:46PM +0100, Dave Gordon wrote:
> More Coccinellery ...
> 
> Wherever we find "INTEL_INFO(dev)->gen", and have a suitable
> "dev_priv" in scope, replace it with "INTEL_GEN(dev_priv)",
> which is the preferred wasy to access this device property.
> 
> This patch covers all the files that contained only relatively
> few instances, and where no manual fixup was required. A few
> more complex instances may be updated in a later patch.
> 
> @dev_priv_param@
> function FUNC;
> idexpression struct drm_device *DEV;

Oh. That's how you catch those.

> identifier DEV_PRIV;
> @@
> FUNC(..., struct drm_i915_private *DEV_PRIV, ...)
> {
> <...
> -   INTEL_INFO(DEV)->gen
> +   INTEL_GEN(DEV_PRIV)
> ...>
> }
> 
> @dev_priv_local@
> idexpression struct drm_device *DEV;
> identifier DEV_PRIV;
> expression E;
> @@
> {
> ...
> (
> struct drm_i915_private *DEV_PRIV;
> |
> struct drm_i915_private *DEV_PRIV = E;
> )
> <...
> -   INTEL_INFO(DEV)->gen
> +   INTEL_GEN(DEV_PRIV)
> ...>
> }

Looks good, will have to wait until just after another merge point so
that we can apply to dinq (as well as applies to nightly).

Nothing appeared out-of-place running this against intel_display.c, just
a residual unused struct drm_dev.

Reviewed-by: Chris Wilson 
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH] drm/i915: prefer INTEL_GEN(dev_priv) to INTEL_INFO(dev)->gen

2016-09-09 Thread Dave Gordon
More Coccinellery ...

Wherever we find "INTEL_INFO(dev)->gen", and have a suitable
"dev_priv" in scope, replace it with "INTEL_GEN(dev_priv)",
which is the preferred wasy to access this device property.

This patch covers all the files that contained only relatively
few instances, and where no manual fixup was required. A few
more complex instances may be updated in a later patch.

@dev_priv_param@
function FUNC;
idexpression struct drm_device *DEV;
identifier DEV_PRIV;
@@
FUNC(..., struct drm_i915_private *DEV_PRIV, ...)
{
<...
-   INTEL_INFO(DEV)->gen
+   INTEL_GEN(DEV_PRIV)
...>
}

@dev_priv_local@
idexpression struct drm_device *DEV;
identifier DEV_PRIV;
expression E;
@@
{
...
(
struct drm_i915_private *DEV_PRIV;
|
struct drm_i915_private *DEV_PRIV = E;
)
<...
-   INTEL_INFO(DEV)->gen
+   INTEL_GEN(DEV_PRIV)
...>
}

Signed-off-by: Dave Gordon 
---
 drivers/gpu/drm/i915/i915_gem.c|  4 ++--
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |  6 +++---
 drivers/gpu/drm/i915/i915_gem_gtt.c|  4 ++--
 drivers/gpu/drm/i915/i915_gpu_error.c  | 14 +++---
 drivers/gpu/drm/i915/i915_irq.c| 12 ++--
 drivers/gpu/drm/i915/intel_color.c |  2 +-
 drivers/gpu/drm/i915/intel_crt.c   |  6 +++---
 drivers/gpu/drm/i915/intel_ddi.c   |  4 ++--
 drivers/gpu/drm/i915/intel_dp.c| 14 +++---
 drivers/gpu/drm/i915/intel_dpll_mgr.c  |  2 +-
 drivers/gpu/drm/i915/intel_lvds.c  |  4 ++--
 drivers/gpu/drm/i915/intel_pm.c| 18 +-
 drivers/gpu/drm/i915/intel_psr.c   |  4 ++--
 drivers/gpu/drm/i915/intel_sdvo.c  |  8 
 drivers/gpu/drm/i915/intel_tv.c|  2 +-
 15 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 2401818..da9b4fa 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4343,7 +4343,7 @@ void i915_gem_init_swizzling(struct drm_device *dev)
 {
struct drm_i915_private *dev_priv = to_i915(dev);
 
-   if (INTEL_INFO(dev)->gen < 5 ||
+   if (INTEL_GEN(dev_priv) < 5 ||
dev_priv->mm.bit_6_swizzle_x == I915_BIT_6_SWIZZLE_NONE)
return;
 
@@ -4413,7 +4413,7 @@ static void init_unused_rings(struct drm_device *dev)
u32 temp = I915_READ(GEN7_MSG_CTL);
temp &= ~(WAIT_FOR_PCH_FLR_ACK | 
WAIT_FOR_PCH_RESET_ACK);
I915_WRITE(GEN7_MSG_CTL, temp);
-   } else if (INTEL_INFO(dev)->gen >= 7) {
+   } else if (INTEL_GEN(dev_priv) >= 7) {
u32 temp = I915_READ(HSW_NDE_RSTWRN_OPT);
temp &= ~RESET_PCH_HANDSHAKE_ENABLE;
I915_WRITE(HSW_NDE_RSTWRN_OPT, temp);
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c 
b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 9432d4c..b065116 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1460,19 +1460,19 @@ static void eb_export_fence(struct drm_i915_gem_object 
*obj,
}
 
if (instp_mode != dev_priv->relative_constants_mode) {
-   if (INTEL_INFO(dev_priv)->gen < 4) {
+   if (INTEL_GEN(dev_priv) < 4) {
DRM_DEBUG("no rel constants on pre-gen4\n");
return -EINVAL;
}
 
-   if (INTEL_INFO(dev_priv)->gen > 5 &&
+   if (INTEL_GEN(dev_priv) > 5 &&
instp_mode == I915_EXEC_CONSTANTS_REL_SURFACE) {
DRM_DEBUG("rel surface constants mode invalid 
on gen5+\n");
return -EINVAL;
}
 
/* The HW changed the meaning on this bit on gen6 */
-   if (INTEL_INFO(dev_priv)->gen >= 6)
+   if (INTEL_GEN(dev_priv) >= 6)
instp_mask &= ~I915_EXEC_CONSTANTS_REL_SURFACE;
}
break;
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c 
b/drivers/gpu/drm/i915/i915_gem_gtt.c
index e16c380..ba661b9 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2281,7 +2281,7 @@ void i915_gem_suspend_gtt_mappings(struct drm_device *dev)
/* Don't bother messing with faults pre GEN6 as we have little
 * documentation supporting that it's a good idea.
 */
-   if (INTEL_INFO(dev)->gen < 6)
+   if (INTEL_GEN(dev_priv) < 6)
return;
 
i915_check_and_clear_faults(dev_priv);
@@ -3260,7 +3260,7 @@ void i915_gem_restore_gtt_mappings(struct drm_device *dev)
WARN_ON(i915_gem_object_set_to_gtt_domain(obj, false));
}
 
-   

Re: [Intel-gfx] [PATCH] drm/i915: prefer INTEL_GEN(dev_priv) to INTEL_INFO(dev)->gen

2016-06-13 Thread Dave Gordon

On 13/06/16 10:28, Tvrtko Ursulin wrote:


On 10/06/16 18:35, Dave Gordon wrote:

More Coccinellery ...

Wherever we find "INTEL_INFO(dev)->gen", and have a suitable
"dev_priv" in scope, replace it with "INTEL_GEN(dev_priv)".
At this time, we've found 189 instances, and each replacement
saves one memory cycle at runtime and two bytes of codespace
(~360 bytes total text size reduction).

@dev_priv_param@
function FUNC;
idexpression struct drm_device *DEV;
identifier DEV_PRIV;
@@
FUNC(..., struct drm_i915_private *DEV_PRIV, ...)
{
 <...
-   INTEL_INFO(DEV)->gen
+   INTEL_GEN(DEV_PRIV)
 ...>
}

@dev_priv_local@
idexpression struct drm_device *DEV;
identifier DEV_PRIV;
expression E;
@@
{
 ...
(
 struct drm_i915_private *DEV_PRIV;
|
 struct drm_i915_private *DEV_PRIV = E;
)
 <...
-   INTEL_INFO(DEV)->gen
+   INTEL_GEN(DEV_PRIV)
 ...>
}

Plus manual deletion of one now-unused local "dev".

Signed-off-by: Dave Gordon 
---
  drivers/gpu/drm/i915/i915_debugfs.c|  52 +++---
  drivers/gpu/drm/i915/i915_dma.c|  16 ++---
  drivers/gpu/drm/i915/i915_drv.c|   2 +-
  drivers/gpu/drm/i915/i915_gem.c|   4 +-
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   8 +--
  drivers/gpu/drm/i915/i915_gem_fence.c  |   8 +--
  drivers/gpu/drm/i915/i915_gem_gtt.c|  12 ++--
  drivers/gpu/drm/i915/i915_gem_stolen.c |   6 +-
  drivers/gpu/drm/i915/i915_gpu_error.c  |  14 ++--
  drivers/gpu/drm/i915/i915_irq.c|  12 ++--
  drivers/gpu/drm/i915/i915_suspend.c|  20 +++---
  drivers/gpu/drm/i915/intel_color.c |   2 +-
  drivers/gpu/drm/i915/intel_crt.c   |   6 +-
  drivers/gpu/drm/i915/intel_ddi.c   |   4 +-
  drivers/gpu/drm/i915/intel_display.c   | 111 ++---
  drivers/gpu/drm/i915/intel_dp.c|  20 +++---
  drivers/gpu/drm/i915/intel_dpll_mgr.c  |   2 +-
  drivers/gpu/drm/i915/intel_lvds.c  |   4 +-
  drivers/gpu/drm/i915/intel_pm.c|  18 ++---
  drivers/gpu/drm/i915/intel_psr.c   |   4 +-
  drivers/gpu/drm/i915/intel_sdvo.c  |   8 +--
  drivers/gpu/drm/i915/intel_tv.c|   2 +-
  22 files changed, 167 insertions(+), 168 deletions(-)


[snip]


@@ -553,7 +553,7 @@ void i915_gem_restore_fences(struct drm_device *dev)
  uint32_t swizzle_x = I915_BIT_6_SWIZZLE_UNKNOWN;
  uint32_t swizzle_y = I915_BIT_6_SWIZZLE_UNKNOWN;

-if (INTEL_INFO(dev)->gen >= 8 || IS_VALLEYVIEW(dev)) {
+if (INTEL_GEN(dev_priv) >= 8 || IS_VALLEYVIEW(dev)) {


While we are churning :), could looks for both dev_priv and dev in the
same condition like here and tidy those.


[snip]


A few instances of the small comment I made above, which I think would
be a good opportunity. Otherwise all looks OK.

Reviewed-by: Tvrtko Ursulin 

But needs more acks, since last time we discussed this conclusion was it
was too much disruption for the benefit.

Regards,
Tvrtko


Yes, that's why this was a minimal set for replacement of one specific 
but very common idiom that has a definite benefit. At the other extreme, 
I have a Cocci patch to replace *all* INTEL_INFO()->gen with INTEL_GEN() 
and then replace the 'dev' parameter to INTEL_INFO(), INTEL_GEN() and 
all the IS_X() macros wherever possible; but that really is a lot of 
churn for proportionately less benefit. Or we could pick replacements on 
a file-by-file basis rather than according to which macro they use. Or 
maybe one patch each for the big targets (debugfs.c, display.c) and 
another one that does all the files where there are only a few lines of 
changes.


Opinions, anybody?

.Dave.
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH] drm/i915: prefer INTEL_GEN(dev_priv) to INTEL_INFO(dev)->gen

2016-06-13 Thread Tvrtko Ursulin


On 10/06/16 18:35, Dave Gordon wrote:

More Coccinellery ...

Wherever we find "INTEL_INFO(dev)->gen", and have a suitable
"dev_priv" in scope, replace it with "INTEL_GEN(dev_priv)".
At this time, we've found 189 instances, and each replacement
saves one memory cycle at runtime and two bytes of codespace
(~360 bytes total text size reduction).

@dev_priv_param@
function FUNC;
idexpression struct drm_device *DEV;
identifier DEV_PRIV;
@@
FUNC(..., struct drm_i915_private *DEV_PRIV, ...)
{
 <...
-   INTEL_INFO(DEV)->gen
+   INTEL_GEN(DEV_PRIV)
 ...>
}

@dev_priv_local@
idexpression struct drm_device *DEV;
identifier DEV_PRIV;
expression E;
@@
{
 ...
(
 struct drm_i915_private *DEV_PRIV;
|
 struct drm_i915_private *DEV_PRIV = E;
)
 <...
-   INTEL_INFO(DEV)->gen
+   INTEL_GEN(DEV_PRIV)
 ...>
}

Plus manual deletion of one now-unused local "dev".

Signed-off-by: Dave Gordon 
---
  drivers/gpu/drm/i915/i915_debugfs.c|  52 +++---
  drivers/gpu/drm/i915/i915_dma.c|  16 ++---
  drivers/gpu/drm/i915/i915_drv.c|   2 +-
  drivers/gpu/drm/i915/i915_gem.c|   4 +-
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |   8 +--
  drivers/gpu/drm/i915/i915_gem_fence.c  |   8 +--
  drivers/gpu/drm/i915/i915_gem_gtt.c|  12 ++--
  drivers/gpu/drm/i915/i915_gem_stolen.c |   6 +-
  drivers/gpu/drm/i915/i915_gpu_error.c  |  14 ++--
  drivers/gpu/drm/i915/i915_irq.c|  12 ++--
  drivers/gpu/drm/i915/i915_suspend.c|  20 +++---
  drivers/gpu/drm/i915/intel_color.c |   2 +-
  drivers/gpu/drm/i915/intel_crt.c   |   6 +-
  drivers/gpu/drm/i915/intel_ddi.c   |   4 +-
  drivers/gpu/drm/i915/intel_display.c   | 111 ++---
  drivers/gpu/drm/i915/intel_dp.c|  20 +++---
  drivers/gpu/drm/i915/intel_dpll_mgr.c  |   2 +-
  drivers/gpu/drm/i915/intel_lvds.c  |   4 +-
  drivers/gpu/drm/i915/intel_pm.c|  18 ++---
  drivers/gpu/drm/i915/intel_psr.c   |   4 +-
  drivers/gpu/drm/i915/intel_sdvo.c  |   8 +--
  drivers/gpu/drm/i915/intel_tv.c|   2 +-
  22 files changed, 167 insertions(+), 168 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index e4f2c55..6a106d5 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -672,7 +672,7 @@ static int i915_gem_pageflip_info(struct seq_file *m, void 
*data)
   intel_crtc_get_vblank_counter(crtc));
seq_printf(m, "%d prepares\n", 
atomic_read(>pending));

-   if (INTEL_INFO(dev)->gen >= 4)
+   if (INTEL_GEN(dev_priv) >= 4)
addr = 
I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane)));
else
addr = I915_READ(DSPADDR(crtc->plane));
@@ -869,7 +869,7 @@ static int i915_interrupt_info(struct seq_file *m, void 
*data)
   I915_READ(GEN8_PCU_IIR));
seq_printf(m, "PCU interrupt enable:\t%08x\n",
   I915_READ(GEN8_PCU_IER));
-   } else if (INTEL_INFO(dev)->gen >= 8) {
+   } else if (INTEL_GEN(dev_priv) >= 8) {
seq_printf(m, "Master Interrupt Control:\t%08x\n",
   I915_READ(GEN8_MASTER_IRQ));

@@ -995,7 +995,7 @@ static int i915_interrupt_info(struct seq_file *m, void 
*data)
   I915_READ(GTIMR));
}
for_each_engine(engine, dev_priv) {
-   if (INTEL_INFO(dev)->gen >= 6) {
+   if (INTEL_GEN(dev_priv) >= 6) {
seq_printf(m,
   "Graphics Interrupt mask (%s):  %08x\n",
   engine->name, I915_READ_IMR(engine));
@@ -1232,7 +1232,7 @@ static int i915_frequency_info(struct seq_file *m, void 
*unused)
   "efficient (RPe) frequency: %d MHz\n",
   intel_gpu_freq(dev_priv, 
dev_priv->rps.efficient_freq));
mutex_unlock(_priv->rps.hw_lock);
-   } else if (INTEL_INFO(dev)->gen >= 6) {
+   } else if (INTEL_GEN(dev_priv) >= 6) {
u32 rp_state_limits;
u32 gt_perf_status;
u32 rp_state_cap;
@@ -1745,7 +1745,7 @@ static int i915_fbc_fc_get(void *data, u64 *val)
struct drm_device *dev = data;
struct drm_i915_private *dev_priv = dev->dev_private;

-   if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev))
+   if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev))
return -ENODEV;

*val = dev_priv->fbc.false_color;
@@ -1759,7 +1759,7 @@ static int i915_fbc_fc_set(void *data, u64 val)
struct drm_i915_private *dev_priv = dev->dev_private;
u32 reg;

-   if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev))
+   if 

[Intel-gfx] [PATCH] drm/i915: prefer INTEL_GEN(dev_priv) to INTEL_INFO(dev)->gen

2016-06-10 Thread Dave Gordon
More Coccinellery ...

Wherever we find "INTEL_INFO(dev)->gen", and have a suitable
"dev_priv" in scope, replace it with "INTEL_GEN(dev_priv)".
At this time, we've found 189 instances, and each replacement
saves one memory cycle at runtime and two bytes of codespace
(~360 bytes total text size reduction).

@dev_priv_param@
function FUNC;
idexpression struct drm_device *DEV;
identifier DEV_PRIV;
@@
FUNC(..., struct drm_i915_private *DEV_PRIV, ...)
{
<...
-   INTEL_INFO(DEV)->gen
+   INTEL_GEN(DEV_PRIV)
...>
}

@dev_priv_local@
idexpression struct drm_device *DEV;
identifier DEV_PRIV;
expression E;
@@
{
...
(
struct drm_i915_private *DEV_PRIV;
|
struct drm_i915_private *DEV_PRIV = E;
)
<...
-   INTEL_INFO(DEV)->gen
+   INTEL_GEN(DEV_PRIV)
...>
}

Plus manual deletion of one now-unused local "dev".

Signed-off-by: Dave Gordon 
---
 drivers/gpu/drm/i915/i915_debugfs.c|  52 +++---
 drivers/gpu/drm/i915/i915_dma.c|  16 ++---
 drivers/gpu/drm/i915/i915_drv.c|   2 +-
 drivers/gpu/drm/i915/i915_gem.c|   4 +-
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |   8 +--
 drivers/gpu/drm/i915/i915_gem_fence.c  |   8 +--
 drivers/gpu/drm/i915/i915_gem_gtt.c|  12 ++--
 drivers/gpu/drm/i915/i915_gem_stolen.c |   6 +-
 drivers/gpu/drm/i915/i915_gpu_error.c  |  14 ++--
 drivers/gpu/drm/i915/i915_irq.c|  12 ++--
 drivers/gpu/drm/i915/i915_suspend.c|  20 +++---
 drivers/gpu/drm/i915/intel_color.c |   2 +-
 drivers/gpu/drm/i915/intel_crt.c   |   6 +-
 drivers/gpu/drm/i915/intel_ddi.c   |   4 +-
 drivers/gpu/drm/i915/intel_display.c   | 111 ++---
 drivers/gpu/drm/i915/intel_dp.c|  20 +++---
 drivers/gpu/drm/i915/intel_dpll_mgr.c  |   2 +-
 drivers/gpu/drm/i915/intel_lvds.c  |   4 +-
 drivers/gpu/drm/i915/intel_pm.c|  18 ++---
 drivers/gpu/drm/i915/intel_psr.c   |   4 +-
 drivers/gpu/drm/i915/intel_sdvo.c  |   8 +--
 drivers/gpu/drm/i915/intel_tv.c|   2 +-
 22 files changed, 167 insertions(+), 168 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index e4f2c55..6a106d5 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -672,7 +672,7 @@ static int i915_gem_pageflip_info(struct seq_file *m, void 
*data)
   intel_crtc_get_vblank_counter(crtc));
seq_printf(m, "%d prepares\n", 
atomic_read(>pending));
 
-   if (INTEL_INFO(dev)->gen >= 4)
+   if (INTEL_GEN(dev_priv) >= 4)
addr = 
I915_HI_DISPBASE(I915_READ(DSPSURF(crtc->plane)));
else
addr = I915_READ(DSPADDR(crtc->plane));
@@ -869,7 +869,7 @@ static int i915_interrupt_info(struct seq_file *m, void 
*data)
   I915_READ(GEN8_PCU_IIR));
seq_printf(m, "PCU interrupt enable:\t%08x\n",
   I915_READ(GEN8_PCU_IER));
-   } else if (INTEL_INFO(dev)->gen >= 8) {
+   } else if (INTEL_GEN(dev_priv) >= 8) {
seq_printf(m, "Master Interrupt Control:\t%08x\n",
   I915_READ(GEN8_MASTER_IRQ));
 
@@ -995,7 +995,7 @@ static int i915_interrupt_info(struct seq_file *m, void 
*data)
   I915_READ(GTIMR));
}
for_each_engine(engine, dev_priv) {
-   if (INTEL_INFO(dev)->gen >= 6) {
+   if (INTEL_GEN(dev_priv) >= 6) {
seq_printf(m,
   "Graphics Interrupt mask (%s):   %08x\n",
   engine->name, I915_READ_IMR(engine));
@@ -1232,7 +1232,7 @@ static int i915_frequency_info(struct seq_file *m, void 
*unused)
   "efficient (RPe) frequency: %d MHz\n",
   intel_gpu_freq(dev_priv, 
dev_priv->rps.efficient_freq));
mutex_unlock(_priv->rps.hw_lock);
-   } else if (INTEL_INFO(dev)->gen >= 6) {
+   } else if (INTEL_GEN(dev_priv) >= 6) {
u32 rp_state_limits;
u32 gt_perf_status;
u32 rp_state_cap;
@@ -1745,7 +1745,7 @@ static int i915_fbc_fc_get(void *data, u64 *val)
struct drm_device *dev = data;
struct drm_i915_private *dev_priv = dev->dev_private;
 
-   if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev))
+   if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev))
return -ENODEV;
 
*val = dev_priv->fbc.false_color;
@@ -1759,7 +1759,7 @@ static int i915_fbc_fc_set(void *data, u64 val)
struct drm_i915_private *dev_priv = dev->dev_private;
u32 reg;
 
-   if (INTEL_INFO(dev)->gen < 7 || !HAS_FBC(dev))
+   if (INTEL_GEN(dev_priv) < 7 || !HAS_FBC(dev))