Linux CXL
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: dave.jiang@intel.com, dan.j.williams@intel.com
Cc: jonathan.cameron@huawei.com, alison.schofield@intel.com,
	ira.weiny@intel.com, vishal.l.verma@intel.com,
	seven.yi.lee@gmail.com, ming.li@zohomail.com,
	a.manzanares@samsung.com, fan.ni@samsung.com,
	anisa.su@samsung.com, dave@stgolabs.net,
	linux-cxl@vger.kernel.org
Subject: [PATCH 4/4] tools/testing/cxl: Set Shutdown State support
Date: Wed, 19 Feb 2025 17:36:04 -0800	[thread overview]
Message-ID: <20250220013604.263489-5-dave@stgolabs.net> (raw)
In-Reply-To: <20250220013604.263489-1-dave@stgolabs.net>

Add support to emulate the CXL Set Shutdown State operation.

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Li Ming <ming.li@zohomail.com>
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 tools/testing/cxl/test/mem.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
index 495199238335..9ca210b80e27 100644
--- a/tools/testing/cxl/test/mem.c
+++ b/tools/testing/cxl/test/mem.c
@@ -65,6 +65,10 @@ static struct cxl_cel_entry mock_cel[] = {
 		.opcode = cpu_to_le16(CXL_MBOX_OP_GET_HEALTH_INFO),
 		.effect = CXL_CMD_EFFECT_NONE,
 	},
+	{
+		.opcode = cpu_to_le16(CXL_MBOX_OP_SET_SHUTDOWN_STATE),
+		.effect = POLICY_CHANGE_IMMEDIATE,
+	},
 	{
 		.opcode = cpu_to_le16(CXL_MBOX_OP_GET_POISON),
 		.effect = CXL_CMD_EFFECT_NONE,
@@ -161,6 +165,7 @@ struct cxl_mockmem_data {
 	u8 event_buf[SZ_4K];
 	u64 timestamp;
 	unsigned long sanitize_timeout;
+	u8 shutdown_state;
 };
 
 static struct mock_event_log *event_find_log(struct device *dev, int log_type)
@@ -1088,6 +1093,21 @@ static int mock_health_info(struct cxl_mbox_cmd *cmd)
 	return 0;
 }
 
+static int mock_set_shutdown_state(struct cxl_mockmem_data *mdata,
+				   struct cxl_mbox_cmd *cmd)
+{
+	struct cxl_mbox_set_shutdown_state_in *ss = cmd->payload_in;
+
+	if (cmd->size_in != sizeof(*ss))
+		return -EINVAL;
+
+	if (cmd->size_out != 0)
+		return -EINVAL;
+
+	mdata->shutdown_state = ss->state;
+	return 0;
+}
+
 static struct mock_poison {
 	struct cxl_dev_state *cxlds;
 	u64 dpa;
@@ -1421,6 +1441,9 @@ static int cxl_mock_mbox_send(struct cxl_mailbox *cxl_mbox,
 	case CXL_MBOX_OP_PASSPHRASE_SECURE_ERASE:
 		rc = mock_passphrase_secure_erase(mdata, cmd);
 		break;
+	case CXL_MBOX_OP_SET_SHUTDOWN_STATE:
+		rc = mock_set_shutdown_state(mdata, cmd);
+		break;
 	case CXL_MBOX_OP_GET_POISON:
 		rc = mock_get_poison(cxlds, cmd);
 		break;
-- 
2.39.5


  parent reply	other threads:[~2025-02-20  1:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-20  1:36 [PATCH v4 0/4] cxl: Dirty shutdown followups Davidlohr Bueso
2025-02-20  1:36 ` [PATCH 1/4] cxl/pci: Introduce cxl_gpf_get_dvsec() Davidlohr Bueso
2025-02-20 15:34   ` Dave Jiang
2025-02-20 16:08   ` Ira Weiny
2025-02-20 17:04   ` Jonathan Cameron
2025-02-21  0:15   ` Fan Ni
2025-02-20  1:36 ` [PATCH 2/4] cxl/pmem: Rename cxl_dirty_shutdown_state() Davidlohr Bueso
2025-02-20 16:08   ` Ira Weiny
2025-02-20 17:12   ` Jonathan Cameron
2025-02-20 19:51     ` Davidlohr Bueso
2025-02-20  1:36 ` [PATCH 3/4] cxl/pmem: Export dirty shutdown count via sysfs Davidlohr Bueso
2025-02-20 16:11   ` Ira Weiny
2025-02-20 17:29   ` Jonathan Cameron
2025-02-20 19:28     ` Davidlohr Bueso
2025-02-20  1:36 ` Davidlohr Bueso [this message]
2025-02-20 16:13   ` [PATCH 4/4] tools/testing/cxl: Set Shutdown State support Ira Weiny
2025-02-20 17:30   ` Jonathan Cameron
  -- strict thread matches above, loose matches on Subject: below --
2025-02-20 22:02 [PATCH v5 0/4] cxl: Dirty shutdown followups Davidlohr Bueso
2025-02-20 22:02 ` [PATCH 4/4] tools/testing/cxl: Set Shutdown State support Davidlohr Bueso
2025-02-19  6:28 [PATCH v3 0/4] cxl: Dirty shutdown followups Davidlohr Bueso
2025-02-19  6:28 ` [PATCH 4/4] tools/testing/cxl: Set Shutdown State support Davidlohr Bueso
2025-02-19 16:48   ` Dave Jiang
2025-02-20  1:01   ` Li Ming
2025-02-19  2:14 [PATCH v2 0/4] cxl: Dirty shutdown followups Davidlohr Bueso
2025-02-19  2:14 ` [PATCH 4/4] tools/testing/cxl: Set Shutdown State support Davidlohr Bueso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250220013604.263489-5-dave@stgolabs.net \
    --to=dave@stgolabs.net \
    --cc=a.manzanares@samsung.com \
    --cc=alison.schofield@intel.com \
    --cc=anisa.su@samsung.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=fan.ni@samsung.com \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=ming.li@zohomail.com \
    --cc=seven.yi.lee@gmail.com \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox