On Mon, Jan 31, 2022 at 5:20 PM Alison Schofield <[email protected]> wrote: > > Dan, One follow up below... > > On Wed, Jan 26, 2022 at 03:41:14PM -0800, Dan Williams wrote: > > On Tue, Jan 18, 2022 at 12:20 PM <[email protected]> wrote: > > > > > > From: Alison Schofield <[email protected]> > > > > > > Users may want the ability to change the partition layout of a CXL > > > memory device. > > > > > > Add interfaces to libcxl to allocate and send a SET_PARTITION_INFO > > > mailbox as defined in the CXL 2.0 specification. > > > > > > Signed-off-by: Alison Schofield <[email protected]> > > > --- > > > cxl/lib/libcxl.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++ > > > cxl/lib/libcxl.sym | 5 +++++ > > > cxl/lib/private.h | 8 ++++++++ > > > cxl/libcxl.h | 5 +++++ > > > 4 files changed, 68 insertions(+) > > > > > > diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c > > > index 5b1fc32..5a5b189 100644 > > > --- a/cxl/lib/libcxl.c > > > +++ b/cxl/lib/libcxl.c > > > @@ -1230,6 +1230,21 @@ > > > cxl_cmd_partition_info_get_next_persistent_bytes(struct cxl_cmd *cmd) > > > cmd_partition_get_capacity_field(cmd, next_persistent_cap); > > > } > > > > > > +CXL_EXPORT struct cxl_cmd *cxl_cmd_new_set_partition_info(struct > > > cxl_memdev *memdev, > > > + unsigned long long volatile_capacity, int flags) > > > +{ > > > + struct cxl_cmd_set_partition_info *set_partition; > > > + struct cxl_cmd *cmd; > > > + > > > + cmd = cxl_cmd_new_generic(memdev, > > > + CXL_MEM_COMMAND_ID_SET_PARTITION_INFO); > > > + > > > + set_partition = (struct cxl_cmd_set_partition_info > > > *)cmd->send_cmd->in.payload; > > > > ->in.payload is a 'void *', no casting required. > > > > send_cmd->in.payload is a __u64 so this cast is needed. > > Of course, I wondered what Dan was thinking ;) and I see that struct > cxl_cmd's input_payload is indeed a 'void *'. > > I believe this is the correct payload here, umm.. because it works ;) > > But - let me know if you suspect something is off here.
You're right... ...however :), I think this casting is what the core cxl_cmd_alloc_send() helper is doing for everyone when it does: cmd->send_cmd->in.payload = (u64)cmd->input_payload; ...so cxl_cmd_new_set_partition_info() can safely switch to the shorter cmd->input_payload and drop its own redundant local casting.
