From: Dan Williams <dan.j.williams@intel.com>
To: Dave Jiang <dave.jiang@intel.com>, <linux-cxl@vger.kernel.org>
Cc: <dan.j.williams@intel.com>, <ira.weiny@intel.com>,
<vishal.l.verma@intel.com>, <alison.schofield@intel.com>,
<jonathan.cameron@huawei.com>
Subject: RE: [PATCH v3 5/8] cxl: create emulated cxl_hdm for devices that do not have HDM decoders
Date: Tue, 7 Feb 2023 16:53:03 -0800 [thread overview]
Message-ID: <63e2f26f63be1_e3dae294a0@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <167406534263.1455071.15469331778875048496.stgit@djiang5-mobl3.local>
Dave Jiang wrote:
> CXL rev3 spec 8.1.3
>
> RCDs may not have HDM register blocks. Create a fake HDM with information
> from the CXL PCIe DVSEC registers. The decoder count will be set to the
> HDM count retrieved from the DVSEC cap register.
>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
>
> ---
> v3:
> - Move relevant changes from next patch in series. (Jonathan)
> - Add kernel doc update. (Jonathan)
> v2:
> - Set target_count to same as number of ranges. (Jonathan)
> ---
> drivers/cxl/core/hdm.c | 58 ++++++++++++++++++++++++++++++++++++++++--------
> drivers/cxl/core/pci.c | 9 +++++--
> drivers/cxl/cxl.h | 3 ++
> drivers/cxl/port.c | 2 +-
> 4 files changed, 57 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c
> index af1f5f906f52..86fe1be2e961 100644
> --- a/drivers/cxl/core/hdm.c
> +++ b/drivers/cxl/core/hdm.c
> @@ -101,11 +101,34 @@ static int map_hdm_decoder_regs(struct cxl_port *port, void __iomem *crb,
> BIT(CXL_CM_CAP_CAP_ID_HDM));
> }
>
> +static struct cxl_hdm *devm_cxl_setup_emulated_hdm(struct cxl_port *port,
> + struct cxl_endpoint_dvsec_info *info)
> +{
> + struct device *dev = &port->dev;
> + struct cxl_hdm *cxlhdm;
> +
> + if (!info->mem_enabled)
> + return ERR_PTR(-ENODEV);
> +
> + cxlhdm = devm_kzalloc(dev, sizeof(*cxlhdm), GFP_KERNEL);
> + if (!cxlhdm)
> + return ERR_PTR(-ENOMEM);
> +
> + cxlhdm->port = port;
> + cxlhdm->decoder_count = info->ranges;
> + cxlhdm->target_count = info->ranges;
> + dev_set_drvdata(&port->dev, cxlhdm);
> +
> + return cxlhdm;
> +}
> +
> /**
> * devm_cxl_setup_hdm - map HDM decoder component registers
> * @port: cxl_port to map
> + * @info: cached DVSEC range register info
> */
> -struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port)
> +struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port,
> + struct cxl_endpoint_dvsec_info *info)
> {
> struct device *dev = &port->dev;
> struct cxl_hdm *cxlhdm;
> @@ -119,6 +142,9 @@ struct cxl_hdm *devm_cxl_setup_hdm(struct cxl_port *port)
> cxlhdm->port = port;
> crb = ioremap(port->component_reg_phys, CXL_COMPONENT_REG_BLOCK_SIZE);
> if (!crb) {
> + if (info->mem_enabled)
> + return devm_cxl_setup_emulated_hdm(port, info);
> +
> dev_err(dev, "No component registers mapped\n");
> return ERR_PTR(-ENXIO);
> }
> @@ -815,19 +841,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
> - */
> -int devm_cxl_enumerate_decoders(struct cxl_hdm *cxlhdm,
> - struct cxl_endpoint_dvsec_info *info)
> +static void cxl_settle_decoders(struct cxl_hdm *cxlhdm)
> {
> void __iomem *hdm = cxlhdm->regs.hdm_decoder;
> - struct cxl_port *port = cxlhdm->port;
> - int i, committed;
> - u64 dpa_base = 0;
> + int committed, i;
> u32 ctrl;
>
> + if (!hdm)
> + return;
Nice, I like the semantic of a 'struct cxl_hdm' with NULL
regs.hdm_decoder == emulated.
This patch looks good to me.
next prev parent reply other threads:[~2023-02-08 0:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 18:08 [PATCH v3 0/8] cxl: Introduce HDM decoder emulation from DVSEC range registers Dave Jiang
2023-01-18 18:08 ` [PATCH v3 1/8] cxl: break out range register decoding from cxl_hdm_decode_init() Dave Jiang
2023-02-07 21:55 ` Dan Williams
2023-02-07 21:58 ` Dan Williams
2023-02-07 22:22 ` Dave Jiang
2023-01-18 18:08 ` [PATCH v3 2/8] cxl: export cxl_dvsec_rr_decode() to cxl_port Dave Jiang
2023-02-07 22:26 ` Dan Williams
2023-01-18 18:08 ` [PATCH v3 3/8] cxl: refactor cxl_hdm_decode_init() Dave Jiang
2023-02-07 22:30 ` Dan Williams
2023-01-18 18:08 ` [PATCH v3 4/8] cxl: emulate HDM decoder from DVSEC range registers Dave Jiang
2023-02-07 22:39 ` Dan Williams
2023-02-07 22:48 ` Dave Jiang
2023-01-18 18:09 ` [PATCH v3 5/8] cxl: create emulated cxl_hdm for devices that do not have HDM decoders Dave Jiang
2023-02-08 0:53 ` Dan Williams [this message]
2023-01-18 18:09 ` [PATCH v3 6/8] cxl: create emulated decoders for devices without " Dave Jiang
2023-01-23 14:07 ` Jonathan Cameron
2023-02-08 0:55 ` Dan Williams
2023-01-18 18:09 ` [PATCH v3 7/8] cxl: Add emulation when HDM decoders are not committed Dave Jiang
2023-02-08 1:04 ` Dan Williams
2023-01-18 18:09 ` [PATCH v3 8/8] cxl: remove locked check for dvsec_range_allowed() Dave Jiang
2023-02-08 1:37 ` Dan 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=63e2f26f63be1_e3dae294a0@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=jonathan.cameron@huawei.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