Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-6.3/cxl' into cxl/next

Pick up some final miscellaneous updates for v6.3 including support for
communicating 'exclusive' and 'enabled' state of commands.

+33 -9
+7 -2
drivers/cxl/core/mbox.c
··· 453 453 * structures. 454 454 */ 455 455 cxl_for_each_cmd(cmd) { 456 - const struct cxl_command_info *info = &cmd->info; 456 + struct cxl_command_info info = cmd->info; 457 457 458 - if (copy_to_user(&q->commands[j++], info, sizeof(*info))) 458 + if (test_bit(info.id, cxlmd->cxlds->enabled_cmds)) 459 + info.flags |= CXL_MEM_COMMAND_FLAG_ENABLED; 460 + if (test_bit(info.id, cxlmd->cxlds->exclusive_cmds)) 461 + info.flags |= CXL_MEM_COMMAND_FLAG_EXCLUSIVE; 462 + 463 + if (copy_to_user(&q->commands[j++], &info, sizeof(info))) 459 464 return -EFAULT; 460 465 461 466 if (j == n_commands)
+1 -1
drivers/cxl/core/memdev.c
··· 242 242 if (!cxlmd) 243 243 return ERR_PTR(-ENOMEM); 244 244 245 - rc = ida_alloc_range(&cxl_memdev_ida, 0, CXL_MEM_MAX_DEVS, GFP_KERNEL); 245 + rc = ida_alloc_max(&cxl_memdev_ida, CXL_MEM_MAX_DEVS - 1, GFP_KERNEL); 246 246 if (rc < 0) 247 247 goto err; 248 248 cxlmd->id = rc;
-1
drivers/cxl/cxlmem.h
··· 565 565 struct cxl_command_info info; 566 566 enum cxl_opcode opcode; 567 567 u32 flags; 568 - #define CXL_CMD_FLAG_NONE 0 569 568 #define CXL_CMD_FLAG_FORCE_ENABLE BIT(0) 570 569 }; 571 570
+25 -5
include/uapi/linux/cxl_mem.h
··· 11 11 /** 12 12 * DOC: UAPI 13 13 * 14 - * Not all of all commands that the driver supports are always available for use 15 - * by userspace. Userspace must check the results from the QUERY command in 16 - * order to determine the live set of commands. 14 + * Not all of the commands that the driver supports are available for use by 15 + * userspace at all times. Userspace can check the result of the QUERY command 16 + * to determine the live set of commands. Alternatively, it can issue the 17 + * command and check for failure. 17 18 */ 18 19 19 20 #define CXL_MEM_QUERY_COMMANDS _IOR(0xCE, 1, struct cxl_mem_query_commands) 20 21 #define CXL_MEM_SEND_COMMAND _IOWR(0xCE, 2, struct cxl_send_command) 21 22 23 + /* 24 + * NOTE: New defines must be added to the end of the list to preserve 25 + * compatibility because this enum is exported to user space. 26 + */ 22 27 #define CXL_CMDS \ 23 28 ___C(INVALID, "Invalid Command"), \ 24 29 ___C(IDENTIFY, "Identify Command"), \ ··· 73 68 * struct cxl_command_info - Command information returned from a query. 74 69 * @id: ID number for the command. 75 70 * @flags: Flags that specify command behavior. 71 + * 72 + * CXL_MEM_COMMAND_FLAG_USER_ENABLED 73 + * 74 + * The given command id is supported by the driver and is supported by 75 + * a related opcode on the device. 76 + * 77 + * CXL_MEM_COMMAND_FLAG_EXCLUSIVE 78 + * 79 + * Requests with the given command id will terminate with EBUSY as the 80 + * kernel actively owns management of the given resource. For example, 81 + * the label-storage-area can not be written while the kernel is 82 + * actively managing that space. 83 + * 76 84 * @size_in: Expected input size, or ~0 if variable length. 77 85 * @size_out: Expected output size, or ~0 if variable length. 78 86 * ··· 95 77 * bytes of output. 96 78 * 97 79 * - @id = 10 98 - * - @flags = 0 80 + * - @flags = CXL_MEM_COMMAND_FLAG_ENABLED 99 81 * - @size_in = ~0 100 82 * - @size_out = 0 101 83 * ··· 105 87 __u32 id; 106 88 107 89 __u32 flags; 108 - #define CXL_MEM_COMMAND_FLAG_MASK GENMASK(0, 0) 90 + #define CXL_MEM_COMMAND_FLAG_MASK GENMASK(1, 0) 91 + #define CXL_MEM_COMMAND_FLAG_ENABLED BIT(0) 92 + #define CXL_MEM_COMMAND_FLAG_EXCLUSIVE BIT(1) 109 93 110 94 __u32 size_in; 111 95 __u32 size_out;