From: Paulo Zanoni <paulo.r.zanoni@intel.com>
To: Imre Deak <imre.deak@intel.com>, intel-gfx@lists.freedesktop.org
Cc: Jani Nikula <jani.nikula@intel.com>
Subject: Re: [PATCH 05/10] drm/i915/vlv: Use power well CTL IDX instead of ID
Date: Wed, 01 Aug 2018 15:15:40 -0700 [thread overview]
Message-ID: <1533161740.2571.18.camel@intel.com> (raw)
In-Reply-To: <20180720141504.22832-6-imre.deak@intel.com>
Em Sex, 2018-07-20 às 17:14 +0300, Imre Deak escreveu:
> Atm, we determine the control/status flag offsets within the PUNIT
> control/status registers based on the power well's ID. Since the
> power
> well ID enum is global across all platforms, the associated macros to
> get the flag offsets involves some magic. This makes checking the
> register/bit definitions against the specification more difficult
> than
> necessary. Also the values in the power well ID enum must stay fixed,
> making code maintenance of the enum cumbersome.
>
> To solve the above define the control/status flag indices right after
> the corresponding registers and use these to derive the
> control/status
> flag values by storing the indices in the i915_power_well_desc
> struct.
>
> Initializing anonymous unions requires - even named - initializers to
> be in order of the struct declaration, hence the reordering of the
> .id
> fields.
My C-fu is not as strong as I thought it was. After some playing with
this it seems the only requirement is to initialize the enum exactly
after .id. Ok.
But then, since we're reordering anyway, shouldn't we also move .ops
down when relevant, and keep the ordering "perfect" for every member?
Anyway, the patch does what it says, so with or without the new color:
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
> drivers/gpu/drm/i915/i915_drv.h | 7 +++++
> drivers/gpu/drm/i915/i915_reg.h | 22 ++++++++++----
> drivers/gpu/drm/i915/intel_runtime_pm.c | 52
> ++++++++++++++++++++++++---------
> 3 files changed, 62 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h
> b/drivers/gpu/drm/i915/i915_drv.h
> index 3ae200a9e8f1..d31a8ef05d18 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -874,6 +874,13 @@ struct i915_power_well_desc {
> */
> union {
> struct {
> + /*
> + * request/status flag index in the PUNIT
> power well
> + * control/status registers.
> + */
> + u8 idx;
> + } vlv;
> + struct {
> enum dpio_phy phy;
> } bxt;
> struct {
> diff --git a/drivers/gpu/drm/i915/i915_reg.h
> b/drivers/gpu/drm/i915/i915_reg.h
> index 8af945d8a995..f76bb4f3c944 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -1144,11 +1144,23 @@ enum i915_power_well_id {
>
> #define PUNIT_REG_PWRGT_CTRL 0x60
> #define PUNIT_REG_PWRGT_STATUS 0x61
> -#define PUNIT_PWRGT_MASK(power_well) (3 <<
> ((power_well) * 2))
> -#define PUNIT_PWRGT_PWR_ON(power_well) (0 << ((power_well)
> * 2))
> -#define PUNIT_PWRGT_CLK_GATE(power_well) (1 <<
> ((power_well) * 2))
> -#define PUNIT_PWRGT_RESET(power_well) (2 <<
> ((power_well) * 2))
> -#define PUNIT_PWRGT_PWR_GATE(power_well) (3 <<
> ((power_well) * 2))
> +#define PUNIT_PWRGT_MASK(pw_idx) (3 << ((pw_idx) *
> 2))
> +#define PUNIT_PWRGT_PWR_ON(pw_idx) (0 << ((pw_idx)
> * 2))
> +#define PUNIT_PWRGT_CLK_GATE(pw_idx) (1 <<
> ((pw_idx) * 2))
> +#define PUNIT_PWRGT_RESET(pw_idx) (2 << ((pw_idx) *
> 2))
> +#define PUNIT_PWRGT_PWR_GATE(pw_idx) (3 <<
> ((pw_idx) * 2))
> +
> +#define PUNIT_PWGT_IDX_RENDER 0
> +#define PUNIT_PWGT_IDX_MEDIA 1
> +#define PUNIT_PWGT_IDX_DISP2D 3
> +#define PUNIT_PWGT_IDX_DPIO_CMN_BC 5
> +#define PUNIT_PWGT_IDX_DPIO_TX_B_LANES_01 6
> +#define PUNIT_PWGT_IDX_DPIO_TX_B_LANES_23 7
> +#define PUNIT_PWGT_IDX_DPIO_TX_C_LANES_01 8
> +#define PUNIT_PWGT_IDX_DPIO_TX_C_LANES_23 9
> +#define PUNIT_PWGT_IDX_DPIO_RX0 10
> +#define PUNIT_PWGT_IDX_DPIO_RX1 11
> +#define PUNIT_PWGT_IDX_DPIO_CMN_D 12
>
> #define PUNIT_REG_GPU_LFM 0xd3
> #define PUNIT_REG_GPU_FREQ_REQ 0xd4
> diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c
> b/drivers/gpu/drm/i915/intel_runtime_pm.c
> index 8b3c241bee55..05d8cdab08cc 100644
> --- a/drivers/gpu/drm/i915/intel_runtime_pm.c
> +++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
> @@ -872,14 +872,14 @@ static void
> i830_pipes_power_well_sync_hw(struct drm_i915_private *dev_priv,
> static void vlv_set_power_well(struct drm_i915_private *dev_priv,
> struct i915_power_well *power_well,
> bool enable)
> {
> - enum i915_power_well_id power_well_id = power_well->desc-
> >id;
> + int pw_idx = power_well->desc->vlv.idx;
> u32 mask;
> u32 state;
> u32 ctrl;
>
> - mask = PUNIT_PWRGT_MASK(power_well_id);
> - state = enable ? PUNIT_PWRGT_PWR_ON(power_well_id) :
> - PUNIT_PWRGT_PWR_GATE(power_well_id);
> + mask = PUNIT_PWRGT_MASK(pw_idx);
> + state = enable ? PUNIT_PWRGT_PWR_ON(pw_idx) :
> + PUNIT_PWRGT_PWR_GATE(pw_idx);
>
> mutex_lock(&dev_priv->pcu_lock);
>
> @@ -920,14 +920,14 @@ static void vlv_power_well_disable(struct
> drm_i915_private *dev_priv,
> static bool vlv_power_well_enabled(struct drm_i915_private
> *dev_priv,
> struct i915_power_well
> *power_well)
> {
> - enum i915_power_well_id power_well_id = power_well->desc-
> >id;
> + int pw_idx = power_well->desc->vlv.idx;
> bool enabled = false;
> u32 mask;
> u32 state;
> u32 ctrl;
>
> - mask = PUNIT_PWRGT_MASK(power_well_id);
> - ctrl = PUNIT_PWRGT_PWR_ON(power_well_id);
> + mask = PUNIT_PWRGT_MASK(pw_idx);
> + ctrl = PUNIT_PWRGT_PWR_ON(pw_idx);
>
> mutex_lock(&dev_priv->pcu_lock);
>
> @@ -936,8 +936,8 @@ static bool vlv_power_well_enabled(struct
> drm_i915_private *dev_priv,
> * We only ever set the power-on and power-gate states,
> anything
> * else is unexpected.
> */
> - WARN_ON(state != PUNIT_PWRGT_PWR_ON(power_well_id) &&
> - state != PUNIT_PWRGT_PWR_GATE(power_well_id));
> + WARN_ON(state != PUNIT_PWRGT_PWR_ON(pw_idx) &&
> + state != PUNIT_PWRGT_PWR_GATE(pw_idx));
> if (state == ctrl)
> enabled = true;
>
> @@ -2179,8 +2179,11 @@ static const struct i915_power_well_desc
> vlv_power_wells[] = {
> {
> .name = "display",
> .domains = VLV_DISPLAY_POWER_DOMAINS,
> - .id = PUNIT_POWER_WELL_DISP2D,
> .ops = &vlv_display_power_well_ops,
> + .id = PUNIT_POWER_WELL_DISP2D,
> + {
> + .vlv.idx = PUNIT_PWGT_IDX_DISP2D,
> + },
> },
> {
> .name = "dpio-tx-b-01",
> @@ -2190,6 +2193,9 @@ static const struct i915_power_well_desc
> vlv_power_wells[] = {
> VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS,
> .ops = &vlv_dpio_power_well_ops,
> .id = PUNIT_POWER_WELL_DPIO_TX_B_LANES_01,
> + {
> + .vlv.idx =
> PUNIT_PWGT_IDX_DPIO_TX_B_LANES_01,
> + },
> },
> {
> .name = "dpio-tx-b-23",
> @@ -2199,6 +2205,9 @@ static const struct i915_power_well_desc
> vlv_power_wells[] = {
> VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS,
> .ops = &vlv_dpio_power_well_ops,
> .id = PUNIT_POWER_WELL_DPIO_TX_B_LANES_23,
> + {
> + .vlv.idx =
> PUNIT_PWGT_IDX_DPIO_TX_B_LANES_23,
> + },
> },
> {
> .name = "dpio-tx-c-01",
> @@ -2208,6 +2217,9 @@ static const struct i915_power_well_desc
> vlv_power_wells[] = {
> VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS,
> .ops = &vlv_dpio_power_well_ops,
> .id = PUNIT_POWER_WELL_DPIO_TX_C_LANES_01,
> + {
> + .vlv.idx =
> PUNIT_PWGT_IDX_DPIO_TX_C_LANES_01,
> + },
> },
> {
> .name = "dpio-tx-c-23",
> @@ -2217,12 +2229,18 @@ static const struct i915_power_well_desc
> vlv_power_wells[] = {
> VLV_DPIO_TX_C_LANES_23_POWER_DOMAINS,
> .ops = &vlv_dpio_power_well_ops,
> .id = PUNIT_POWER_WELL_DPIO_TX_C_LANES_23,
> + {
> + .vlv.idx =
> PUNIT_PWGT_IDX_DPIO_TX_C_LANES_23,
> + },
> },
> {
> .name = "dpio-common",
> .domains = VLV_DPIO_CMN_BC_POWER_DOMAINS,
> - .id = PUNIT_POWER_WELL_DPIO_CMN_BC,
> .ops = &vlv_dpio_cmn_power_well_ops,
> + .id = PUNIT_POWER_WELL_DPIO_CMN_BC,
> + {
> + .vlv.idx = PUNIT_PWGT_IDX_DPIO_CMN_BC,
> + },
> },
> };
>
> @@ -2242,20 +2260,26 @@ static const struct i915_power_well_desc
> chv_power_wells[] = {
> * required for any pipe to work.
> */
> .domains = CHV_DISPLAY_POWER_DOMAINS,
> - .id = CHV_DISP_PW_PIPE_A,
> .ops = &chv_pipe_power_well_ops,
> + .id = CHV_DISP_PW_PIPE_A,
> },
> {
> .name = "dpio-common-bc",
> .domains = CHV_DPIO_CMN_BC_POWER_DOMAINS,
> - .id = PUNIT_POWER_WELL_DPIO_CMN_BC,
> .ops = &chv_dpio_cmn_power_well_ops,
> + .id = PUNIT_POWER_WELL_DPIO_CMN_BC,
> + {
> + .vlv.idx = PUNIT_PWGT_IDX_DPIO_CMN_BC,
> + },
> },
> {
> .name = "dpio-common-d",
> .domains = CHV_DPIO_CMN_D_POWER_DOMAINS,
> + .ops = &chv_dpio_cmn_power_well_ops,
> .id = PUNIT_POWER_WELL_DPIO_CMN_D,
> - .ops = &chv_dpio_cmn_power_well_ops,
> + {
> + .vlv.idx = PUNIT_PWGT_IDX_DPIO_CMN_D,
> + },
> },
> };
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-08-01 22:15 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-20 14:14 [PATCH 00/10] drm/i915: Clean up power well descriptors Imre Deak
2018-07-20 14:14 ` [PATCH 01/10] drm/i915/icl: Fix power well anonymous union initializers Imre Deak
2018-07-30 6:07 ` Rodrigo Vivi
2018-08-01 21:01 ` Paulo Zanoni
2018-08-02 23:17 ` Lucas De Marchi
2018-08-03 0:24 ` Paulo Zanoni
2018-08-03 10:23 ` Imre Deak
2018-08-03 21:09 ` Lucas De Marchi
2018-07-20 14:14 ` [PATCH 02/10] drm/i915: Rename intel_power_domains_fini() to intel_power_domains_fini_hw() Imre Deak
2018-07-30 6:09 ` Rodrigo Vivi
2018-08-01 21:02 ` Paulo Zanoni
2018-07-20 14:14 ` [PATCH 03/10] drm/i915/vlv: Remove redundant power well ID asserts Imre Deak
2018-08-01 21:03 ` Paulo Zanoni
2018-07-20 14:14 ` [PATCH 04/10] drm/i915: Constify power well descriptors Imre Deak
2018-08-01 21:39 ` Paulo Zanoni
2018-08-02 12:03 ` Imre Deak
2018-08-02 23:04 ` Paulo Zanoni
2018-07-20 14:14 ` [PATCH 05/10] drm/i915/vlv: Use power well CTL IDX instead of ID Imre Deak
2018-08-01 22:15 ` Paulo Zanoni [this message]
2018-08-02 11:56 ` Imre Deak
2018-07-20 14:15 ` [PATCH 06/10] drm/i915/ddi: " Imre Deak
2018-08-02 20:40 ` Paulo Zanoni
2018-08-03 9:13 ` Imre Deak
2018-07-20 14:15 ` [PATCH 07/10] drm/i915: Remove redundant power well IDs Imre Deak
2018-08-02 21:26 ` Paulo Zanoni
2018-08-03 9:31 ` Imre Deak
2018-07-20 14:15 ` [PATCH 08/10] drm/i915: Make power well ID names more uniform Imre Deak
2018-08-02 21:32 ` Paulo Zanoni
2018-07-20 14:15 ` [PATCH 09/10] drm/i915: Use existing power well IDs where possible Imre Deak
2018-08-02 21:39 ` Paulo Zanoni
2018-08-03 9:34 ` Imre Deak
2018-07-20 14:15 ` [PATCH 10/10] drm/i915/icl: Add missing power gate enums Imre Deak
2018-08-02 21:46 ` Paulo Zanoni
2018-07-20 14:53 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Clean up power well descriptors Patchwork
2018-07-20 14:57 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-07-20 15:15 ` ✓ Fi.CI.BAT: success " Patchwork
2018-07-21 15:39 ` ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1533161740.2571.18.camel@intel.com \
--to=paulo.r.zanoni@intel.com \
--cc=imre.deak@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).