[{"id":3674859,"web_url":"http://patchwork.ozlabs.org/comment/3674859/","msgid":"<20260408165701.GA295705@bhelgaas>","list_archive_url":null,"date":"2026-04-08T16:57:01","subject":"Re: [PATCH v8 2/2] PCI: s390: Expose the UID as an arch specific PCI\n slot attribute","submitter":{"id":67298,"url":"http://patchwork.ozlabs.org/api/people/67298/","name":"Bjorn Helgaas","email":"helgaas@kernel.org"},"content":"On Tue, Apr 07, 2026 at 03:24:46PM +0200, Niklas Schnelle wrote:\n> On s390, an individual PCI function can generally be identified by two\n> identifiers, the FID and the UID. Which identifier is used depends on\n> the scope and the platform configuration.\n> \n> The first identifier, the FID, is always available and identifies a PCI\n> device uniquely within a machine. The FID may be virtualized by\n> hypervisors, but on the LPAR level, the machine scope makes it\n> impossible to create the same configuration based on FIDs on two\n> different LPARs of the same machine, and difficult to reuse across\n> machines.\n> \n> Such matching LPAR configurations are useful, though, allowing\n> standardized setups and booting a Linux installation on different LPARs.\n> To this end the UID, or user-defined identifier, was introduced. While\n> it is only guaranteed to be unique within an LPAR and only if indicated\n> by firmware, it allows users to replicate PCI device setups.\n> \n> On s390, which uses a machine hypervisor, a per PCI function hotplug\n> model is used. The shortcoming with the UID then is, that it is not\n> visible to the user without first attaching the PCI function and\n> accessing the \"uid\" device attribute. The FID, on the other hand, is\n> used as the slot name and is thus known even with the PCI function in\n> standby.\n> \n> Remedy this shortcoming by providing the UID as an attribute on the slot\n> allowing the user to identify a PCI function based on the UID without\n> having to first attach it. Do this via a macro mechanism analogous to\n> what was introduced by commit 265baca69a07 (\"s390/pci: Stop usurping\n> pdev->dev.groups\") for the PCI device attributes.\n> \n> Reviewed-by: Gerd Bayer <gbayer@linux.ibm.com>\n> Reviewed-by: Julian Ruess <julianr@linux.ibm.com>\n> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>\n\nAcked-by: Bjorn Helgaas <bhelgaas@google.com> # drivers/pci/slot.c\n\n> ---\n>  Documentation/arch/s390/pci.rst |  7 +++++++\n>  arch/s390/include/asm/pci.h     |  4 ++++\n>  arch/s390/pci/pci_sysfs.c       | 20 ++++++++++++++++++++\n>  drivers/pci/slot.c              | 13 ++++++++++++-\n>  4 files changed, 43 insertions(+), 1 deletion(-)\n> \n> diff --git a/Documentation/arch/s390/pci.rst b/Documentation/arch/s390/pci.rst\n> index c3476de4f03278d07099aa32cbea0f868b6e9c9c..80f4ba19315994da056a10b4d216d61ff22ea5aa 100644\n> --- a/Documentation/arch/s390/pci.rst\n> +++ b/Documentation/arch/s390/pci.rst\n> @@ -58,6 +58,13 @@ Entries specific to zPCI functions and entries that hold zPCI information.\n>  \n>    - /sys/bus/pci/slots/XXXXXXXX/power\n>  \n> +  In addition to using the FID as the name of the slot, the slot directory\n> +  also contains the following s390-specific slot attributes.\n> +\n> +  - uid:\n> +    The User-defined identifier (UID) of the function which may be configured\n> +    by this slot. See also the corresponding attribute of the device.\n> +\n>    A physical function that currently supports a virtual function cannot be\n>    powered off until all virtual functions are removed with:\n>    echo 0 > /sys/bus/pci/devices/DDDD:BB:dd.f/sriov_numvf\n> diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h\n> index c0ff19dab5807c7e1aabb48a0e9436aac45ec97d..5dcf35f0f325f5f44b28109a1c8d9aef18401035 100644\n> --- a/arch/s390/include/asm/pci.h\n> +++ b/arch/s390/include/asm/pci.h\n> @@ -208,6 +208,10 @@ extern const struct attribute_group zpci_ident_attr_group;\n>  \t\t\t    &pfip_attr_group,\t\t \\\n>  \t\t\t    &zpci_ident_attr_group,\n>  \n> +extern const struct attribute_group zpci_slot_attr_group;\n> +\n> +#define ARCH_PCI_SLOT_GROUPS (&zpci_slot_attr_group)\n> +\n>  extern unsigned int s390_pci_force_floating __initdata;\n>  extern unsigned int s390_pci_no_rid;\n>  \n> diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c\n> index c2444a23e26c4218832bb91930b5f0ffd498d28f..d98d97df792adb3c7e415a8d374cc2f3a65fbb52 100644\n> --- a/arch/s390/pci/pci_sysfs.c\n> +++ b/arch/s390/pci/pci_sysfs.c\n> @@ -187,6 +187,17 @@ static ssize_t index_show(struct device *dev,\n>  }\n>  static DEVICE_ATTR_RO(index);\n>  \n> +static ssize_t zpci_uid_slot_show(struct pci_slot *slot, char *buf)\n> +{\n> +\tstruct zpci_dev *zdev = container_of(slot->hotplug, struct zpci_dev,\n> +\t\t\t\t\t     hotplug_slot);\n> +\n> +\treturn sysfs_emit(buf, \"0x%x\\n\", zdev->uid);\n> +}\n> +\n> +static struct pci_slot_attribute zpci_slot_attr_uid =\n> +\t__ATTR(uid, 0444, zpci_uid_slot_show, NULL);\n> +\n>  static umode_t zpci_index_is_visible(struct kobject *kobj,\n>  \t\t\t\t     struct attribute *attr, int n)\n>  {\n> @@ -243,6 +254,15 @@ const struct attribute_group pfip_attr_group = {\n>  \t.attrs = pfip_attrs,\n>  };\n>  \n> +static struct attribute *zpci_slot_attrs[] = {\n> +\t&zpci_slot_attr_uid.attr,\n> +\tNULL,\n> +};\n> +\n> +const struct attribute_group zpci_slot_attr_group = {\n> +\t.attrs = zpci_slot_attrs,\n> +};\n> +\n>  static struct attribute *clp_fw_attrs[] = {\n>  \t&uid_checking_attr.attr,\n>  \tNULL,\n> diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c\n> index 787311614e5b6ebb39e7284f9b9f205a0a684d6d..2f8fcfbbec24e73d0bb6e40fd04c05a94f518045 100644\n> --- a/drivers/pci/slot.c\n> +++ b/drivers/pci/slot.c\n> @@ -96,7 +96,18 @@ static struct attribute *pci_slot_default_attrs[] = {\n>  \t&pci_slot_attr_cur_speed.attr,\n>  \tNULL,\n>  };\n> -ATTRIBUTE_GROUPS(pci_slot_default);\n> +\n> +static const struct attribute_group pci_slot_default_group = {\n> +\t.attrs = pci_slot_default_attrs,\n> +};\n> +\n> +static const struct attribute_group *pci_slot_default_groups[] = {\n> +\t&pci_slot_default_group,\n> +#ifdef ARCH_PCI_SLOT_GROUPS\n> +\tARCH_PCI_SLOT_GROUPS,\n> +#endif\n> +\tNULL,\n> +};\n>  \n>  static const struct kobj_type pci_slot_ktype = {\n>  \t.sysfs_ops = &pci_slot_sysfs_ops,\n> \n> -- \n> 2.51.0\n>","headers":{"Return-Path":"\n <linux-pci+bounces-52164-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=SjmR8BBz;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=104.64.211.4; helo=sin.lore.kernel.org;\n envelope-from=linux-pci+bounces-52164-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"SjmR8BBz\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frTkX6LsTz1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 02:57:08 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sin.lore.kernel.org (Postfix) with ESMTP id EB6233007287\n\tfor <incoming@patchwork.ozlabs.org>; Wed,  8 Apr 2026 16:57:06 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 9952A3D3498;\n\tWed,  8 Apr 2026 16:57:03 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 74C353B4E8B;\n\tWed,  8 Apr 2026 16:57:03 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 09662C19421;\n\tWed,  8 Apr 2026 16:57:02 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775667423; cv=none;\n b=O0yXvPsG1NlTcWc8BF/ECCqKgPZuJ8ASYOHY1C+WuDO/v+xZqwvsPo+gN8B2rvxjazHM3J9rXAubFUdFmLwjsdu8PS9o+QbXSgybOFQmQFje6LQDq99PzLI1jKDNqj5OCKFe64B3oEsin4Z0HzZA8c3xO9h7cnrTI5jU+7IGQPY=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775667423; c=relaxed/simple;\n\tbh=Fyd2zhpxrgiBWe6iATMFl98c+D/8YDmtxcr+Cd6TbB4=;\n\th=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type:\n\t Content-Disposition:In-Reply-To;\n b=CyNfPkgl8iugXpdpfZZXw8ySswU3vtMCriCKtIm97eERFcw7F/KiSHM3FPi/CsqHOxtiGrKMlWKMsmqH/zNhFSo0VUF8WHzD2hjs/7MkV1XEtTDxrBtss8CY6a/FHsack2XelbPfuWkQqxsu8hPk+R/gIouFMTffayRCwPaXO20=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=SjmR8BBz; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1775667423;\n\tbh=Fyd2zhpxrgiBWe6iATMFl98c+D/8YDmtxcr+Cd6TbB4=;\n\th=Date:From:To:Cc:Subject:In-Reply-To:From;\n\tb=SjmR8BBzyo3kOL2RXsoqweOvvpg80BEqxHIdpLN5hezmtF5FfftkiNd/yCzJqnwJP\n\t zv841WkXnntkui8zi4J/OD6S1Rngz1Ns9ug+mK/IrbFDQN78UPXpxq6L5/j0OIecCc\n\t lciYjF4cNpc5cuDkWEtXJ2+CM7yDDZDrEQK36jL2nw1NQTQKbO6Xb5p/SNmmPLMCi8\n\t o5oxds9BBwuXTpXr67c+/9tFxa2FgTSsWEj/mbw8T0MpiNVYIozudslU1lcrF7U7iT\n\t U1bLz6iZ7lzPGFM7g6HdJEbETU6aR+SnuTLg2B1LeGBc4YkRjsp2C00Tmvz+izXmuG\n\t 4e7juJfBxbGMA==","Date":"Wed, 8 Apr 2026 11:57:01 -0500","From":"Bjorn Helgaas <helgaas@kernel.org>","To":"Niklas Schnelle <schnelle@linux.ibm.com>","Cc":"Bjorn Helgaas <bhelgaas@google.com>, Jonathan Corbet <corbet@lwn.net>,\n\tLukas Wunner <lukas@wunner.de>,\n\tShuah Khan <skhan@linuxfoundation.org>,\n\tFarhan Ali <alifm@linux.ibm.com>,\n\tAlexander Gordeev <agordeev@linux.ibm.com>,\n\tChristian Borntraeger <borntraeger@linux.ibm.com>,\n\tGerald Schaefer <gerald.schaefer@linux.ibm.com>,\n\tGerd Bayer <gbayer@linux.ibm.com>,\n\tHeiko Carstens <hca@linux.ibm.com>,\n\tJulian Ruess <julianr@linux.ibm.com>,\n\tMatthew Rosato <mjrosato@linux.ibm.com>,\n\tPeter Oberparleiter <oberpar@linux.ibm.com>,\n\tRamesh Errabolu <ramesh@linux.ibm.com>,\n\tSven Schnelle <svens@linux.ibm.com>,\n\tVasily Gorbik <gor@linux.ibm.com>, linux-doc@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,\n\tlinux-s390@vger.kernel.org","Subject":"Re: [PATCH v8 2/2] PCI: s390: Expose the UID as an arch specific PCI\n slot attribute","Message-ID":"<20260408165701.GA295705@bhelgaas>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260407-uid_slot-v8-2-15ae4409d2ce@linux.ibm.com>"}}]