CXL: Miscellaneous fixes
v4 cover CXL: Miscellaneous fixes
These are minor fixes I have seen along the way in the CXL code.
This includes fixing the query command to account for kernel exclusive and enabled commands.
To: "Dan Williams" <[email protected]>
---
Changes in v4:
- Pick up tags from v3
- Jonathan: Add documentation for the flags
- Link to v3: https://lore.kernel.org/r/[email protected]
---
Ira Weiny (4):
cxl/mem: Remove unused CXL_CMD_FLAG_NONE define cxl/uapi: Add warning on CXL command enum cxl/uapi: Tag commands from cxl_query_cmd() cxl/mem: Fix UAPI command comment
drivers/cxl/core/mbox.c | 9 +++++++-- drivers/cxl/cxlmem.h | 1 - include/uapi/linux/cxl_mem.h | 30 +++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 8 deletions(-)
---
base-commit: 22b8077d0fcec86c6ed0e0fce9f7e7e5a4c2d56a
change-id: 20221222-cxl-misc-793ec2442455
Best regards,
Signature · 1 line
Ira Weiny <[email protected]>
PATCH v4 1/4 cxl/mem: Remove unused CXL_CMD_FLAG_NONE define
CXL_CMD_FLAG_NONE is not used, remove it.
--- drivers/cxl/cxlmem.h | 1 - 1 file changed, 1 deletion(-)
drivers/cxl/cxlmem.h +0 -1
@@ -393,7 +393,6 @@ struct cxl_mem_command {struct cxl_command_info info;enum cxl_opcode opcode;u32 flags; -#define CXL_CMD_FLAG_NONE 0#define CXL_CMD_FLAG_FORCE_ENABLE BIT(0) };
Signature · 1 line
2.39.1
PATCH v4 2/4 cxl/uapi: Add warning on CXL command enum
In reply to Ira WeinyThe CXL command enum is exported to user space and must maintain backwards compatibility.
Add comment that new defines must be added to the end of the list.
--- include/uapi/linux/cxl_mem.h | 4 ++++ 1 file changed, 4 insertions(+)
include/uapi/linux/cxl_mem.h +4 -0
@@ -19,6 +19,10 @@#define CXL_MEM_QUERY_COMMANDS _IOR(0xCE, 1, struct cxl_mem_query_commands)#define CXL_MEM_SEND_COMMAND _IOWR(0xCE, 2, struct cxl_send_command) +/* +* NOTE: New defines must be added to the end of the list to preserve +* compatibility because this enum is exported to user space. +*/ #define CXL_CMDS \ ___C(INVALID, "Invalid Command"), \ ___C(IDENTIFY, "Identify Command"), \
Signature · 1 line
2.39.1
PATCH v4 3/4 cxl/uapi: Tag commands from cxl_query_cmd()
In reply to Ira WeinyIt was pointed out that commands not supported by the device or excluded by the kernel were being returned in cxl_query_cmd().[1]
While libcxl correctly handles failing commands, it is more efficient to not issue an invalid command in the first place. This can't be done without additional information being returned from cxl_query_cmd(). In addition, information about the availability of commands can be useful for debugging.
Add flags to struct cxl_command_info which reflect if a command is enabled and/or exclusive to the kernel.
[1] https://lore.kernel.org/all/[email protected]/
---
Changes for v4:
Jonathan
Add Documentation for the flags
--- drivers/cxl/core/mbox.c | 9 +++++++-- include/uapi/linux/cxl_mem.h | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-)
drivers/cxl/core/mbox.c +7 -2
@@ -445,9 +445,14 @@ int cxl_query_cmd(struct cxl_memdev *cxlmd,* structures. */ cxl_for_each_cmd (cmd) { -const struct cxl_command_info *info = &cmd->info; +struct cxl_command_info info = cmd->info; -if (copy_to_user (&q->commands[j++], info,sizeof (*info))) +if (test_bit (info.id, cxlmd->cxlds->enabled_cmds)) + info.flags |=CXL_MEM_COMMAND_FLAG_ENABLED ; +if (test_bit (info.id, cxlmd->cxlds->exclusive_cmds)) + info.flags |=CXL_MEM_COMMAND_FLAG_EXCLUSIVE ; + +if (copy_to_user (&q->commands[j++], &info,sizeof (info)))return -EFAULT ;if (j == n_commands)
include/uapi/linux/cxl_mem.h +17 -2
@@ -72,6 +72,19 @@ static const struct {* struct cxl_command_info - Command information returned from a query. * @id: ID number for the command. * @flags: Flags that specify command behavior. +* +* CXL_MEM_COMMAND_FLAG_USER_ENABLED +* +* The given command id is supported by the driver and is supported by +* a related opcode on the device. +* +* CXL_MEM_COMMAND_FLAG_EXCLUSIVE +* +* Requests with the given command id will terminate with EBUSY as the +* kernel actively owns management of the given resource. For example, +* the label-storage-area can not be written while the kernel is +* actively managing that space. +* * @size_in: Expected input size, or ~0 if variable length. * @size_out: Expected output size, or ~0 if variable length. *
@@ -81,7 +94,7 @@ static const struct {* bytes of output. * * - @id = 10 -* - @flags = 0 +* - @flags = CXL_MEM_COMMAND_FLAG_ENABLED * - @size_in = ~0 * - @size_out = 0 *
@@ -91,7 +104,9 @@ struct cxl_command_info {__u32 id;__u32 flags; -#define CXL_MEM_COMMAND_FLAG_MASK GENMASK(0, 0) +#define CXL_MEM_COMMAND_FLAG_MASK GENMASK(1, 0) +#define CXL_MEM_COMMAND_FLAG_ENABLED BIT(0) +#define CXL_MEM_COMMAND_FLAG_EXCLUSIVE BIT(1)__u32 size_in;__u32 size_out;
Signature · 1 line
2.39.1
PATCH v4 4/4 cxl/mem: Fix UAPI command comment
In reply to Ira WeinyThe command comment had grammatical errors. In an attempt to fix those it was noted that the comment and the query command were not in sync.
Now that the query command returns excluded and device unsupported command information. Update the kdoc and fix the grammatical errors.
[1] https://lore.kernel.org/all/[email protected]/
--- include/uapi/linux/cxl_mem.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
include/uapi/linux/cxl_mem.h +4 -3
@@ -11,9 +11,10 @@/** * DOC: UAPI * -* Not all of all commands that the driver supports are always available for use -* by userspace. Userspace must check the results from the QUERY command in -* order to determine the live set of commands. +* Not all of the commands that the driver supports are available for use by +* userspace at all times. Userspace can check the result of the QUERY command +* to determine the live set of commands. Alternatively, it can issue the +* command and check for failure. */ #define CXL_MEM_QUERY_COMMANDS _IOR(0xCE, 1, struct cxl_mem_query_commands)
Signature · 1 line
2.39.1