* [PATCH] cxl/core: Check existence of cxl_memdev_state in poison test
@ 2026-03-31 0:50 Alison Schofield
2026-03-31 5:58 ` Alejandro Lucero Palau
2026-04-01 17:19 ` Dave Jiang
0 siblings, 2 replies; 3+ messages in thread
From: Alison Schofield @ 2026-03-31 0:50 UTC (permalink / raw)
To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
Vishal Verma, Ira Weiny, Dan Williams, Alejandro Lucero
Cc: linux-cxl
Before now, all CXL memdevs were assumed to have a mailbox-backed
cxl_memdev_state, so poison command checks could safely dereference
the @mds.
With the introduction of Type 2 devices, a memdev may not implement
a mailbox interface, and so there is no associated cxl_memdev_state.
Guard against this case by returning false when @mds is absent.
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
drivers/cxl/core/memdev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
index 273c22118d3d..591425866045 100644
--- a/drivers/cxl/core/memdev.c
+++ b/drivers/cxl/core/memdev.c
@@ -204,6 +204,9 @@ bool cxl_memdev_has_poison_cmd(struct cxl_memdev *cxlmd,
{
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
+ if (!mds)
+ return 0;
+
return test_bit(cmd, mds->poison.enabled_cmds);
}
--
2.37.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cxl/core: Check existence of cxl_memdev_state in poison test
2026-03-31 0:50 [PATCH] cxl/core: Check existence of cxl_memdev_state in poison test Alison Schofield
@ 2026-03-31 5:58 ` Alejandro Lucero Palau
2026-04-01 17:19 ` Dave Jiang
1 sibling, 0 replies; 3+ messages in thread
From: Alejandro Lucero Palau @ 2026-03-31 5:58 UTC (permalink / raw)
To: Alison Schofield, Davidlohr Bueso, Jonathan Cameron, Dave Jiang,
Vishal Verma, Ira Weiny, Dan Williams
Cc: linux-cxl
Hi Allison,
I think the introduction of type2 is weakening some assumptions of the
core design, and this check is another example after similar ones added
for type2. Not sure how this could be addressed properly, so I will look
at how to make this integration seamless.
By now, as this check is necessary, at least as a sanity check:
Reviewed-by: Alejandro Lucero <alucerop@amd.com>
On 3/31/26 01:50, Alison Schofield wrote:
> Before now, all CXL memdevs were assumed to have a mailbox-backed
> cxl_memdev_state, so poison command checks could safely dereference
> the @mds.
>
> With the introduction of Type 2 devices, a memdev may not implement
> a mailbox interface, and so there is no associated cxl_memdev_state.
> Guard against this case by returning false when @mds is absent.
>
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> ---
> drivers/cxl/core/memdev.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> index 273c22118d3d..591425866045 100644
> --- a/drivers/cxl/core/memdev.c
> +++ b/drivers/cxl/core/memdev.c
> @@ -204,6 +204,9 @@ bool cxl_memdev_has_poison_cmd(struct cxl_memdev *cxlmd,
> {
> struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
>
> + if (!mds)
> + return 0;
> +
> return test_bit(cmd, mds->poison.enabled_cmds);
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cxl/core: Check existence of cxl_memdev_state in poison test
2026-03-31 0:50 [PATCH] cxl/core: Check existence of cxl_memdev_state in poison test Alison Schofield
2026-03-31 5:58 ` Alejandro Lucero Palau
@ 2026-04-01 17:19 ` Dave Jiang
1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2026-04-01 17:19 UTC (permalink / raw)
To: Alison Schofield, Davidlohr Bueso, Jonathan Cameron, Vishal Verma,
Ira Weiny, Dan Williams, Alejandro Lucero
Cc: linux-cxl
On 3/30/26 5:50 PM, Alison Schofield wrote:
> Before now, all CXL memdevs were assumed to have a mailbox-backed
> cxl_memdev_state, so poison command checks could safely dereference
> the @mds.
>
> With the introduction of Type 2 devices, a memdev may not implement
> a mailbox interface, and so there is no associated cxl_memdev_state.
> Guard against this case by returning false when @mds is absent.
>
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Applied to cxl/next
261a02b93d9b
> ---
> drivers/cxl/core/memdev.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
> index 273c22118d3d..591425866045 100644
> --- a/drivers/cxl/core/memdev.c
> +++ b/drivers/cxl/core/memdev.c
> @@ -204,6 +204,9 @@ bool cxl_memdev_has_poison_cmd(struct cxl_memdev *cxlmd,
> {
> struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
>
> + if (!mds)
> + return 0;
> +
> return test_bit(cmd, mds->poison.enabled_cmds);
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-01 17:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 0:50 [PATCH] cxl/core: Check existence of cxl_memdev_state in poison test Alison Schofield
2026-03-31 5:58 ` Alejandro Lucero Palau
2026-04-01 17:19 ` Dave Jiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox