On 21-02-01 13:15:35, Konrad Rzeszutek Wilk wrote: > > +/** > > + * struct cxl_send_command - Send a command to a memory device. > > + * @id: The command to send to the memory device. This must be one of the > > + * commands returned by the query command. > > + * @flags: Flags for the command (input). > > + * @rsvd: Must be zero. > > + * @retval: Return value from the memory device (output). > > + * @size_in: Size of the payload to provide to the device (input). > > + * @size_out: Size of the payload received from the device (input/output). This > > + * field is filled in by userspace to let the driver know how much > > + * space was allocated for output. It is populated by the driver to > > + * let userspace know how large the output payload actually was. > > + * @in_payload: Pointer to memory for payload input (little endian order). > > + * @out_payload: Pointer to memory for payload output (little endian order). > > + * > > + * Mechanism for userspace to send a command to the hardware for processing. The > > + * driver will do basic validation on the command sizes. In some cases even the > > + * payload may be introspected. Userspace is required to allocate large > > + * enough buffers for size_out which can be variable length in certain > > + * situations. > > + */ > I think (and this would help if you ran `pahole` on this structure) has > some gaps in it: > > > +struct cxl_send_command { > > + __u32 id; > > + __u32 flags; > > + __u32 rsvd; > > + __u32 retval; > > + > > + struct { > > + __s32 size_in; > > Here..Maybe just add: > > __u32 rsv_2; > > + __u64 in_payload; > > + }; > > + > > + struct { > > + __s32 size_out; > > And here. Maybe just add: > __u32 rsv_2; > > + __u64 out_payload; > > + }; > > +}; > > Perhaps to prepare for the future where this may need to be expanded, you > could add a size at the start of the structure, and > maybe what version of structure it is? > > Maybe for all the new structs you are adding? Thanks for catching the holes. It broke somewhere in the earlier RFC changes. I don't think we need to size or version. Reserved fields are good enough near term future proofing and if we get to a point where the command is woefully incompetent, I think it'd be time to just make cxl_send_command2. Generally, I think cxl_send_command is fairly future proof because it's so simple. As you get more complex, you might need better mechanisms, like deferred command completion for example. It's unclear to me whether we'll get to that point though, and if we do, I think a new command is warranted.