linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>, Ira Weiny <ira.weiny@intel.com>,
	<linux-pci@vger.kernel.org>, <lukas@wunner.de>,
	<bhelgaas@google.com>
Subject: Re: [PATCH v15 6/7] cxl/port: Read CDAT table
Date: Tue, 19 Jul 2022 12:26:55 -0700	[thread overview]
Message-ID: <62d7057f47fcd_97b642948e@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <20220719174601.000020c4@Huawei.com>

Jonathan Cameron wrote:
> On Mon, 18 Jul 2022 18:55:01 -0700
> Dan Williams <dan.j.williams@intel.com> wrote:
> 
> > From: Ira Weiny <ira.weiny@intel.com>
> > 
> > The per-device CDAT data provides performance data that is relevant for
> > mapping which CXL devices can participate in which CXL ranges by QTG
> > (QoS Throttling Group) (per ECN: CXL 2.0 CEDT CFMWS & QTG_DSM) [1]. The
> > QTG association specified in the ECN is advisory. Until the
> > cxl_acpi driver grows support for invoking the QTG _DSM method the CDAT
> > data is only of interest to userspace that may need it for debug
> > purposes.
> > 
> > Search the DOE mailboxes available, query CDAT data, cache the data and
> > make it available via a sysfs binary attribute per endpoint at:
> > 
> > /sys/bus/cxl/devices/endpointX/CDAT
> > 
> > ...similar to other ACPI-structured table data in
> > /sys/firmware/ACPI/tables. The CDAT is relative to 'struct cxl_port'
> > objects since switches in addition to endpoints can host a CDAT
> > instance. Switch CDAT support is not implemented.
> > 
> > This does not support table updates at runtime. It will always provide
> > whatever was there when first cached. It is also the case that table
> > updates are not expected outside of explicit DPA address map affecting
> > commands like Set Partition with the immediate flag set. Given that the
> > driver does not support Set Partition with the immediate flag set there
> > is no current need for update support.
> > 
> > Link: https://www.computeexpresslink.org/spec-landing [1]
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Co-developed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> > [djbw: drop in-kernel parsing infra for now, and other minor fixups]
> > Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> One comment inline that basically says the error message will do for now
> if we race with an autonomous update of CDAT by the device. (see response
> to earlier version on why that can happen).
> 
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > ---
> > diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c
> > index 7672789c3225..9240df53ed87 100644
> > --- a/drivers/cxl/core/pci.c
> > +++ b/drivers/cxl/core/pci.c
> 
> 
> > +/**
> > + * read_cdat_data - Read the CDAT data on this port
> > + * @port: Port to read data from
> > + *
> > + * This call will sleep waiting for responses from the DOE mailbox.
> > + */
> > +void read_cdat_data(struct cxl_port *port)
> > +{
> > +	struct pci_doe_mb *cdat_doe;
> > +	struct device *dev = &port->dev;
> > +	struct device *uport = port->uport;
> > +	size_t cdat_length;
> > +	int rc;
> > +
> > +	cdat_doe = find_cdat_doe(uport);
> > +	if (!cdat_doe) {
> > +		dev_dbg(dev, "No CDAT mailbox\n");
> > +		return;
> > +	}
> > +
> > +	port->cdat_available = true;
> > +
> > +	if (cxl_cdat_get_length(dev, cdat_doe, &cdat_length)) {
> > +		dev_dbg(dev, "No CDAT length\n");
> > +		return;
> > +	}
> > +
> > +	port->cdat.table = devm_kzalloc(dev, cdat_length, GFP_KERNEL);
> > +	if (!port->cdat.table)
> > +		return;
> > +
> > +	port->cdat.length = cdat_length;
> > +	rc = cxl_cdat_read_table(dev, cdat_doe, &port->cdat);
> > +	if (rc) {
> > +		/* Don't leave table data allocated on error */
> > +		devm_kfree(dev, port->cdat.table);
> > +		port->cdat.table = NULL;
> > +		port->cdat.length = 0;
> > +		dev_err(dev, "CDAT data read error\n");
> 
> This will be sufficient for now for the race against autonomous CDAT
> update potential issue mentioned in earlier review.  If it happens
> and someone really cares they can unbind and rebind the device.

Even it is too late to change the spec, which I do not think it is, it
is not too late to make a public statement that Linux has no interest in
supporting such shenanigans outside of a documented set of explicit
commands that have a CDAT-update side effect.

  reply	other threads:[~2022-07-19 19:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15  3:04 [PATCH V14 0/7] CXL: Read CDAT ira.weiny
2022-07-15  3:04 ` [PATCH V14 1/7] PCI: Add vendor ID for the PCI SIG ira.weiny
2022-07-15  3:04 ` [PATCH V14 2/7] PCI: Replace magic constant for PCI Sig Vendor ID ira.weiny
2022-07-15  3:04 ` [PATCH V14 3/7] PCI/DOE: Add DOE mailbox support functions ira.weiny
2022-07-19 16:35   ` Jonathan Cameron
2022-07-19 19:16     ` Ira Weiny
2022-07-19 19:50       ` Ira Weiny
2022-07-20 11:24       ` Jonathan Cameron
2022-07-15  3:04 ` [PATCH V14 4/7] cxl/pci: Create PCI DOE mailbox's for memory devices ira.weiny
2022-07-19 16:38   ` Jonathan Cameron
2022-07-15  3:04 ` [PATCH V14 5/7] driver-core: Introduce BIN_ATTR_ADMIN_{RO,RW} ira.weiny
2022-07-19 16:39   ` Jonathan Cameron
2022-07-15  3:04 ` [PATCH V14 6/7] cxl/port: Read CDAT table ira.weiny
2022-07-16  3:27   ` Dan Williams
2022-07-19  1:19   ` Dan Williams
2022-07-19  1:55   ` [PATCH v15 " Dan Williams
2022-07-19 16:46     ` Jonathan Cameron
2022-07-19 19:26       ` Dan Williams [this message]
2022-07-15  3:04 ` [PATCH V14 7/7] cxl/port: Introduce cxl_cdat_valid() ira.weiny
2022-07-16  2:26   ` Dan Williams
2022-07-19 16:47     ` Jonathan Cameron
2022-07-19 15:21 ` [PATCH V14 0/7] CXL: Read CDAT Jonathan Cameron
2022-07-19 19:23   ` 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=62d7057f47fcd_97b642948e@dwillia2-xfh.jf.intel.com.notmuch \
    --to=dan.j.williams@intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    /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).