From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: <alejandro.lucero-palau@amd.com>
Cc: <linux-cxl@vger.kernel.org>, <dan.j.williams@intel.com>,
<dave.jiang@intel.com>, Alejandro Lucero <alucerop@amd.com>,
"Alison Schofield" <alison.schofield@intel.com>
Subject: Re: [PATCH v2 1/3] cxl: support Type2 when initializing cxl_dev_state
Date: Fri, 27 Feb 2026 12:14:43 +0000 [thread overview]
Message-ID: <20260227121443.000011ff@huawei.com> (raw)
In-Reply-To: <20260225121430.3839189-2-alejandro.lucero-palau@amd.com>
On Wed, 25 Feb 2026 12:14:28 +0000
alejandro.lucero-palau@amd.com wrote:
> From: Alejandro Lucero <alucerop@amd.com>
>
> In preparation for type2 drivers add function and macro for
> differentiating CXL memory expanders (type 3) from CXL device
> accelerators (type 2) helping accel drivers to embed cxl_dev_state
Slight preference for
"to embed struct cxl_dev_state"
> inside a private struct.
I'd be tempted to call this "a driver specific structure".
private is a little too much of a guide to how this 'might' be used
in the long run.
>
> Update type3 driver for using this same initialization.
>
> Signed-off-by: Alejandro Lucero <alucerop@amd.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> Reviewed-by: Alison Schofield <alison.schofield@intel.com>
One minor wording comment below.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> diff --git a/drivers/cxl/cxlmem.h b/drivers/cxl/cxlmem.h
> index e21d744d639b..9daf4bc42692 100644
> --- a/drivers/cxl/cxlmem.h
> +++ b/drivers/cxl/cxlmem.h
> @@ -523,6 +523,37 @@ to_cxl_memdev_state(struct cxl_dev_state *cxlds)
> return container_of(cxlds, struct cxl_memdev_state, cxlds);
> }
>
> +struct cxl_dev_state *_devm_cxl_dev_state_create(struct device *dev,
> + enum cxl_devtype type,
> + u64 serial, u16 dvsec,
> + size_t size, bool has_mbox);
> +
> +/**
> + * cxl_dev_state_create - safely create and cast a cxl dev state embedded in a
> + * driver specific struct.
> + *
> + * @parent: device behind the request
> + * @type: CXL device type
> + * @serial: device identification
> + * @dvsec: dvsec capability offset
> + * @drv_struct: driver struct embedding a cxl_dev_state struct
> + * @member: drv_struct member as cxl_dev_state
* @member: name of the struct cxl_dev_state member in drv_struct
("as" to me implies a cast, which had me briefly confused).
> + * @mbox: true if mailbox supported
> + *
> + * Returns a pointer to the drv_struct allocated and embedding a cxl_dev_state
> + * struct initialized.
> + *
> + * Introduced for Type2 driver support.
> + */
> +#define devm_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 *)_devm_cxl_dev_state_create(parent, type, serial, dvsec, \
> + sizeof(drv_struct), mbox); \
> + })
> +
next prev parent reply other threads:[~2026-02-27 12:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 12:14 [PATCH v2 0/3] type2 support preparation alejandro.lucero-palau
2026-02-25 12:14 ` [PATCH v2 1/3] cxl: support Type2 when initializing cxl_dev_state alejandro.lucero-palau
2026-02-25 15:43 ` Gregory Price
2026-02-27 19:54 ` Alejandro Lucero Palau
2026-02-27 12:14 ` Jonathan Cameron [this message]
2026-02-27 20:00 ` Alejandro Lucero Palau
2026-02-25 12:14 ` [PATCH v2 2/3] cxl: export internal structs for external Type2 drivers alejandro.lucero-palau
2026-02-25 15:35 ` Gregory Price
2026-02-27 19:53 ` Alejandro Lucero Palau
2026-02-27 12:21 ` Jonathan Cameron
2026-02-27 20:02 ` Alejandro Lucero Palau
2026-02-25 12:14 ` [PATCH v2 3/3] cxl: Move pci generic code alejandro.lucero-palau
2026-02-25 16:00 ` Gregory Price
2026-02-27 19:59 ` Alejandro Lucero Palau
2026-02-27 23:07 ` Gregory Price
2026-02-27 12:24 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260227121443.000011ff@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alejandro.lucero-palau@amd.com \
--cc=alison.schofield@intel.com \
--cc=alucerop@amd.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=linux-cxl@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.