* [PATCH] cxl/port: Restart port enumeration when a sibling adds the dport first
@ 2026-07-12 1:28 Alison Schofield
2026-07-13 2:45 ` Li Ming
0 siblings, 1 reply; 2+ messages in thread
From: Alison Schofield @ 2026-07-12 1:28 UTC (permalink / raw)
To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Ira Weiny, Dan Williams, Li Ming
Cc: linux-cxl
Endpoint probes can race while enumerating a shared switch. If a
sibling probe adds the dport first, the losing probe treats the
existing dport as an error and fails to enumerate the endpoint.
Treat this race the same as the existing port-created case by
restarting the port walk, allowing it to find the existing dport
and continue enumeration.
This race was discovered while testing a cxl_test mixed-granularity
topology, where twelve endpoints behind shared switches are probed in
parallel during module load.
Fixes: 4f06d81e7c6a ("cxl: Defer dport allocation for switch ports")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
drivers/cxl/core/port.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
index 1215ee4f4035..65f2d2f1eb00 100644
--- a/drivers/cxl/core/port.c
+++ b/drivers/cxl/core/port.c
@@ -1749,8 +1749,8 @@ static int add_port_attach_ep(struct cxl_memdev *cxlmd,
parent_dport, uport_dev,
dport_dev);
if (IS_ERR(dport)) {
- /* Port already exists, restart iteration */
- if (PTR_ERR(dport) == -EAGAIN)
+ /* Port or dport already exists, restart iteration */
+ if (PTR_ERR(dport) == -EAGAIN || PTR_ERR(dport) == -EBUSY)
return 0;
return PTR_ERR(dport);
}
--
2.37.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] cxl/port: Restart port enumeration when a sibling adds the dport first
2026-07-12 1:28 [PATCH] cxl/port: Restart port enumeration when a sibling adds the dport first Alison Schofield
@ 2026-07-13 2:45 ` Li Ming
0 siblings, 0 replies; 2+ messages in thread
From: Li Ming @ 2026-07-13 2:45 UTC (permalink / raw)
To: Alison Schofield
Cc: linux-cxl, Davidlohr Bueso, Jonathan Cameron, Dave Jiang,
Vishal Verma, Ira Weiny, Dan Williams
On 7/12/2026 9:28 AM, Alison Schofield wrote:
> Endpoint probes can race while enumerating a shared switch. If a
> sibling probe adds the dport first, the losing probe treats the
> existing dport as an error and fails to enumerate the endpoint.
>
> Treat this race the same as the existing port-created case by
> restarting the port walk, allowing it to find the existing dport
> and continue enumeration.
>
> This race was discovered while testing a cxl_test mixed-granularity
> topology, where twelve endpoints behind shared switches are probed in
> parallel during module load.
Hi Alison,
Per commit log, I think the root cause is probe_dport() called in devm_cxl_create_port() twice, and the second time failed because the dport has been added.
But devm_cxl_create_port() is protected by its parent port's device lock, probe_dport() is called only when a new port is created in devm_cxl_create_port(). If a port can be found, will return -EAGAIN directly in devm_cxl_create_port().
So If probe_dport() was called twice, is it something wrong in find_cxl_port_by_uport()? Or I miss some details?
Ming
> Fixes: 4f06d81e7c6a ("cxl: Defer dport allocation for switch ports")
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> ---
> drivers/cxl/core/port.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cxl/core/port.c b/drivers/cxl/core/port.c
> index 1215ee4f4035..65f2d2f1eb00 100644
> --- a/drivers/cxl/core/port.c
> +++ b/drivers/cxl/core/port.c
> @@ -1749,8 +1749,8 @@ static int add_port_attach_ep(struct cxl_memdev *cxlmd,
> parent_dport, uport_dev,
> dport_dev);
> if (IS_ERR(dport)) {
> - /* Port already exists, restart iteration */
> - if (PTR_ERR(dport) == -EAGAIN)
> + /* Port or dport already exists, restart iteration */
> + if (PTR_ERR(dport) == -EAGAIN || PTR_ERR(dport) == -EBUSY)
> return 0;
> return PTR_ERR(dport);
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-13 2:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-12 1:28 [PATCH] cxl/port: Restart port enumeration when a sibling adds the dport first Alison Schofield
2026-07-13 2:45 ` Li Ming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox