* [PATCH] cxl/ras: Fix match_memdev_by_parent() pointer type mismatch
@ 2026-06-08 22:43 Terry Bowman
2026-06-09 14:34 ` Dave Jiang
2026-06-09 17:10 ` Alison Schofield
0 siblings, 2 replies; 5+ messages in thread
From: Terry Bowman @ 2026-06-08 22:43 UTC (permalink / raw)
To: dave, jic23, dave.jiang, alison.schofield, vishal.l.verma,
ira.weiny, djbw, ming.li, rrichter, Benjamin.Cheatham
Cc: Smita.KoralahalliChannabasappa, terry.bowman, stable, linux-cxl,
linux-kernel, PradeepVineshReddy.Kodamati
bus_find_device() passes its data argument directly to the match
function as a const void *. match_memdev_by_parent() compares
dev->parent against this pointer:
dev->parent == uport
cxlmd->dev.parent is set in cxl_memdev_alloc() as:
dev->parent = cxlds->dev; /* cxlds->dev == &pdev->dev */
So cxlmd->dev.parent holds a struct device * pointing to &pdev->dev.
However, bus_find_device() is called with pdev (struct pci_dev *)
rather than &pdev->dev (struct device *). Since struct pci_dev does
not begin with struct device, the two pointer values differ, causing
the comparison to always evaluate false.
As a result, cxl_cper_handle_prot_err() silently drops every CPER
error report for CXL endpoint devices -- bus_find_device() always
returns NULL and the function returns early without emitting any
kernel trace event.
Fix by passing &pdev->dev instead of pdev.
Fixes: 3c70ec71abda ("cxl/ras: Fix CPER handler device confusion")
Reported-by: Sashiko <sashiko@linuxfoundation.org>
Signed-off-by: Terry Bowman <terry.bowman@amd.com>
---
drivers/cxl/core/ras.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/cxl/core/ras.c b/drivers/cxl/core/ras.c
index 006c6ffc2f56..7ec2dab152a7 100644
--- a/drivers/cxl/core/ras.c
+++ b/drivers/cxl/core/ras.c
@@ -94,8 +94,7 @@ void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data)
if (!pdev->dev.driver)
return;
- struct device *mem_dev __free(put_device) = bus_find_device(
- &cxl_bus_type, NULL, pdev, match_memdev_by_parent);
+ struct device *mem_dev __free(put_device) = bus_find_device(&cxl_bus_type, NULL, &pdev->dev, match_memdev_by_parent);
if (!mem_dev)
return;
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cxl/ras: Fix match_memdev_by_parent() pointer type mismatch
2026-06-08 22:43 [PATCH] cxl/ras: Fix match_memdev_by_parent() pointer type mismatch Terry Bowman
@ 2026-06-09 14:34 ` Dave Jiang
2026-06-09 17:10 ` Alison Schofield
1 sibling, 0 replies; 5+ messages in thread
From: Dave Jiang @ 2026-06-09 14:34 UTC (permalink / raw)
To: Terry Bowman, dave, jic23, alison.schofield, vishal.l.verma,
ira.weiny, djbw, ming.li, rrichter, Benjamin.Cheatham
Cc: Smita.KoralahalliChannabasappa, stable, linux-cxl, linux-kernel,
PradeepVineshReddy.Kodamati
On 6/8/26 3:43 PM, Terry Bowman wrote:
> bus_find_device() passes its data argument directly to the match
> function as a const void *. match_memdev_by_parent() compares
> dev->parent against this pointer:
>
> dev->parent == uport
>
> cxlmd->dev.parent is set in cxl_memdev_alloc() as:
>
> dev->parent = cxlds->dev; /* cxlds->dev == &pdev->dev */
>
> So cxlmd->dev.parent holds a struct device * pointing to &pdev->dev.
> However, bus_find_device() is called with pdev (struct pci_dev *)
> rather than &pdev->dev (struct device *). Since struct pci_dev does
> not begin with struct device, the two pointer values differ, causing
> the comparison to always evaluate false.
>
> As a result, cxl_cper_handle_prot_err() silently drops every CPER
> error report for CXL endpoint devices -- bus_find_device() always
> returns NULL and the function returns early without emitting any
> kernel trace event.
>
> Fix by passing &pdev->dev instead of pdev.
>
> Fixes: 3c70ec71abda ("cxl/ras: Fix CPER handler device confusion")
> Reported-by: Sashiko <sashiko@linuxfoundation.org>
> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Probably good to keep the original line wrapping. I can fix that on apply.
> ---
> drivers/cxl/core/ras.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/cxl/core/ras.c b/drivers/cxl/core/ras.c
> index 006c6ffc2f56..7ec2dab152a7 100644
> --- a/drivers/cxl/core/ras.c
> +++ b/drivers/cxl/core/ras.c
> @@ -94,8 +94,7 @@ void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data)
> if (!pdev->dev.driver)
> return;
>
> - struct device *mem_dev __free(put_device) = bus_find_device(
> - &cxl_bus_type, NULL, pdev, match_memdev_by_parent);
> + struct device *mem_dev __free(put_device) = bus_find_device(&cxl_bus_type, NULL, &pdev->dev, match_memdev_by_parent);
> if (!mem_dev)
> return;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cxl/ras: Fix match_memdev_by_parent() pointer type mismatch
2026-06-08 22:43 [PATCH] cxl/ras: Fix match_memdev_by_parent() pointer type mismatch Terry Bowman
2026-06-09 14:34 ` Dave Jiang
@ 2026-06-09 17:10 ` Alison Schofield
2026-06-09 18:17 ` Bowman, Terry
1 sibling, 1 reply; 5+ messages in thread
From: Alison Schofield @ 2026-06-09 17:10 UTC (permalink / raw)
To: Terry Bowman
Cc: dave, jic23, dave.jiang, vishal.l.verma, ira.weiny, djbw,
ming.li, rrichter, Benjamin.Cheatham,
Smita.KoralahalliChannabasappa, stable, linux-cxl, linux-kernel,
PradeepVineshReddy.Kodamati
On Mon, Jun 08, 2026 at 05:43:19PM -0500, Terry Bowman wrote:
> bus_find_device() passes its data argument directly to the match
> function as a const void *. match_memdev_by_parent() compares
> dev->parent against this pointer:
>
> dev->parent == uport
>
> cxlmd->dev.parent is set in cxl_memdev_alloc() as:
>
> dev->parent = cxlds->dev; /* cxlds->dev == &pdev->dev */
>
> So cxlmd->dev.parent holds a struct device * pointing to &pdev->dev.
> However, bus_find_device() is called with pdev (struct pci_dev *)
> rather than &pdev->dev (struct device *). Since struct pci_dev does
> not begin with struct device, the two pointer values differ, causing
> the comparison to always evaluate false.
>
> As a result, cxl_cper_handle_prot_err() silently drops every CPER
> error report for CXL endpoint devices -- bus_find_device() always
> returns NULL and the function returns early without emitting any
> kernel trace event.
>
> Fix by passing &pdev->dev instead of pdev.
>
> Fixes: 3c70ec71abda ("cxl/ras: Fix CPER handler device confusion")
> Reported-by: Sashiko <sashiko@linuxfoundation.org>
> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
Hi Terry,
The commit log is burying the lead- no endpoint errors reported.
There is no need for the full struct layout analysis in the
changelog. The important part in the functional regression
and the pointer mismatch as root cause.
Please reframe the commit message along the lines of background,
problem, cause, fix, and validation. Something like-
CXL endpoint CPER protocol errors are processed by ...
Following commit 3c70ec71abda, endpoint CPER protocol errors are
silently dropped and no trace events are emitted. This happens
because bus_find_device() is called with the wrong pointer type,
so the memdev parent match never succeeds.
Fix it by ...
How do we know it works now?
-- Alison
> ---
> drivers/cxl/core/ras.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/cxl/core/ras.c b/drivers/cxl/core/ras.c
> index 006c6ffc2f56..7ec2dab152a7 100644
> --- a/drivers/cxl/core/ras.c
> +++ b/drivers/cxl/core/ras.c
> @@ -94,8 +94,7 @@ void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data)
> if (!pdev->dev.driver)
> return;
>
> - struct device *mem_dev __free(put_device) = bus_find_device(
> - &cxl_bus_type, NULL, pdev, match_memdev_by_parent);
> + struct device *mem_dev __free(put_device) = bus_find_device(&cxl_bus_type, NULL, &pdev->dev, match_memdev_by_parent);
> if (!mem_dev)
> return;
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cxl/ras: Fix match_memdev_by_parent() pointer type mismatch
2026-06-09 17:10 ` Alison Schofield
@ 2026-06-09 18:17 ` Bowman, Terry
2026-06-09 20:33 ` Alison Schofield
0 siblings, 1 reply; 5+ messages in thread
From: Bowman, Terry @ 2026-06-09 18:17 UTC (permalink / raw)
To: Alison Schofield
Cc: dave, jic23, dave.jiang, vishal.l.verma, ira.weiny, djbw,
ming.li, rrichter, Benjamin.Cheatham,
Smita.KoralahalliChannabasappa, stable, linux-cxl, linux-kernel,
PradeepVineshReddy.Kodamati
On 6/9/2026 12:10 PM, Alison Schofield wrote:
> On Mon, Jun 08, 2026 at 05:43:19PM -0500, Terry Bowman wrote:
>> bus_find_device() passes its data argument directly to the match
>> function as a const void *. match_memdev_by_parent() compares
>> dev->parent against this pointer:
>>
>> dev->parent == uport
>>
>> cxlmd->dev.parent is set in cxl_memdev_alloc() as:
>>
>> dev->parent = cxlds->dev; /* cxlds->dev == &pdev->dev */
>>
>> So cxlmd->dev.parent holds a struct device * pointing to &pdev->dev.
>> However, bus_find_device() is called with pdev (struct pci_dev *)
>> rather than &pdev->dev (struct device *). Since struct pci_dev does
>> not begin with struct device, the two pointer values differ, causing
>> the comparison to always evaluate false.
>>
>> As a result, cxl_cper_handle_prot_err() silently drops every CPER
>> error report for CXL endpoint devices -- bus_find_device() always
>> returns NULL and the function returns early without emitting any
>> kernel trace event.
>>
>> Fix by passing &pdev->dev instead of pdev.
>>
>> Fixes: 3c70ec71abda ("cxl/ras: Fix CPER handler device confusion")
>> Reported-by: Sashiko <sashiko@linuxfoundation.org>
>> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
>
> Hi Terry,
>
> The commit log is burying the lead- no endpoint errors reported.
>
> There is no need for the full struct layout analysis in the
> changelog. The important part in the functional regression
> and the pointer mismatch as root cause.
>
> Please reframe the commit message along the lines of background,
> problem, cause, fix, and validation. Something like-
>
> CXL endpoint CPER protocol errors are processed by ...
>
> Following commit 3c70ec71abda, endpoint CPER protocol errors are
> silently dropped and no trace events are emitted. This happens
> because bus_find_device() is called with the wrong pointer type,
> so the memdev parent match never succeeds.
>
> Fix it by ...
>
Ok.
>
> How do we know it works now?
>
> -- Alison
>
>
I have not tested this patch yet.
- Terry
>
>
>> ---
>> drivers/cxl/core/ras.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/cxl/core/ras.c b/drivers/cxl/core/ras.c
>> index 006c6ffc2f56..7ec2dab152a7 100644
>> --- a/drivers/cxl/core/ras.c
>> +++ b/drivers/cxl/core/ras.c
>> @@ -94,8 +94,7 @@ void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data)
>> if (!pdev->dev.driver)
>> return;
>>
>> - struct device *mem_dev __free(put_device) = bus_find_device(
>> - &cxl_bus_type, NULL, pdev, match_memdev_by_parent);
>> + struct device *mem_dev __free(put_device) = bus_find_device(&cxl_bus_type, NULL, &pdev->dev, match_memdev_by_parent);
>> if (!mem_dev)
>> return;
>>
>> --
>> 2.34.1
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] cxl/ras: Fix match_memdev_by_parent() pointer type mismatch
2026-06-09 18:17 ` Bowman, Terry
@ 2026-06-09 20:33 ` Alison Schofield
0 siblings, 0 replies; 5+ messages in thread
From: Alison Schofield @ 2026-06-09 20:33 UTC (permalink / raw)
To: Bowman, Terry
Cc: dave, jic23, dave.jiang, vishal.l.verma, ira.weiny, djbw,
ming.li, rrichter, Benjamin.Cheatham,
Smita.KoralahalliChannabasappa, stable, linux-cxl, linux-kernel,
PradeepVineshReddy.Kodamati
On Tue, Jun 09, 2026 at 01:17:32PM -0500, Bowman, Terry wrote:
> On 6/9/2026 12:10 PM, Alison Schofield wrote:
> > On Mon, Jun 08, 2026 at 05:43:19PM -0500, Terry Bowman wrote:
> >> bus_find_device() passes its data argument directly to the match
> >> function as a const void *. match_memdev_by_parent() compares
> >> dev->parent against this pointer:
> >>
> >> dev->parent == uport
> >>
> >> cxlmd->dev.parent is set in cxl_memdev_alloc() as:
> >>
> >> dev->parent = cxlds->dev; /* cxlds->dev == &pdev->dev */
> >>
> >> So cxlmd->dev.parent holds a struct device * pointing to &pdev->dev.
> >> However, bus_find_device() is called with pdev (struct pci_dev *)
> >> rather than &pdev->dev (struct device *). Since struct pci_dev does
> >> not begin with struct device, the two pointer values differ, causing
> >> the comparison to always evaluate false.
> >>
> >> As a result, cxl_cper_handle_prot_err() silently drops every CPER
> >> error report for CXL endpoint devices -- bus_find_device() always
> >> returns NULL and the function returns early without emitting any
> >> kernel trace event.
> >>
> >> Fix by passing &pdev->dev instead of pdev.
> >>
> >> Fixes: 3c70ec71abda ("cxl/ras: Fix CPER handler device confusion")
> >> Reported-by: Sashiko <sashiko@linuxfoundation.org>
> >> Signed-off-by: Terry Bowman <terry.bowman@amd.com>
> >
> > Hi Terry,
> >
> > The commit log is burying the lead- no endpoint errors reported.
> >
> > There is no need for the full struct layout analysis in the
> > changelog. The important part in the functional regression
> > and the pointer mismatch as root cause.
> >
> > Please reframe the commit message along the lines of background,
> > problem, cause, fix, and validation. Something like-
> >
> > CXL endpoint CPER protocol errors are processed by ...
> >
> > Following commit 3c70ec71abda, endpoint CPER protocol errors are
> > silently dropped and no trace events are emitted. This happens
> > because bus_find_device() is called with the wrong pointer type,
> > so the memdev parent match never succeeds.
> >
> > Fix it by ...
> >
>
> Ok.
>
> >
> > How do we know it works now?
> >
> > -- Alison
> >
> >
>
> I have not tested this patch yet.
I am intentionally being a pest on the commit message, however I am
not intentionally being a pest on the testing of this patch, because
it is obviously wrong code and obvious that the errors cannot be
reported unless this is fixed.
I was just after confirmation that we now see the errors once again,
and it's not something else that is broken.
--Alison
>
> - Terry
>
> >
> >
> >> ---
> >> drivers/cxl/core/ras.c | 3 +--
> >> 1 file changed, 1 insertion(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/cxl/core/ras.c b/drivers/cxl/core/ras.c
> >> index 006c6ffc2f56..7ec2dab152a7 100644
> >> --- a/drivers/cxl/core/ras.c
> >> +++ b/drivers/cxl/core/ras.c
> >> @@ -94,8 +94,7 @@ void cxl_cper_handle_prot_err(struct cxl_cper_prot_err_work_data *data)
> >> if (!pdev->dev.driver)
> >> return;
> >>
> >> - struct device *mem_dev __free(put_device) = bus_find_device(
> >> - &cxl_bus_type, NULL, pdev, match_memdev_by_parent);
> >> + struct device *mem_dev __free(put_device) = bus_find_device(&cxl_bus_type, NULL, &pdev->dev, match_memdev_by_parent);
> >> if (!mem_dev)
> >> return;
> >>
> >> --
> >> 2.34.1
> >>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-09 20:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-08 22:43 [PATCH] cxl/ras: Fix match_memdev_by_parent() pointer type mismatch Terry Bowman
2026-06-09 14:34 ` Dave Jiang
2026-06-09 17:10 ` Alison Schofield
2026-06-09 18:17 ` Bowman, Terry
2026-06-09 20:33 ` Alison Schofield
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®