Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Piotr Piórkowski" <piotr.piorkowski@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH] drm/xe: Check pat.ops before dumping PAT settings
Date: Mon, 8 Apr 2024 13:48:08 +0200	[thread overview]
Message-ID: <20240408114808.refdhytzjg4d5i7v@intel.com> (raw)
In-Reply-To: <13d417c7-365a-419a-8f9b-c6aaf695f1e6@intel.com>

Michal Wajdeczko <michal.wajdeczko@intel.com> wrote on pon [2024-kwi-08 11:06:27 +0200]:
> 
> 
> On 08.04.2024 09:23, Piotr Piórkowski wrote:
> > Michal Wajdeczko <michal.wajdeczko@intel.com> wrote on pią [2024-kwi-05 16:36:25 +0200]:
> >> We may leave pat.ops unset when running on brand new platform or
> >> when running as a VF.  While the former is unlikely, the latter
> >> is valid (future) use case and will cause NPD when someone will
> >> try to dump PAT settings by debugfs.
> >>
> >> It's better to check pointer to pat.ops instead of specific .dump
> >> hook, as we have this hook always defined for every .ops variant.
> >>
> >> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> >> ---
> >>  drivers/gpu/drm/xe/xe_pat.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpu/drm/xe/xe_pat.c b/drivers/gpu/drm/xe/xe_pat.c
> >> index 66d8e3dd8237..f0031c2e9818 100644
> >> --- a/drivers/gpu/drm/xe/xe_pat.c
> >> +++ b/drivers/gpu/drm/xe/xe_pat.c
> >> @@ -447,7 +447,7 @@ void xe_pat_dump(struct xe_gt *gt, struct drm_printer *p)
> >>  {
> >>  	struct xe_device *xe = gt_to_xe(gt);
> >>  
> >> -	if (!xe->pat.ops->dump)
> >> +	if (!xe->pat.ops)
> > 
> > You are right that we currently have a dump pointer set for each xe_pat_ops structure,
> > and in this situation it is enough to check the ops for the cases you listed.
> > But I assume that since we are verifying the dump pointer here, that formally, for some
> > future case, we may not set this pointer.
> > Therefore, it seems to me that it would be more correct for you to check both pointers
> > here: ops and dump.
> 
> that was also my first choice but after looking at xe_pat_init() and
> reviewing existing ops that choice didn't hold as IMO keeping runtime
> check for future potential lack of .dump hook is very questionable
> 
> what I was considered instead was to add to xe_pat_init_early():
> 
> 	xe_assert(xe, !xe->pat.ops || xe->pat.ops.dump);
> 
> to perform early checkout of the selected .ops and make sure that we
> didn't miss to setup .dump hoot but then realized that the other hook
> .program_media is used without any extra runtime or debug check while
> some .ops may have it unset. so finally decided to just go with quick
> fix to close existing gap, postpone further fixes to follow up series
> (that likely could be done by the PAT code owners)

Yes, you are right that the other pointers are also not checked.
However, we have a small difference here:
If someone in the future forgets to set program_media or program_graphics,
and he tests it on a newly added platform, he will quickly find out about it
during device probe, because it is called in:
xe_device_probe() -> xe_gt_init_hwconfig() -> xe_pat_init()
The dump() is called only in dump_pat_on_error() or in debugfs.
So in the case of dump(), there is a higher chance that the end user has face
a NULL pointer. And I think we prefer to avoid the NULL pointer (even more so
in this case, where dump is not a critical functionality).

[Intentionally I'm ignoring the fact here that I guess we have tests checking debugfs]

Piotr

> 
> Michal
> 
> > 
> > Thanks,
> > Piotr
> > 
> >>  		return;
> >>  
> >>  	xe->pat.ops->dump(gt, p);
> >> -- 
> >> 2.43.0
> >>
> > 

-- 

      reply	other threads:[~2024-04-08 11:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-05 14:36 [PATCH] drm/xe: Check pat.ops before dumping PAT settings Michal Wajdeczko
2024-04-05 17:21 ` ✓ CI.Patch_applied: success for " Patchwork
2024-04-05 17:21 ` ✓ CI.checkpatch: " Patchwork
2024-04-05 17:22 ` ✓ CI.KUnit: " Patchwork
2024-04-05 17:34 ` ✓ CI.Build: " Patchwork
2024-04-05 17:37 ` ✓ CI.Hooks: " Patchwork
2024-04-05 17:39 ` ✓ CI.checksparse: " Patchwork
2024-04-05 18:03 ` ✓ CI.BAT: " Patchwork
2024-04-08  7:23 ` [PATCH] " Piotr Piórkowski
2024-04-08  9:06   ` Michal Wajdeczko
2024-04-08 11:48     ` Piotr Piórkowski [this message]

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=20240408114808.refdhytzjg4d5i7v@intel.com \
    --to=piotr.piorkowski@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michal.wajdeczko@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