From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: <linux-cxl@vger.kernel.org>, <dan.j.williams@intel.com>,
<ira.weiny@intel.com>, <vishal.l.verma@intel.com>,
<alison.schofield@intel.com>, <rrichter@amd.com>,
<terry.bowman@amd.com>
Subject: Re: [RFC PATCH 6/8] cxl: create emulated decoders for devices without HDM decoders
Date: Mon, 19 Dec 2022 17:00:31 +0000 [thread overview]
Message-ID: <20221219170031.00000193@Huawei.com> (raw)
In-Reply-To: <166984996963.2805382.2390204746333079984.stgit@djiang5-desk3.ch.intel.com>
On Wed, 30 Nov 2022 16:12:49 -0700
Dave Jiang <dave.jiang@intel.com> wrote:
> CXL rev3.0 spec 8.1.3
> RCDs may not have HDM register blocks. Create fake decoders based on CXL
> PCIe DVSEC registers. The DVSEC Range Regiters provide the memory range for
Spell check (not that I can talk about spelling ;)
> these decoder structs. For the RCD, there can be up to 2 decoders depending
> on the DVSEC Capability register HDM_count.
>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
A few trivial things inline. LGTM otherwise.
> ---
> drivers/cxl/core/hdm.c | 59 +++++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 50 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index 3a9e9b854587..60b6c141f514 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -721,6 +721,29 @@ static int cxl_setup_hdm_decoder_from_dvsec(struct cxl_port *port,
> return 0;
> }
>
> +static int init_emulated_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
> + struct cxl_endpoint_dvsec_info *info, int which)
> +{
> + if (info->dvsec_range[which].start == CXL_RESOURCE_NONE)
> + return -ENODEV;
> +
> + cxld->hpa_range = (struct range) {
> + .start = info->dvsec_range[which].start,
> + .end = info->dvsec_range[which].end,
> + };
> +
> + cxld->flags = CXL_DECODER_F_ENABLE | CXL_DECODER_F_LOCK;
> + cxld->target_type = CXL_DECODER_ACCELERATOR;
Why accelerator? Comment needed.
blank line
> + if (cxld->id != port->commit_end + 1) {
> + dev_warn(&port->dev,
> + "decoder%d.%d: Committed out of order\n",
> + port->id, cxld->id);
> + return -ENXIO;
> + }
blank line
> + port->commit_end = cxld->id;
blank line.
> + return 0;
> +}
> +
> static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
> int *target_map, void __iomem *hdm, int which,
> u64 *dpa_base, struct cxl_endpoint_dvsec_info *info)
> @@ -739,6 +762,13 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
> if (is_endpoint_decoder(&cxld->dev))
> cxled = to_cxl_endpoint_decoder(&cxld->dev);
>
> + if (!hdm) {
> + if (cxled)
> + return init_emulated_hdm_decoder(port, cxld, info, which);
> + else
> + return -EINVAL;
if (!cxled)
return -EINVAL;
return init_emulated_hdm_decoder(....);
I'd prefer puting the error case out of line and normal one in main flow
as much as possible.
> + }
> +
> ctrl = readl(hdm + CXL_HDM_DECODER0_CTRL_OFFSET(which));
> base = ioread64_hi_lo(hdm + CXL_HDM_DECODER0_BASE_LOW_OFFSET(which));
> size = ioread64_hi_lo(hdm + CXL_HDM_DECODER0_SIZE_LOW_OFFSET(which));
> @@ -832,19 +862,15 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld,
> return 0;
> }
>
> +
> +/**
> + * devm_cxl_enumerate_decoders - add decoder objects per HDM register set
> + * @cxlhdm: Structure to populate with HDM capabilities
Docs update got missed somewhere.
> + */
> +int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,
> + struct cxl_endpoint_dvsec_info *info)
> +{
> + void __iomem *hdm = cxlhdm->regs.hdm_decoder;
> + struct cxl_port *port = cxlhdm->port;
> + int i;
> + u64 dpa_base = 0;
> +
> + cxl_settle_decoders(cxlhdm);
>
> for (i = 0; i < cxlhdm->decoder_count; i++) {
> int target_map[CXL_DECODER_MAX_INTERLEAVE] = { 0 };
>
>
next prev parent reply other threads:[~2022-12-19 17:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-30 23:12 [RFC PATCH 0/8] cxl: Introduce HDM decoder emulation from DVSEC range registers Dave Jiang
2022-11-30 23:12 ` [RFC PATCH 1/8] cxl: break out range register decoding from cxl_hdm_decode_init() Dave Jiang
2022-12-19 15:59 ` Jonathan Cameron
2023-01-03 21:32 ` Dave Jiang
2022-11-30 23:12 ` [RFC PATCH 2/8] cxl: export cxl_dvsec_rr_decode() to cxl_port Dave Jiang
2022-12-19 16:11 ` Jonathan Cameron
2022-11-30 23:12 ` [RFC PATCH 3/8] cxl: refactor cxl_hdm_decode_init() Dave Jiang
2022-12-19 16:19 ` Jonathan Cameron
2022-11-30 23:12 ` [RFC PATCH 4/8] cxl: emulate HDM decoder from DVSEC range registers Dave Jiang
2022-12-19 16:42 ` Jonathan Cameron
2023-01-03 23:20 ` Dave Jiang
2023-01-04 16:07 ` Dave Jiang
2023-01-05 10:51 ` Jonathan Cameron
2022-11-30 23:12 ` [RFC PATCH 5/8] cxl: create emulated cxl_hdm for devices that do not have HDM decoders Dave Jiang
2022-12-19 16:52 ` Jonathan Cameron
2022-11-30 23:12 ` [RFC PATCH 6/8] cxl: create emulated decoders for devices without " Dave Jiang
2022-12-19 17:00 ` Jonathan Cameron [this message]
2022-11-30 23:12 ` [RFC PATCH 7/8] cxl: suppress component register discovery failure warning for RCD Dave Jiang
2022-12-19 17:35 ` Jonathan Cameron
2022-11-30 23:13 ` [RFC PATCH 8/8] cxl: remove locked check for dvsec_range_allowed() Dave Jiang
2022-12-19 16:12 ` [RFC PATCH 0/8] cxl: Introduce HDM decoder emulation from DVSEC range registers Jonathan Cameron
2022-12-19 16:19 ` 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=20221219170031.00000193@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=rrichter@amd.com \
--cc=terry.bowman@amd.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox