Re: [PATCH v7 8/8] cxl: Allow auto-committed BI hdm decoders
Alison Schofield <[email protected]> Tue, 4 Aug 2026 17:51:36 -0700
| Newsgroups | org.kernel.vger.linux-cxl |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Jul 28, 2026 at 07:41:36AM -0700, Davidlohr Bueso wrote: > Allow auto-committed BI hdm decoders on sane platforms, rejecting > only broken paths (ie: one that cannot route BISnp, or BI paired > with a host-only target range type). > > The respective region creation is done like any other committed > decoder - with cxlds->bi set by the time an decoder attaches. > > A committed BI decoder under a window without the BI restriction is > refused (undefined behavior per the CFMWS Window Restrictions), as > is a committed decoder attaching to a region of a different > coherency model. Hi Davidlohr, A question about reading the CTRL register twice - > > Signed-off-by: Davidlohr Bueso <[email protected]> > --- > drivers/cxl/core/hdm.c | 24 +++++++++++++++++------- > drivers/cxl/core/pci.c | 36 +++++++++++++++++++++++++++++------- > drivers/cxl/core/region.c | 33 +++++++++++++++++++++++++++++++++ > drivers/cxl/port.c | 4 ++++ > 4 files changed, 83 insertions(+), 14 deletions(-) > > diff --git a/drivers/cxl/core/hdm.c b/drivers/cxl/core/hdm.c > index f437fe15c6df..c5be6fe4c77a 100644 > --- a/drivers/cxl/core/hdm.c > +++ b/drivers/cxl/core/hdm.c > @@ -1061,13 +1061,23 @@ static int init_hdm_decoder(struct cxl_port *port, struct cxl_decoder *cxld, > else > cxld->target_type = CXL_DECODER_DEVMEM; > > - /* > - * Autocommit BI-enabled decoders is not supported. > - * At this point cxlds->bi is not yet setup, so there > - * are no guarantees that the platform supports BI. > - */ > - if (FIELD_GET(CXL_HDM_DECODER0_CTRL_BI, ctrl)) > - return -ENXIO; > + if (FIELD_GET(CXL_HDM_DECODER0_CTRL_BI, ctrl)) { > + struct cxl_dev_state *cxlds = cxled ? > + cxled_to_memdev(cxled)->cxlds : NULL; Here we first read CTRL register - > + > + if (cxld->target_type == CXL_DECODER_HOSTONLYMEM) { > + dev_warn(&port->dev, > + "decoder%d.%d: BI with host-only\n", > + port->id, cxld->id); > + return -ENXIO; > + } > + if (cxlds && !cxlds->bi_capable) { > + dev_warn(&port->dev, > + "decoder%d.%d: path not BI capable\n", > + port->id, cxld->id); > + return -ENXIO; > + } > + } > > guard(rwsem_write)(&cxl_rwsem.region); > if (cxld->id != cxl_num_decoders_committed(port)) { > > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > index 76c6dc28a407..5578ef68034d 100644 > --- a/drivers/cxl/core/region.c > +++ b/drivers/cxl/core/region.c > @@ -1827,6 +1827,21 @@ static int cxl_region_attach_position(struct cxl_region *cxlr, > return rc; > } > > +/* Read back the committed BI bit of an auto-discovered decoder */ > +static bool cxled_committed_bi(struct cxl_endpoint_decoder *cxled) > +{ > + struct cxl_port *port = cxled_to_port(cxled); > + struct cxl_hdm *cxlhdm = dev_get_drvdata(&port->dev); > + u32 ctrl; > + > + if (!cxlhdm || !cxlhdm->regs.hdm_decoder) > + return false; > + > + ctrl = readl(cxlhdm->regs.hdm_decoder + > + CXL_HDM_DECODER0_CTRL_OFFSET(cxled->cxld.id)); > + return FIELD_GET(CXL_HDM_DECODER0_CTRL_BI, ctrl); And then we re-read it here. Could we record the bit at the earlier read? > +} snip to end