dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arun Iyengar" <aiyengar1990@gmail.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH v3 4/7] accel/rocket: Serialise core probe and removal
Date: Sat, 05 Dec 2026 07:16:57 +0000	[thread overview]
Message-ID: <sashiko-outbox-251215@kernel.org> (raw)
In-Reply-To: <20261205-rocket-fixes-v3-4-e5032fa408a3@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] accel/rocket: data race on cores[].dev in find_core_for_dev()
--

commit 6ee33960d02b264188a1fc48c67da8a831b94644
Author: Arun Iyengar <aiyengar1990@gmail.com>

accel/rocket: Serialise core probe and removal

This commit allocates the first free core slot on probe, clears it on
removal or probe failure, picks a bound core in rocket_open(), and
serialises probe, removal, and open with rocket_cores_lock.

Link: https://lore.kernel.org/all/20260922080114.44662-5-royalnet026@gmail.com/

> diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c
> index e45b3c22b31e6..bf8d118b932e7 100644
> --- a/drivers/accel/rocket/rocket_drv.c
> +++ b/drivers/accel/rocket/rocket_drv.c

[ ... ]

> @@ -246,12 +269,16 @@ static int find_core_for_dev(struct device *dev);
>  static void rocket_remove(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
> -	int core = find_core_for_dev(dev);
> +	int core;
> +
> +	guard(mutex)(&rocket_cores_lock);
>  
> +	core = find_core_for_dev(dev);
>  	if (core < 0)
>  		return;
>  
>  	rocket_core_fini(&rdev->cores[core]);
> +	rdev->cores[core].dev = NULL;

[Severity: Low]
Can clearing and reusing rdev->cores[core].dev here race with unlocked
reads in find_core_for_dev()?

rocket_device_runtime_suspend() and rocket_device_runtime_resume() call
find_core_for_dev() without rocket_cores_lock, and cannot take it without
deadlocking against rocket_probe() -> rocket_core_init() ->
pm_runtime_resume_and_get().

When a lower-indexed core is unbound or rebound while a higher-indexed
core suspends or resumes, the plain stores in rocket_remove() and
rocket_probe() race with the plain loads in find_core_for_dev():

CPU0                                CPU1
rocket_remove(core0)                rocket_device_runtime_suspend(core1)
  guard(mutex)(&rocket_cores_lock)    find_core_for_dev(core1)
  rdev->cores[0].dev = NULL;            if (dev == rdev->cores[0].dev)
                                          <-- data race

This is an unmarked data race under the kernel memory model and will
trigger KCSAN reports.  Using READ_ONCE() and WRITE_ONCE() on
rdev->cores[core].dev would avoid it.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-rocket-fixes-v3-0-e5032fa408a3@gmail.com?part=4

  reply	other threads:[~2026-12-05  7:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  6:51 [PATCH v3 0/7] accel/rocket: Fix teardown with a job on the NPU Arun Iyengar via B4 Relay
2026-12-05  6:51 ` [PATCH v3 1/7] accel/rocket: Wait for in-flight jobs before releasing the file's BOs Arun Iyengar via B4 Relay
2026-12-05  6:51 ` [PATCH v3 2/7] accel/rocket: Reset the core before detaching its IOMMU Arun Iyengar via B4 Relay
2026-12-05  6:51 ` [PATCH v3 3/7] accel/rocket: Stop the scheduler before releasing the IOMMU group Arun Iyengar via B4 Relay
2026-12-05  6:51 ` [PATCH v3 4/7] accel/rocket: Serialise core probe and removal Arun Iyengar via B4 Relay
2026-12-05  7:16   ` sashiko-bot [this message]
2026-12-05  6:51 ` [PATCH v3 5/7] accel/rocket: Reset the core at unbind Arun Iyengar via B4 Relay
2026-12-05  6:51 ` [PATCH v3 6/7] accel/rocket: Free the jobs left at scheduler teardown Arun Iyengar via B4 Relay
2026-12-05  6:51 ` [PATCH v3 7/7] accel/rocket: Move open files off a core at unbind Arun Iyengar via B4 Relay
2026-12-05  7:31   ` 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=sashiko-outbox-251215@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aiyengar1990@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=media-ci@linuxtv.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox