From: Bjorn Helgaas <helgaas@kernel.org>
To: Niklas Schnelle <schnelle@linux.ibm.com>
Cc: Narendra K <narendra_k@dell.com>,
Viktor Mihajlovski <mihajlov@linux.ibm.com>,
Stefan Raspl <raspl@linux.ibm.com>,
Peter Oberparleiter <oberpar@linux.ibm.com>,
linux-netdev@vger.kernel.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH 1/1] s390/pci: expose a PCI device's UID as its index
Date: Wed, 14 Apr 2021 15:17:55 -0500 [thread overview]
Message-ID: <20210414201755.GA2532433@bjorn-Precision-5520> (raw)
In-Reply-To: <20210412135905.1434249-2-schnelle@linux.ibm.com>
On Mon, Apr 12, 2021 at 03:59:05PM +0200, Niklas Schnelle wrote:
> On s390 each PCI device has a user-defined ID (UID) exposed under
> /sys/bus/pci/devices/<dev>/uid. This ID was designed to serve as the PCI
> device's primary index and to match the device within Linux to the
> device configured in the hypervisor. To serve as a primary identifier
> the UID must be unique within the Linux instance, this is guaranteed by
> the platform if and only if the UID Uniqueness Checking flag is set
> within the CLP List PCI Functions response.
>
> In this sense the UID serves an analogous function as the SMBIOS
> instance number or ACPI index exposed as the "index" respectively
> "acpi_index" device attributes and used by e.g. systemd to set interface
> names. As s390 does not use and will likely never use ACPI nor SMBIOS
> there is no conflict and we can just expose the UID under the "index"
> attribute whenever UID Uniqueness Checking is active and get systemd's
> interface naming support for free.
>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> Acked-by: Viktor Mihajlovski <mihajlov@linux.ibm.com>
This seems like a nice solution to me.
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> ---
> Documentation/ABI/testing/sysfs-bus-pci | 11 +++++---
> arch/s390/pci/pci_sysfs.c | 35 +++++++++++++++++++++++++
> 2 files changed, 42 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
> index 25c9c39770c6..1241b6d11a52 100644
> --- a/Documentation/ABI/testing/sysfs-bus-pci
> +++ b/Documentation/ABI/testing/sysfs-bus-pci
> @@ -195,10 +195,13 @@ What: /sys/bus/pci/devices/.../index
> Date: July 2010
> Contact: Narendra K <narendra_k@dell.com>, linux-bugs@dell.com
> Description:
> - Reading this attribute will provide the firmware
> - given instance (SMBIOS type 41 device type instance) of the
> - PCI device. The attribute will be created only if the firmware
> - has given an instance number to the PCI device.
> + Reading this attribute will provide the firmware given instance
> + number of the PCI device. Depending on the platform this can
> + be for example the SMBIOS type 41 device type instance or the
> + user-defined ID (UID) on s390. The attribute will be created
> + only if the firmware has given an instance number to the PCI
> + device and that number is guaranteed to uniquely identify the
> + device in the system.
> Users:
> Userspace applications interested in knowing the
> firmware assigned device type instance of the PCI
> diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
> index e14d346dafd6..20dbb2058d51 100644
> --- a/arch/s390/pci/pci_sysfs.c
> +++ b/arch/s390/pci/pci_sysfs.c
> @@ -138,6 +138,38 @@ static ssize_t uid_is_unique_show(struct device *dev,
> }
> static DEVICE_ATTR_RO(uid_is_unique);
>
> +#ifndef CONFIG_DMI
> +/* analogous to smbios index */
I think this is smbios_attr_instance, right? Maybe mention that
specifically to make it easier to match these up.
Looks like smbios_attr_instance and the similar ACPI stuff could use
some updating to use the current attribute group infrastructure.
> +static ssize_t index_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct zpci_dev *zdev = to_zpci(to_pci_dev(dev));
> + u32 index = ~0;
> +
> + if (zpci_unique_uid)
> + index = zdev->uid;
> +
> + return sysfs_emit(buf, "%u\n", index);
> +}
> +static DEVICE_ATTR_RO(index);
> +
> +static umode_t zpci_unique_uids(struct kobject *kobj,
> + struct attribute *attr, int n)
> +{
> + return zpci_unique_uid ? attr->mode : 0;
> +}
> +
> +static struct attribute *zpci_ident_attrs[] = {
> + &dev_attr_index.attr,
> + NULL,
> +};
> +
> +static struct attribute_group zpci_ident_attr_group = {
> + .attrs = zpci_ident_attrs,
> + .is_visible = zpci_unique_uids,
It's conventional to name these functions *_is_visible() (another
convention that smbios_attr_instance and acpi_attr_index probably
predate).
> +};
> +#endif
> +
> static struct bin_attribute *zpci_bin_attrs[] = {
> &bin_attr_util_string,
> &bin_attr_report_error,
> @@ -179,5 +211,8 @@ static struct attribute_group pfip_attr_group = {
> const struct attribute_group *zpci_attr_groups[] = {
> &zpci_attr_group,
> &pfip_attr_group,
> +#ifndef CONFIG_DMI
> + &zpci_ident_attr_group,
> +#endif
> NULL,
> };
> --
> 2.25.1
>
next prev parent reply other threads:[~2021-04-14 20:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-12 13:59 [PATCH 0/1] Use of /sys/bus/pci/devices/…/index for non-SMBIOS platforms Niklas Schnelle
2021-04-12 13:59 ` [PATCH 1/1] s390/pci: expose a PCI device's UID as its index Niklas Schnelle
2021-04-14 20:17 ` Bjorn Helgaas [this message]
2021-04-15 7:24 ` Niklas Schnelle
2021-04-16 17:58 ` K, Narendra
2021-04-17 10:47 ` Viktor Mihajlovski
2021-04-18 8:18 ` K, Narendra
2021-04-13 5:39 ` [PATCH 0/1] Use of /sys/bus/pci/devices/…/index for non-SMBIOS platforms Leon Romanovsky
2021-04-13 6:57 ` Niklas Schnelle
2021-04-13 7:32 ` Leon Romanovsky
2021-04-13 7:53 ` Niklas Schnelle
2021-04-13 18:22 ` K, Narendra
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=20210414201755.GA2532433@bjorn-Precision-5520 \
--to=helgaas@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-netdev@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mihajlov@linux.ibm.com \
--cc=narendra_k@dell.com \
--cc=oberpar@linux.ibm.com \
--cc=raspl@linux.ibm.com \
--cc=schnelle@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).