diff mbox series

cxl/core: Rename functions that handle mbox commands

Message ID 20220401214530.1188359-1-alison.schofield@intel.com
State New, archived
Headers show
Series cxl/core: Rename functions that handle mbox commands | expand

Commit Message

Alison Schofield April 1, 2022, 9:45 p.m. UTC
From: Alison Schofield <alison.schofield@intel.com>

Mailbox commands are sent to the hardware either on behalf of
userspace (IOCTLs) or by internal kernel users. Update the
naming scheme to delineate the IOCTL versus internal pathways
and to more accurately reflect the work each function performs.

IOCTL pathway functions:
cxl_ioctl_query()		prev: cxl_query_cmd()
cxl_ioctl_send()		prev: cxl_send_cmd()
cxl_ioctl_send_checks()		prev: cxl_validate_cmd_from_user()
cxl_ioctl_send_to_kbuf()	prev: handle_mailbox_cmd_from_user()

Internal pathway functions:
cxl_internal_cmd_send()		prev: cxl_mbox_send_cmd()
cxl_pci_mbox_send()		prev: cxl_pci_mbox_send() (no change)

Suggested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---

Dan - I can rebase on top of cxl/preview next week if that is
preferable. Let me know. Meanwhile, let's see how folks like 
the new names.


 drivers/cxl/core/core.h   |  6 ++---
 drivers/cxl/core/mbox.c   | 55 +++++++++++++++++++--------------------
 drivers/cxl/core/memdev.c |  4 +--
 drivers/cxl/cxlmem.h      |  4 +--
 drivers/cxl/pmem.c        | 11 ++++----
 5 files changed, 40 insertions(+), 40 deletions(-)


base-commit: 9b688fc651b9d2b633e8d959454670aba1c39162
prerequisite-patch-id: 2b66d88f7526f26eb5fb1a42721d3fbde4da20ad
prerequisite-patch-id: cfd4e0a4c852002789432c11abbebfa8b21616a3
prerequisite-patch-id: dbf2fd54ad4926ccd3b1910a534dba7c01c85af6
prerequisite-patch-id: e875aafbd5c11ca5abdba3e4a81122fd034007a6
prerequisite-patch-id: 5dfa246306ae578c294eafb19381658d54497137
prerequisite-patch-id: 0339fd1db77bf0c090ce0aac9481fab439b205c5
prerequisite-patch-id: b4fefc6fb780e7b1cd830f6702012f61f88f5496
prerequisite-patch-id: 74d6bf0328e6452120751b69e84aabca3fecdd0a
prerequisite-patch-id: ece44797d2d18194a9d34b93bba88e5358ffe782
diff mbox series

Patch

diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h
index d345c76373f1..2f5dbaca832e 100644
--- a/drivers/cxl/core/core.h
+++ b/drivers/cxl/core/core.h
@@ -15,9 +15,9 @@  extern struct device_attribute dev_attr_delete_region;
 
 struct cxl_send_command;
 struct cxl_mem_query_commands;
-int cxl_query_cmd(struct cxl_memdev *cxlmd,
-		  struct cxl_mem_query_commands __user *q);
-int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s);
+int cxl_ioctl_query(struct cxl_memdev *cxlmd,
+		    struct cxl_mem_query_commands __user *q);
+int cxl_ioctl_send(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s);
 void __iomem *devm_cxl_iomap_block(struct device *dev, resource_size_t addr,
 				   resource_size_t length);
 
diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index 839207b627a8..4c779e9444d2 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -139,7 +139,7 @@  static const char *cxl_mem_opcode_to_name(u16 opcode)
 }
 
 /**
- * cxl_mbox_send_cmd() - Send a mailbox command to a device.
+ * cxl_internal_cmd_send() - Send a mailbox command to a device.
  * @cxlds: The device data for the operation
  * @opcode: Opcode for the mailbox command.
  * @in: The input payload for the mailbox command.
@@ -160,8 +160,8 @@  static const char *cxl_mem_opcode_to_name(u16 opcode)
  * error. While this distinction can be useful for commands from userspace, the
  * kernel will only be able to use results when both are successful.
  */
