All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cxl/mbox: Serialize RAW Get/Set Feature commands
@ 2026-07-14  3:10 Richard Cheng
  2026-07-14  3:21 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Cheng @ 2026-07-14  3:10 UTC (permalink / raw)
  To: dave, jic23, dave.jiang, alison.schofield, vishal.l.verma, djbw,
	danwilliams
  Cc: iweiny, ming.li, shiju.jose, alucerop, linux-cxl, linux-kernel,
	kobak, kaihengf, newtonl, kristinc, mochs, Richard Cheng

Dave Jiang's patch [1] adds feat_mutex to serialize kernel-managed Get
and Set Feature operations. However, the RAW command path calls
mbox_send() directly and bypasses cxl_get_feature() and
cxl_set_feature().

Take feat_mutex around each RAW Get and Set Feature mailbox send. This
prevents individual RAW Feature commands from interleaving with
kernel-managed Feature helper loops. Other RAW commands are unchanged.

[1]:
https://lore.kernel.org/linux-cxl/20260709155841.1895915-1-dave.jiang@intel.com/
Signed-off-by: Richard Cheng <icheng@nvidia.com>
---
 drivers/cxl/core/mbox.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index 0370ac39ec4a..55b0c3ac1ede 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -599,6 +599,8 @@ static int handle_mailbox_cmd_from_user(struct cxl_mailbox *cxl_mbox,
 					u32 *retval)
 {
 	struct device *dev = cxl_mbox->host;
+	bool is_feature_cmd = mbox_cmd->opcode == CXL_MBOX_OP_GET_FEATURE ||
+			      mbox_cmd->opcode == CXL_MBOX_OP_SET_FEATURE;
 	int rc;
 
 	dev_dbg(dev,
@@ -608,7 +610,11 @@ static int handle_mailbox_cmd_from_user(struct cxl_mailbox *cxl_mbox,
 		cxl_mem_opcode_to_name(mbox_cmd->opcode),
 		mbox_cmd->opcode, mbox_cmd->size_in);
 
+	if (is_feature_cmd)
+		mutex_lock(&cxl_mbox->feat_mutex);
 	rc = cxl_mbox->mbox_send(cxl_mbox, mbox_cmd);
+	if (is_feature_cmd)
+		mutex_unlock(&cxl_mbox->feat_mutex);
 	if (rc)
 		goto out;
 
-- 
2.43.0


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

end of thread, other threads:[~2026-07-14  3:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-14  3:10 [PATCH] cxl/mbox: Serialize RAW Get/Set Feature commands Richard Cheng
2026-07-14  3:21 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.