Skip to content

Commit e4f9ab0

Browse files
niklas88Vasily Gorbik
authored andcommitted
PCI: s390: Expose the UID as an arch specific PCI slot attribute
On s390, an individual PCI function can generally be identified by two identifiers, the FID and the UID. Which identifier is used depends on the scope and the platform configuration. The first identifier, the FID, is always available and identifies a PCI device uniquely within a machine. The FID may be virtualized by hypervisors, but on the LPAR level, the machine scope makes it impossible to create the same configuration based on FIDs on two different LPARs of the same machine, and difficult to reuse across machines. Such matching LPAR configurations are useful, though, allowing standardized setups and booting a Linux installation on different LPARs. To this end the UID, or user-defined identifier, was introduced. While it is only guaranteed to be unique within an LPAR and only if indicated by firmware, it allows users to replicate PCI device setups. On s390, which uses a machine hypervisor, a per PCI function hotplug model is used. The shortcoming with the UID then is, that it is not visible to the user without first attaching the PCI function and accessing the "uid" device attribute. The FID, on the other hand, is used as the slot name and is thus known even with the PCI function in standby. Remedy this shortcoming by providing the UID as an attribute on the slot allowing the user to identify a PCI function based on the UID without having to first attach it. Do this via a macro mechanism analogous to what was introduced by commit 265baca ("s390/pci: Stop usurping pdev->dev.groups") for the PCI device attributes. Reviewed-by: Gerd Bayer <gbayer@linux.ibm.com> Reviewed-by: Julian Ruess <julianr@linux.ibm.com> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> # drivers/pci/slot.c Link: https://lore.kernel.org/r/20260407-uid_slot-v8-2-15ae4409d2ce@linux.ibm.com Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 737c4f4 commit e4f9ab0

4 files changed

Lines changed: 43 additions & 1 deletion

File tree

Documentation/arch/s390/pci.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ Entries specific to zPCI functions and entries that hold zPCI information.
5858

5959
- /sys/bus/pci/slots/XXXXXXXX/power
6060

61+
In addition to using the FID as the name of the slot, the slot directory
62+
also contains the following s390-specific slot attributes.
63+
64+
- uid:
65+
The User-defined identifier (UID) of the function which may be configured
66+
by this slot. See also the corresponding attribute of the device.
67+
6168
A physical function that currently supports a virtual function cannot be
6269
powered off until all virtual functions are removed with:
6370
echo 0 > /sys/bus/pci/devices/DDDD:BB:dd.f/sriov_numvf

arch/s390/include/asm/pci.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ extern const struct attribute_group zpci_ident_attr_group;
208208
&pfip_attr_group, \
209209
&zpci_ident_attr_group,
210210

211+
extern const struct attribute_group zpci_slot_attr_group;
212+
213+
#define ARCH_PCI_SLOT_GROUPS (&zpci_slot_attr_group)
214+
211215
extern unsigned int s390_pci_force_floating __initdata;
212216
extern unsigned int s390_pci_no_rid;
213217

arch/s390/pci/pci_sysfs.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,17 @@ static ssize_t index_show(struct device *dev,
187187
}
188188
static DEVICE_ATTR_RO(index);
189189

190+
static ssize_t zpci_uid_slot_show(struct pci_slot *slot, char *buf)
191+
{
192+
struct zpci_dev *zdev = container_of(slot->hotplug, struct zpci_dev,
193+
hotplug_slot);
194+
195+
return sysfs_emit(buf, "0x%x\n", zdev->uid);
196+
}
197+
198+
static struct pci_slot_attribute zpci_slot_attr_uid =
199+
__ATTR(uid, 0444, zpci_uid_slot_show, NULL);
200+
190201
static umode_t zpci_index_is_visible(struct kobject *kobj,
191202
struct attribute *attr, int n)
192203
{
@@ -243,6 +254,15 @@ const struct attribute_group pfip_attr_group = {
243254
.attrs = pfip_attrs,
244255
};
245256

257+
static struct attribute *zpci_slot_attrs[] = {
258+
&zpci_slot_attr_uid.attr,
259+
NULL,
260+
};
261+
262+
const struct attribute_group zpci_slot_attr_group = {
263+
.attrs = zpci_slot_attrs,
264+
};
265+
246266
static struct attribute *clp_fw_attrs[] = {
247267
&uid_checking_attr.attr,
248268
NULL,

drivers/pci/slot.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,18 @@ static struct attribute *pci_slot_default_attrs[] = {
9696
&pci_slot_attr_cur_speed.attr,
9797
NULL,
9898
};
99-
ATTRIBUTE_GROUPS(pci_slot_default);
99+
100+
static const struct attribute_group pci_slot_default_group = {
101+
.attrs = pci_slot_default_attrs,
102+
};
103+
104+
static const struct attribute_group *pci_slot_default_groups[] = {
105+
&pci_slot_default_group,
106+
#ifdef ARCH_PCI_SLOT_GROUPS
107+
ARCH_PCI_SLOT_GROUPS,
108+
#endif
109+
NULL,
110+
};
100111

101112
static const struct kobj_type pci_slot_ktype = {
102113
.sysfs_ops = &pci_slot_sysfs_ops,

0 commit comments

Comments
 (0)