Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Coelho, Luciano" <luciano.coelho@intel.com>
To: "Kandpal, Suraj" <suraj.kandpal@intel.com>,
	"intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH] drm/i915/display: pre-initialize some values in probe_gmdid_display()
Date: Thu, 22 Jun 2023 09:50:19 +0000	[thread overview]
Message-ID: <cd448c6eed0d0da17ed21f4c25be3ffb20028792.camel@intel.com> (raw)
In-Reply-To: <SN7PR11MB675089A23F9DFA474BF19721E35CA@SN7PR11MB6750.namprd11.prod.outlook.com>

On Tue, 2023-06-20 at 10:30 +0000, Kandpal, Suraj wrote:
> > When intel_display_device_probe() (and, subsequently,
> > probe_gmdid_display()) returns, the caller expects ver, rel and
> > step to be
> > initialized.  Since there's no way to check that there was a
> > failure and
> > no_display was returned without some further refactoring, pre-
> > initiliaze all
> > these values to zero to keep it simple and safe.
> > 
> > Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> 
> Looks okay to me just a small suggestion/question below.
> 
> > ---
> >  drivers/gpu/drm/i915/display/intel_display_device.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_display_device.c
> > b/drivers/gpu/drm/i915/display/intel_display_device.c
> > index 464df1764a86..fb6354e9e704 100644
> > --- a/drivers/gpu/drm/i915/display/intel_display_device.c
> > +++ b/drivers/gpu/drm/i915/display/intel_display_device.c
> > @@ -731,6 +731,15 @@ probe_gmdid_display(struct drm_i915_private
> > *i915, u16 *ver, u16 *rel, u16 *step
> >  	u32 val;
> >  	int i;
> > 
> > +	/* The caller expects to ver, rel and step to be
> > initialized
> > +	 * here, and there's no good way to check when there was a
> > +	 * failure and no_display was returned.  So initialize all
> > these
> > +	 * values here zero, to be sure.
> > +	 */
> > +	*ver = 0;
> > +	*rel = 0;
> > +	*step = 0;
> > +
> 
> From what I can see this is only called from
> intel_display_device_probe() which is in turn
> called from intel_device_info_driver_create() where the above
> variables are defined maybe 
> we initialize these values there itself.

Thanks for the review!

I thought about initializing the variables on the caller side, but
reckoned that it would be more intuitive to initialize them in the
probe_gmdid_display() function instead, because the caller expects
those values to be set in successful cases and there's no way for it to
know whether there was a failure or not (because we return a pointer to
local no_display structure that the caller doesn't know about).

Obviously with the current code in the caller, that doesn't make much
difference, but I thought it was cleaner as I did.

But I'm okay to change it and initialize them at the caller, so just
let me know if you want that.

--
Cheers,
Luca.

  reply	other threads:[~2023-06-22  9:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01  9:03 [Intel-gfx] [PATCH] drm/i915/display: pre-initialize some values in probe_gmdid_display() Luca Coelho
2023-06-01 16:04 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2023-06-03 14:43 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2023-06-20 10:30 ` [Intel-gfx] [PATCH] " Kandpal, Suraj
2023-06-22  9:50   ` Coelho, Luciano [this message]
2023-06-22 10:08     ` Kandpal, Suraj
2023-06-22 12:09       ` Coelho, Luciano
2023-08-08 13:41         ` Hogander, Jouni

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=cd448c6eed0d0da17ed21f4c25be3ffb20028792.camel@intel.com \
    --to=luciano.coelho@intel.com \
    --cc=intel-gfx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox