All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: "Kandpal, Suraj" <suraj.kandpal@intel.com>,
	"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>
Cc: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
Subject: RE: [PATCH 8/9] drm/i915/dpll: Accept intel_display as argument for shared_dpll_init
Date: Tue, 11 Feb 2025 18:57:25 +0200	[thread overview]
Message-ID: <8734gk1ksq.fsf@intel.com> (raw)
In-Reply-To: <SN7PR11MB6750C81DB52D61A104B27223E3FD2@SN7PR11MB6750.namprd11.prod.outlook.com>

On Tue, 11 Feb 2025, "Kandpal, Suraj" <suraj.kandpal@intel.com> wrote:
>> -----Original Message-----
>> From: Nikula, Jani <jani.nikula@intel.com>
>> Sent: Tuesday, February 11, 2025 6:45 PM
>> To: Kandpal, Suraj <suraj.kandpal@intel.com>; intel-
>> xe@lists.freedesktop.org; intel-gfx@lists.freedesktop.org
>> Cc: Nautiyal, Ankit K <ankit.k.nautiyal@intel.com>; Kandpal, Suraj
>> <suraj.kandpal@intel.com>
>> Subject: Re: [PATCH 8/9] drm/i915/dpll: Accept intel_display as argument for
>> shared_dpll_init
>>
>> On Tue, 11 Feb 2025, Suraj Kandpal <suraj.kandpal@intel.com> wrote:
>> > Use intel_display as an argument for intel_shared_dpll_init() and
>> > replace drm_i915_private in function wherever possible.
>> > While at it prefer using display->platform.xx over IS_PLATFORM.
>> >
>> > Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
>> > ---
>> >  .../drm/i915/display/intel_display_driver.c   |  2 +-
>> >  drivers/gpu/drm/i915/display/intel_dpll_mgr.c | 49
>> > ++++++++++---------  drivers/gpu/drm/i915/display/intel_dpll_mgr.h |
>> > 3 +-
>> >  3 files changed, 27 insertions(+), 27 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/i915/display/intel_display_driver.c
>> > b/drivers/gpu/drm/i915/display/intel_display_driver.c
>> > index 978f530c810e..852f1129a058 100644
>> > --- a/drivers/gpu/drm/i915/display/intel_display_driver.c
>> > +++ b/drivers/gpu/drm/i915/display/intel_display_driver.c
>> > @@ -448,7 +448,7 @@ int intel_display_driver_probe_nogem(struct
>> intel_display *display)
>> >     }
>> >
>> >     intel_plane_possible_crtcs_init(display);
>> > -   intel_shared_dpll_init(i915);
>> > +   intel_shared_dpll_init(display);
>> >     intel_fdi_pll_freq_update(i915);
>> >
>> >     intel_update_czclk(i915);
>> > diff --git a/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
>> > b/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
>> > index f94da1ffc8ce..26b6b9372fa3 100644
>> > --- a/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
>> > +++ b/drivers/gpu/drm/i915/display/intel_dpll_mgr.c
>> > @@ -2042,8 +2042,8 @@ static void bxt_ddi_pll_enable(struct
>> > intel_display *display,  {
>> >     const struct bxt_dpll_hw_state *hw_state = &dpll_hw_state->bxt;
>> >     enum port port = (enum port)pll->info->id; /* 1:1 port->PLL mapping
>> */
>> > -   enum dpio_phy phy;
>> > -   enum dpio_channel ch;
>> > +   enum dpio_phy phy = DPIO_PHY0;
>> > +   enum dpio_channel ch = DPIO_CH0;
>>
>> Unrelated change, please drop.
>>
>
> The problem is by dropping these changes I am not able to build the kernel and it throws the following warning because of which I had to add this
>
>
> drivers/gpu/drm/i915/display/intel_dpll_mgr.c: In function _bxt_ddi_pll_enable_:
> ./drivers/gpu/drm/xe/compat-i915-headers/../../i915/i915_reg_defs.h:240:56: error: _phy_ is used uninitialized [-Werror=uniniti
> alized]
>   240 |         (BUILD_BUG_ON_ZERO(!__is_constexpr(__c_index)) +                        \
>       |                                                        ^
> drivers/gpu/drm/i915/display/intel_dpll_mgr.c:2047:23: note: _phy_ was declared here
>  2047 |         enum dpio_phy phy;
>       |                       ^~~
> In file included from ./drivers/gpu/drm/xe/compat-i915-headers/i915_reg_defs.h:6,
>                  from drivers/gpu/drm/i915/display/intel_display_reg_defs.h:9,
>                  from drivers/gpu/drm/i915/display/bxt_dpio_phy_regs.h:9,
>                  from drivers/gpu/drm/i915/display/intel_dpll_mgr.c:27:
> ./drivers/gpu/drm/xe/compat-i915-headers/../../i915/i915_reg_defs.h:213:58: error: _ch_ is used uninitialized [-Werror=uninitia
> lized]
>   213 | #define _PICK_EVEN(__index, __a, __b) ((__a) + (__index) * ((__b) - (__a)))
>       |                                                          ^
> drivers/gpu/drm/i915/display/intel_dpll_mgr.c:2048:27: note: _ch_ was declared here
>  2048 |         enum dpio_channel ch;

Did you think to look into why this happens? I encourage you to always
do that instead of just silencing the warning. You'll learn about C and
the compiler.

It's quite interesting and subtle and deserves to be mentioned in the
commit message.

For i915.ko, bxt_port_to_phy_channel() is a regular function, and the
compiler will likely assume it'll initialize the parameters. And it
does.

For xe.ko, bxt_port_to_phy_channel() is a static inline stub, and the
compiler can be absolutely certain the parameters aren't initialized.

So, why does this cause an error now? The above didn't change now!

With IS_GEMINILAKE() || IS_BROXTON() the compiler can be sure it's false
for xe.ko. The whole chain bxt_pll_mgr -> bxt_plls -> bxt_ddi_pll_funcs
-> bxt_ddi_pll_enable can be optimized away. It's unreachable.

Not so with display->platform.geminilake ||
display->platform.broxton. The compiler sees use of uninitialized
variables.

BR,
Jani.



>
> Regards,
> Suraj Kandpal
>
>> With that fixed,
>>
>> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>>
>>
>> >     u32 temp;
>> >
>> >     bxt_port_to_phy_channel(display, port, &phy, &ch); @@ -4302,40
>> > +4302,41 @@ static const struct intel_dpll_mgr adlp_pll_mgr = {
>> >
>> >  /**
>> >   * intel_shared_dpll_init - Initialize shared DPLLs
>> > - * @i915: i915 device
>> > + * @display: intel_display device
>> >   *
>> > - * Initialize shared DPLLs for @i915.
>> > + * Initialize shared DPLLs for @display.
>> >   */
>> > -void intel_shared_dpll_init(struct drm_i915_private *i915)
>> > +void intel_shared_dpll_init(struct intel_display *display)
>> >  {
>> > +   struct drm_i915_private *i915 = to_i915(display->drm);
>> >     const struct intel_dpll_mgr *dpll_mgr = NULL;
>> >     const struct dpll_info *dpll_info;
>> >     int i;
>> >
>> > -   mutex_init(&i915->display.dpll.lock);
>> > +   mutex_init(&display->dpll.lock);
>> >
>> > -   if (DISPLAY_VER(i915) >= 14 || IS_DG2(i915))
>> > +   if (DISPLAY_VER(display) >= 14 || display->platform.dg2)
>> >             /* No shared DPLLs on DG2; port PLLs are part of the PHY */
>> >             dpll_mgr = NULL;
>> > -   else if (IS_ALDERLAKE_P(i915))
>> > +   else if (display->platform.alderlake_p)
>> >             dpll_mgr = &adlp_pll_mgr;
>> > -   else if (IS_ALDERLAKE_S(i915))
>> > +   else if (display->platform.alderlake_s)
>> >             dpll_mgr = &adls_pll_mgr;
>> > -   else if (IS_DG1(i915))
>> > +   else if (display->platform.dg1)
>> >             dpll_mgr = &dg1_pll_mgr;
>> > -   else if (IS_ROCKETLAKE(i915))
>> > +   else if (display->platform.rocketlake)
>> >             dpll_mgr = &rkl_pll_mgr;
>> > -   else if (DISPLAY_VER(i915) >= 12)
>> > +   else if (DISPLAY_VER(display) >= 12)
>> >             dpll_mgr = &tgl_pll_mgr;
>> > -   else if (IS_JASPERLAKE(i915) || IS_ELKHARTLAKE(i915))
>> > +   else if (display->platform.jasperlake ||
>> > +display->platform.elkhartlake)
>> >             dpll_mgr = &ehl_pll_mgr;
>> > -   else if (DISPLAY_VER(i915) >= 11)
>> > +   else if (DISPLAY_VER(display) >= 11)
>> >             dpll_mgr = &icl_pll_mgr;
>> > -   else if (IS_GEMINILAKE(i915) || IS_BROXTON(i915))
>> > +   else if (display->platform.geminilake || display->platform.broxton)
>> >             dpll_mgr = &bxt_pll_mgr;
>> > -   else if (DISPLAY_VER(i915) == 9)
>> > +   else if (DISPLAY_VER(display) == 9)
>> >             dpll_mgr = &skl_pll_mgr;
>> > -   else if (HAS_DDI(i915))
>> > +   else if (HAS_DDI(display))
>> >             dpll_mgr = &hsw_pll_mgr;
>> >     else if (HAS_PCH_IBX(i915) || HAS_PCH_CPT(i915))
>> >             dpll_mgr = &pch_pll_mgr;
>> > @@ -4346,20 +4347,20 @@ void intel_shared_dpll_init(struct
>> drm_i915_private *i915)
>> >     dpll_info = dpll_mgr->dpll_info;
>> >
>> >     for (i = 0; dpll_info[i].name; i++) {
>> > -           if (drm_WARN_ON(&i915->drm,
>> > -                           i >= ARRAY_SIZE(i915-
>> >display.dpll.shared_dplls)))
>> > +           if (drm_WARN_ON(display->drm,
>> > +                           i >= ARRAY_SIZE(display->dpll.shared_dplls)))
>> >                     break;
>> >
>> >             /* must fit into unsigned long bitmask on 32bit */
>> > -           if (drm_WARN_ON(&i915->drm, dpll_info[i].id >= 32))
>> > +           if (drm_WARN_ON(display->drm, dpll_info[i].id >= 32))
>> >                     break;
>> >
>> > -           i915->display.dpll.shared_dplls[i].info = &dpll_info[i];
>> > -           i915->display.dpll.shared_dplls[i].index = i;
>> > +           display->dpll.shared_dplls[i].info = &dpll_info[i];
>> > +           display->dpll.shared_dplls[i].index = i;
>> >     }
>> >
>> > -   i915->display.dpll.mgr = dpll_mgr;
>> > -   i915->display.dpll.num_shared_dpll = i;
>> > +   display->dpll.mgr = dpll_mgr;
>> > +   display->dpll.num_shared_dpll = i;
>> >  }
>> >
>> >  /**
>> > diff --git a/drivers/gpu/drm/i915/display/intel_dpll_mgr.h
>> > b/drivers/gpu/drm/i915/display/intel_dpll_mgr.h
>> > index 3d988f17f31d..caffb084830c 100644
>> > --- a/drivers/gpu/drm/i915/display/intel_dpll_mgr.h
>> > +++ b/drivers/gpu/drm/i915/display/intel_dpll_mgr.h
>> > @@ -35,7 +35,6 @@
>> >                  ((__pll) = &(__display)->dpll.shared_dplls[(__i)]) ; (__i)++)
>> >
>> >  enum tc_port;
>> > -struct drm_i915_private;
>> >  struct drm_printer;
>> >  struct intel_atomic_state;
>> >  struct intel_crtc;
>> > @@ -422,7 +421,7 @@ bool intel_dpll_get_hw_state(struct intel_display
>> > *display,  void intel_enable_shared_dpll(const struct intel_crtc_state
>> > *crtc_state);  void intel_disable_shared_dpll(const struct
>> > intel_crtc_state *crtc_state);  void
>> > intel_shared_dpll_swap_state(struct intel_atomic_state *state); -void
>> > intel_shared_dpll_init(struct drm_i915_private *i915);
>> > +void intel_shared_dpll_init(struct intel_display *display);
>> >  void intel_dpll_update_ref_clks(struct intel_display *display);  void
>> > intel_dpll_readout_hw_state(struct intel_display *display);  void
>> > intel_dpll_sanitize_state(struct intel_display *display);
>>
>> --
>> Jani Nikula, Intel

-- 
Jani Nikula, Intel

  reply	other threads:[~2025-02-11 16:57 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11 10:48 [PATCH 0/9] drm_i915_private to intel_display cleanup Suraj Kandpal
2025-02-11 10:48 ` [PATCH 1/9] drm/i915/display_debug_fs: Use intel_display wherever possible Suraj Kandpal
2025-02-11 12:51   ` Jani Nikula
2025-02-11 12:52   ` Jani Nikula
2025-02-11 10:48 ` [PATCH 2/9] drm/i915/display_debug_fs: Prefer using display->platform Suraj Kandpal
2025-02-11 12:53   ` Jani Nikula
2025-02-11 10:48 ` [PATCH 3/9] drm/i915/dpll: Change param to intel_display in for_each_shared_dpll Suraj Kandpal
2025-02-11 12:56   ` Jani Nikula
2025-02-11 10:48 ` [PATCH 4/9] drm/i915/dpll: Use intel_display for dpll dump and compare hw state Suraj Kandpal
2025-02-11 12:59   ` Jani Nikula
2025-02-11 10:48 ` [PATCH 5/9] drm/i915/dpll: Use intel_display possible in shared_dpll_mgr hooks Suraj Kandpal
2025-02-11 13:10   ` Jani Nikula
2025-02-11 10:48 ` [PATCH 6/9] drm/i915/dpll: Use intel_display for asserting pll Suraj Kandpal
2025-02-11 13:12   ` Jani Nikula
2025-02-11 10:48 ` [PATCH 7/9] drm/i915/dpll: Use intel_display for update_refclk hook Suraj Kandpal
2025-02-11 13:12   ` Jani Nikula
2025-02-11 10:48 ` [PATCH 8/9] drm/i915/dpll: Accept intel_display as argument for shared_dpll_init Suraj Kandpal
2025-02-11 13:14   ` Jani Nikula
2025-02-11 14:23     ` Kandpal, Suraj
2025-02-11 16:57       ` Jani Nikula [this message]
2025-02-12  7:35         ` Kandpal, Suraj
2025-02-11 10:48 ` [PATCH 9/9] drm/i915/dpll: Replace all other leftover drm_i915_private Suraj Kandpal
2025-02-11 13:17   ` Jani Nikula
2025-02-11 11:50 ` ✓ CI.Patch_applied: success for drm_i915_private to intel_display cleanup (rev2) Patchwork
2025-02-11 11:51 ` ✗ CI.checkpatch: warning " Patchwork
2025-02-11 11:52 ` ✓ CI.KUnit: success " Patchwork
2025-02-11 12:09 ` ✓ CI.Build: " Patchwork
2025-02-11 12:10 ` ✗ Fi.CI.CHECKPATCH: warning " Patchwork
2025-02-11 12:10 ` ✗ Fi.CI.SPARSE: " Patchwork
2025-02-11 12:10 ` ✗ CI.Hooks: failure " Patchwork
2025-02-11 12:11 ` ✗ CI.checksparse: warning " Patchwork
2025-02-11 12:31 ` ✓ Xe.CI.BAT: success " Patchwork
2025-02-11 13:45 ` ✓ i915.CI.BAT: " Patchwork
2025-02-11 16:23 ` ✗ i915.CI.Full: failure " Patchwork
2025-02-11 20:46 ` ✗ Xe.CI.Full: " Patchwork
2025-02-12  9:54 ` [PATCH 0/9] drm_i915_private to intel_display cleanup Kandpal, Suraj
  -- strict thread matches above, loose matches on Subject: below --
2025-02-10 12:39 Suraj Kandpal
2025-02-10 12:39 ` [PATCH 8/9] drm/i915/dpll: Accept intel_display as argument for shared_dpll_init Suraj Kandpal

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=8734gk1ksq.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=suraj.kandpal@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.