From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: <alejandro.lucero-palau@amd.com>
Cc: <linux-cxl@vger.kernel.org>, <netdev@vger.kernel.org>,
<dan.j.williams@intel.com>, <edward.cree@amd.com>,
<davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>,
<edumazet@google.com>, <dave.jiang@intel.com>,
Alejandro Lucero <alucerop@amd.com>
Subject: Re: [PATCH v22 11/25] cxl/hdm: Add support for getting region from committed decoder
Date: Mon, 15 Dec 2025 13:50:47 +0000 [thread overview]
Message-ID: <20251215135047.000018f7@huawei.com> (raw)
In-Reply-To: <20251205115248.772945-12-alejandro.lucero-palau@amd.com>
On Fri, 5 Dec 2025 11:52:34 +0000
<alejandro.lucero-palau@amd.com> wrote:
> From: Alejandro Lucero <alucerop@amd.com>
>
> A Type2 device configured by the BIOS can already have its HDM
> committed. Add a cxl_get_committed_decoder() function for cheking
checking if this is so after memdev creation.
> so after memdev creation. A CXL region should have been created
> during memdev initialization, therefore a Type2 driver can ask for
> such a region for working with the HPA. If the HDM is not committed,
> a Type2 driver will create the region after obtaining proper HPA
> and DPA space.
>
> Signed-off-by: Alejandro Lucero <alucerop@amd.com>
Hi Alejandro,
I'm in two minds about this. In general there are devices that have
been configured by the BIOS because they are already in use. I'm not sure
the driver you are working with here is necessarily set up to survive
that sort of live setup without interrupting data flows.
If it is fair enough to support this, otherwise my inclination is tear
down whatever the bios did and start again (unless locked - in which
case go grumble at your BIOS folk). Reasoning being that we then only
have to handle the equivalent of the hotplug flow in both cases rather
than having to handle 2.
There are also the TSP / encrypted link cases where we need to be careful.
I have no idea if that applies here.
So I'm not against this in general, just not sure there is an argument
for this approach 'yet'. If there is, give more breadcrumbs to it in this
commit message.
A few comments inline.
> ---
> drivers/cxl/core/hdm.c | 44 ++++++++++++++++++++++++++++++++++++++++++
> include/cxl/cxl.h | 3 +++
> 2 files changed, 47 insertions(+)
>
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index d3a094ca01ad..fa99657440d1 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -92,6 +92,7 @@ static void parse_hdm_decoder_caps(struct cxl_hdm *cxlhdm)
> static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info)
> {
> struct cxl_hdm *cxlhdm;
> + struct cxl_port *port;
> void __iomem *hdm;
> u32 ctrl;
> int i;
> @@ -105,6 +106,10 @@ static bool should_emulate_decoders(struct cxl_endpoint_dvsec_info *info)
> if (!hdm)
> return true;
>
> + port = cxlhdm->port;
> + if (is_cxl_endpoint(port))
> + return false;
Why this change? If it was valid before this patch as an early exit
then do it in a patch that justifies that not buried in here.
> +
> /*
> * If HDM decoders are present and the driver is in control of
> * Mem_Enable skip DVSEC based emulation
> @@ -686,6 +691,45 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, u64 size)
> return devm_add_action_or_reset(&port->dev, cxl_dpa_release, cxled);
> }
>
> +static int find_committed_decoder(struct device *dev, const void *data)
Function name rather suggests it finds committed decoders on 'whatever'
but it only works for the endpoint decoders. Rename it to avoid this
confusion.
> +{
> + struct cxl_endpoint_decoder *cxled;
> + struct cxl_port *port;
> +
> + if (!is_endpoint_decoder(dev))
> + return 0;
> +
> + cxled = to_cxl_endpoint_decoder(dev);
> + port = cxled_to_port(cxled);
> +
> + return cxled->cxld.id == (port->hdm_end);
Drop the ()
> +}
> +
> +struct cxl_endpoint_decoder *cxl_get_committed_decoder(struct cxl_memdev *cxlmd,
> + struct cxl_region **cxlr)
> +{
> + struct cxl_port *endpoint = cxlmd->endpoint;
> + struct cxl_endpoint_decoder *cxled;
> + struct device *cxled_dev;
> +
> + if (!endpoint)
> + return NULL;
> +
> + guard(rwsem_read)(&cxl_rwsem.dpa);
> + cxled_dev = device_find_child(&endpoint->dev, NULL,
> + find_committed_decoder);
> +
> + if (!cxled_dev)
> + return NULL;
> +
> + cxled = to_cxl_endpoint_decoder(cxled_dev);
> + *cxlr = cxled->cxld.region;
> +
> + put_device(cxled_dev);
Probably use a __free() for this.
> + return cxled;
> +}
> +EXPORT_SYMBOL_NS_GPL(cxl_get_committed_decoder, "CXL");
> +
> static void cxld_set_interleave(struct cxl_decoder *cxld, u32 *ctrl)
> {
> u16 eig;
> diff --git a/include/cxl/cxl.h b/include/cxl/cxl.h
> index 043fc31c764e..2ff3c19c684c 100644
> --- a/include/cxl/cxl.h
> +++ b/include/cxl/cxl.h
> @@ -250,4 +250,7 @@ int cxl_set_capacity(struct cxl_dev_state *cxlds, u64 capacity);
> struct cxl_memdev *devm_cxl_add_memdev(struct device *host,
> struct cxl_dev_state *cxlds,
> const struct cxl_memdev_ops *ops);
> +struct cxl_region;
> +struct cxl_endpoint_decoder *cxl_get_committed_decoder(struct cxl_memdev *cxlmd,
> + struct cxl_region **cxlr);
> #endif /* __CXL_CXL_H__ */
next prev parent reply other threads:[~2025-12-15 13:50 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 11:52 [PATCH v22 00/25] Type2 device basic support alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 01/25] cxl/mem: Arrange for always-synchronous memdev attach alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 02/25] cxl/port: Arrange for always synchronous endpoint attach alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 03/25] cxl/mem: Introduce a memdev creation ->probe() operation alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 04/25] cxl: Add type2 device basic support alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 05/25] sfc: add cxl support alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 06/25] cxl: Move pci generic code alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 07/25] cxl/sfc: Map cxl component regs alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 08/25] cxl/sfc: Initialize dpa without a mailbox alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 09/25] cxl: Prepare memdev creation for type2 alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 10/25] sfc: create type2 cxl memdev alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 11/25] cxl/hdm: Add support for getting region from committed decoder alejandro.lucero-palau
2025-12-15 13:50 ` Jonathan Cameron [this message]
2025-12-18 11:52 ` Alejandro Lucero Palau
2025-12-18 15:03 ` Jonathan Cameron
2025-12-18 15:27 ` Alejandro Lucero Palau
2025-12-19 11:02 ` Jonathan Cameron
2025-12-05 11:52 ` [PATCH v22 12/25] cxl: Add function for obtaining region range alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 13/25] cxl: Export functions for unwinding cxl by accelerators alejandro.lucero-palau
2025-12-15 13:53 ` Jonathan Cameron
2025-12-18 12:07 ` Alejandro Lucero Palau
2025-12-05 11:52 ` [PATCH v22 14/25] sfc: obtain decoder and region if committed by firmware alejandro.lucero-palau
2025-12-15 13:57 ` Jonathan Cameron
2025-12-18 12:14 ` Alejandro Lucero Palau
2025-12-05 11:52 ` [PATCH v22 15/25] cxl: Define a driver interface for HPA free space enumeration alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 16/25] sfc: get root decoder alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 17/25] cxl: Define a driver interface for DPA allocation alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 18/25] sfc: get endpoint decoder alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 19/25] cxl: Make region type based on endpoint type alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 20/25] cxl/region: Factor out interleave ways setup alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 21/25] cxl/region: Factor out interleave granularity setup alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 22/25] cxl: Allow region creation by type2 drivers alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 23/25] cxl: Avoid dax creation for accelerators alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 24/25] sfc: create cxl region alejandro.lucero-palau
2025-12-05 11:52 ` [PATCH v22 25/25] sfc: support pio mapping based on cxl alejandro.lucero-palau
2025-12-07 7:12 ` [PATCH v22 00/25] Type2 device basic support dan.j.williams
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=20251215135047.000018f7@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alejandro.lucero-palau@amd.com \
--cc=alucerop@amd.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=edward.cree@amd.com \
--cc=kuba@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).