From: Dan Williams <dan.j.williams@intel.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Dan Williams <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>, Robert Richter <rrichter@amd.com>,
<alison.schofield@intel.com>, <terry.bowman@amd.com>,
<bhelgaas@google.com>, <dave.jiang@intel.com>,
<nvdimm@lists.linux.dev>
Subject: Re: [PATCH v6 07/12] cxl/ACPI: Register CXL host ports by bridge device
Date: Fri, 2 Dec 2022 23:28:16 -0800 [thread overview]
Message-ID: <638afa9033fd6_3cbe0294e@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20221202161120.00005be9@Huawei.com>
Jonathan Cameron wrote:
> On Thu, 01 Dec 2022 13:33:59 -0800
> Dan Williams <dan.j.williams@intel.com> wrote:
>
> > From: Robert Richter <rrichter@amd.com>
> >
> > A port of a CXL host bridge links to the bridge's ACPI device
> > (&adev->dev) with its corresponding uport/dport device (uport_dev and
> > dport_dev respectively). The device is not a direct parent device in
> > the PCI topology as pdev->dev.parent points to a PCI bridge's (struct
> > pci_host_bridge) device. The following CXL memory device hierarchy
> > would be valid for an endpoint once an RCD EP would be enabled (note
> > this will be done in a later patch):
> >
> > VH mode:
> >
> > cxlmd->dev.parent->parent
> > ^^^\^^^^^^\ ^^^^^^\
> > \ \ pci_dev (Type 1, Downstream Port)
> > \ pci_dev (Type 0, PCI Express Endpoint)
> > cxl mem device
> >
> > RCD mode:
> >
> > cxlmd->dev.parent->parent
> > ^^^\^^^^^^\ ^^^^^^\
> > \ \ pci_host_bridge
> > \ pci_dev (Type 0, RCiEP)
> > cxl mem device
> >
> > In VH mode a downstream port is created by port enumeration and thus
> > always exists.
> >
> > Now, in RCD mode the host bridge also already exists but it references
> > to an ACPI device. A port lookup by the PCI device's parent device
> > will fail as a direct link to the registered port is missing. The ACPI
> > device of the bridge must be determined first.
> >
> > To prevent this, change port registration of a CXL host to use the
> > bridge device instead. Do this also for the VH case as port topology
> > will better reflect the PCI topology then.
> >
> > Signed-off-by: Robert Richter <rrichter@amd.com>
> > [djbw: rebase on brige mocking]
> > Reviewed-by: Robert Richter <rrichter@amd.com>
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> Trivial comment inline. Looks fine to me otherwise...
>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
>
> > ---
> > drivers/cxl/acpi.c | 35 +++++++++++++++++++----------------
> > 1 file changed, 19 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
> > index b8407b77aff6..50d82376097c 100644
> > --- a/drivers/cxl/acpi.c
> > +++ b/drivers/cxl/acpi.c
> > @@ -193,35 +193,34 @@ static int add_host_bridge_uport(struct device *match, void *arg)
> > {
> > struct cxl_port *root_port = arg;
> > struct device *host = root_port->dev.parent;
> > - struct acpi_device *bridge = to_cxl_host_bridge(host, match);
> > + struct acpi_device *hb = to_cxl_host_bridge(host, match);
> > struct acpi_pci_root *pci_root;
> > struct cxl_dport *dport;
> > struct cxl_port *port;
> > + struct device *bridge;
> > int rc;
> >
> > - if (!bridge)
> > + if (!hb)
> > return 0;
> >
> > - dport = cxl_find_dport_by_dev(root_port, match);
> > + pci_root = acpi_pci_find_root(hb->handle);
> > + bridge = pci_root->bus->bridge;
> > + dport = cxl_find_dport_by_dev(root_port, bridge);
> > if (!dport) {
> > dev_dbg(host, "host bridge expected and not found\n");
> > return 0;
> > }
> >
> > - /*
> > - * Note that this lookup already succeeded in
> > - * to_cxl_host_bridge(), so no need to check for failure here
> > - */
> > - pci_root = acpi_pci_find_root(bridge->handle);
> > - rc = devm_cxl_register_pci_bus(host, match, pci_root->bus);
> > + rc = devm_cxl_register_pci_bus(host, bridge, pci_root->bus);
> > if (rc)
> > return rc;
> >
> > - port = devm_cxl_add_port(host, match, dport->component_reg_phys, dport);
> > + port = devm_cxl_add_port(host, bridge, dport->component_reg_phys,
> > + dport);
> > if (IS_ERR(port))
> > return PTR_ERR(port);
> >
> > - dev_info(pci_root->bus->bridge, "host supports CXL\n");
> > + dev_info(bridge, "host supports CXL\n");
> >
> > return 0;
> > }
> > @@ -253,18 +252,20 @@ static int cxl_get_chbcr(union acpi_subtable_headers *header, void *arg,
> > static int add_host_bridge_dport(struct device *match, void *arg)
> > {
> > acpi_status status;
> > + struct device *bridge;
> > unsigned long long uid;
> > struct cxl_dport *dport;
> > struct cxl_chbs_context ctx;
> > + struct acpi_pci_root *pci_root;
> > struct cxl_port *root_port = arg;
> > struct device *host = root_port->dev.parent;
> > - struct acpi_device *bridge = to_cxl_host_bridge(host, match);
> > + struct acpi_device *hb = to_cxl_host_bridge(host, match);
> >
> > - if (!bridge)
> > + if (!hb)
> > return 0;
> >
> > - status = acpi_evaluate_integer(bridge->handle, METHOD_NAME__UID, NULL,
> > - &uid);
> > + status =
> > + acpi_evaluate_integer(hb->handle, METHOD_NAME__UID, NULL, &uid);
>
> Bit ugly. Maybe a good case for a slightly longer line!
I just went ahead and shortened @status to @rc since there's no other
usages in this function.
next prev parent reply other threads:[~2022-12-03 7:28 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 21:33 [PATCH v6 00/12] cxl: Add support for Restricted CXL hosts (RCD mode) Dan Williams
2022-12-01 21:33 ` [PATCH v6 01/12] cxl/acpi: Simplify cxl_nvdimm_bridge probing Dan Williams
2022-12-02 15:02 ` Jonathan Cameron
2022-12-01 21:33 ` [PATCH v6 02/12] cxl/region: Drop redundant pmem region release handling Dan Williams
2022-12-02 15:43 ` Jonathan Cameron
2022-12-01 21:33 ` [PATCH v6 03/12] cxl/pmem: Refactor nvdimm device registration, delete the workqueue Dan Williams
2022-12-02 15:42 ` Jonathan Cameron
2022-12-01 21:33 ` [PATCH v6 04/12] cxl/pmem: Remove the cxl_pmem_wq and related infrastructure Dan Williams
2022-12-02 15:44 ` Jonathan Cameron
2022-12-01 21:33 ` [PATCH v6 05/12] cxl/acpi: Move rescan to the workqueue Dan Williams
2022-12-02 15:50 ` Jonathan Cameron
2022-12-03 7:14 ` Dan Williams
2022-12-01 21:33 ` [PATCH v6 06/12] tools/testing/cxl: Make mock CEDT parsing more robust Dan Williams
2022-12-01 21:57 ` Dave Jiang
2022-12-02 15:58 ` Jonathan Cameron
2022-12-03 7:22 ` Dan Williams
2022-12-01 21:33 ` [PATCH v6 07/12] cxl/ACPI: Register CXL host ports by bridge device Dan Williams
2022-12-01 22:00 ` Dave Jiang
2022-12-02 16:11 ` Jonathan Cameron
2022-12-03 7:28 ` Dan Williams [this message]
2022-12-01 21:34 ` [PATCH v6 08/12] cxl/acpi: Extract component registers of restricted hosts from RCRB Dan Williams
2022-12-01 23:55 ` Dave Jiang
2022-12-02 8:16 ` Robert Richter
2022-12-03 7:04 ` Dan Williams
2022-12-03 8:41 ` Dan Williams
2022-12-03 16:03 ` Robert Richter
2022-12-03 17:06 ` Dan Williams
2022-12-02 16:38 ` Jonathan Cameron
2022-12-03 7:39 ` Dan Williams
2022-12-01 21:34 ` [PATCH v6 09/12] cxl/mem: Move devm_cxl_add_endpoint() from cxl_core to cxl_mem Dan Williams
2022-12-02 16:40 ` Jonathan Cameron
2022-12-01 21:34 ` [PATCH v6 10/12] cxl/port: Add RCD endpoint port enumeration Dan Williams
2022-12-02 8:21 ` Robert Richter
2022-12-03 7:05 ` Dan Williams
2022-12-02 16:45 ` Jonathan Cameron
2022-12-01 21:34 ` [PATCH v6 11/12] tools/testing/cxl: Add an RCH topology Dan Williams
2022-12-02 8:05 ` Robert Richter
2022-12-02 17:04 ` Jonathan Cameron
2022-12-03 7:50 ` Dan Williams
2022-12-01 21:34 ` [PATCH v6 12/12] cxl/acpi: Set ACPI's CXL _OSC to indicate RCD mode support Dan Williams
2022-12-02 17:05 ` Jonathan Cameron
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=638afa9033fd6_3cbe0294e@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=bhelgaas@google.com \
--cc=dave.jiang@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=rrichter@amd.com \
--cc=terry.bowman@amd.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