On 28.11.22 13:58:55, Dan Williams wrote:
> Robert Richter wrote:
> > On 24.11.22 10:35:21, Dan Williams wrote:
> > > From: Robert Richter <[email protected]>
> > > @@ -228,27 +235,46 @@ static int add_host_bridge_uport(struct device
> > > *match, void *arg)
> > > struct cxl_chbs_context {
> > > struct device *dev;
> > > unsigned long long uid;
> > > - resource_size_t chbcr;
> > > + struct acpi_cedt_chbs chbs;
> > > };
> > >
> > > -static int cxl_get_chbcr(union acpi_subtable_headers *header, void *arg,
> > > - const unsigned long end)
> > > +static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg,
> > > + const unsigned long end)
> > > {
> > > struct cxl_chbs_context *ctx = arg;
> > > struct acpi_cedt_chbs *chbs;
> > >
> > > - if (ctx->chbcr)
> > > + if (ctx->chbs.base)
> > > return 0;
> > >
> > > chbs = (struct acpi_cedt_chbs *) header;
> > >
> > > if (ctx->uid != chbs->uid)
> > > return 0;
> > > - ctx->chbcr = chbs->base;
> > > + ctx->chbs = *chbs;
> > >
> > > return 0;
> > > }
> > >
> > > +static resource_size_t cxl_get_chbcr(struct cxl_chbs_context *ctx)
> > > +{
> > > + struct acpi_cedt_chbs *chbs = &ctx->chbs;
> > > +
> > > + if (!chbs->base)
> > > + return CXL_RESOURCE_NONE;
> > > +
> > > + if (chbs->cxl_version != ACPI_CEDT_CHBS_VERSION_CXL11)
> > > + return chbs->base;
> > > +
> > > + if (chbs->length != CXL_RCRB_SIZE)
> > > + return CXL_RESOURCE_NONE;
> > > +
> > > + dev_dbg(ctx->dev, "RCRB found for UID %lld: %pa\n", ctx->uid,
> > > + &chbs->base);
> > > +
> > > + return cxl_rcrb_to_component(ctx->dev, chbs->base, CXL_RCRB_DOWNSTREAM);
> > > +}
> > > +
> >
> > I have an improved version of this code which squashes cxl_get_chbcr()
> > into cxl_get_chbs() (basically extends the original cxl_get_chbcr()
> > function).
>
> Care to send it? If I see it before the next posting I can fold it in,
> otherwise it can be a follow-on cleanup.
Here comes the delta patch of that change. Since you probably reworked
this patch already I hope the changes will apply cleanly or with small
conflicts only.
-- >8 --
>From 65a6e03e53f2298c46d3fe0c16150aa7d539cfca Mon Sep 17 00:00:00 2001
From: Robert Richter <[email protected]>
Date: Wed, 30 Nov 2022 14:39:08 +0100
Subject: [PATCH v5] delta
Signed-off-by: Robert Richter <[email protected]>
---
drivers/cxl/acpi.c | 59 +++++++++++++++++++++++-----------------------
1 file changed, 30 insertions(+), 29 deletions(-)
diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
index f13b702e9fd5..1eb564e697fb 100644
--- a/drivers/cxl/acpi.c
+++ b/drivers/cxl/acpi.c
@@ -233,46 +233,47 @@ static int add_host_bridge_uport(struct device *match,
void *arg)
}
struct cxl_chbs_context {
- struct device *dev;
- unsigned long long uid;
- struct acpi_cedt_chbs chbs;
+ struct device *dev;
+ unsigned long long uid;
+ resource_size_t rcrb;
+ resource_size_t chbcr;
+ u32 cxl_version;
};
-static int cxl_get_chbs(union acpi_subtable_headers *header, void *arg,
- const unsigned long end)
+static int cxl_get_chbcr(union acpi_subtable_headers *header, void *arg,
+ const unsigned long end)
{
struct cxl_chbs_context *ctx = arg;
struct acpi_cedt_chbs *chbs;
- if (ctx->chbs.base)
+ if (ctx->chbcr)
return 0;
chbs = (struct acpi_cedt_chbs *) header;
if (ctx->uid != chbs->uid)
return 0;
- ctx->chbs = *chbs;
-
- return 0;
-}
-static resource_size_t cxl_get_chbcr(struct cxl_chbs_context *ctx)
-{
- struct acpi_cedt_chbs *chbs = &ctx->chbs;
+ ctx->cxl_version = chbs->cxl_version;
+ ctx->rcrb = CXL_RESOURCE_NONE;
+ ctx->chbcr = CXL_RESOURCE_NONE;
if (!chbs->base)
- return CXL_RESOURCE_NONE;
+ return 0;
- if (chbs->cxl_version != ACPI_CEDT_CHBS_VERSION_CXL11)
- return chbs->base;
+ if (chbs->cxl_version != ACPI_CEDT_CHBS_VERSION_CXL11) {
+ ctx->chbcr = chbs->base;
+ return 0;
+ }
if (chbs->length != CXL_RCRB_SIZE)
- return CXL_RESOURCE_NONE;
+ return 0;
- dev_dbg(ctx->dev, "RCRB found for UID %lld: %pa\n", ctx->uid,
- &chbs->base);
+ ctx->rcrb = chbs->base;
+ ctx->chbcr = cxl_rcrb_to_component(ctx->dev, chbs->base,
+ CXL_RCRB_DOWNSTREAM);
- return cxl_rcrb_to_component(ctx->dev, chbs->base, CXL_RCRB_DOWNSTREAM);
+ return 0;
}
static int add_host_bridge_dport(struct device *match, void *arg)
@@ -284,7 +285,6 @@ static int add_host_bridge_dport(struct device *match, void
*arg)
struct cxl_chbs_context ctx;
struct acpi_pci_root *pci_root;
struct cxl_port *root_port = arg;
- resource_size_t component_reg_phys;
struct device *host = root_port->dev.parent;
struct acpi_device *hb = to_cxl_host_bridge(host, match);
@@ -304,25 +304,26 @@ static int add_host_bridge_dport(struct device *match,
void *arg)
.dev = match,
.uid = uid,
};
- acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbs, &ctx);
+ acpi_table_parse_cedt(ACPI_CEDT_TYPE_CHBS, cxl_get_chbcr, &ctx);
+
+ if (ctx.rcrb != CXL_RESOURCE_NONE)
+ dev_dbg(match, "RCRB found for UID %lld: %pa\n", uid,
&ctx.rcrb);
- component_reg_phys = cxl_get_chbcr(&ctx);
- if (component_reg_phys == CXL_RESOURCE_NONE) {
+ if (ctx.chbcr == CXL_RESOURCE_NONE) {
dev_warn(match, "No CHBS found for Host Bridge (UID %lld)\n",
uid);
return 0;
}
- dev_dbg(match, "CHBCR found: %pa\n", &component_reg_phys);
+ dev_dbg(match, "CHBCR found: %pa\n", &ctx.chbcr);
pci_root = acpi_pci_find_root(hb->handle);
bridge = pci_root->bus->bridge;
- if (ctx.chbs.cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11)
+ if (ctx.cxl_version == ACPI_CEDT_CHBS_VERSION_CXL11)
dport = devm_cxl_add_rch_dport(root_port, bridge, uid,
- component_reg_phys,
- ctx.chbs.base);
+ ctx.chbcr, ctx.rcrb);
else
dport = devm_cxl_add_dport(root_port, bridge, uid,
- component_reg_phys);
+ ctx.chbcr);
if (IS_ERR(dport))
return PTR_ERR(dport);
--
2.30.2