Linux CXL
 help / color / mirror / Atom feed
* [PATCH] cxl/mbox: Check enabled_cmds before sending SET_SHUTDOWN_STATE
@ 2025-02-07 19:34 alison.schofield
  2025-02-07 20:06 ` Dan Williams
  0 siblings, 1 reply; 3+ messages in thread
From: alison.schofield @ 2025-02-07 19:34 UTC (permalink / raw)
  To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
	Vishal Verma, Ira Weiny, Dan Williams
  Cc: linux-cxl

From: Alison Schofield <alison.schofield@intel.com>

The CXL specification defines CXL_MBOX_OP_SET_SHUTDOWN_STATE as
optional. Check the enabled_cmds bitmap before sending to device.

This appeared with cxl-test where mock support for this command
is not present and -EIO is returned, leading to a WARN_ONCE()
stack trace and dev_warn()'s on every cxl_nvdimm_probe.

Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---

Not sure what we actually want to do when not supported.
Most cmds just return 0, like I did here, but maybe for
this functionality something more is warranted.

wrt cxl-test support, also not sure if this feature wants some
round-trip testing support via cxl-test mocking. I do like the
-EIO from cxl-test as a loud reminder when running cxl-test 
that something new has come in that cxl-test doesn't know about.


 drivers/cxl/core/mbox.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index c5eedcae3b02..f06a1ed81a6c 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -1289,6 +1289,10 @@ int cxl_dirty_shutdown_state(struct cxl_memdev_state *mds)
 		.state = 1
 	};
 
+	if (!test_bit(CXL_MEM_COMMAND_ID_SET_SHUTDOWN_STATE,
+		      cxl_mbox->enabled_cmds))
+		return 0;
+
 	mbox_cmd = (struct cxl_mbox_cmd) {
 		.opcode = CXL_MBOX_OP_SET_SHUTDOWN_STATE,
 		.size_in = sizeof(in),

base-commit: 5585e342e8d38cc598279bdb87f235f8b954dd5a
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-07 21:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-07 19:34 [PATCH] cxl/mbox: Check enabled_cmds before sending SET_SHUTDOWN_STATE alison.schofield
2025-02-07 20:06 ` Dan Williams
2025-02-07 21:19   ` Alison Schofield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox