From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Davidlohr Bueso <dave@stgolabs.net>,
Dave Jiang <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
"Ira Weiny" <ira.weiny@intel.com>
Subject: Re: [PATCH v2 3/8] cxl/decoder: Move decoder register programming to a helper
Date: Mon, 23 Jun 2025 11:51:52 +0100 [thread overview]
Message-ID: <20250623115152.00005aba@huawei.com> (raw)
In-Reply-To: <20250619050416.782871-4-dan.j.williams@intel.com>
On Wed, 18 Jun 2025 22:04:11 -0700
Dan Williams <dan.j.williams@intel.com> wrote:
> In preparation for converting to rw_semaphore_acquire semantics move the
> contents of an open-coded {down,up}_read(&cxl_dpa_rwsem) section to a
> helper function.
>
> Cc: Davidlohr Bueso <dave@stgolabs.net>
> Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Alison Schofield <alison.schofield@intel.com>
> Cc: Vishal Verma <vishal.l.verma@intel.com>
> Cc: Ira Weiny <ira.weiny@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Seems reasonable.
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
> ---
> drivers/cxl/core/hdm.c | 77 +++++++++++++++++++++++-------------------
> 1 file changed, 42 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index ab1007495f6b..81556d12e9b8 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -764,14 +764,53 @@ static int cxld_await_commit(void __iomem *hdm, int id)
> return -ETIMEDOUT;
> }
>
> +static void setup_hw_decoder(struct cxl_decoder *cxld, void __iomem *hdm)
> +{
> + int id = cxld->id;
> + u64 base, size;
> + u32 ctrl;
> +
> + /* common decoder settings */
> + ctrl = readl(hdm + CXL_HDM_DECODER0_CTRL_OFFSET(cxld->id));
> + cxld_set_interleave(cxld, &ctrl);
> + cxld_set_type(cxld, &ctrl);
> + base = cxld->hpa_range.start;
> + size = range_len(&cxld->hpa_range);
> +
> + writel(upper_32_bits(base), hdm + CXL_HDM_DECODER0_BASE_HIGH_OFFSET(id));
> + writel(lower_32_bits(base), hdm + CXL_HDM_DECODER0_BASE_LOW_OFFSET(id));
> + writel(upper_32_bits(size), hdm + CXL_HDM_DECODER0_SIZE_HIGH_OFFSET(id));
> + writel(lower_32_bits(size), hdm + CXL_HDM_DECODER0_SIZE_LOW_OFFSET(id));
> +
> + if (is_switch_decoder(&cxld->dev)) {
> + struct cxl_switch_decoder *cxlsd =
> + to_cxl_switch_decoder(&cxld->dev);
> + void __iomem *tl_hi = hdm + CXL_HDM_DECODER0_TL_HIGH(id);
> + void __iomem *tl_lo = hdm + CXL_HDM_DECODER0_TL_LOW(id);
> + u64 targets;
> +
> + cxlsd_set_targets(cxlsd, &targets);
> + writel(upper_32_bits(targets), tl_hi);
> + writel(lower_32_bits(targets), tl_lo);
> + } else {
> + struct cxl_endpoint_decoder *cxled =
> + to_cxl_endpoint_decoder(&cxld->dev);
> + void __iomem *sk_hi = hdm + CXL_HDM_DECODER0_SKIP_HIGH(id);
> + void __iomem *sk_lo = hdm + CXL_HDM_DECODER0_SKIP_LOW(id);
> +
> + writel(upper_32_bits(cxled->skip), sk_hi);
> + writel(lower_32_bits(cxled->skip), sk_lo);
> + }
> +
> + writel(ctrl, hdm + CXL_HDM_DECODER0_CTRL_OFFSET(id));
> +}
> +
> static int cxl_decoder_commit(struct cxl_decoder *cxld)
> {
> struct cxl_port *port = to_cxl_port(cxld->dev.parent);
> struct cxl_hdm *cxlhdm = dev_get_drvdata(&port->dev);
> void __iomem *hdm = cxlhdm->regs.hdm_decoder;
> int id = cxld->id, rc;
> - u64 base, size;
> - u32 ctrl;
>
> if (cxld->flags & CXL_DECODER_F_ENABLE)
> return 0;
> @@ -804,39 +843,7 @@ static int cxl_decoder_commit(struct cxl_decoder *cxld)
> }
>
> down_read(&cxl_dpa_rwsem);
> - /* common decoder settings */
> - ctrl = readl(hdm + CXL_HDM_DECODER0_CTRL_OFFSET(cxld->id));
> - cxld_set_interleave(cxld, &ctrl);
> - cxld_set_type(cxld, &ctrl);
> - base = cxld->hpa_range.start;
> - size = range_len(&cxld->hpa_range);
> -
> - writel(upper_32_bits(base), hdm + CXL_HDM_DECODER0_BASE_HIGH_OFFSET(id));
> - writel(lower_32_bits(base), hdm + CXL_HDM_DECODER0_BASE_LOW_OFFSET(id));
> - writel(upper_32_bits(size), hdm + CXL_HDM_DECODER0_SIZE_HIGH_OFFSET(id));
> - writel(lower_32_bits(size), hdm + CXL_HDM_DECODER0_SIZE_LOW_OFFSET(id));
> -
> - if (is_switch_decoder(&cxld->dev)) {
> - struct cxl_switch_decoder *cxlsd =
> - to_cxl_switch_decoder(&cxld->dev);
> - void __iomem *tl_hi = hdm + CXL_HDM_DECODER0_TL_HIGH(id);
> - void __iomem *tl_lo = hdm + CXL_HDM_DECODER0_TL_LOW(id);
> - u64 targets;
> -
> - cxlsd_set_targets(cxlsd, &targets);
> - writel(upper_32_bits(targets), tl_hi);
> - writel(lower_32_bits(targets), tl_lo);
> - } else {
> - struct cxl_endpoint_decoder *cxled =
> - to_cxl_endpoint_decoder(&cxld->dev);
> - void __iomem *sk_hi = hdm + CXL_HDM_DECODER0_SKIP_HIGH(id);
> - void __iomem *sk_lo = hdm + CXL_HDM_DECODER0_SKIP_LOW(id);
> -
> - writel(upper_32_bits(cxled->skip), sk_hi);
> - writel(lower_32_bits(cxled->skip), sk_lo);
> - }
> -
> - writel(ctrl, hdm + CXL_HDM_DECODER0_CTRL_OFFSET(id));
> + setup_hw_decoder(cxld, hdm);
> up_read(&cxl_dpa_rwsem);
>
> port->commit_end++;
next prev parent reply other threads:[~2025-06-23 10:51 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-19 5:04 [PATCH v2 0/8] cleanup: Introduce ACQUIRE(), a guard() for conditional locks Dan Williams
2025-06-19 5:04 ` [PATCH v2 1/8] cleanup: Introduce ACQUIRE() and ACQUIRE_ERR() " Dan Williams
2025-06-19 21:17 ` Dan Williams
2025-06-23 10:05 ` Jonathan Cameron
2025-07-10 22:46 ` dan.j.williams
2025-06-19 5:04 ` [PATCH v2 2/8] cxl/mbox: Convert poison list mutex to ACQUIRE() Dan Williams
2025-06-20 20:43 ` Alison Schofield
2025-06-23 10:08 ` Jonathan Cameron
2025-07-10 22:25 ` dan.j.williams
2025-06-23 14:49 ` Dave Jiang
2025-06-19 5:04 ` [PATCH v2 3/8] cxl/decoder: Move decoder register programming to a helper Dan Williams
2025-06-20 21:00 ` Alison Schofield
2025-06-23 10:51 ` Jonathan Cameron [this message]
2025-06-23 14:50 ` Dave Jiang
2025-06-19 5:04 ` [PATCH v2 4/8] cxl/decoder: Drop pointless locking Dan Williams
2025-06-19 23:40 ` Davidlohr Bueso
2025-06-20 21:02 ` Alison Schofield
2025-06-23 10:53 ` Jonathan Cameron
2025-06-23 14:51 ` Dave Jiang
2025-06-19 5:04 ` [PATCH v2 5/8] cxl/region: Split commit_store() into __commit() and queue_reset() helpers Dan Williams
2025-06-20 21:32 ` Alison Schofield
2025-06-21 4:51 ` dan.j.williams
2025-06-23 10:59 ` Jonathan Cameron
2025-06-23 14:59 ` Dave Jiang
2025-06-19 5:04 ` [PATCH v2 6/8] cxl/region: Move ready-to-probe state check to a helper Dan Williams
2025-06-23 15:01 ` Dave Jiang
2025-06-19 5:04 ` [PATCH v2 7/8] cxl/region: Introduce CLASS(cxl_decoder_detach...) consolidate multiple paths Dan Williams
2025-06-23 10:49 ` Jonathan Cameron
2025-07-11 4:12 ` dan.j.williams
2025-06-19 5:04 ` [PATCH v2 8/8] cxl: Convert to ACQUIRE() for conditional rwsem locking Dan Williams
2025-06-23 10:32 ` Jonathan Cameron
2025-07-11 3:21 ` dan.j.williams
2025-06-19 11:13 ` [PATCH v2 0/8] cleanup: Introduce ACQUIRE(), a guard() for conditional locks Peter Zijlstra
2025-07-02 23:39 ` Alison Schofield
2025-07-11 4:28 ` 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=20250623115152.00005aba@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vishal.l.verma@intel.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 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.