diff mbox series

[RESEND] drm/i915: add display engine uncore helpers

Message ID 20200121113915.9813-1-jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series [RESEND] drm/i915: add display engine uncore helpers | expand

Commit Message

Jani Nikula Jan. 21, 2020, 11:39 a.m. UTC
Add convenience helpers for the most common uncore operations with
struct drm_i915_private * as context rather than struct intel_uncore *.

The goal is to replace all instances of I915_READ(),
I915_POSTING_READ(), I915_WRITE(), I915_READ_FW(), and I915_WRITE_FW()
in display/ with these, to finally be able to get rid of the implicit
dev_priv local parameter use.

The idea is that any non-u32 reads or writes are special enough that
they can use the intel_uncore_* functions directly.

v2:
- rename the file intel_de.h
- move intel_de_wait_for_* there too
- also add de fw helpers

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/display/intel_de.h       | 72 +++++++++++++++++++
 .../drm/i915/display/intel_display_types.h    |  1 +
 drivers/gpu/drm/i915/i915_drv.h               | 14 ----
 3 files changed, 73 insertions(+), 14 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/display/intel_de.h

Comments

Chris Wilson Jan. 21, 2020, 1:03 p.m. UTC | #1
Quoting Jani Nikula (2020-01-21 11:39:15)
> Add convenience helpers for the most common uncore operations with
> struct drm_i915_private * as context rather than struct intel_uncore *.
> 
> The goal is to replace all instances of I915_READ(),
> I915_POSTING_READ(), I915_WRITE(), I915_READ_FW(), and I915_WRITE_FW()
> in display/ with these, to finally be able to get rid of the implicit
> dev_priv local parameter use.
> 
> The idea is that any non-u32 reads or writes are special enough that
> they can use the intel_uncore_* functions directly.
> 
> v2:
> - rename the file intel_de.h
> - move intel_de_wait_for_* there too
> - also add de fw helpers
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_de.h       | 72 +++++++++++++++++++
>  .../drm/i915/display/intel_display_types.h    |  1 +
>  drivers/gpu/drm/i915/i915_drv.h               | 14 ----
>  3 files changed, 73 insertions(+), 14 deletions(-)
>  create mode 100644 drivers/gpu/drm/i915/display/intel_de.h
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_de.h b/drivers/gpu/drm/i915/display/intel_de.h
> new file mode 100644
> index 000000000000..00da10bf35f5
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/display/intel_de.h
> @@ -0,0 +1,72 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2019 Intel Corporation
> + */
> +
> +#ifndef __INTEL_DE_H__
> +#define __INTEL_DE_H__
> +
> +#include "i915_drv.h"
> +#include "i915_reg.h"
> +#include "intel_uncore.h"
> +
> +static inline u32
> +intel_de_read(struct drm_i915_private *i915, i915_reg_t reg)
> +{
> +       return intel_uncore_read(&i915->uncore, reg);
> +}
> +
> +static inline void
> +intel_de_posting_read(struct drm_i915_private *i915, i915_reg_t reg)
> +{
> +       intel_uncore_posting_read(&i915->uncore, reg);
> +}
> +
> +/* Note: read the warnings for intel_uncore_*_fw() functions! */
> +static inline u32
> +intel_de_read_fw(struct drm_i915_private *i915, i915_reg_t reg)
> +{
> +       return intel_uncore_read_fw(&i915->uncore, reg);
> +}
> +
> +static inline void
> +intel_de_write(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
> +{
> +       intel_uncore_write(&i915->uncore, reg, val);
> +}
> +
> +/* Note: read the warnings for intel_uncore_*_fw() functions! */
> +static inline void
> +intel_de_write_fw(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
> +{
> +       intel_uncore_write_fw(&i915->uncore, reg, val);
> +}
> +
> +static inline void
> +intel_de_rmw(struct drm_i915_private *i915, i915_reg_t reg, u32 clear, u32 set)
> +{
> +       intel_uncore_rmw(&i915->uncore, reg, clear, set);
> +}
> +
> +static inline int
> +intel_de_wait_for_register(struct drm_i915_private *i915, i915_reg_t reg,
> +                          u32 mask, u32 value, unsigned int timeout)
> +{
> +       return intel_wait_for_register(&i915->uncore, reg, mask, value, timeout);
> +}
> +
> +static inline int
> +intel_de_wait_for_set(struct drm_i915_private *i915, i915_reg_t reg,
> +                     u32 mask, unsigned int timeout)
> +{
> +       return intel_de_wait_for_register(i915, reg, mask, mask, timeout);
> +}
> +
> +static inline int
> +intel_de_wait_for_clear(struct drm_i915_private *i915, i915_reg_t reg,
> +                       u32 mask, unsigned int timeout)
> +{
> +       return intel_de_wait_for_register(i915, reg, mask, 0, timeout);
> +}
> +
> +#endif /* __INTEL_DE_H__ */
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> index 155ce49ae764..0d7adc2c167a 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -44,6 +44,7 @@
>  #include <media/cec-notifier.h>
>  
>  #include "i915_drv.h"
> +#include "intel_de.h"

I don't think you want to include it from types.h though -- I think you
want to avoid inlines (at least inlines that depend upon external types)
away from the types.h so you can avoid the dreaded cycles.

So other than that,
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Or you may want to make the placement of the final include(s) a
separate patch.
-Chris
Jani Nikula Jan. 21, 2020, 1:58 p.m. UTC | #2
On Tue, 21 Jan 2020, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Quoting Jani Nikula (2020-01-21 11:39:15)
>> Add convenience helpers for the most common uncore operations with
>> struct drm_i915_private * as context rather than struct intel_uncore *.
>> 
>> The goal is to replace all instances of I915_READ(),
>> I915_POSTING_READ(), I915_WRITE(), I915_READ_FW(), and I915_WRITE_FW()
>> in display/ with these, to finally be able to get rid of the implicit
>> dev_priv local parameter use.
>> 
>> The idea is that any non-u32 reads or writes are special enough that
>> they can use the intel_uncore_* functions directly.
>> 
>> v2:
>> - rename the file intel_de.h
>> - move intel_de_wait_for_* there too
>> - also add de fw helpers
>> 
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
>> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>>  drivers/gpu/drm/i915/display/intel_de.h       | 72 +++++++++++++++++++
>>  .../drm/i915/display/intel_display_types.h    |  1 +
>>  drivers/gpu/drm/i915/i915_drv.h               | 14 ----
>>  3 files changed, 73 insertions(+), 14 deletions(-)
>>  create mode 100644 drivers/gpu/drm/i915/display/intel_de.h
>> 
>> diff --git a/drivers/gpu/drm/i915/display/intel_de.h b/drivers/gpu/drm/i915/display/intel_de.h
>> new file mode 100644
>> index 000000000000..00da10bf35f5
>> --- /dev/null
>> +++ b/drivers/gpu/drm/i915/display/intel_de.h
>> @@ -0,0 +1,72 @@
>> +/* SPDX-License-Identifier: MIT */
>> +/*
>> + * Copyright © 2019 Intel Corporation
>> + */
>> +
>> +#ifndef __INTEL_DE_H__
>> +#define __INTEL_DE_H__
>> +
>> +#include "i915_drv.h"
>> +#include "i915_reg.h"
>> +#include "intel_uncore.h"
>> +
>> +static inline u32
>> +intel_de_read(struct drm_i915_private *i915, i915_reg_t reg)
>> +{
>> +       return intel_uncore_read(&i915->uncore, reg);
>> +}
>> +
>> +static inline void
>> +intel_de_posting_read(struct drm_i915_private *i915, i915_reg_t reg)
>> +{
>> +       intel_uncore_posting_read(&i915->uncore, reg);
>> +}
>> +
>> +/* Note: read the warnings for intel_uncore_*_fw() functions! */
>> +static inline u32
>> +intel_de_read_fw(struct drm_i915_private *i915, i915_reg_t reg)
>> +{
>> +       return intel_uncore_read_fw(&i915->uncore, reg);
>> +}
>> +
>> +static inline void
>> +intel_de_write(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
>> +{
>> +       intel_uncore_write(&i915->uncore, reg, val);
>> +}
>> +
>> +/* Note: read the warnings for intel_uncore_*_fw() functions! */
>> +static inline void
>> +intel_de_write_fw(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
>> +{
>> +       intel_uncore_write_fw(&i915->uncore, reg, val);
>> +}
>> +
>> +static inline void
>> +intel_de_rmw(struct drm_i915_private *i915, i915_reg_t reg, u32 clear, u32 set)
>> +{
>> +       intel_uncore_rmw(&i915->uncore, reg, clear, set);
>> +}
>> +
>> +static inline int
>> +intel_de_wait_for_register(struct drm_i915_private *i915, i915_reg_t reg,
>> +                          u32 mask, u32 value, unsigned int timeout)
>> +{
>> +       return intel_wait_for_register(&i915->uncore, reg, mask, value, timeout);
>> +}
>> +
>> +static inline int
>> +intel_de_wait_for_set(struct drm_i915_private *i915, i915_reg_t reg,
>> +                     u32 mask, unsigned int timeout)
>> +{
>> +       return intel_de_wait_for_register(i915, reg, mask, mask, timeout);
>> +}
>> +
>> +static inline int
>> +intel_de_wait_for_clear(struct drm_i915_private *i915, i915_reg_t reg,
>> +                       u32 mask, unsigned int timeout)
>> +{
>> +       return intel_de_wait_for_register(i915, reg, mask, 0, timeout);
>> +}
>> +
>> +#endif /* __INTEL_DE_H__ */
>> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
>> index 155ce49ae764..0d7adc2c167a 100644
>> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
>> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
>> @@ -44,6 +44,7 @@
>>  #include <media/cec-notifier.h>
>>  
>>  #include "i915_drv.h"
>> +#include "intel_de.h"
>
> I don't think you want to include it from types.h though -- I think you
> want to avoid inlines (at least inlines that depend upon external types)
> away from the types.h so you can avoid the dreaded cycles.

Eventually yes, but I also don't want to splatter #include "intel_de.h"
everywhere just yet... this seemed to fit the bill. ;)

> So other than that,
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>
> Or you may want to make the placement of the final include(s) a
> separate patch.

Thanks for the review. Do you insist on a re-spin with the includes
sorted out before merge?

BR,
Jani.
Chris Wilson Jan. 21, 2020, 2:11 p.m. UTC | #3
Quoting Jani Nikula (2020-01-21 13:58:08)
> On Tue, 21 Jan 2020, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> > Quoting Jani Nikula (2020-01-21 11:39:15)
> >> Add convenience helpers for the most common uncore operations with
> >> struct drm_i915_private * as context rather than struct intel_uncore *.
> >> 
> >> The goal is to replace all instances of I915_READ(),
> >> I915_POSTING_READ(), I915_WRITE(), I915_READ_FW(), and I915_WRITE_FW()
> >> in display/ with these, to finally be able to get rid of the implicit
> >> dev_priv local parameter use.
> >> 
> >> The idea is that any non-u32 reads or writes are special enough that
> >> they can use the intel_uncore_* functions directly.
> >> 
> >> v2:
> >> - rename the file intel_de.h
> >> - move intel_de_wait_for_* there too
> >> - also add de fw helpers
> >> 
> >> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> >> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> >> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> >> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> >> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> >> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> >> ---
> >>  drivers/gpu/drm/i915/display/intel_de.h       | 72 +++++++++++++++++++
> >>  .../drm/i915/display/intel_display_types.h    |  1 +
> >>  drivers/gpu/drm/i915/i915_drv.h               | 14 ----
> >>  3 files changed, 73 insertions(+), 14 deletions(-)
> >>  create mode 100644 drivers/gpu/drm/i915/display/intel_de.h
> >> 
> >> diff --git a/drivers/gpu/drm/i915/display/intel_de.h b/drivers/gpu/drm/i915/display/intel_de.h
> >> new file mode 100644
> >> index 000000000000..00da10bf35f5
> >> --- /dev/null
> >> +++ b/drivers/gpu/drm/i915/display/intel_de.h
> >> @@ -0,0 +1,72 @@
> >> +/* SPDX-License-Identifier: MIT */
> >> +/*
> >> + * Copyright © 2019 Intel Corporation
> >> + */
> >> +
> >> +#ifndef __INTEL_DE_H__
> >> +#define __INTEL_DE_H__
> >> +
> >> +#include "i915_drv.h"
> >> +#include "i915_reg.h"
> >> +#include "intel_uncore.h"
> >> +
> >> +static inline u32
> >> +intel_de_read(struct drm_i915_private *i915, i915_reg_t reg)
> >> +{
> >> +       return intel_uncore_read(&i915->uncore, reg);
> >> +}
> >> +
> >> +static inline void
> >> +intel_de_posting_read(struct drm_i915_private *i915, i915_reg_t reg)
> >> +{
> >> +       intel_uncore_posting_read(&i915->uncore, reg);
> >> +}
> >> +
> >> +/* Note: read the warnings for intel_uncore_*_fw() functions! */
> >> +static inline u32
> >> +intel_de_read_fw(struct drm_i915_private *i915, i915_reg_t reg)
> >> +{
> >> +       return intel_uncore_read_fw(&i915->uncore, reg);
> >> +}
> >> +
> >> +static inline void
> >> +intel_de_write(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
> >> +{
> >> +       intel_uncore_write(&i915->uncore, reg, val);
> >> +}
> >> +
> >> +/* Note: read the warnings for intel_uncore_*_fw() functions! */
> >> +static inline void
> >> +intel_de_write_fw(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
> >> +{
> >> +       intel_uncore_write_fw(&i915->uncore, reg, val);
> >> +}
> >> +
> >> +static inline void
> >> +intel_de_rmw(struct drm_i915_private *i915, i915_reg_t reg, u32 clear, u32 set)
> >> +{
> >> +       intel_uncore_rmw(&i915->uncore, reg, clear, set);
> >> +}
> >> +
> >> +static inline int
> >> +intel_de_wait_for_register(struct drm_i915_private *i915, i915_reg_t reg,
> >> +                          u32 mask, u32 value, unsigned int timeout)
> >> +{
> >> +       return intel_wait_for_register(&i915->uncore, reg, mask, value, timeout);
> >> +}
> >> +
> >> +static inline int
> >> +intel_de_wait_for_set(struct drm_i915_private *i915, i915_reg_t reg,
> >> +                     u32 mask, unsigned int timeout)
> >> +{
> >> +       return intel_de_wait_for_register(i915, reg, mask, mask, timeout);
> >> +}
> >> +
> >> +static inline int
> >> +intel_de_wait_for_clear(struct drm_i915_private *i915, i915_reg_t reg,
> >> +                       u32 mask, unsigned int timeout)
> >> +{
> >> +       return intel_de_wait_for_register(i915, reg, mask, 0, timeout);
> >> +}
> >> +
> >> +#endif /* __INTEL_DE_H__ */
> >> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> >> index 155ce49ae764..0d7adc2c167a 100644
> >> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> >> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> >> @@ -44,6 +44,7 @@
> >>  #include <media/cec-notifier.h>
> >>  
> >>  #include "i915_drv.h"
> >> +#include "intel_de.h"
> >
> > I don't think you want to include it from types.h though -- I think you
> > want to avoid inlines (at least inlines that depend upon external types)
> > away from the types.h so you can avoid the dreaded cycles.
> 
> Eventually yes, but I also don't want to splatter #include "intel_de.h"
> everywhere just yet... this seemed to fit the bill. ;)
> 
> > So other than that,
> > Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> >
> > Or you may want to make the placement of the final include(s) a
> > separate patch.
> 
> Thanks for the review. Do you insist on a re-spin with the includes
> sorted out before merge?

Nope. So long as you are aware that the current placement can easily lead
into a trap, fine.
-Chris
Jani Nikula Jan. 23, 2020, 9:36 a.m. UTC | #4
On Tue, 21 Jan 2020, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Quoting Jani Nikula (2020-01-21 13:58:08)
>> On Tue, 21 Jan 2020, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>> > Quoting Jani Nikula (2020-01-21 11:39:15)
>> >> Add convenience helpers for the most common uncore operations with
>> >> struct drm_i915_private * as context rather than struct intel_uncore *.
>> >> 
>> >> The goal is to replace all instances of I915_READ(),
>> >> I915_POSTING_READ(), I915_WRITE(), I915_READ_FW(), and I915_WRITE_FW()
>> >> in display/ with these, to finally be able to get rid of the implicit
>> >> dev_priv local parameter use.
>> >> 
>> >> The idea is that any non-u32 reads or writes are special enough that
>> >> they can use the intel_uncore_* functions directly.
>> >> 
>> >> v2:
>> >> - rename the file intel_de.h
>> >> - move intel_de_wait_for_* there too
>> >> - also add de fw helpers
>> >> 
>> >> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> >> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
>> >> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
>> >> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
>> >> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
>> >> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> >> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> >> ---
>> >>  drivers/gpu/drm/i915/display/intel_de.h       | 72 +++++++++++++++++++
>> >>  .../drm/i915/display/intel_display_types.h    |  1 +
>> >>  drivers/gpu/drm/i915/i915_drv.h               | 14 ----
>> >>  3 files changed, 73 insertions(+), 14 deletions(-)
>> >>  create mode 100644 drivers/gpu/drm/i915/display/intel_de.h
>> >> 
>> >> diff --git a/drivers/gpu/drm/i915/display/intel_de.h b/drivers/gpu/drm/i915/display/intel_de.h
>> >> new file mode 100644
>> >> index 000000000000..00da10bf35f5
>> >> --- /dev/null
>> >> +++ b/drivers/gpu/drm/i915/display/intel_de.h
>> >> @@ -0,0 +1,72 @@
>> >> +/* SPDX-License-Identifier: MIT */
>> >> +/*
>> >> + * Copyright © 2019 Intel Corporation
>> >> + */
>> >> +
>> >> +#ifndef __INTEL_DE_H__
>> >> +#define __INTEL_DE_H__
>> >> +
>> >> +#include "i915_drv.h"
>> >> +#include "i915_reg.h"
>> >> +#include "intel_uncore.h"
>> >> +
>> >> +static inline u32
>> >> +intel_de_read(struct drm_i915_private *i915, i915_reg_t reg)
>> >> +{
>> >> +       return intel_uncore_read(&i915->uncore, reg);
>> >> +}
>> >> +
>> >> +static inline void
>> >> +intel_de_posting_read(struct drm_i915_private *i915, i915_reg_t reg)
>> >> +{
>> >> +       intel_uncore_posting_read(&i915->uncore, reg);
>> >> +}
>> >> +
>> >> +/* Note: read the warnings for intel_uncore_*_fw() functions! */
>> >> +static inline u32
>> >> +intel_de_read_fw(struct drm_i915_private *i915, i915_reg_t reg)
>> >> +{
>> >> +       return intel_uncore_read_fw(&i915->uncore, reg);
>> >> +}
>> >> +
>> >> +static inline void
>> >> +intel_de_write(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
>> >> +{
>> >> +       intel_uncore_write(&i915->uncore, reg, val);
>> >> +}
>> >> +
>> >> +/* Note: read the warnings for intel_uncore_*_fw() functions! */
>> >> +static inline void
>> >> +intel_de_write_fw(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
>> >> +{
>> >> +       intel_uncore_write_fw(&i915->uncore, reg, val);
>> >> +}
>> >> +
>> >> +static inline void
>> >> +intel_de_rmw(struct drm_i915_private *i915, i915_reg_t reg, u32 clear, u32 set)
>> >> +{
>> >> +       intel_uncore_rmw(&i915->uncore, reg, clear, set);
>> >> +}
>> >> +
>> >> +static inline int
>> >> +intel_de_wait_for_register(struct drm_i915_private *i915, i915_reg_t reg,
>> >> +                          u32 mask, u32 value, unsigned int timeout)
>> >> +{
>> >> +       return intel_wait_for_register(&i915->uncore, reg, mask, value, timeout);
>> >> +}
>> >> +
>> >> +static inline int
>> >> +intel_de_wait_for_set(struct drm_i915_private *i915, i915_reg_t reg,
>> >> +                     u32 mask, unsigned int timeout)
>> >> +{
>> >> +       return intel_de_wait_for_register(i915, reg, mask, mask, timeout);
>> >> +}
>> >> +
>> >> +static inline int
>> >> +intel_de_wait_for_clear(struct drm_i915_private *i915, i915_reg_t reg,
>> >> +                       u32 mask, unsigned int timeout)
>> >> +{
>> >> +       return intel_de_wait_for_register(i915, reg, mask, 0, timeout);
>> >> +}
>> >> +
>> >> +#endif /* __INTEL_DE_H__ */
>> >> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
>> >> index 155ce49ae764..0d7adc2c167a 100644
>> >> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
>> >> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
>> >> @@ -44,6 +44,7 @@
>> >>  #include <media/cec-notifier.h>
>> >>  
>> >>  #include "i915_drv.h"
>> >> +#include "intel_de.h"
>> >
>> > I don't think you want to include it from types.h though -- I think you
>> > want to avoid inlines (at least inlines that depend upon external types)
>> > away from the types.h so you can avoid the dreaded cycles.
>> 
>> Eventually yes, but I also don't want to splatter #include "intel_de.h"
>> everywhere just yet... this seemed to fit the bill. ;)
>> 
>> > So other than that,
>> > Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>> >
>> > Or you may want to make the placement of the final include(s) a
>> > separate patch.
>> 
>> Thanks for the review. Do you insist on a re-spin with the includes
>> sorted out before merge?
>
> Nope. So long as you are aware that the current placement can easily lead
> into a trap, fine.

Thanks, and pushed to dinq.

Time to unleash cocci to rid us of I915_READ, I915_WRITE, and friends
also in display/.

BR,
Jani.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_de.h b/drivers/gpu/drm/i915/display/intel_de.h
new file mode 100644
index 000000000000..00da10bf35f5
--- /dev/null
+++ b/drivers/gpu/drm/i915/display/intel_de.h
@@ -0,0 +1,72 @@ 
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __INTEL_DE_H__
+#define __INTEL_DE_H__
+
+#include "i915_drv.h"
+#include "i915_reg.h"
+#include "intel_uncore.h"
+
+static inline u32
+intel_de_read(struct drm_i915_private *i915, i915_reg_t reg)
+{
+	return intel_uncore_read(&i915->uncore, reg);
+}
+
+static inline void
+intel_de_posting_read(struct drm_i915_private *i915, i915_reg_t reg)
+{
+	intel_uncore_posting_read(&i915->uncore, reg);
+}
+
+/* Note: read the warnings for intel_uncore_*_fw() functions! */
+static inline u32
+intel_de_read_fw(struct drm_i915_private *i915, i915_reg_t reg)
+{
+	return intel_uncore_read_fw(&i915->uncore, reg);
+}
+
+static inline void
+intel_de_write(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
+{
+	intel_uncore_write(&i915->uncore, reg, val);
+}
+
+/* Note: read the warnings for intel_uncore_*_fw() functions! */
+static inline void
+intel_de_write_fw(struct drm_i915_private *i915, i915_reg_t reg, u32 val)
+{
+	intel_uncore_write_fw(&i915->uncore, reg, val);
+}
+
+static inline void
+intel_de_rmw(struct drm_i915_private *i915, i915_reg_t reg, u32 clear, u32 set)
+{
+	intel_uncore_rmw(&i915->uncore, reg, clear, set);
+}
+
+static inline int
+intel_de_wait_for_register(struct drm_i915_private *i915, i915_reg_t reg,
+			   u32 mask, u32 value, unsigned int timeout)
+{
+	return intel_wait_for_register(&i915->uncore, reg, mask, value, timeout);
+}
+
+static inline int
+intel_de_wait_for_set(struct drm_i915_private *i915, i915_reg_t reg,
+		      u32 mask, unsigned int timeout)
+{
+	return intel_de_wait_for_register(i915, reg, mask, mask, timeout);
+}
+
+static inline int
+intel_de_wait_for_clear(struct drm_i915_private *i915, i915_reg_t reg,
+			u32 mask, unsigned int timeout)
+{
+	return intel_de_wait_for_register(i915, reg, mask, 0, timeout);
+}
+
+#endif /* __INTEL_DE_H__ */
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 155ce49ae764..0d7adc2c167a 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -44,6 +44,7 @@ 
 #include <media/cec-notifier.h>
 
 #include "i915_drv.h"
+#include "intel_de.h"
 
 struct drm_printer;
 
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 077af22b8340..16f6e957f821 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2010,20 +2010,6 @@  int i915_reg_read_ioctl(struct drm_device *dev, void *data,
 #define I915_READ_FW(reg__) __I915_REG_OP(read_fw, dev_priv, (reg__))
 #define I915_WRITE_FW(reg__, val__) __I915_REG_OP(write_fw, dev_priv, (reg__), (val__))
 
-/* register wait wrappers for display regs */
-#define intel_de_wait_for_register(dev_priv_, reg_, mask_, value_, timeout_) \
-	intel_wait_for_register(&(dev_priv_)->uncore, \
-				(reg_), (mask_), (value_), (timeout_))
-
-#define intel_de_wait_for_set(dev_priv_, reg_, mask_, timeout_) ({	\
-	u32 mask__ = (mask_);						\
-	intel_de_wait_for_register((dev_priv_), (reg_),			\
-				   mask__, mask__, (timeout_)); \
-})
-
-#define intel_de_wait_for_clear(dev_priv_, reg_, mask_, timeout_) \
-	intel_de_wait_for_register((dev_priv_), (reg_), (mask_), 0, (timeout_))
-
 /* i915_mm.c */
 int remap_io_mapping(struct vm_area_struct *vma,
 		     unsigned long addr, unsigned long pfn, unsigned long size,