All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alexandru Dadu" <alexandru.dadu@imgtec.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v6 2/3] drm/imagination: Propagate all errors from KCCB command submission code
Date: Thu, 24 Sep 2026 06:31:42 +0000	[thread overview]
Message-ID: <20260924063142.804531F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260924-b4-upstream-propagate-all-errors-from-kccb-cmd-submission-code-v6-2-d9d5375665ed@imgtec.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] drm/imagination: use-after-free and state corruption due to missing CCCB rollback on KCCB kick failure
- [Medium] drm/imagination: resource leak of KCCB slot reservations on error
--

commit a2bdc84028e3fc1451749b3764c3318c1a8c6d75
Author: Alessio Belle <alessio.belle@imgtec.com>

drm/imagination: Propagate all errors from KCCB command submission code

This commit updates the KCCB command submission code to propagate errors
back to the caller. The DRM scheduler's run_job callback is updated to
return these errors instead of unconditionally succeeding.

> diff --git a/drivers/gpu/drm/imagination/pvr_ccb.c b/drivers/gpu/drm/imagination/pvr_ccb.c
> --- a/drivers/gpu/drm/imagination/pvr_ccb.c
> +++ b/drivers/gpu/drm/imagination/pvr_ccb.c
[ ... ]
> @@ -264,19 +269,25 @@ pvr_kccb_send_cmd_reserved_powered(struct pvr_device *pvr_dev,
>  	struct rogue_fwif_ccb_ctl *ctrl = pvr_ccb->ctrl;
>  	u32 old_write_offset;
>  	u32 new_write_offset;
> +	int err;
>  
> -	WARN_ON(pvr_dev->lost);
> +	if (pvr_dev->lost)
> +		return -EIO;

[Severity: Medium]
If we return early here, does it leak the KCCB slot reservation?

When this is called from pvr_kccb_send_cmd_powered(), a slot has already 
been reserved by incrementing pvr_dev->kccb.reserved_count. The success 
path decrements this count later in the function, but this early return 
does not, which could lead to slot starvation and eventual -EBUSY errors 
on all future KCCB submissions.

[ ... ]
> diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c
> --- a/drivers/gpu/drm/imagination/pvr_queue.c
> +++ b/drivers/gpu/drm/imagination/pvr_queue.c
[ ... ]
> @@ -809,9 +809,10 @@ static struct dma_fence *pvr_queue_run_job(struct drm_sched_job *sched_job)
>  		struct pvr_queue *queue = container_of(job->base.sched,
>  						       struct pvr_queue, scheduler);
>  
> -		pvr_cccb_send_kccb_kick(pvr_dev, &queue->cccb,
> -					pvr_context_get_fw_addr(job->ctx) + queue->ctx_offset,
> -					job->hwrt);
> +		err = pvr_cccb_send_kccb_kick(pvr_dev, &queue->cccb,
> +					      pvr_context_get_fw_addr(job->ctx) +
> +					      queue->ctx_offset,
> +					      job->hwrt);
>  
>  		trace_pvr_job_submit_fw(job);
>  	}

[Severity: High]
If pvr_cccb_send_kccb_kick() fails here and pvr_queue_run_job() returns 
ERR_PTR(err), could this lead to a use-after-free and state corruption?

Earlier in pvr_queue_run_job(), pvr_queue_submit_job_to_cccb() is called 
which increments queue->in_flight_job_count and writes the job's commands 
into the firmware's CCCB ring buffer. If the kick fails and the DRM 
scheduler frees this job, the commands remain in the CCCB without being 
rolled back. 

When a subsequent job is successfully submitted, won't the firmware 
process the leftover commands from the freed job, accessing freed resources?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260924-b4-upstream-propagate-all-errors-from-kccb-cmd-submission-code-v6-0-d9d5375665ed@imgtec.com?part=2

  reply	other threads:[~2026-09-24  6:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  6:19 [PATCH v6 0/3] drm/imagination: Propagate all KCCB command submission code errors Alexandru Dadu
2026-09-24  6:19 ` [PATCH v6 1/3] drm/imagination: Release KCCB slot on error path in pvr_queue_run_job() Alexandru Dadu
2026-09-24  6:19 ` [PATCH v6 2/3] drm/imagination: Propagate all errors from KCCB command submission code Alexandru Dadu
2026-09-24  6:31   ` sashiko-bot [this message]
2026-09-24  6:19 ` [PATCH v6 3/3] drm/imagination: Release pm references in case of error Alexandru Dadu
2026-09-24  6:29   ` sashiko-bot

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=20260924063142.804531F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexandru.dadu@imgtec.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.