From: Alison Schofield <alison.schofield@intel.com>
To: Dan Williams <dan.j.williams@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ben Widawsky <bwidawsk@kernel.org>,
Dave Jiang <dave.jiang@intel.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v3 2/3] cxl/acpi: Support CXL XOR Interleave Math (CXIMS)
Date: Fri, 16 Sep 2022 09:26:48 -0700 [thread overview]
Message-ID: <YySjyPtc0Oges2zH@aschofie-mobl2> (raw)
In-Reply-To: <6cbe113e3aebc732d10cb77a316f547b581f22fa.1663291370.git.alison.schofield@intel.com>
On Thu, Sep 15, 2022 at 06:30:23PM -0700, alison.schofield@intel.com wrote:
> From: Alison Schofield <alison.schofield@intel.com>
>
> When the CFMWS is using XOR math, parse the corresponding
> CXIMS structure and store the xormaps in the root decoder
> structure. Use the xormaps in a new lookup, cxl_hb_xor(),
> to find a targets entry in the host bridge interleave
> target list.
>
> Defined in CXL Specfication 3.0 Section: 9.17.1
>
> Signed-off-by: Alison Schofield <alison.schofield@intel.com>
> ---
> drivers/cxl/cxl.h | 2 +
> drivers/cxl/acpi.c | 132 +++++++++++++++++++++++++++++++++++++++++++--
> 2 files changed, 129 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index f680450f0b16..0a17a7007bff 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -330,12 +330,14 @@ struct cxl_switch_decoder {
> * @res: host / parent resource for region allocations
> * @region_id: region id for next region provisioning event
> * @calc_hb: which host bridge covers the n'th position by granularity
> + * @platform_data: platform specific configuration data
> * @cxlsd: base cxl switch decoder
> */
> struct cxl_root_decoder {
> struct resource *res;
> atomic_t region_id;
> struct cxl_dport *(*calc_hb)(struct cxl_root_decoder *cxlrd, int pos);
> + void *platform_data;
> struct cxl_switch_decoder cxlsd;
> };
>
> diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
> index fb649683dd3a..3ff0fd6e3e93 100644
> --- a/drivers/cxl/acpi.c
> +++ b/drivers/cxl/acpi.c
> @@ -9,6 +9,106 @@
> #include "cxlpci.h"
> #include "cxl.h"
>
> +struct cxims_data {
> + int nr_maps;
> + u64 xormaps[];
> +};
> +
> +/*
> + * Find a targets entry (n) in the host bridge interleave list.
> + * CXL Specfication 3.0 Table 9-22
> + */
> +static struct cxl_dport *cxl_hb_xor(struct cxl_root_decoder *cxlrd, int pos)
> +{
> + struct cxl_switch_decoder *cxlsd = &cxlrd->cxlsd;
> + struct cxims_data *cximsd = cxlrd->platform_data;
> + struct cxl_decoder *cxld = &cxlsd->cxld;
> + int ig = cxld->interleave_granularity;
> + int iw = cxld->interleave_ways;
> + int i, eiw, n = 0;
> + u64 hpa, mask;
> +
> + if (dev_WARN_ONCE(&cxld->dev,
> + cxld->interleave_ways != cxlsd->nr_targets,
> + "misconfigured root decoder\n"))
> + return NULL;
> +
> + if (iw == 1)
> + /* Entry is always 0 for no interleave */
> + return cxlrd->cxlsd.target[0];
> +
> + hpa = cxlrd->res->start + pos * ig;
> +
> + if (iw == 3) {
> + /* Initialize 'i' for the modulo calc */
> + i = 0;
> + goto no_map;
> + }
> +
> + /* IW: 2,4,6,8,12,16 begin building 'n' using xormaps */
> + for (i = 0; i < cximsd->nr_maps; i++)
> + n |= (hweight64(hpa & cximsd->xormaps[i]) & 1) << i;
> +
> +no_map:
> + /* IW: 3,6,12 add a modulo calculation to 'n' */
> + if (!is_power_of_2(iw)) {
> + eiw = ilog2(iw / 3) + 8;
> + mask = GENMASK(51, eiw + ig);
lkp i386 build warned:
>> drivers/cxl/acpi.c:56:10: warning: shift count is negative
+[-Wshift-count-negative]
mask = GENMASK(51, eiw + ig);
^~~~~~~~~~~~~~~~~~~~~
Will change to GENMASK_ULL.
> + n |= (hpa & mask) % 3 << i;
> + }
> +
> + return cxlrd->cxlsd.target[n];
> +}
snip
> +
>
next prev parent reply other threads:[~2022-09-16 16:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 1:30 [PATCH v3 0/3] CXL XOR Interleave Arithmetic alison.schofield
2022-09-16 1:30 ` [PATCH v3 1/3] For ACPICA: Add the CXIMS structure definition to the CEDT table alison.schofield
2022-09-16 1:30 ` [PATCH v3 2/3] cxl/acpi: Support CXL XOR Interleave Math (CXIMS) alison.schofield
2022-09-16 16:26 ` Alison Schofield [this message]
2022-09-16 1:30 ` [PATCH v3 3/3] tools/testing/cxl: Add XOR math support alison.schofield
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=YySjyPtc0Oges2zH@aschofie-mobl2 \
--to=alison.schofield@intel.com \
--cc=bwidawsk@kernel.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-cxl@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 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).