Re: [PATCH v2 09/11] PCI/IDE: Report available IDE streams

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dionna Amalie Glaze wrote:
> On Mon, Mar 3, 2025 at 11:20 PM Dan Williams <dan.j.williams@xxxxxxxxx> wrote:
> >
> > The limited number of link-encryption (IDE) streams that a given set of
> > host bridges supports is a platform specific detail. Provide
> > pci_ide_init_nr_streams() as a generic facility for either platform TSM
> > drivers, or PCI core native IDE, to report the number available streams.
> > After invoking pci_ide_init_nr_streams() an "available_secure_streams"
> > attribute appears in PCI host bridge sysfs to convey that count.
> >
> > Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
> > Cc: Lukas Wunner <lukas@xxxxxxxxx>
> > Cc: Samuel Ortiz <sameo@xxxxxxxxxxxx>
> > Cc: Alexey Kardashevskiy <aik@xxxxxxx>
> > Cc: Xu Yilun <yilun.xu@xxxxxxxxxxxxxxx>
> > Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
> > ---
> >  .../ABI/testing/sysfs-devices-pci-host-bridge      |   12 ++++
> >  drivers/pci/ide.c                                  |   58 ++++++++++++++++++++
> >  drivers/pci/pci.h                                  |    3 +
> >  drivers/pci/probe.c                                |   12 ++++
> >  include/linux/pci.h                                |    8 +++
> >  5 files changed, 92 insertions(+), 1 deletion(-)
> >
> > diff --git a/Documentation/ABI/testing/sysfs-devices-pci-host-bridge b/Documentation/ABI/testing/sysfs-devices-pci-host-bridge
> > index 51dc9eed9353..4624469e56d4 100644
> > --- a/Documentation/ABI/testing/sysfs-devices-pci-host-bridge
> > +++ b/Documentation/ABI/testing/sysfs-devices-pci-host-bridge
> > @@ -20,6 +20,7 @@ What:         pciDDDD:BB/streamH.R.E:DDDD:BB:DD:F
> >  Date:          December, 2024
> >  Contact:       linux-pci@xxxxxxxxxxxxxxx
> >  Description:
> > +<<<<<<< current
> 
> Drop?

Whoops, surprised checkpatch did not flag that.

> 
> >                 (RO) When a platform has established a secure connection, PCIe
> >                 IDE, between two Partner Ports, this symlink appears. The
> >                 primary function is to account the stream slot / resources
> > @@ -30,3 +31,14 @@ Description:
> >                 assigned Selective IDE Stream Register Block in the Root Port
> >                 and Endpoint, and H represents a platform specific pool of
> >                 stream resources shared by the Root Ports in a host bridge.
> > +
> > +What:          pciDDDD:BB/available_secure_streams
> > +Date:          December, 2024
> > +Contact:       linux-pci@xxxxxxxxxxxxxxx
> > +Description:
> > +               (RO) When a host bridge has Root Ports that support PCIe IDE
> > +               (link encryption and integrity protection) there may be a
> > +               limited number of streams that can be used for establishing new
> > +               secure links. This attribute decrements upon secure link setup,
> > +               and increments upon secure link teardown. The in-use stream
> > +               count is determined by counting stream symlinks.
> 
> Please describe the expected form metavariables DDDD and BB will take.

I went ahead and folded the below into the preceding patch, and will add
another "See /sys/devices/pciDDDD:BB entry..." note.

diff --git a/Documentation/ABI/testing/sysfs-devices-pci-host-bridge b/Documentation/ABI/testing/sysfs-devices-pci-host-bridge
index 51dc9eed9353..8ea48b7aa996 100644
--- a/Documentation/ABI/testing/sysfs-devices-pci-host-bridge
+++ b/Documentation/ABI/testing/sysfs-devices-pci-host-bridge
@@ -5,8 +5,10 @@ Contact:	linux-pci@xxxxxxxxxxxxxxx
 Description:
 		A PCI host bridge device parents a PCI bus device topology. PCI
 		controllers may also parent host bridges. The DDDD:BB format
-		conveys the PCI domain number and root bus number of the
-		host bridge.
+		conveys the PCI domain number and root bus number (in
+		hexadecimal) of the host bridge. Note that the domain number may
+		be larger than the 16-bits that the "DDDD" format implies for
+		emulated host-bridges.
 
 What:		pciDDDD:BB/firmware_node
 Date:		December, 2024
@@ -14,7 +16,9 @@ Contact:	linux-pci@xxxxxxxxxxxxxxx
 Description:
 		(RO) Symlink to the platform firmware device object "companion"
 		of the host bridge. For example, an ACPI device with an _HID of
-		PNP0A08 (/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00).
+		PNP0A08 (/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00). See
+		/sys/devices/pciDDDD:BB entry for details about the DDDD:BB
+		format.
 
 What:		pciDDDD:BB/streamH.R.E:DDDD:BB:DD:F
 Date:		December, 2024
@@ -29,4 +33,6 @@ Description:
 		bus:BB device:DD function:F. Where R and E represent the
 		assigned Selective IDE Stream Register Block in the Root Port
 		and Endpoint, and H represents a platform specific pool of
-		stream resources shared by the Root Ports in a host bridge.
+		stream resources shared by the Root Ports in a host bridge.  See
+		/sys/devices/pciDDDD:BB entry for details about the DDDD:BB
+		format.

> > diff --git a/drivers/pci/ide.c b/drivers/pci/ide.c
> > index b2091f6260e6..0c72985e6a65 100644
> > --- a/drivers/pci/ide.c
> > +++ b/drivers/pci/ide.c
> > @@ -439,3 +439,61 @@ void pci_ide_stream_disable(struct pci_dev *pdev, struct pci_ide *ide)
> >         pci_write_config_dword(pdev, pos + PCI_IDE_SEL_CTL, 0);
> >  }
> >  EXPORT_SYMBOL_GPL(pci_ide_stream_disable);
> > +
> > +static ssize_t available_secure_streams_show(struct device *dev,
> > +                                            struct device_attribute *attr,
> > +                                            char *buf)
> > +{
> > +       struct pci_host_bridge *hb = to_pci_host_bridge(dev);
> > +       int avail;
> > +
> > +       if (hb->nr_ide_streams < 0)
> > +               return -ENXIO;
> > +
> > +       avail = hb->nr_ide_streams -
> > +               bitmap_weight(hb->ide_stream_map, hb->nr_ide_streams);
> > +       return sysfs_emit(buf, "%d\n", avail);
> > +}
> > +static DEVICE_ATTR_RO(available_secure_streams);
> > +
> > +static struct attribute *pci_ide_attrs[] = {
> > +       &dev_attr_available_secure_streams.attr,
> > +       NULL,
> > +};
> > +
> > +static umode_t pci_ide_attr_visible(struct kobject *kobj, struct attribute *a, int n)
> > +{
> > +       struct device *dev = kobj_to_dev(kobj);
> > +       struct pci_host_bridge *hb = to_pci_host_bridge(dev);
> > +
> > +       if (a == &dev_attr_available_secure_streams.attr)
> > +               if (hb->nr_ide_streams < 0)
> > +                       return 0;
> > +
> > +       return a->mode;
> > +}
> > +
> > +struct attribute_group pci_ide_attr_group = {
> > +       .attrs = pci_ide_attrs,
> > +       .is_visible = pci_ide_attr_visible,
> > +};
> > +
> > +/**
> > + * pci_init_nr_ide_streams() - size the pool of IDE Stream resources
> 
> /size/sets the size of/

Fixed.

> > + * @hb: host bridge boundary for the stream pool
> > + * @nr: number of streams
> > + *
> > + * Enable IDE Stream establishment by setting the number of stream
> > + * resources available at the host bridge. Platform init code must set
> > + * this before the first pci_ide_stream_alloc() call.
> 
> Is failing to call this a caught error by pci_ide_stream_alloc?

Good point, it should.

> > + *
> > + * The "PCI_IDE" symbol namespace is required because this is typically
> > + * a detail that is settled in early PCI init, i.e. only an expert or
> > + * test module should consume this export.
> 
> Perhaps start with "Expert use only"?

Updated it to:

@@ -480,17 +490,18 @@ struct attribute_group pci_ide_attr_group = {
 };
 
 /**
- * pci_ide_init_nr_streams() - size the pool of IDE Stream resources
+ * pci_ide_init_nr_streams() - sets size of the pool of IDE Stream resources
  * @hb: host bridge boundary for the stream pool
  * @nr: number of streams
  *
- * Enable IDE Stream establishment by setting the number of stream
- * resources available at the host bridge. Platform init code must set
- * this before the first pci_ide_stream_alloc() call.
+ * Platform PCI init and/or expert test module use only. Enable IDE
+ * Stream establishment by setting the number of stream resources
+ * available at the host bridge. Platform init code must set this before
+ * the first pci_ide_stream_alloc() call.
  *
  * The "PCI_IDE" symbol namespace is required because this is typically
- * a detail that is settled in early PCI init, i.e. only an expert or
- * test module should consume this export.
+ * a detail that is settled in early PCI init. I.e. this export is not
+ * for endpoint drivers.
  */

Thanks for the fixup suggestions.




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux