[{"id":3673237,"web_url":"http://patchwork.ozlabs.org/comment/3673237/","msgid":"<bde50f9a-bbe1-43ba-b2f4-24951dd0cccf@linux.ibm.com>","list_archive_url":null,"date":"2026-04-03T17:19:59","subject":"Re: [PATCH v6 2/2] PCI: s390: Expose the UID as an arch specific PCI\n slot attribute","submitter":{"id":73785,"url":"http://patchwork.ozlabs.org/api/people/73785/","name":"Farhan Ali","email":"alifm@linux.ibm.com"},"content":"On 4/2/2026 1:34 PM, 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> ---\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 31c24ed5506f1fc07f89821f67a814118514f441..4c0f35c8a5588eee3cf0d596e0057f24b3ed079c 100644\n> --- a/Documentation/arch/s390/pci.rst\n> +++ b/Documentation/arch/s390/pci.rst\n> @@ -57,6 +57,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\nI think the way we assign the same pci slot to multifunctions (PF and VF \non the same LPAR), IIUC we could possibly display the wrong uid here. I \nam hoping my patch [1] can fix this. I am curious, is there any \ns390-tool that would use the uid? Though this would only impact the NETD \ndevices on newer machines, so I don't know if we want to gate this \nbehind my patch?\n\n[1] https://lore.kernel.org/all/20260330174011.1161-2-alifm@linux.ibm.com/\n\nThanks\n\nFarhan\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>","headers":{"Return-Path":"\n <linux-pci+bounces-51829-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=ibm.com header.i=@ibm.com header.a=rsa-sha256\n header.s=pp1 header.b=rZaItZL4;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-pci+bounces-51829-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com\n header.b=\"rZaItZL4\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=148.163.158.5","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.ibm.com"],"Received":["from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fnQTY3bspz1yCt\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 04 Apr 2026 04:20:17 +1100 (AEDT)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id E8411300539C\n\tfor <incoming@patchwork.ozlabs.org>; Fri,  3 Apr 2026 17:20:10 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id DD0143CF02A;\n\tFri,  3 Apr 2026 17:20:09 +0000 (UTC)","from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com\n [148.163.158.5])\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 13B5E3CCA0C;\n\tFri,  3 Apr 2026 17:20:06 +0000 (UTC)","from pps.filterd (m0360072.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 632MX4Q13676159;\n\tFri, 3 Apr 2026 17:20:04 GMT","from ppma11.dal12v.mail.ibm.com\n (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219])\n\tby mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4d66msghj2-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tFri, 03 Apr 2026 17:20:03 +0000 (GMT)","from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1])\n\tby ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id\n 633EhATV008703;\n\tFri, 3 Apr 2026 17:20:03 GMT","from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4])\n\tby ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4d6v11xn7v-1\n\t(version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT);\n\tFri, 03 Apr 2026 17:20:02 +0000","from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com\n [10.39.53.232])\n\tby smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n 633HK1Ig20251350\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);\n\tFri, 3 Apr 2026 17:20:01 GMT","from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id 7197058053;\n\tFri,  3 Apr 2026 17:20:01 +0000 (GMT)","from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with ESMTP id A17E558043;\n\tFri,  3 Apr 2026 17:19:59 +0000 (GMT)","from [9.61.255.240] (unknown [9.61.255.240])\n\tby smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP;\n\tFri,  3 Apr 2026 17:19:59 +0000 (GMT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775236809; cv=none;\n b=V4svs6g2GJXdd6Oj1eESoqIrbR/F5MJFeTU7MgBNfFIyZgzHgvElTqlvl2y/jrihL163SP34R39b53vozCPsG1rxB76kgoy7PeGxo4wtPRkm9aPaldC0NN3Ve7rFp1ww6Wil2kKJ8GThrFDxnwNY6LrVHPC8Z+qyO/5LqTlEhTM=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775236809; c=relaxed/simple;\n\tbh=7HUxjHlLX7tKAP5UZ9w1O1GhJcWKtKba8jFl34koW54=;\n\th=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:\n\t In-Reply-To:Content-Type;\n b=gUyogjjyLQj2WyHfXwz/PXypbddoL3tH/PF+YXuXR1vS59DnGhG2Fn1LEdjVcg1KZoq8JuLOZLASZqZKvmuNT2OIfxxLbzJ6ufr22LDlKNKwUb5T+UQgT9+ru9pBTXCI/1ymz58RaKPfRrcsaD1CPiPKYfZ8G+A8KuLlf69DQ0k=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=linux.ibm.com;\n spf=pass smtp.mailfrom=linux.ibm.com;\n dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com\n header.b=rZaItZL4; arc=none smtp.client-ip=148.163.158.5","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc\n\t:content-transfer-encoding:content-type:date:from:in-reply-to\n\t:message-id:mime-version:references:subject:to; s=pp1; bh=bekqmO\n\tottmfu/C/eY2bs7mtQZVOoQW7nKirlmasQaKs=; b=rZaItZL4lXE1udtUzBHW0E\n\txnOlEaBrQwTDgl1pPkyPto0Ux6HF+yB1zxxauZAS3NzPHTtSxpsEIn2IC6KqYO4L\n\tXDjOu8UKChc7+PI/EMFXlXpxp+i4M+a1H4ACnaivYauPnZMQynzaQxh3qM4RLo7s\n\tAk6l+5hETmtPiNogWco8tQhupLkwCvcdxYbaZHSsSG9P96KtUwkJGh0YiME2qzL0\n\tHoSQ8OeHkehhc+Ldk0jELUziP/HcOPCz9iogrD//f3mlSuQ+y6fsfPX/gKPX5Gc4\n\t/fz+MpkDcr2GC5Ps0C64l6x7Xkhfh856NlFx914ujaFXNd5pdYic80jCzlHmtOsw\n\t==","Message-ID":"<bde50f9a-bbe1-43ba-b2f4-24951dd0cccf@linux.ibm.com>","Date":"Fri, 3 Apr 2026 10:19:59 -0700","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","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v6 2/2] PCI: s390: Expose the UID as an arch specific PCI\n slot attribute","To":"Niklas Schnelle <schnelle@linux.ibm.com>,\n        Bjorn Helgaas <bhelgaas@google.com>, Jonathan Corbet <corbet@lwn.net>,\n        Lukas Wunner <lukas@wunner.de>, Shuah Khan <skhan@linuxfoundation.org>","Cc":"Alexander Gordeev <agordeev@linux.ibm.com>,\n        Christian Borntraeger <borntraeger@linux.ibm.com>,\n        Gerald Schaefer <gerald.schaefer@linux.ibm.com>,\n        Gerd Bayer <gbayer@linux.ibm.com>, Heiko Carstens <hca@linux.ibm.com>,\n        Julian Ruess <julianr@linux.ibm.com>,\n        Matthew Rosato\n <mjrosato@linux.ibm.com>,\n        Peter Oberparleiter <oberpar@linux.ibm.com>,\n        Ramesh Errabolu <ramesh@linux.ibm.com>,\n        Sven Schnelle <svens@linux.ibm.com>,\n Vasily Gorbik <gor@linux.ibm.com>,\n        linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,\n        linux-pci@vger.kernel.org, linux-s390@vger.kernel.org","References":"<20260402-uid_slot-v6-0-d5ea0a14ddb9@linux.ibm.com>\n <20260402-uid_slot-v6-2-d5ea0a14ddb9@linux.ibm.com>","Content-Language":"en-US","From":"Farhan Ali <alifm@linux.ibm.com>","In-Reply-To":"<20260402-uid_slot-v6-2-d5ea0a14ddb9@linux.ibm.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","X-TM-AS-GCONF":"00","X-Proofpoint-Reinject":"loops=2 maxloops=12","X-Authority-Analysis":"v=2.4 cv=J6enLQnS c=1 sm=1 tr=0 ts=69cff6c4 cx=c_pps\n a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17\n a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VwQbUJbxAAAA:8\n a=VnNF1IyMAAAA:8 a=zab_MO1Yg7CTISiwoJcA:9 a=QEXdDO2ut3YA:10","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDAzMDE1NCBTYWx0ZWRfX5LQFWOEzEKoj\n sv9QIsXSkhcl9+YSN1NNR1mene1qjziSaxZZ7/4Demu9AojEBiEEqbpoN/+vBWJtNciwqFwdV8X\n S2taKkVsx23y7yoUAemgnncRAMTZ4AkBgXCAxFRtwHDYjdLc7Ck69Ig4dLHdWonOMmvhvO6o4jL\n Qz7D2Qcfh0Oboe8aAnvJMQ813JQj8EUrL6BWneN+g/Lzmol/QzMFqZFbno+SEopEPCJqo3Qo175\n wyEzciK4c8xxqWaVyJ/zBsPYfuKezqdqN8t36AJRQeLmtSSOaUWzQEL6647lzF3+5sCQSGIPK67\n NPnm4EpKLqzVCG1xlkeRL+Tn8HdLPg5grbzWcn5aTlonnGwYxp61fdCz+6GAEKH7N+2nTL9v4q9\n cNobk3epuDFDBkPEkybq0zm2woqh1vroasReDwy4vRQlK5xHyZgKW7KkTcHZ4zoOXcPWTsvBi8Y\n pZ0jsI13F1tS6CuRj/A==","X-Proofpoint-GUID":"ttKxjis-mUI1CHId1Ow0JEo2NRbZ3Qse","X-Proofpoint-ORIG-GUID":"7HTSU5BayCQorpXQvpwkBPttdMaWSRRL","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-03_05,2026-04-03_01,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n suspectscore=0 clxscore=1015 adultscore=0 priorityscore=1501 bulkscore=0\n phishscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 impostorscore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2604030154"}}]