Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: intel-xe@lists.freedesktop.org,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Subject: Re: [PATCH] drm/xe: Do not dereference NULL job->fence in trace points
Date: Thu, 6 Jun 2024 02:55:23 +0000	[thread overview]
Message-ID: <ZmElG5XGOt82S/6m@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <ngmanv6726qo7ggl7w7eb2ifhox3mjvfcug74ljassq224hv6a@edjwmgcr7rmv>

On Wed, Jun 05, 2024 at 06:13:42PM -0500, Lucas De Marchi wrote:
> On Tue, Jun 04, 2024 at 10:50:41PM GMT, Matthew Brost wrote:
> > job->fence is not assigned until xe_sched_job_arm(), check for
> > job->fence in xe_sched_job_seqno() so any usage of this function (trace
> > points) do not result in NULL ptr dereference. Also check job->fence
> > before assigning error in job trace points.
> > 
> > Fixes: 0ac7a2c745e8 drm/xe: ("Don't initialize fences at xe_sched_job_create()")
> > Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_sched_job.h | 2 +-
> > drivers/gpu/drm/xe/xe_trace.h     | 2 +-
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_sched_job.h b/drivers/gpu/drm/xe/xe_sched_job.h
> > index 002c3b5c0a5c..f362e28455db 100644
> > --- a/drivers/gpu/drm/xe/xe_sched_job.h
> > +++ b/drivers/gpu/drm/xe/xe_sched_job.h
> > @@ -70,7 +70,7 @@ to_xe_sched_job(struct drm_sched_job *drm)
> > 
> > static inline u32 xe_sched_job_seqno(struct xe_sched_job *job)
> > {
> > -	return job->fence->seqno;
> > +	return job->fence ? job->fence->seqno : 0;
> > }
> > 
> > static inline u32 xe_sched_job_lrc_seqno(struct xe_sched_job *job)
> > diff --git a/drivers/gpu/drm/xe/xe_trace.h b/drivers/gpu/drm/xe/xe_trace.h
> > index 450f407c66e8..e4cba64474e6 100644
> > --- a/drivers/gpu/drm/xe/xe_trace.h
> > +++ b/drivers/gpu/drm/xe/xe_trace.h
> > @@ -270,7 +270,7 @@ DECLARE_EVENT_CLASS(xe_sched_job,
> > 			   __entry->guc_state =
> > 			   atomic_read(&job->q->guc->state);
> > 			   __entry->flags = job->q->flags;
> > -			   __entry->error = job->fence->error;
> > +			   __entry->error = job->fence ? job->fence->error : 0;
> 
> we already include xe_sched_job.h in this file and even call
> xe_sched_job_lrc_seqno() a few lines above this. Why can't we call the
> function you just fixed? With that changed,

We do call that function above, it just is not in the diff.

We don't have a helper to go from job -> job->fence->error hence the
open coding here. I could add a helper if you like.

Matt

> 
> 	Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
> 
> 
> Lucas De Marchi
> 
> > 			   __entry->fence = job->fence;
> > 			   __entry->batch_addr = (u64)job->ptrs[0].batch_addr;
> > 			   ),
> > -- 
> > 2.34.1
> > 

  reply	other threads:[~2024-06-06  2:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05  5:50 [PATCH] drm/xe: Do not dereference NULL job->fence in trace points Matthew Brost
2024-06-05  7:26 ` ✓ CI.Patch_applied: success for " Patchwork
2024-06-05  7:26 ` ✗ CI.checkpatch: warning " Patchwork
2024-06-05  7:27 ` ✓ CI.KUnit: success " Patchwork
2024-06-05  7:39 ` ✓ CI.Build: " Patchwork
2024-06-05  7:39 ` ✗ CI.Hooks: failure " Patchwork
2024-06-05  7:40 ` ✓ CI.checksparse: success " Patchwork
2024-06-05  8:12 ` ✓ CI.BAT: " Patchwork
2024-06-05 18:38 ` ✗ CI.FULL: failure " Patchwork
2024-06-05 23:13 ` [PATCH] " Lucas De Marchi
2024-06-06  2:55   ` Matthew Brost [this message]
2024-06-06  5:21     ` Lucas De Marchi
2024-06-06 16:23       ` Matthew Brost

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=ZmElG5XGOt82S/6m@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=thomas.hellstrom@linux.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