From: Fan Ni <nifan.cxl@gmail.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-cxl@vger.kernel.org, Ira Weiny <ira.weiny@intel.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Alejandro Lucero <alucerop@amd.com>,
Dave Jiang <dave.jiang@intel.com>
Subject: Re: [PATCH v3 1/6] cxl: Remove the CXL_DECODER_MIXED mistake
Date: Tue, 4 Feb 2025 09:42:56 -0800 [thread overview]
Message-ID: <Z6JRoGZGGpxVr9wJ@fan> (raw)
In-Reply-To: <173864304660.668823.17000888505587850279.stgit@dwillia2-xfh.jf.intel.com>
On Mon, Feb 03, 2025 at 08:24:06PM -0800, Dan Williams wrote:
> CXL_DECODER_MIXED is a safety mechanism introduced for the case where
> platform firmware has programmed an endpoint decoder that straddles a
> DPA partition boundary. While the kernel is careful to only allocate DPA
> capacity within a single partition there is no guarantee that platform
> firmware, or anything that touched the device before the current kernel,
> gets that right.
>
> However, __cxl_dpa_reserve() will never get to the CXL_DECODER_MIXED
> designation because of the way it tracks partition boundaries. A
> request_resource() that spans ->ram_res and ->pmem_res fails with the
> following signature:
>
> __cxl_dpa_reserve: cxl_port endpoint15: decoder15.0: failed to reserve allocation
>
> CXL_DECODER_MIXED is dead defensive programming after the driver has
> already given up on the device. It has never offered any protection in
> practice, just delete it.
>
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Reviewed-by: Alejandro Lucero <alucerop@amd.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Fan Ni <fan.ni@samsung.com>
> ---
> drivers/cxl/core/hdm.c | 6 +++---
> drivers/cxl/core/region.c | 12 ------------
> drivers/cxl/cxl.h | 4 +---
> 3 files changed, 4 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index 50e6a45b30ba..b7f6a2d69f78 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -332,9 +332,9 @@ static int __cxl_dpa_reserve(struct cxl_endpoint_decoder *cxled,
> else if (resource_contains(&cxlds->ram_res, res))
> cxled->mode = CXL_DECODER_RAM;
> else {
> - dev_warn(dev, "decoder%d.%d: %pr mixed mode not supported\n",
> - port->id, cxled->cxld.id, cxled->dpa_res);
> - cxled->mode = CXL_DECODER_MIXED;
> + dev_warn(dev, "decoder%d.%d: %pr does not map any partition\n",
> + port->id, cxled->cxld.id, res);
> + cxled->mode = CXL_DECODER_NONE;
> }
>
> port->hdm_end++;
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index e8d11a988fd9..34aa3d45fafa 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2738,18 +2738,6 @@ static int poison_by_decoder(struct device *dev, void *arg)
> if (!cxled->dpa_res || !resource_size(cxled->dpa_res))
> return rc;
>
> - /*
> - * Regions are only created with single mode decoders: pmem or ram.
> - * Linux does not support mixed mode decoders. This means that
> - * reading poison per endpoint decoder adheres to the requirement
> - * that poison reads of pmem and ram must be separated.
> - * CXL 3.0 Spec 8.2.9.8.4.1
> - */
> - if (cxled->mode == CXL_DECODER_MIXED) {
> - dev_dbg(dev, "poison list read unsupported in mixed mode\n");
> - return rc;
> - }
> -
> cxlmd = cxled_to_memdev(cxled);
> if (cxled->skip) {
> offset = cxled->dpa_res->start - cxled->skip;
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index bbbaa0d0a670..9fd1524ed150 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -380,7 +380,6 @@ enum cxl_decoder_mode {
> CXL_DECODER_NONE,
> CXL_DECODER_RAM,
> CXL_DECODER_PMEM,
> - CXL_DECODER_MIXED,
> CXL_DECODER_DEAD,
> };
>
> @@ -390,10 +389,9 @@ static inline const char *cxl_decoder_mode_name(enum cxl_decoder_mode mode)
> [CXL_DECODER_NONE] = "none",
> [CXL_DECODER_RAM] = "ram",
> [CXL_DECODER_PMEM] = "pmem",
> - [CXL_DECODER_MIXED] = "mixed",
> };
>
> - if (mode >= CXL_DECODER_NONE && mode <= CXL_DECODER_MIXED)
> + if (mode >= CXL_DECODER_NONE && mode < CXL_DECODER_DEAD)
> return names[mode];
> return "mixed";
> }
>
--
Fan Ni
next prev parent reply other threads:[~2025-02-04 17:43 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-04 4:24 [PATCH v3 0/6] cxl: DPA partition metadata is a mess Dan Williams
2025-02-04 4:24 ` [PATCH v3 1/6] cxl: Remove the CXL_DECODER_MIXED mistake Dan Williams
2025-02-04 17:42 ` Fan Ni [this message]
2025-02-04 4:24 ` [PATCH v3 2/6] cxl: Introduce to_{ram,pmem}_{res,perf}() helpers Dan Williams
2025-02-04 11:30 ` Jonathan Cameron
2025-02-04 17:50 ` Fan Ni
2025-02-04 4:24 ` [PATCH v3 3/6] cxl: Introduce 'struct cxl_dpa_partition' and 'struct cxl_range_info' Dan Williams
2025-02-04 11:50 ` Jonathan Cameron
2025-02-04 18:50 ` Dan Williams
2025-02-04 4:24 ` [PATCH v3 4/6] cxl: Make cxl_dpa_alloc() DPA partition number agnostic Dan Williams
2025-02-04 12:13 ` Jonathan Cameron
2025-02-04 4:24 ` [PATCH v3 5/6] cxl: Kill enum cxl_decoder_mode Dan Williams
2025-02-04 12:23 ` Jonathan Cameron
2025-02-04 18:57 ` Dan Williams
2025-02-04 4:24 ` [PATCH v3 6/6] cxl: Cleanup partition size and perf helpers Dan Williams
2025-02-04 12:32 ` Jonathan Cameron
2025-02-04 20:52 ` Ira Weiny
2025-02-04 10:42 ` [PATCH v3 0/6] cxl: DPA partition metadata is a mess Alejandro Lucero Palau
2025-02-04 21:33 ` Dave Jiang
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=Z6JRoGZGGpxVr9wJ@fan \
--to=nifan.cxl@gmail.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alucerop@amd.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@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.