summaryrefslogtreecommitdiffstats
path: root/drivers/cxl
diff options
context:
space:
mode:
authorIra Weiny <ira.weiny@intel.com>2023-02-02 17:04:26 -0800
committerDan Williams <dan.j.williams@intel.com>2023-02-10 17:54:45 -0800
commit814a15f3b4131d3205bd47e23b50ccc6c666ce1d (patch)
treeae54a8dc438841b4c29bac66bb9aa014b6644821 /drivers/cxl
parent11ef026e467b05eac0a2ceb981d351ddc4b12216 (diff)
downloadlinux-stable-814a15f3b4131d3205bd47e23b50ccc6c666ce1d.tar.gz
linux-stable-814a15f3b4131d3205bd47e23b50ccc6c666ce1d.tar.bz2
linux-stable-814a15f3b4131d3205bd47e23b50ccc6c666ce1d.zip
cxl/uapi: Tag commands from cxl_query_cmd()
It 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/63b4ec4e37cc1_5178e2941d@dwillia2-xfh.jf.intel.com.notmuch/ Suggested-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Ira Weiny <ira.weiny@intel.com> Link: https://lore.kernel.org/r/20221222-cxl-misc-v4-3-62f701c1cdd1@intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/cxl')
-rw-r--r--drivers/cxl/core/mbox.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index 202d49dd9911..fd3b13b0fb7f 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -451,9 +451,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)