[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <291cb69e-9018-4c7e-a6e0-ee6b4b475bf7@amd.com>
Date: Thu, 8 May 2025 11:19:03 +0100
From: Alejandro Lucero Palau <alucerop@....com>
To: Alison Schofield <alison.schofield@...el.com>,
alejandro.lucero-palau@....com
Cc: linux-cxl@...r.kernel.org, netdev@...r.kernel.org,
dan.j.williams@...el.com, edward.cree@....com, davem@...emloft.net,
kuba@...nel.org, pabeni@...hat.com, edumazet@...gle.com,
dave.jiang@...el.com, Jonathan Cameron <Jonathan.Cameron@...wei.com>
Subject: Re: [PATCH v14 01/22] cxl: add type2 device basic support
On 5/8/25 01:25, Alison Schofield wrote:
> On Thu, Apr 17, 2025 at 10:29:04PM +0100, alejandro.lucero-palau@....com wrote:
>> From: Alejandro Lucero <alucerop@....com>
>>
>> Differentiate CXL memory expanders (type 3) from CXL device accelerators
>> (type 2) with a new function for initializing cxl_dev_state and a macro
>> for helping accel drivers to embed cxl_dev_state inside a private
>> struct.
>>
>> Move structs to include/cxl as the size of the accel driver private
>> struct embedding cxl_dev_state needs to know the size of this struct.
>>
>> Use same new initialization with the type3 pci driver.
>>
>> Signed-off-by: Alejandro Lucero <alucerop@....com>
> snip
>
>
>> +
>> +struct cxl_dev_state *_cxl_dev_state_create(struct device *dev,
>> + enum cxl_devtype type, u64 serial,
>> + u16 dvsec, size_t size,
>> + bool has_mbox);
>> +
>> +#define cxl_dev_state_create(parent, type, serial, dvsec, drv_struct, member, mbox) \
>> + ({ \
>> + static_assert(__same_type(struct cxl_dev_state, \
>> + ((drv_struct *)NULL)->member)); \
>> + static_assert(offsetof(drv_struct, member) == 0); \
>> + (drv_struct *)_cxl_dev_state_create(parent, type, serial, dvsec, \
>> + sizeof(drv_struct), mbox); \
>> + })
> I spent a bit of time unravelling this macro and came to understand that
> as a macro it can enforce compile time correctness, and that is all good.
> However, a comment would be appreciated.
> Perhaps: Safely create and cast a cxl dev state embedded in a driver
> specific struct. Introduced for Type 2 driver support.
>
I can do that. Note that the commit refers to the change due to type2
support, but I can add also your suggestion at the macro definition.
Thank you
Powered by blists - more mailing lists