-int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in,
-		      size_t in_size, void *out, size_t out_size)
+int cxl_internal_cmd_send(struct cxl_dev_state *cxlds, u16 opcode, void *in,
+			  size_t in_size, void *out, size_t out_size)
 {
 	const struct cxl_mem_command *cmd = cxl_mem_find_command(opcode);
 	struct cxl_mbox_cmd mbox_cmd = {
@@ -193,7 +193,7 @@  int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in,
 
 	return 0;
 }
-EXPORT_SYMBOL_NS_GPL(cxl_mbox_send_cmd, CXL);
+EXPORT_SYMBOL_NS_GPL(cxl_internal_cmd_send, CXL);
 
 static bool cxl_mem_raw_command_allowed(u16 opcode)
 {
@@ -375,7 +375,7 @@  static int cxl_to_mem_cmd(struct cxl_mem_command *mem_cmd,
 }
 
 /**
- * cxl_validate_cmd_from_user() - Check fields for CXL_MEM_SEND_COMMAND.
+ * cxl_ioctl_send_checks() - Check userspace send request
  * @mbox_cmd: Sanitized and populated &struct cxl_mbox_cmd.
  * @cxlds: The device data for the operation
  * @send_cmd: &struct cxl_send_command copied in from userspace.
@@ -391,9 +391,9 @@  static int cxl_to_mem_cmd(struct cxl_mem_command *mem_cmd,
  * The result of this command is a fully validated command in @mbox_cmd that is
  * safe to send to the hardware.
  */
-static int cxl_validate_cmd_from_user(struct cxl_mbox_cmd *mbox_cmd,
-				      struct cxl_dev_state *cxlds,
-				      const struct cxl_send_command *send_cmd)
+static int cxl_ioctl_send_checks(struct cxl_mbox_cmd *mbox_cmd,
+				 struct cxl_dev_state *cxlds,
+				 const struct cxl_send_command *send_cmd)
 {
 	struct cxl_mem_command mem_cmd;
 	int rc;
@@ -424,8 +424,8 @@  static int cxl_validate_cmd_from_user(struct cxl_mbox_cmd *mbox_cmd,
 				 send_cmd->in.payload);
 }
 
-int cxl_query_cmd(struct cxl_memdev *cxlmd,
-		  struct cxl_mem_query_commands __user *q)
+int cxl_ioctl_query(struct cxl_memdev *cxlmd,
+		    struct cxl_mem_query_commands __user *q)
 {
 	struct device *dev = &cxlmd->dev;
 	struct cxl_mem_command *cmd;
@@ -459,7 +459,7 @@  int cxl_query_cmd(struct cxl_memdev *cxlmd,
 }
 
 /**
- * handle_mailbox_cmd_from_user() - Dispatch a mailbox command for userspace.
+ * cxl_ioctl_send_to_kbuf() - Dispatch a mailbox command for userspace.
  * @cxlds: The device data for the operation
  * @mbox_cmd: The validated mailbox command.
  * @out_payload: Pointer to userspace's output payload.
@@ -479,12 +479,11 @@  int cxl_query_cmd(struct cxl_memdev *cxlmd,
  * Dispatches a mailbox command on behalf of a userspace request.
  * The output payload is copied to userspace.
  *
- * See cxl_send_cmd().
+ * See cxl_ioctl_send().
  */
-static int handle_mailbox_cmd_from_user(struct cxl_dev_state *cxlds,
-					struct cxl_mbox_cmd *mbox_cmd,
-					u64 out_payload, s32 *size_out,
-					u32 *retval)
+static int cxl_ioctl_send_to_kbuf(struct cxl_dev_state *cxlds,
+				  struct cxl_mbox_cmd *mbox_cmd,
+				  u64 out_payload, s32 *size_out, u32 *retval)
 {
 	struct device *dev = cxlds->dev;
 	int rc;
@@ -523,7 +522,7 @@  static int handle_mailbox_cmd_from_user(struct cxl_dev_state *cxlds,
 	return rc;
 }
 
-int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s)
+int cxl_ioctl_send(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s)
 {
 	struct cxl_dev_state *cxlds = cxlmd->cxlds;
 	struct device *dev = &cxlmd->dev;
@@ -536,12 +535,12 @@  int cxl_send_cmd(struct cxl_memdev *cxlmd, struct cxl_send_command __user *s)
 	if (copy_from_user(&send, s, sizeof(send)))
 		return -EFAULT;
 
-	rc = cxl_validate_cmd_from_user(&mbox_cmd, cxlmd->cxlds, &send);
+	rc = cxl_ioctl_send_checks(&mbox_cmd, cxlmd->cxlds, &send);
 	if (rc)
 		return rc;
 
-	rc = handle_mailbox_cmd_from_user(cxlds, &mbox_cmd, send.out.payload,
-					  &send.out.size, &send.retval);
+	rc = cxl_ioctl_send_to_kbuf(cxlds, &mbox_cmd, send.out.payload,
+				    &send.out.size, &send.retval);
 	if (rc)
 		return rc;
 
@@ -565,8 +564,8 @@  static int cxl_xfer_log(struct cxl_dev_state *cxlds, uuid_t *uuid, u32 size, u8
 		};
 		int rc;
 
-		rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_GET_LOG, &log, sizeof(log),
-				       out, xfer_size);
+		rc = cxl_internal_cmd_send(cxlds, CXL_MBOX_OP_GET_LOG, &log,
+					   sizeof(log), out, xfer_size);
 		if (rc < 0)
 			return rc;
 
@@ -618,8 +617,8 @@  static struct cxl_mbox_get_supported_logs *cxl_get_gsl(struct cxl_dev_state *cxl
 	if (!ret)
 		return ERR_PTR(-ENOMEM);
 
-	rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_GET_SUPPORTED_LOGS, NULL, 0, ret,
-			       cxlds->payload_size);
+	rc = cxl_internal_cmd_send(cxlds, CXL_MBOX_OP_GET_SUPPORTED_LOGS, NULL,
+				   0, ret, cxlds->payload_size);
 	if (rc < 0) {
 		kvfree(ret);
 		return ERR_PTR(rc);
@@ -723,8 +722,8 @@  static int cxl_mem_get_partition_info(struct cxl_dev_state *cxlds)
 	} __packed pi;
 	int rc;
 
-	rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_GET_PARTITION_INFO, NULL, 0,
-			       &pi, sizeof(pi));
+	rc = cxl_internal_cmd_send(cxlds, CXL_MBOX_OP_GET_PARTITION_INFO, NULL,
+				   0, &pi, sizeof(pi));
 
 	if (rc)
 		return rc;
@@ -756,8 +755,8 @@  int cxl_dev_state_identify(struct cxl_dev_state *cxlds)
 	struct cxl_mbox_identify id;
 	int rc;
 
-	rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_IDENTIFY, NULL, 0, &id,
-			       sizeof(id));
+	rc = cxl_internal_cmd_send(cxlds, CXL_MBOX_OP_IDENTIFY, NULL, 0, &id,
+				   sizeof(id));
 	if (rc < 0)
 		return rc;
 
diff --git a/drivers/cxl/core/memdev.c b/drivers/cxl/core/memdev.c
index ad8c9f61c38a..1962511df769 100644
--- a/drivers/cxl/core/memdev.c
+++ b/drivers/cxl/core/memdev.c
@@ -268,9 +268,9 @@  static long __cxl_memdev_ioctl(struct cxl_memdev *cxlmd, unsigned int cmd,
 {
 	switch (cmd) {
 	case CXL_MEM_QUERY_COMMANDS:
-		return cxl_query_cmd(cxlmd, (void __user *)arg);
+		return cxl_ioctl_query(cxlmd, (void __user *)arg);
 	case CXL_MEM_SEND_COMMAND:
-		return cxl_send_cmd(cxlmd, (void __user *)arg);
+		return cxl_ioctl_send(cxlmd, (void __user *)arg);
 	default:
 		return -ENOTTY;
 	}
diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h
index dee574527e50..2719c0430440 100644
--- a/drivers/cxl/cxlmem.h
+++ b/drivers/cxl/cxlmem.h
@@ -296,8 +296,8 @@  struct cxl_mem_command {
 #define CXL_CMD_FLAG_FORCE_ENABLE BIT(0)
 };
 
-int cxl_mbox_send_cmd(struct cxl_dev_state *cxlds, u16 opcode, void *in,
-		      size_t in_size, void *out, size_t out_size);
+int cxl_internal_cmd_send(struct cxl_dev_state *cxlds, u16 opcode, void *in,
+		size_t in_size, void *out, size_t out_size);
 int cxl_dev_state_identify(struct cxl_dev_state *cxlds);
 int cxl_enumerate_cmds(struct cxl_dev_state *cxlds);
 int cxl_mem_create_range_info(struct cxl_dev_state *cxlds);
diff --git a/drivers/cxl/pmem.c b/drivers/cxl/pmem.c
index 35c6f3af18f2..4c19defa77ff 100644
--- a/drivers/cxl/pmem.c
+++ b/drivers/cxl/pmem.c
@@ -112,8 +112,9 @@  static int cxl_pmem_get_config_data(struct cxl_dev_state *cxlds,
 		.length = cmd->in_length,
 	};
 
-	rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_GET_LSA, &get_lsa,
-			       sizeof(get_lsa), cmd->out_buf, cmd->in_length);
+	rc = cxl_internal_cmd_send(cxlds, CXL_MBOX_OP_GET_LSA, &get_lsa,
+				   sizeof(get_lsa), cmd->out_buf,
+				   cmd->in_length);
 	cmd->status = 0;
 
 	return rc;
@@ -143,9 +144,9 @@  static int cxl_pmem_set_config_data(struct cxl_dev_state *cxlds,
 	};
 	memcpy(set_lsa->data, cmd->in_buf, cmd->in_length);
 
-	rc = cxl_mbox_send_cmd(cxlds, CXL_MBOX_OP_SET_LSA, set_lsa,
-			       struct_size(set_lsa, data, cmd->in_length),
-			       NULL, 0);
+	rc = cxl_internal_cmd_send(cxlds, CXL_MBOX_OP_SET_LSA, set_lsa,
+				   struct_size(set_lsa, data, cmd->in_length),
+				   NULL, 0);
 
 	/*
 	 * Set "firmware" status (4-packed bytes at the end of the input