From: Jiaxing Hu <gahing@gahingwoo.com>
To: royalnet026@gmail.com
Cc: tomeu@tomeuvizoso.net, heiko@sntech.de,
linux-rockchip@lists.infradead.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Jiaxing Hu <gahing@gahingwoo.com>
Subject: Re: [PATCH 2/2] accel/rocket: keep core slots stable across unbind and rebind
Date: Thu, 30 Jul 2026 23:32:56 +1200 [thread overview]
Message-ID: <20260730113256.1418091-1-gahing@gahingwoo.com> (raw)
In-Reply-To: <20260730080355.177422-3-royalnet026@gmail.com>
Hi Igor,
I like this one. Making .dev the liveness marker is the right shape, and
the analysis of the three jobs num_cores was doing is exactly right.
But making .dev load-bearing needs one more site than the patch touches:
rocket_probe()'s failure path never clears it.
rdev->cores[core].dev = &pdev->dev;
...
ret = rocket_core_init(&rdev->cores[core]);
if (ret) {
rdev->num_cores--;
if (rdev->num_cores == 0) {
rocket_device_fini(rdev);
rdev = NULL;
devres_release_group(&drm_dev->dev, rdev_group);
}
}
Before this patch that was harmless, because every lookup was bounded by
num_cores and the slot fell outside it. After it, the slot stays marked
live while its rocket_core is half-initialised.
It only bites when the failing core is not the last one bound. If
num_cores drops to zero the whole cores array is freed by the devres
release from patch 1, and the stale .dev goes with it. So the case to
test is core N failing to init while cores 0..N-1 are already up,
easiest with a forced error return in rocket_core_init(), since a real
-EPROBE_DEFER retries rather than failing.
What that leaves behind:
- find_core_for_dev() finds the slot, so the runtime PM callbacks run
against a core whose clocks/resets/IRQ were never set up;
- rocket_first_live_core() can return it, and rocket_open() then builds
the IOMMU domain against that device;
- rocket_job_open() adds &cores[core].sched to the scheds array, and
that scheduler was never drm_sched_init()ed.
That last one also overflows. scheds is sized rdev->num_cores, but the
loop now counts live slots, and after a failed init there is one more
live slot than num_cores, so the last scheds[n++] writes one element
past the allocation.
One line fixes all of it:
if (ret) {
rdev->cores[core].dev = NULL;
rdev->num_cores--;
...
Two smaller things, neither blocking:
The slot scan in rocket_probe() is a scan-then-claim with nothing
serialising it against another core's probe. Platform probing is
synchronous today so it cannot bite, and the old code had the same
property via num_cores, so it is no worse. Just worth knowing it is
still there if rocket ever gains async probe.
sched_to_core() scanning max_cores now walks slots whose .sched is not
initialised. Comparing &cores[core].sched against a live scheduler
pointer can never match on those, so it is correct as written; a .dev
check would make it obviously correct to a reader.
I have only RK3576 here, so this is a code review rather than a
Tested-by. I cannot exercise the multi-core unbind matrix.
Thanks,
Jiaxing
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
next prev parent reply other threads:[~2026-07-30 20:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 8:03 [PATCH 0/2] accel/rocket: fix shared-device lifecycle on probe failure and unbind Igor Paunovic
2026-07-30 8:03 ` [PATCH 1/2] accel/rocket: release the shared device's devres on teardown Igor Paunovic
2026-07-30 8:03 ` [PATCH 2/2] accel/rocket: keep core slots stable across unbind and rebind Igor Paunovic
2026-07-30 11:32 ` Jiaxing Hu [this message]
2026-07-31 6:57 ` Igor Paunovic
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=20260730113256.1418091-1-gahing@gahingwoo.com \
--to=gahing@gahingwoo.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=heiko@sntech.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=royalnet026@gmail.com \
--cc=tomeu@tomeuvizoso.net \
/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