From nobody Mon Jun 8 08:54:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585731; cv=none; d=zohomail.com; s=zohoarc; b=gOMKO0JfpHSxhnz09eCZtkN1knoDk41w8mstowAsvzzDbgYkOEVyDdhK7GODBk5e9u3wKMTQNrHKYNMVFG3nbTQOj87RtyZZo9PEHUg9Bc24IWGml0yWtl1P1P9Hm4SrhxVRkkEkbfm5b1IP42FVLtb20pkxMLEXMKxH6HzzfIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585731; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jnSLmeLJV6kE0iVS5+3SJmFGhHsRiD3c0F7TGZf1V5w=; b=BagKM3/a9Afs1z1uDrqEg+97N/DH9YK9yMPKTCrEhNSSxZidi4Y3POK7EXpT8/l1VwiwV1PjkZwEhi2R1wcENof2vDNQirnoOCG/qoPfpzQzVPg1McuISLau/q9uwwKbunJEfhXQZm4tDCFw5vK3qKAYi9DcaHFtzkygeJFmWa8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585731250357.5204379439525; Thu, 4 Jun 2026 08:08:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328016.1592683 (Exim 4.92) (envelope-from ) id 1wV9gA-0004ub-DE; Thu, 04 Jun 2026 15:08:18 +0000 Received: by outflank-mailman (output) from mailman id 1328016.1592683; Thu, 04 Jun 2026 15:08:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gA-0004u3-7s; Thu, 04 Jun 2026 15:08:18 +0000 Received: by outflank-mailman (input) for mailman id 1328016; Thu, 04 Jun 2026 15:02:00 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9a4-00042c-BJ for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:00 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9a3-001rSt-OC for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:01:59 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a219360-2eae-0a2a0a5409dd-0a2a4507c166-22 for ; Thu, 04 Jun 2026 17:01:59 +0200 Received: from [209.85.215.175] (helo=mail-pg1-f175.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a219365-229c-0a2a45070019-d155d7afc424-3 for ; Thu, 04 Jun 2026 17:01:59 +0200 Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-c85ba774551so327339a12.0 for ; Thu, 04 Jun 2026 08:01:58 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:5e::]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c85df0bdbe4sm5661594a12.32.2026.06.04.08.01.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:01:56 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585317; x=1781190117; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jnSLmeLJV6kE0iVS5+3SJmFGhHsRiD3c0F7TGZf1V5w=; b=iJ1YGbqoa8QOMwaWUrkdZORVJR6dj/LiNaQRp8CVVAEzaHuNhmZiPE3z1Mmk0/Hjgi E/p+xnWqmcJ5/o2YExAjA7nMYPPyk7SZGqqPhaLLfyK9ULrwec6b3USG8tewMeuxkVcN 92hXBlUmqDx/lU6LekzhC3Utn+vkn8LTujDJx3j98TD5tJk+ABnhNJcvlfc0Hk6XgSqs Hk9+iuhzlkO2Sutk1FlGdBnPtp7A/89TrzTqasfwF7VqCixbxJkL9AEl0Bci/eg6sFIq C4c/9NcRx6nRDS2C0xK96SnFJ87o0P9Hm40TRmICbJXCxf+7R1m2OOIKATgyIFEvvXa2 f5gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585317; x=1781190117; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jnSLmeLJV6kE0iVS5+3SJmFGhHsRiD3c0F7TGZf1V5w=; b=BJHTgApGjPvDQNPlNWEjXZ5aPrYUIkoFiOSaEkVo3yXtlgTaFbMqQEdGzGC/dGaDFA ZfUsdbO14JA8AsnG+FLjuhXSHCSfN3AXMK6h7A1O7v4y3MzPwKqa/O+wPEJ96GIiPGr/ +YT4v0GwQybvg5v+4wu99B9lZFv1Crx2mSqZ01tAJHdtOq4bZHl324wneNYp/WqGxM6r aNzQ+isFWlWXdsSuINuV4k9LLzHPPvYXhdn6MnuFvKp8fBw1eDTihtLjmsqkIzcb5RuQ E08nkzeXyIROQTIMd1lCz7bryh6hYcH6dHnviSGTJO6Ya9jzrLsHAR5oo5C9xPzXWgV2 DYxQ== X-Forwarded-Encrypted: i=1; AFNElJ+pYb4iQNvEq2MHtsOe7/bcn2orHzEmpMMyTtL8Hltlib8jgpBlgmhfTbR3gmuUdaDkAZKcQV51/hE=@lists.xenproject.org X-Gm-Message-State: AOJu0YyDYvERzjmYJrPDsBtaeSi5MFguahb/p9SVL6Fv3J6MQoJwtOuw izVR52maVsURVC97hF06Z/4QzhZ9nBlhkSAIaFmfPFMbUu49/KF7XC3l X-Gm-Gg: Acq92OGLsChzySuSyABvpeF7cNdZVgQk3o87GxWjQBq95Ofh0KYNXpgsUGkDGL7zEtq wB6olwUlDyVvfV4ZcyJKR/LyZn9yPX9fz0+GHq894RXEyDm5Q4f3yf5KDYGoIl0VHyC1cAJJxLm R0Dc28M8hGmaO+Kolh5Ej6X3YIRfjTwkWNPJi94fGRGtLCsoe3x9EO6nKlzRQ3L92GRu9sMpTJ6 vx7txiFhFVMcV4DDf0PKEBML0cVKK4veqb5Fw6YlFAFiAW6VrSiLHbuJkAVbekKAPU+saBXKnjk YoshaSsPpsmeHZV4eGCBH5OVvilyj0yeIDNuH877pjGaiLvRb3ES+h3o0U0RDWyYgzvpFLbPOrX byPihT6pXtobVh38V3nM3RRzDNSLMU+4KEEqKKGRKgvMEWAyqikihTcRP/Iqz0v4uCpjad1FnuM inRhN+0Khcbaa3GAW1lsQBIy4C56DW3xk4nDRVpPI= X-Received: by 2002:a05:6a21:6083:b0:3a3:a9c4:3d60 with SMTP id adf61e73a8af0-3b4975cdbe8mr9228482637.27.1780585316708; Thu, 04 Jun 2026 08:01:56 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 01/12] PCI: Add helpers to identify SR-IOV PFs/VFs. Date: Thu, 4 Jun 2026 08:01:42 -0700 Message-ID: <20260604150153.3619662-2-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1780585319-0956BC48-CEA36D05/0/0 X-purgate-type: clean X-purgate-size: 1975 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585733221154100 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis Throughout core the pci_dev attribute is_physfn is used to determine whether or not a PF has SR-IOV active. And is_virtfn is used to check if a device is a SR-IOV VF. These attributes should be generalized to represent PFs/VFs for any type of virtualization. So in preparation, wrap the existing usage in helpers and use helpers in subsequent patches to ease the transition. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- include/linux/pci.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index 2c4454583c11..28892243f49f 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -604,6 +604,16 @@ static inline struct pci_dev *pci_physfn(struct pci_de= v *dev) return dev; } =20 +static inline bool pci_is_sriov_physfn(const struct pci_dev *dev) +{ + return dev->is_physfn; +} + +static inline bool pci_is_sriov_virtfn(const struct pci_dev *dev) +{ + return dev->is_virtfn; +} + struct pci_dev *pci_alloc_dev(struct pci_bus *bus); =20 #define to_pci_dev(n) container_of(n, struct pci_dev, dev) @@ -1277,6 +1287,7 @@ void pcibios_setup_bridge(struct pci_bus *bus, unsign= ed long type); void pci_sort_breadthfirst(void); #define dev_is_pci(d) ((d)->bus =3D=3D &pci_bus_type) #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false)) +#define dev_is_sriov_pf(d) ((dev_is_pci(d) ? pci_is_sriov_physfn(to_pci_de= v(d)) : false)) =20 /* Generic PCI functions exported to card drivers */ =20 @@ -2207,6 +2218,7 @@ static inline struct pci_dev *pci_dev_get(struct pci_= dev *dev) { return NULL; } =20 #define dev_is_pci(d) (false) #define dev_is_pf(d) (false) +#define dev_is_sriov_pf(d) (false) static inline bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags) { return false; } static inline int pci_irqd_intx_xlate(struct irq_domain *d, --=20 2.52.0 From nobody Mon Jun 8 08:54:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585718; cv=none; d=zohomail.com; s=zohoarc; b=mbNNUvQvI6mz1IwRMtl3blzkuCvOMwT1LsEAPhZW3Xrt8tvABrxg1rXZuP3rfBXqJnoo6tbAjdcF+4/boYkWkaiXoesCzidzsLO3ej1spamwjLL57Ivq2WFOKTiwHjtHfxMoxRWHTBOeWIYDNZMCOsXoDopYuts909B8A4WWMqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585718; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7P+ek6ocV5HFyMB6++Nc5HRt5X7Za6z5O1aRcqqwv/w=; b=RB0IlVavcUA6+BD+MkQV5BHwBNUn9ADR6sEav8U1fLjt9U3i4IRrRuSfKkVQz58tTJG2B6gNWFfWW1QFrRR1aGUYwU46EfB7mo4l4JF8Bz6WuQOs+uIJn2rf138IG8e0H1i99Xc8wzyEvFTWSqmeW7Of8rISPYaZgRw39Gepe5A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585718213737.7022092064356; Thu, 4 Jun 2026 08:08:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328018.1592688 (Exim 4.92) (envelope-from ) id 1wV9gA-0004zz-MK; Thu, 04 Jun 2026 15:08:18 +0000 Received: by outflank-mailman (output) from mailman id 1328018.1592688; Thu, 04 Jun 2026 15:08:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gA-0004z2-Gi; Thu, 04 Jun 2026 15:08:18 +0000 Received: by outflank-mailman (input) for mailman id 1328018; Thu, 04 Jun 2026 15:02:01 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9a4-000436-S0 for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:00 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9a4-00ALZ2-8f for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:00 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a219365-bab6-0a2a0a5309dd-0a2a4505a566-12 for ; Thu, 04 Jun 2026 17:02:00 +0200 Received: from [209.85.214.180] (helo=mail-pl1-f180.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a219366-aaa8-0a2a45050019-d155d6b4dd9e-3 for ; Thu, 04 Jun 2026 17:01:59 +0200 Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2c0c2d792c8so6017765ad.1 for ; Thu, 04 Jun 2026 08:01:59 -0700 (PDT) Received: from localhost ([2a03:2880:7ff::]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16629d40asm57714915ad.64.2026.06.04.08.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:01:57 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585318; x=1781190118; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7P+ek6ocV5HFyMB6++Nc5HRt5X7Za6z5O1aRcqqwv/w=; b=a/9weNhtqAutJYRA1AzyWuD1LJNdfYLP2LniIkAG8SOCBrEQPsEJ3+6ZF/jam3HN0y +/VYqVrSqPtEKxTm+xT31keqjgS5HpFpBx0H//lzo4yhX6oBmvg/5aKpjidUWNG6Rcs8 F36gTp1YA3arOaCkbo+xpYfRO/5NfAxs++/y/2EYmULPkIyenbXefK0+o6mitjGrYMCA gBivLZcqnI8gIcSpqj/DAwkc6h5+Me+PkwdjpTzlTt5D5aK2Pndrj6oRrY5GYX0OhWR5 TMTg+jPLNtTPaqYGVcFSlA0BLkJk4YkFRF2H7KWTGh/WTJpgQ76T69F+1Qnf7573IQ3O jojw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585318; x=1781190118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7P+ek6ocV5HFyMB6++Nc5HRt5X7Za6z5O1aRcqqwv/w=; b=Swhbq6BHBMtnRS81z1PN7EmYzsu1gx3KrpAVXyZ0Y8D4w9SAKVy6NJcb8Rx4EcxmtJ M1gJhGoVPiEMq+V7nI4fDpXzQgYmVPFbKodEu/wPzT1YM/Jez0wOh3Ox35bqW2jziuT0 9Wf8JVJCfMyRW0KEymRxKdGdZ0OPAhK7RobuWoMvXSVv+IFsUb5ESUopXofeB49gp7IF sd7VkFpcARUc8JoANl/Ah1G7AbxVKTbxhceC02/smGzahKAp27Jo4A5+/IJO3UyYOFvP T6OFUkWDPaLKDRwird9azHHFyDDAOkfTyBPndkJhqGsLv+x1nQFfg99EVB4qJDsaItYq BHBQ== X-Forwarded-Encrypted: i=1; AFNElJ+2CNEwLjsmPgMCFkQ86yBB6jwu3hZPmaN7Ig+dfoM/HGJcaZZDaWsV+ymA/6JxFHzURExliLt+iMU=@lists.xenproject.org X-Gm-Message-State: AOJu0Yxoh1b1WDwYrgBERrfIaGBn4MXMnkUz2QXgF245sUDv+Awrmexv 2DlRNoGue2fnZXmzfCugL0mY/HrsQ84ja2l7+4pceMh2zMYJbprHua+Q X-Gm-Gg: Acq92OHlxzbUjeYSWS5TLrmh2Z3WyL88HFrYyT2jpq3Rs/t6NGInxpK1VtQ6cN+YA4w BBwJw8NM2B1aLFScN98PDafqNMsFYpghuC7/+L+cJl/ENzLfIB+NDuIqhed1qfZJNH0vFyXb5ye yRD32/gmovzYk0n/OPayVoZZgm4U/a9eUnpGxtVXYK5j+vzUwhvOfygoQ/Hx1Hv9npnskgJJAcM XNKetOnXw+vL7i6ljRC5je4UL4mcraof+E7iivgpLX2wFRwPnWzAvoNo5PAWjQg4Cv/hQRvyRso wqubVeU0rWMv5yubqLzV3Ss3hOT/SEiH9RV7oUlYeIzViy/+w0oe46sn6s9Uw2cszCKTZ0yqci/ 2mlT7lexl1lUii2IM0jHaihnZn+j2BBDf/8U24IW8kW7A422zjA5ELpO5pyoiZG8BWSnw X-Received: by 2002:a17:903:948:b0:2bf:305a:310b with SMTP id d9443c01a7336-2c1639edf93mr84099595ad.1.1780585318015; Thu, 04 Jun 2026 08:01:58 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 02/12] PCI: Convert iov.c to pci_is_sriov_* helpers Date: Thu, 4 Jun 2026 08:01:43 -0700 Message-ID: <20260604150153.3619662-3-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1780585320-D937C443-51D6EFCE/0/0 X-purgate-type: clean X-purgate-size: 6430 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585718996154100 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis No functional changes. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- drivers/pci/iov.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 91ac4e37ecb9..5de26057b99a 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -23,7 +23,7 @@ =20 int pci_iov_virtfn_bus(struct pci_dev *dev, int vf_id) { - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return -EINVAL; return dev->bus->number + ((dev->devfn + dev->sriov->offset + dev->sriov->stride * vf_id) >> 8); @@ -31,7 +31,7 @@ int pci_iov_virtfn_bus(struct pci_dev *dev, int vf_id) =20 int pci_iov_virtfn_devfn(struct pci_dev *dev, int vf_id) { - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return -EINVAL; return (dev->devfn + dev->sriov->offset + dev->sriov->stride * vf_id) & 0xff; @@ -42,7 +42,7 @@ int pci_iov_vf_id(struct pci_dev *dev) { struct pci_dev *pf; =20 - if (!dev->is_virtfn) + if (!pci_is_sriov_virtfn(dev)) return -EINVAL; =20 pf =3D pci_physfn(dev); @@ -71,7 +71,7 @@ void *pci_iov_get_pf_drvdata(struct pci_dev *dev, struct = pci_driver *pf_driver) { struct pci_dev *pf_dev; =20 - if (!dev->is_virtfn) + if (!pci_is_sriov_virtfn(dev)) return ERR_PTR(-EINVAL); pf_dev =3D dev->physfn; if (pf_dev->driver !=3D pf_driver) @@ -152,7 +152,7 @@ static void virtfn_remove_bus(struct pci_bus *physbus, = struct pci_bus *virtbus) =20 resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno) { - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return 0; =20 return dev->sriov->barsz[pci_resource_num_to_vf_bar(resno)]; @@ -300,7 +300,7 @@ static umode_t sriov_vf_attrs_are_visible(struct kobjec= t *kobj, struct device *dev =3D kobj_to_dev(kobj); struct pci_dev *pdev =3D to_pci_dev(dev); =20 - if (!pdev->is_virtfn) + if (!pci_is_sriov_virtfn(pdev)) return 0; =20 return a->mode; @@ -604,7 +604,7 @@ static umode_t sriov_pf_attrs_are_visible(struct kobjec= t *kobj, { struct device *dev =3D kobj_to_dev(kobj); =20 - if (!dev_is_pf(dev)) + if (!dev_is_sriov_pf(dev)) return 0; =20 return a->mode; @@ -707,7 +707,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_vir= tfn) if (!pdev) return -ENODEV; =20 - if (!pdev->is_physfn) { + if (!pci_is_sriov_physfn(pdev)) { pci_dev_put(pdev); return -ENOSYS; } @@ -814,7 +814,7 @@ static int sriov_init(struct pci_dev *dev, int pos) =20 ctrl =3D 0; list_for_each_entry(pdev, &dev->bus->devices, bus_list) - if (pdev->is_physfn) + if (pci_is_sriov_physfn(pdev)) goto found; =20 pdev =3D NULL; @@ -1006,7 +1006,7 @@ int pci_iov_init(struct pci_dev *dev) */ void pci_iov_release(struct pci_dev *dev) { - if (dev->is_physfn) + if (pci_is_sriov_physfn(dev)) sriov_release(dev); } =20 @@ -1018,7 +1018,7 @@ void pci_iov_remove(struct pci_dev *dev) { struct pci_sriov *iov =3D dev->sriov; =20 - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return; =20 iov->driver_max_VFs =3D iov->total_VFs; @@ -1035,7 +1035,7 @@ void pci_iov_remove(struct pci_dev *dev) */ void pci_iov_update_resource(struct pci_dev *dev, int resno) { - struct pci_sriov *iov =3D dev->is_physfn ? dev->sriov : NULL; + struct pci_sriov *iov =3D pci_is_sriov_physfn(dev) ? dev->sriov : NULL; struct resource *res =3D pci_resource_n(dev, resno); int vf_bar =3D pci_resource_num_to_vf_bar(resno); struct pci_bus_region region; @@ -1111,7 +1111,7 @@ resource_size_t pci_sriov_resource_alignment(struct p= ci_dev *dev, int resno) */ void pci_restore_iov_state(struct pci_dev *dev) { - if (dev->is_physfn) { + if (pci_is_sriov_physfn(dev)) { sriov_restore_vf_rebar_state(dev); sriov_restore_state(dev); } @@ -1124,7 +1124,7 @@ void pci_restore_iov_state(struct pci_dev *dev) */ void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool auto_probe) { - if (dev->is_physfn) + if (pci_is_sriov_physfn(dev)) dev->sriov->drivers_autoprobe =3D auto_probe; } =20 @@ -1141,7 +1141,7 @@ int pci_iov_bus_range(struct pci_bus *bus) struct pci_dev *dev; =20 list_for_each_entry(dev, &bus->devices, bus_list) { - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) continue; if (dev->sriov->max_VF_buses > max) max =3D dev->sriov->max_VF_buses; @@ -1161,7 +1161,7 @@ int pci_enable_sriov(struct pci_dev *dev, int nr_virt= fn) { might_sleep(); =20 - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return -ENOSYS; =20 return sriov_enable(dev, nr_virtfn); @@ -1176,7 +1176,7 @@ void pci_disable_sriov(struct pci_dev *dev) { might_sleep(); =20 - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return; =20 sriov_disable(dev); @@ -1191,7 +1191,7 @@ EXPORT_SYMBOL_GPL(pci_disable_sriov); */ int pci_num_vf(struct pci_dev *dev) { - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return 0; =20 return dev->sriov->num_VFs; @@ -1212,7 +1212,7 @@ int pci_vfs_assigned(struct pci_dev *dev) unsigned short dev_id; =20 /* only search if we are a PF */ - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return 0; =20 /* @@ -1228,7 +1228,7 @@ int pci_vfs_assigned(struct pci_dev *dev) * It is considered assigned if it is a virtual function with * our dev as the physical function and the assigned bit is set */ - if (vfdev->is_virtfn && (vfdev->physfn =3D=3D dev) && + if (pci_is_sriov_virtfn(vfdev) && (vfdev->physfn =3D=3D dev) && pci_is_dev_assigned(vfdev)) vfs_assigned++; =20 @@ -1254,7 +1254,7 @@ EXPORT_SYMBOL_GPL(pci_vfs_assigned); */ int pci_sriov_set_totalvfs(struct pci_dev *dev, u16 numvfs) { - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return -ENOSYS; =20 if (numvfs > dev->sriov->total_VFs) @@ -1279,7 +1279,7 @@ EXPORT_SYMBOL_GPL(pci_sriov_set_totalvfs); */ int pci_sriov_get_totalvfs(struct pci_dev *dev) { - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return 0; =20 return dev->sriov->driver_max_VFs; @@ -1301,7 +1301,7 @@ int pci_sriov_configure_simple(struct pci_dev *dev, i= nt nr_virtfn) =20 might_sleep(); =20 - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return -ENODEV; =20 if (pci_vfs_assigned(dev)) { --=20 2.52.0 From nobody Mon Jun 8 08:54:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585731; cv=none; d=zohomail.com; s=zohoarc; b=G5UErdux5BsEAllbGqoTOyp0McO1Dl5i1bk4viw+CrbmF2ax/0LUFhXo6Ea5gajvP6NHyGf9ZJUBN3mvlXRwqn32nAmhPYF/foiNQWzK6p1m7ucjKBK/68E6zl1Y7NaycLTHlr7AMsY85K0XLOYns1BNcpumGuQFjLSqQVwNDxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585731; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xxHR67fZ2aTWHsPIWuXVLfBkGwXwQ/JLm/nLvvGQPDw=; b=X2PDHSxch5K+kpzAc68FtYU/PBv2NPJUJ6eveAzVvG9NSC5onY3hfAucpvYUibcFE1aVPaGGeTeqRbx7NhLvw/FulB7KwNZpWAbdJv1YUSVClTfOFek8qVCqq0rMZ91IQzKeW3zawmMPnvUx7GK1L6DPZM1ASKJqEBxYdtJYXw0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585731733870.8308453053452; Thu, 4 Jun 2026 08:08:51 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328021.1592696 (Exim 4.92) (envelope-from ) id 1wV9gB-00055O-3O; Thu, 04 Jun 2026 15:08:19 +0000 Received: by outflank-mailman (output) from mailman id 1328021.1592696; Thu, 04 Jun 2026 15:08:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gA-00053p-Qw; Thu, 04 Jun 2026 15:08:18 +0000 Received: by outflank-mailman (input) for mailman id 1328021; Thu, 04 Jun 2026 15:02:04 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9a8-00044O-DL for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:04 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9a7-001rSt-Nd for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:03 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a219360-2eae-0a2a0a5409dd-0a2a4507c166-44 for ; Thu, 04 Jun 2026 17:02:03 +0200 Received: from [209.85.210.173] (helo=mail-pf1-f173.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a21936a-229c-0a2a45070019-d155d2ada9e9-3 for ; Thu, 04 Jun 2026 17:02:03 +0200 Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-84275887a3fso1160425b3a.1 for ; Thu, 04 Jun 2026 08:02:03 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:8::]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84282882156sm6223764b3a.33.2026.06.04.08.01.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:01:58 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585321; x=1781190121; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xxHR67fZ2aTWHsPIWuXVLfBkGwXwQ/JLm/nLvvGQPDw=; b=rzK/aNZwPdwwPB6KVEaZmrrxFUanV95qRJzDxeHQ1l1Am8D9a7t/weorJE5zTTsaSi 2Bso3wVBcK4ytRWSg1mGd/HzNLdvx3JdV1KtlvG73V7pD6E0kxmvRhhW/ZkqzNJL5NVQ zKpddnfKhfrWoQw4vQ9RcRfFFoQi8tuw9RwBegUclR1AyNqFwjQWIJZXfhIm8idlgZo0 2VVFT2rJ+SKLIHPUIGDtp+wpGOeGKiSXtzsAY8iV3EwXDu5EuD5mHibKR/jyT0DDqW1g 7vr+OMohh+YkwMN6Er6MWkCL8KYDTrpWjcg2y0w/ak015jLbNn4YTgO552xl6c2Ck7/9 CrFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585321; x=1781190121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xxHR67fZ2aTWHsPIWuXVLfBkGwXwQ/JLm/nLvvGQPDw=; b=LBEOaLVTeLZX9y69/QiwiuN6tUsUBvStFeqOHe1cGfCipGcmlJDfVT3846VhNgMy2j LSRrGMAUu61GZFGGQ84v4oai+Q7AYulLm5KIJE01mx5ARxVqmnBoX7Vai7Gb4EkRR5a1 XsHQeQZzwXBbuuBQcFujeYG/ASC3GCwOGlhVhjsahUFHvgEG03cvkWq/cVssa6T3EhMm +PzlUknSm5CDLj8tPHSW7dNzs5vS3ms8Hsuh3D/dfekTq9A9wPANvKdVdpfMmldKE7mx HvCssKy3HQ30ybblLyckBlghR72FUaHLK2u7lwyjbvuA1NwGyBtgfBWrJ1DTVOGgrq5S vJ5Q== X-Forwarded-Encrypted: i=1; AFNElJ+e2wN6OcB8aNQ4lEc1qqLn8a0IH5FmSWtYXvzk7tt0ZitCkb/FMS61j2QZEduvVm/mxwM14YL1mVg=@lists.xenproject.org X-Gm-Message-State: AOJu0YxT68UiI4jxAy6VWw5bkFY/gdF8tHyqWzEV4MdIVBdRIAwqbjwT Y6818jPO6LgbrPKRFIAEhMcfFtNxb86SLtd+PdiJQck+nIusb/6A6Y+R X-Gm-Gg: Acq92OFFDF5pkXrvGsrrWpdy+qeYvqQmwdaxpJwg+ILmWQEwJ+M2CjdxXecEB9N4Rjm 2co6hZ0zLJGUMVORfF+I7jWJbnFbLVXTAqm6VnkFqMrOE42R1JiWDaDKzi1+zwKuBTe2zUe6iOL +Q7cO2RAKpBknkaqJmGux7EG1DCY/AsOq++7t/W4DPw2O7pHV5+iVBp6etuwhk/P9fYjpmKKF/G 2DA02yzYbDzt/JUgZH1XBKJerYHmLAjheO6SKGzHuB0bNDmSMkWLXDGiNjcDK6E5q3XNxklPwEj nSFD9QwF0oBZ+B8ZBbCEfn21oPLZFdH0AxIIA9jzShEptjlbf3k3v5NErH/HwINDIObJMhnWfKD 7CJsP4FhClXAlOlgrAEqImgoFXRqpQJ+0lOEw3ovKXtXRjXfHP0HhfjlpSrBie/tJ9Ik+TXQ/qB c1LPnmT4mFnQL/QEDRJlyvpPpD57LesV3s0w1bfg== X-Received: by 2002:a05:6a00:6c8d:b0:842:47f7:5f1 with SMTP id d2e1a72fcca58-8429b73c68cmr3210028b3a.28.1780585319505; Thu, 04 Jun 2026 08:01:59 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 03/12] PCI: Convert pci.h to pci_is_sriov_* helpers Date: Thu, 4 Jun 2026 08:01:44 -0700 Message-ID: <20260604150153.3619662-4-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1780585323-23979C48-32A9187A/0/0 X-purgate-type: clean X-purgate-size: 740 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585733172154100 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis No functional changes. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- drivers/pci/pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 4a14f88e543a..73b913bcb87a 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -954,7 +954,7 @@ void pci_iov_resource_set_size(struct pci_dev *dev, int= resno, int size); bool pci_iov_is_memory_decoding_enabled(struct pci_dev *dev); static inline u16 pci_iov_vf_rebar_cap(struct pci_dev *dev) { - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return 0; =20 return dev->sriov->vf_rebar_cap; --=20 2.52.0 From nobody Mon Jun 8 08:54:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585721; cv=none; d=zohomail.com; s=zohoarc; b=FcDJQQt45OQqDl3n4bRIn4a9OO8FHiXAb/quoDvHhFtVrE63RVdcLE+bJl8bYGzzhS0JpwBFd7i9ycCbK39oaUTmGTp7s/hi9t/KpVw8P4QOe+N9ghn0neNyS+mbFGPmPf8KNBGnyl3l6UENmiWWJVXNohb3dc+E/khKqxK9/ao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585721; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4avmxi/DteAkFA5/0YsT4Z/7bVnyoihvSIvhh9yQxIo=; b=i+aSmrIJIsIiJE+f2Yv90gd+/8TDdbhGaiPXViodL3peCpgUEvFVLDbs5OdHAe8+XuWliqZlXqhhGUjNxpYnKammLMDaBoXoIP8D8qdOtmi34Mz4BOOW5qmOOIUkUGEozntBHv21EbiHao2QqUWyFeUfB2UkiwutkhYRT6Tdv5o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585721861341.5706998236444; Thu, 4 Jun 2026 08:08:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328024.1592700 (Exim 4.92) (envelope-from ) id 1wV9gB-0005FL-BE; Thu, 04 Jun 2026 15:08:19 +0000 Received: by outflank-mailman (output) from mailman id 1328024.1592700; Thu, 04 Jun 2026 15:08:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gB-0005C8-65; Thu, 04 Jun 2026 15:08:19 +0000 Received: by outflank-mailman (input) for mailman id 1328024; Thu, 04 Jun 2026 15:02:05 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9a9-00044l-Ki for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:05 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9a9-006uM5-17 for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:05 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a219363-e002-0a2a0a5209dd-0a2a4506817e-36 for ; Thu, 04 Jun 2026 17:02:04 +0200 Received: from [209.85.214.172] (helo=mail-pl1-f172.google.com) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a21936b-7371-0a2a45060019-d155d6acf1c7-3 for ; Thu, 04 Jun 2026 17:02:04 +0200 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2bf20f6be6bso6277965ad.3 for ; Thu, 04 Jun 2026 08:02:04 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:55::]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f6e2adsm67111415ad.5.2026.06.04.08.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:02:00 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585323; x=1781190123; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4avmxi/DteAkFA5/0YsT4Z/7bVnyoihvSIvhh9yQxIo=; b=cE6Bedm2o6seYAG5XfrBq3hH2snEQqxY5cfDfRjqIxyrPSLqLgmKjcEUy/x9sLUqAM LsWaXQ6cDb+TF9yyWzNPd/MI9S4seCHOAt+8T4z3g8PWoHTZekfFwGKT3W+wW9pQNbnu 4ByelU2pisFovSvX22e/h1vkQJxE5aGhOCfBsrO+M3g/e7mHUYK0ywKNXBYQpzISZ489 rCfXkSE7030eRHZrTXbvDe0lFrpv1whRtu81ycaO7nDsSWJhyFhW4vsNCW+VOjjnNGB7 AzMCrr7mOXu2oP0xwvNuxPOdjMB614DpRrYBRgxFXsHX0etwy3zo9g7ZBFSB1gCtQDcF C7jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585323; x=1781190123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4avmxi/DteAkFA5/0YsT4Z/7bVnyoihvSIvhh9yQxIo=; b=ZmteGknRbopsMuOFpF3wutaMh45HiZmk6wZqRHY0a34YlUjXELsrhIaaNI6dat1EcP sDiyfGsOeJdGejQQHvxId8hmRaeVPSjg9QtQ63wNP8ml25EsuFzNOKvzZp4MM5GqgGdR Ki0h38ghsjci4h4LJhgLwOcKNT28A0SUZGOi8tm1Ge0eVXPesl8MtP2HvpkEkkBstuEQ QKplUlYd05lkaTAAFS4eHfie8eoQb/LfqLmEvI9zDO+ZoKHR6mTvqMnuwpSg5HbSD7Bl vPPJGezvsRHkSqBuAeR84QD8f+6lmm2p08dVMrdX+FSy4lGh/o0TK2+mgbbm3Hsyy3ut lUWA== X-Forwarded-Encrypted: i=1; AFNElJ++/Km0CEe6+nE0lwqFelz1ouRStaX0kB6Ax1V2sjsL2OS4xkzwVPNar4IXI9xjXJdEj7rO71qtzkY=@lists.xenproject.org X-Gm-Message-State: AOJu0YyC+f/eyqC81qD5eg09dm22Cx4vZG+rEOMBcVlQ1tlvcnRxb5FF TH3kesfOtqNcnoFvAnNLDLnCbA1OVwzpDWm8oNCBOm/XhslJXqSfKU8g X-Gm-Gg: Acq92OGDdrn0h1b1HTknda33Lf3crNvzaEOtTesplfIQzeXIRUGjhfPxO0i9hoWf3QP 3RlrkT7eD1UPLnKU/tvy6fJw4PVK9S/TlynCmGl6VRZq8g00FWqot4VnTsVM7bOGHTWjY36FrtO YZzd+Ku0q4KrP6rXhs6Enzimso9CWDuQ9AXNESJX8YkiidAhS1vAjnqf2JInM5IhfyXf/Fv9Xyn z4wYqIrzDLdoU3IG8VIXteYpGQhRn4OfaCoCPGDenox6g7bOEM1uZ2NfEYzGoJ/D+dxG6C3zL42 d9EgD0qwZxHpnPMJha4yF3B/+mq7zC8dpbBtGmtI3DmRLhWX9wvwOcYMtoej1GHGKqNzwd4h724 i0TxPp+oJ3dth7s7cG+Wz3TrOkULolWHkVr9v6N0Z5cGJaCXZuOkk7W46Z7JqcEKaumtYT3gaUc RAT4x6zC2pkiwRIv0PbSvitN7ZdfOAj8JJElkWEo0= X-Received: by 2002:a17:903:37c4:b0:2b4:59bf:5728 with SMTP id d9443c01a7336-2c1644ca7bfmr89624145ad.25.1780585321320; Thu, 04 Jun 2026 08:02:01 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 04/12] PCI: Convert arch/powerpc to pci_is_sriov_* helpers Date: Thu, 4 Jun 2026 08:01:45 -0700 Message-ID: <20260604150153.3619662-5-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-16d1c6/1780585324-8D584D75-705C585F/0/0 X-purgate-type: clean X-purgate-size: 7215 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585723081154100 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis Convert SR-IOV-specific is_physfn / is_virtfn reads in the PowerPC PCI code to use pci_is_sriov_physfn() / pci_is_sriov_virtfn(). These call sites are all SR-IOV-specific: they guard SR-IOV state dereferences, VF PE management, or sit inside #ifdef CONFIG_PCI_IOV blocks. Converting them keeps SR-IOV semantics intact once is_physfn and is_virtfn widen to cover any virtualization type. Files touched: arch/powerpc/kernel/pci_dn.c arch/powerpc/platforms/powernv/pci-ioda.c arch/powerpc/platforms/powernv/pci-sriov.c arch/powerpc/platforms/pseries/eeh_pseries.c arch/powerpc/platforms/pseries/setup.c No functional changes. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- arch/powerpc/kernel/pci_dn.c | 4 ++-- arch/powerpc/platforms/powernv/pci-ioda.c | 6 +++--- arch/powerpc/platforms/powernv/pci-sriov.c | 10 +++++----- arch/powerpc/platforms/pseries/eeh_pseries.c | 8 ++++---- arch/powerpc/platforms/pseries/setup.c | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c index a7b664befed2..cf44ec368a36 100644 --- a/arch/powerpc/kernel/pci_dn.c +++ b/arch/powerpc/kernel/pci_dn.c @@ -176,7 +176,7 @@ struct pci_dn *add_sriov_vf_pdns(struct pci_dev *pdev) int i; =20 /* Only support IOV for now */ - if (WARN_ON(!pdev->is_physfn)) + if (WARN_ON(!pci_is_sriov_physfn(pdev))) return NULL; =20 /* Check if VFs have been populated */ @@ -221,7 +221,7 @@ void remove_sriov_vf_pdns(struct pci_dev *pdev) int i; =20 /* Only support IOV PF for now */ - if (WARN_ON(!pdev->is_physfn)) + if (WARN_ON(!pci_is_sriov_physfn(pdev))) return; =20 /* Check if VFs have been populated */ diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platf= orms/powernv/pci-ioda.c index 32ecbc46e74b..63eacc8001fe 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -987,7 +987,7 @@ static void pnv_pci_ioda_dma_dev_setup(struct pci_dev *= pdev) pe =3D pnv_pci_bdfn_to_pe(phb, pci_dev_id(pdev)); if (!pe) { /* VF PEs should be pre-configured in pnv_pci_sriov_enable() */ - if (WARN_ON(pdev->is_virtfn)) + if (WARN_ON(pci_is_sriov_virtfn(pdev))) return; =20 pnv_pci_configure_bus(pdev->bus); @@ -2379,7 +2379,7 @@ static void pnv_pci_release_device(struct pci_dev *pd= ev) struct pnv_ioda_pe *pe; =20 /* The VF PE state is torn down when sriov_disable() is called */ - if (pdev->is_virtfn) + if (pci_is_sriov_virtfn(pdev)) return; =20 if (!pdn || pdn->pe_number =3D=3D IODA_INVALID_PE) @@ -2391,7 +2391,7 @@ static void pnv_pci_release_device(struct pci_dev *pd= ev) * the iov state at probe time since we need to fiddle with the IOV * resources. */ - if (pdev->is_physfn) + if (pci_is_sriov_physfn(pdev)) kfree(pdev->dev.archdata.iov_data); #endif =20 diff --git a/arch/powerpc/platforms/powernv/pci-sriov.c b/arch/powerpc/plat= forms/powernv/pci-sriov.c index 7105a573aec4..1113488f4372 100644 --- a/arch/powerpc/platforms/powernv/pci-sriov.c +++ b/arch/powerpc/platforms/powernv/pci-sriov.c @@ -225,7 +225,7 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci= _dev *pdev) =20 void pnv_pci_ioda_fixup_iov(struct pci_dev *pdev) { - if (pdev->is_virtfn) { + if (pci_is_sriov_virtfn(pdev)) { struct pnv_ioda_pe *pe =3D pnv_ioda_get_pe(pdev); =20 /* @@ -235,7 +235,7 @@ void pnv_pci_ioda_fixup_iov(struct pci_dev *pdev) */ pe->pdev =3D pdev; WARN_ON(!(pe->flags & PNV_IODA_PE_VF)); - } else if (pdev->is_physfn) { + } else if (pci_is_sriov_physfn(pdev)) { /* * For PFs adjust their allocated IOV resources to match what * the PHB can support using its M64 BAR table. @@ -479,7 +479,7 @@ static void pnv_ioda_release_vf_PE(struct pci_dev *pdev) =20 phb =3D pci_bus_to_pnvhb(pdev->bus); =20 - if (!pdev->is_physfn) + if (!pci_is_sriov_physfn(pdev)) return; =20 /* FIXME: Use pnv_ioda_release_pe()? */ @@ -508,7 +508,7 @@ static int pnv_pci_vf_resource_shift(struct pci_dev *de= v, int offset) u16 num_vfs; int i; =20 - if (!dev->is_physfn) + if (!pci_is_sriov_physfn(dev)) return -EINVAL; iov =3D pnv_iov_get(dev); =20 @@ -620,7 +620,7 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, = u16 num_vfs) struct pnv_iov_data *iov; struct pci_dn *pdn; =20 - if (!pdev->is_physfn) + if (!pci_is_sriov_physfn(pdev)) return; =20 phb =3D pci_bus_to_pnvhb(pdev->bus); diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/pl= atforms/pseries/eeh_pseries.c index b12ef382fec7..32030ac9be51 100644 --- a/arch/powerpc/platforms/pseries/eeh_pseries.c +++ b/arch/powerpc/platforms/pseries/eeh_pseries.c @@ -54,7 +54,7 @@ static void pseries_pcibios_bus_add_device(struct pci_dev= *pdev) =20 dev_dbg(&pdev->dev, "EEH: Setting up device\n"); #ifdef CONFIG_PCI_IOV - if (pdev->is_virtfn) { + if (pci_is_sriov_virtfn(pdev)) { pdn->device_id =3D pdev->device; pdn->vendor_id =3D pdev->vendor; pdn->class_code =3D pdev->class; @@ -68,7 +68,7 @@ static void pseries_pcibios_bus_add_device(struct pci_dev= *pdev) #endif pseries_eeh_init_edev(pdn); #ifdef CONFIG_PCI_IOV - if (pdev->is_virtfn) { + if (pci_is_sriov_virtfn(pdev)) { /* * FIXME: This really should be handled by choosing the right * parent PE in pseries_eeh_init_edev(). @@ -731,7 +731,7 @@ static int pseries_call_allow_unfreeze(struct eeh_dev *= edev) if (!vf_pe_array) return -ENOMEM; if (pci_num_vf(edev->physfn ? edev->physfn : edev->pdev)) { - if (edev->pdev->is_physfn) { + if (pci_is_sriov_physfn(edev->pdev)) { cur_vfs =3D pci_num_vf(edev->pdev); pdn =3D eeh_dev_to_pdn(edev); parent =3D pdn->parent; @@ -779,7 +779,7 @@ static int pseries_notify_resume(struct eeh_dev *edev) if (rtas_function_token(RTAS_FN_IBM_OPEN_SRIOV_ALLOW_UNFREEZE) =3D=3D RTA= S_UNKNOWN_SERVICE) return -EINVAL; =20 - if (edev->pdev->is_physfn || edev->pdev->is_virtfn) + if (pci_is_sriov_physfn(edev->pdev) || pci_is_sriov_virtfn(edev->pdev)) return pseries_call_allow_unfreeze(edev); =20 return 0; diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platform= s/pseries/setup.c index 50b26ed8432d..8165ae9adbd6 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -778,7 +778,7 @@ static void pseries_pci_fixup_iov_resources(struct pci_= dev *pdev) const int *indexes; struct device_node *dn =3D pci_device_to_OF_node(pdev); =20 - if (!pdev->is_physfn) + if (!pci_is_sriov_physfn(pdev)) return; /*Firmware must support open sriov otherwise don't configure*/ indexes =3D of_get_property(dn, "ibm,open-sriov-vf-bar-info", NULL); @@ -799,7 +799,7 @@ static resource_size_t pseries_pci_iov_resource_alignme= nt(struct pci_dev *pdev, if (!reg) return pci_iov_resource_size(pdev, resno); =20 - if (!pdev->is_physfn) + if (!pci_is_sriov_physfn(pdev)) return 0; return pseries_get_iov_fw_value(pdev, resno - PCI_IOV_RESOURCES, --=20 2.52.0 From nobody Mon Jun 8 08:54:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585735; cv=none; d=zohomail.com; s=zohoarc; b=BK/wfWFcFBlM8GFEd58kqxqUNhAt8FZDfx7Ya5RRHiJlSgpZk2/TRyXciFadtuCpfeL/Gq7VxBg5anrzj6Qog95h6SIK6lrxa2je88a5ZZLqGJWNq44bp8IzasvQ30p7C/N2UrlFtCvxdt7YvV6E0b+DSEGGoReHrStBZJVla7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585735; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NZHMOC3ymQk/hCIs6rXv5bV3psfV3xxIvT+fp4eN0Hg=; b=id8BhOYL+tXXS8qBg8xoUWL/LAtx0DeA5mPpWC1noYPwvkTGo21EPNfZ/NCMa86kz67zM3YtFbC2nRmEBz4Zj06aEcYOC8V2GDqt5EHrtxwBqqQYxsCPl52OvDlU73vI7ErdoEmiArHqnz9s4pBAe2aB2AKVOHRrLvg3O11I8nU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585735592857.7443828084018; Thu, 4 Jun 2026 08:08:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328026.1592708 (Exim 4.92) (envelope-from ) id 1wV9gB-0005Mm-N3; Thu, 04 Jun 2026 15:08:19 +0000 Received: by outflank-mailman (output) from mailman id 1328026.1592708; Thu, 04 Jun 2026 15:08:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gB-0005Jr-Gj; Thu, 04 Jun 2026 15:08:19 +0000 Received: by outflank-mailman (input) for mailman id 1328026; Thu, 04 Jun 2026 15:02:06 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9aA-00046U-Ab for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:06 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9a9-006uM5-Mr for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:05 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a21935e-e002-0a2a0a5209dd-0a2a45039cb0-40 for ; Thu, 04 Jun 2026 17:02:05 +0200 Received: from [209.85.214.179] (helo=mail-pl1-f179.google.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a21936b-672d-0a2a45030019-d155d6b3b402-3 for ; Thu, 04 Jun 2026 17:02:05 +0200 Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2c0c1e0b0faso6076555ad.0 for ; Thu, 04 Jun 2026 08:02:04 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:54::]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c1664ad138sm64224585ad.82.2026.06.04.08.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:02:02 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585323; x=1781190123; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NZHMOC3ymQk/hCIs6rXv5bV3psfV3xxIvT+fp4eN0Hg=; b=nyECiIZ45IWCH0BLwdIqlmN6oi3dOD3IoKtqDWooalKi0uYdUpKNUIkFIzqjDeDt34 Yjpmkys8y5N4NPBTMtFOY+4fdMj4ZDBrKaFlO12MN4dx8UuJFw6SaP982q1FUYvYa0ti GVMpARFGNFe2EaBe5p6vM9/n+sTvXwzc+8xTFvD1QQFGvFnHRxbpD687gcGIWaN1o6RV hmzmgOrk5VyGb4ViRsVBjnDtZ2rME+GcpCIsv4kjvBd6tRw3gxWeI6IZi4tWrfS5R8TQ hsR9O2by9T3MJ12bH5S+5b7VLhpRnGtClaV+0VvvYDhqKDWj8RU+DefmwzuxWLSknCh+ fEYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585323; x=1781190123; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=NZHMOC3ymQk/hCIs6rXv5bV3psfV3xxIvT+fp4eN0Hg=; b=PEn1YlV311Ra47dwOR0byAykv6hIqoRVfL/GYF4lFM3yIxupMB5hNnB3VjB+tBCxde AmFHm+u09DpHcR0H2hyL+R9Afe/dPpysHWeij5iDNC+NpVzgEAGvkPZ7eu2sQPFyPYvF gTOOlu/6RPqbQtf0QwL1QqKCtChgO86LgO/SGkSi98Jy+BumEgO2iYcdNErmgYBQMbba ol8bwqcze/Wku/wCI5LECHqJbjg9xeC/dcf/6v8hG+GxRz/b4Hd3tkf9shyKKCVg93ZS eKV0PheQs7hMNOkUVZL8e7Wjt6sKGPODudUtlWAx+6f/R8FAFuEjKcR/9pAXl0u5SOmi //mQ== X-Forwarded-Encrypted: i=1; AFNElJ/qtcvhO3Iexg1tnlL4tOGmyMHq0P7UTYHGrPegH7lw42oIK8i8LMLlR8vgSKq545k9WVEFOudta6Y=@lists.xenproject.org X-Gm-Message-State: AOJu0YxEY/k3lJMUECZ13d/rDwGZV+O+tDU71uziVbIKla8vznGFBWXd EAtDaWE6gIIVqb/omwPlbt1OgFVXytKsJ1MyA5OhD4aHipjFeWHkESQE X-Gm-Gg: Acq92OELgK1FNuvwOqpwirYZ2B8avQX3hjQFkd5zC+Z+bas4F43lgxxsBpAhl3bcmam jqot6LcOn9JDlheODzJ6wlBJb1Tloq7I15+DCNx6iomZkwXujklzZHDovabo8cpLm9ga1o8gy/d Ki5TAr3MCPp6Jkpv8XuhdBDmpUvRvh4SIMq8zv9TyjXsRfYSgfNVgCZVfFdnK8isccOEsAdITfI YV0DZF1exuMYZ9B12gVACQ6EZesHqJs1WOw0PIpgb8kv0KMvLEkpyK7Wm5/eabB81YnzETAVVHA sc5qcI2Rjczg/ZyGuXgRuVDJfMu193KyrsLKniik4Kbg+X0+UHwHfoUpU2VPrWu4p1HS37RG7CF znHz1hDco56KThS0qEPC0crnUZXk1B4vdeFE3+712ZAtjXkGxlHnrLjfMH0nlrXey6kXzji0O9p erUAqbhiXVBNmRrNFbHiJzvGX76Xi+kVqpke+nMbI= X-Received: by 2002:a17:902:be03:b0:2bf:13b0:f8ed with SMTP id d9443c01a7336-2c163a28b4dmr55201165ad.3.1780585322733; Thu, 04 Jun 2026 08:02:02 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 05/12] PCI: Convert s390/pci/pci.c to pci_is_sriov_* helpers Date: Thu, 4 Jun 2026 08:01:46 -0700 Message-ID: <20260604150153.3619662-6-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-33051d/1780585325-37141938-5AD061F5/0/0 X-purgate-type: clean X-purgate-size: 681 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585736203158500 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis No functional changes. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- arch/s390/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 39bd2adfc240..5e6f600bf60b 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -611,7 +611,7 @@ int pcibios_device_add(struct pci_dev *pdev) =20 /* The pdev has a reference to the zdev via its bus */ zpci_zdev_get(zdev); - if (pdev->is_physfn) + if (pci_is_sriov_physfn(pdev)) pdev->no_vf_scan =3D 1; =20 zpci_map_resources(pdev); --=20 2.52.0 From nobody Mon Jun 8 08:54:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585727; cv=none; d=zohomail.com; s=zohoarc; b=SFuKaeNZoCK/nmcg53vjs9IZCAtZXKMmIGSqQIti0WfV4cieKSvmNXn4LvFXoXJs2F//xpIQeybq7JNEY0LzSEoRLnap7j6sd169VlDBfW/TBXSuz1qHoYNgE8a7zR7aT1vEMHSn3LjO/f+5cdhSKzYaKoARjPFYH5CIwHfjxBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585727; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xaX3iBh5aQ6ieP4wRDACjZGRgQdbq9tB2uoE6aInkl8=; b=HGV5l0LkOkafop1nksqcxew3LhzPd0r5xltkNz1ckp9a/KSqDBLgObqvNMh7gCd4sxThmbay8kxICq473H5/+JFBPXOx+m0PvLQmVlpR0Pp9D+Hgr/kQxhszThBWAcQ6nSHOMPuwjrT5cZ3ya2hXLuErcMfII0SPHONk/bvr4MY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585727083990.3213220208305; Thu, 4 Jun 2026 08:08:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328027.1592717 (Exim 4.92) (envelope-from ) id 1wV9gC-0005XE-6o; Thu, 04 Jun 2026 15:08:20 +0000 Received: by outflank-mailman (output) from mailman id 1328027.1592717; Thu, 04 Jun 2026 15:08:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gB-0005U4-TA; Thu, 04 Jun 2026 15:08:19 +0000 Received: by outflank-mailman (input) for mailman id 1328027; Thu, 04 Jun 2026 15:02:08 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9aB-00046h-T0 for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9aB-00ALcc-9a for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:07 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a219360-bab6-0a2a0a5309dd-0a2a4504ca5a-42 for ; Thu, 04 Jun 2026 17:02:07 +0200 Received: from [209.85.216.54] (helo=mail-pj1-f54.google.com) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a21936d-1dec-0a2a45040019-d155d836c520-3 for ; Thu, 04 Jun 2026 17:02:07 +0200 Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-36ab8816a35so480701a91.1 for ; Thu, 04 Jun 2026 08:02:06 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:41::]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36f6d109dcdsm4398717a91.9.2026.06.04.08.02.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:02:03 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585325; x=1781190125; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xaX3iBh5aQ6ieP4wRDACjZGRgQdbq9tB2uoE6aInkl8=; b=Ifx0RzeWY15z2I60MHVeDWX1r9Erb4zYyBD1EA3U3TzXlRkObNYRfhkA7sIqKFO4CI YObzC0ygy/8KNYyR4ofNwYjCoO6zJebsIMmXQChIyK/DyNuJ47X6VYMxLCOtl4ygVyJy gUBRdTnKH/mu1/+523z/nyRYNyhujAN/0cghjaXMQ6YvgHqh0RaTeVsrVgn+1YhgGQ+9 Pxccshm0Lpog5dqId8Vf90P++p6kBwyedU1pgFrnvXIXfeNZn3FF2PNWin0B83F+ZMlN Bv/go44szf5O/VlEmY9it+WWFLiqpYhchsJ0dn8h0ft00mMnuh4iZidEucB5mK2+cYXr Y5+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585325; x=1781190125; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xaX3iBh5aQ6ieP4wRDACjZGRgQdbq9tB2uoE6aInkl8=; b=OOWTmtc1+vyi2vVRL4SYD5jc+FxKs1S8IUDtM7YGv2iK0hi35SDf/23CvWxOKkoR7i jioeevqyfBeWqh5s+8AR6AbOUBs66x96eueU4nSgSFhPVe+Wv+Y+k12l4mhSJfB+bZXr SHcFumRBs9hDmhW7TFkZYtOrgNsD04plEIa/59szr4e6gfVn5jzhQc+1ZZWLjzT4Jx28 M+vT08Umhenc1EXol0k1IwhvTmHG+laNQp3G9RqZXDXSxyHcy3V+vL0KAkbII4YrQF0h w7bKYe44ymwSp5tKDTZ85nKok7rdPGuGpEqKzLhgZpLzVVBS2frmxEnyyvt/gQH+bxSI wrPQ== X-Forwarded-Encrypted: i=1; AFNElJ9YM2DYyTqIyJJC6FVOIggBmbpHrOWIBpbs+cmwtvjhDIRYGjT7pKKyOh2DqxIZiCkrleI0LHL0aas=@lists.xenproject.org X-Gm-Message-State: AOJu0YyxUAawBvuJ/n5rfNO1l5+7HkVXB679WgUpVTkTOryQaB9SDtSI UHeknSyJhtS0N5jDKgRle3Jc1X8ecoxaSOijOxWuKlvJ4mMfHV5xrvGx X-Gm-Gg: Acq92OEjg8oY09oRUjdHFCyaGYrkO7hVkw/gudfDb8X8sG95F60Ip3mdrrCkTcpVWOH zGmEQQxvT4REVo2iLw2mw3Lf4t0qyADuPP3zEQQDee8ec528Rv8XaaLvNxAKlClk1wwIzfvtetN f7Vaa2AYIqnW1aXsFWeXhOldUMyYb6x3AZg6dqO5m4Fyz7RXBvtNtOmyDwzJX6CIoa2NU+ek5bL TjwbLubjew4ZSGbswSgOlHpigIS10v0aC/pYy3UOIeBqI347Y9d8nOtUgPjqONeGsDqHj8Y618H ST/VX/5PmvLqpv7Jwm3PvcXEuKYG4Rhi7YTYRp2hJ0Yqd0rPblEsufrM2bo3PTAd6Xjf+ZzrpKQ oAdupAxfK5G81DMIy1KsZbHnCwKwMIE548MhmY9GpisJ0F1jKiwuXRh6Zakuq9TXkP7XfjfSaFq z4IwytLrMOyyfLM1KTqp77jcSSxYYidadpmu1FzdI= X-Received: by 2002:a17:90b:3bc4:b0:36a:1ed8:6fe6 with SMTP id 98e67ed59e1d1-36e332f7e45mr8166646a91.24.1780585324132; Thu, 04 Jun 2026 08:02:04 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 06/12] PCI: Convert vfio_pci_core.c to pci_is_sriov_* helpers Date: Thu, 4 Jun 2026 08:01:47 -0700 Message-ID: <20260604150153.3619662-7-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ebf023/1780585327-4197A3FF-2626D5A3/0/0 X-purgate-type: clean X-purgate-size: 2535 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585728140158500 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis No functional changes. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- drivers/vfio/pci/vfio_pci_core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_c= ore.c index 3f8d093aacf8..ad8069612cb2 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -1856,7 +1856,7 @@ int vfio_pci_core_match_token_uuid(struct vfio_device= *core_vdev, * * If the VF token is provided but unused, an error is generated. */ - if (vdev->pdev->is_virtfn) { + if (pci_is_sriov_virtfn(vdev->pdev)) { struct vfio_pci_core_device *pf_vdev =3D vdev->sriov_pf_core_dev; bool match; =20 @@ -1979,13 +1979,13 @@ static int vfio_pci_bus_notifier(struct notifier_bl= ock *nb, struct pci_dev *physfn =3D pci_physfn(pdev); =20 if (action =3D=3D BUS_NOTIFY_ADD_DEVICE && - pdev->is_virtfn && physfn =3D=3D vdev->pdev) { + pci_is_sriov_virtfn(pdev) && physfn =3D=3D vdev->pdev) { pci_info(vdev->pdev, "Captured SR-IOV VF %s driver_override\n", pci_name(pdev)); WARN_ON(device_set_driver_override(&pdev->dev, vdev->vdev.ops->name)); } else if (action =3D=3D BUS_NOTIFY_BOUND_DRIVER && - pdev->is_virtfn && physfn =3D=3D vdev->pdev) { + pci_is_sriov_virtfn(pdev) && physfn =3D=3D vdev->pdev) { struct pci_driver *drv =3D pci_dev_driver(pdev); =20 if (drv && drv !=3D pci_dev_driver(vdev->pdev)) @@ -2005,7 +2005,7 @@ static int vfio_pci_vf_init(struct vfio_pci_core_devi= ce *vdev) struct pci_dev *physfn; int ret; =20 - if (pdev->is_virtfn) { + if (pci_is_sriov_virtfn(pdev)) { /* * If this VF was created by our vfio_pci_core_sriov_configure() * then we can find the PF vfio_pci_core_device now, and due to @@ -2025,7 +2025,7 @@ static int vfio_pci_vf_init(struct vfio_pci_core_devi= ce *vdev) } =20 /* Not a SRIOV PF */ - if (!pdev->is_physfn) + if (!pci_is_sriov_physfn(pdev)) return 0; =20 vdev->vf_token =3D kzalloc_obj(*vdev->vf_token); @@ -2166,7 +2166,7 @@ int vfio_pci_core_register_device(struct vfio_pci_cor= e_device *vdev) return -EBUSY; } =20 - if (pci_is_root_bus(pdev->bus) || pdev->is_virtfn) { + if (pci_is_root_bus(pdev->bus) || pci_is_sriov_virtfn(pdev)) { ret =3D vfio_assign_device_set(&vdev->vdev, vdev); } else if (!pci_probe_reset_slot(pdev->slot)) { ret =3D vfio_assign_device_set(&vdev->vdev, pdev->slot); --=20 2.52.0 From nobody Mon Jun 8 08:54:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585722; cv=none; d=zohomail.com; s=zohoarc; b=k+x2QvGkN6Rhz/epkcCfuksdi72EeKwusf1MHFvs4lBmwvKu6BpQBtIeIbvLbRS8MoxH217va1nxPnVPrC6rc1V/JIeDEMmNK+2UHWlwoRD3uK2NcbX1BEUa9RllOjvjt2iYf3uRBcXu+cDrS/L4vSN5mW88gy60Cdp2VCZJSrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585722; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2hIFtvWihjq2T5uRD8ilA/smzXwEZg9tgf7CPYlO5lE=; b=JMBsVO5ygNPNqLGmuDUA6rh9BhTOPZa2AWJzLsZF23M/CKHSBjKA8i0eCxGrUE1OWKbNnEFGYIWGoQy2vZt+wfoLOeS4NHlleAPBC/YkwrFZlSJSyLqtbgVeyHER0w9IezP6uMsqkNJ3T7Qk7twXIXMFEVH2fc2Q+iHU0i276Fw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585722456280.7812603087798; Thu, 4 Jun 2026 08:08:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328028.1592725 (Exim 4.92) (envelope-from ) id 1wV9gC-0005eL-Kv; Thu, 04 Jun 2026 15:08:20 +0000 Received: by outflank-mailman (output) from mailman id 1328028.1592725; Thu, 04 Jun 2026 15:08:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gC-0005ci-B6; Thu, 04 Jun 2026 15:08:20 +0000 Received: by outflank-mailman (input) for mailman id 1328028; Thu, 04 Jun 2026 15:02:08 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9aC-00046q-Pk for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9aB-00B95r-Vi for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:07 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a219364-2eae-0a2a0a5409dd-0a2a4509e686-34 for ; Thu, 04 Jun 2026 17:02:07 +0200 Received: from [209.85.216.51] (helo=mail-pj1-f51.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a21936e-2497-0a2a45090019-d155d833a85c-3 for ; Thu, 04 Jun 2026 17:02:07 +0200 Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-36baec934b6so1175763a91.0 for ; Thu, 04 Jun 2026 08:02:07 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:55::]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36f711e7b53sm3448820a91.14.2026.06.04.08.02.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:02:05 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585326; x=1781190126; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2hIFtvWihjq2T5uRD8ilA/smzXwEZg9tgf7CPYlO5lE=; b=NSxFMYAXMKWId4jjaXoN4ue9mkvh4bNKpdQopMJ6FFTWSGB5s1T4wjzYIT1cA2mFWZ n21CAw7OwiLvfK4OS0jahvIjLJUpltr6TnYoHuBz7Id41ndYrqIXvSqL2ocsYRgupUFZ tSVNNdQ26uFlDPvdqzdhKI1JsRanAfIVTju0QDpX6Sb8YzFap6f2neFHQ9A0t8uPenoe bfa9DmgKoR9xCmCdIDa6zhgI0gXmGi1pxCQbWBsdcV4xb/cK07ArUP0uGAwP4/9VXAO+ eZ2FBd68T5zduRefSL70pzrhFEuFPq0EioYR+XmP2j44cXBRDuSOEBqi4QEad5AK34+C BWfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585326; x=1781190126; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2hIFtvWihjq2T5uRD8ilA/smzXwEZg9tgf7CPYlO5lE=; b=Y6vjAZJp3CHcaJ2ShmvH6kOHouhOL9YJTrhgb66KXMWj8PrJ7XTtZFM0cv6pVe2JCL 0shI0ekX0Y+j45tNPHcpb5HIzRZ2rPTf9kwRfnk0D7Y0bOeZ4fvoaBgyqAKbmK67uLJ1 oYh8CGoeWu82+ykztu07wHI908VrzXYqh3L5rbnc0kQ7S1ZdOrdvqdRJp5KS6pbLrGbO qrFgCfeZrJ3dP9Rc9DrrxBOK82/x6z++IJ/t1PjHrF/yMjyiDGCi1b/O9jnhAFKFXNGa 8zwc+qpAkuufFIQf8mmge+vl+CwCPNCHGhZwnl3dPaJBa6fn30phk1nVqL8OCX4fDXoH ffFg== X-Forwarded-Encrypted: i=1; AFNElJ8UBUvXgLehRY7Iuylm/HetSPLVGbz3xkqIyApzzALQcDgfWD052F09VJY9/qVNP+n9QfVWgA1CKNs=@lists.xenproject.org X-Gm-Message-State: AOJu0Yxhr70cnO4o0yvWO0A5XBy/FS2Ihs6Uo1UxIoTcHB5HApOdh6Uu VxLTRhNt42LKq/ca3fKDi7dhmVKbpWcBOeLN05zZOuSqxOseP5AI1oc8 X-Gm-Gg: Acq92OHjJtTyK9eBGGjFybpDtoNDmtZZJ9M7j1rtGME4bWAu0hKiCx33w3owZF1TWwt iSwZ2mNfYCq3q1k3e0ZRIer/rkItYCwugKxiV9AqmfLepw39WhwWUs+fAvycI236H8VxqRWsHB2 tk4Zc0fLRUVnWPvxBY4kOUa/pKNpD9Bq/0Pg2zZpTcFTsu/LY9t2W8r0sC/0GEPRsr7bSDemi+Y T91HXC9ZqmgPwYAaDa+bX1f708ismCvWHGAa7cBr92M25zwJ7l5CP5UZAXDdBWLbn53T5aY/X4N RCkxIuXm6chu81JN2liIFhm3KBmj0wf4sFO8STzP9kKRv+mRK7xyLouxYxGUsM3nBjf145OpQ5y Gn+8vOQZWRCr2EQYKjTBxcP1NaxcuIGlGrptJobi29nDhN/AjDsDYpGEsgVibIRAyY/L7p8W2 X-Received: by 2002:a17:90b:2b8c:b0:36a:8519:a4e9 with SMTP id 98e67ed59e1d1-36f7898e08dmr3643368a91.18.1780585325710; Thu, 04 Jun 2026 08:02:05 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 07/12] PCI: Convert xen-pciback and pci-driver to pci_is_sriov_* helpers Date: Thu, 4 Jun 2026 08:01:48 -0700 Message-ID: <20260604150153.3619662-8-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1780585327-89174A53-2C063857/0/0 X-purgate-type: clean X-purgate-size: 1680 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585724387158500 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis No functional changes. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis Reviewed-by: Juergen Gross --- drivers/pci/pci-driver.c | 4 ++-- drivers/xen/xen-pciback/pci_stub.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index d10ece0889f0..926f80bccd70 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -357,7 +357,7 @@ static void local_pci_probe_callback(struct work_struct= *work) static bool pci_physfn_is_probed(struct pci_dev *dev) { #ifdef CONFIG_PCI_IOV - return dev->is_virtfn && dev->physfn->is_probed; + return pci_is_sriov_virtfn(dev) && dev->physfn->is_probed; #else return false; #endif @@ -453,7 +453,7 @@ static int __pci_device_probe(struct pci_driver *drv, s= truct pci_dev *pci_dev) #ifdef CONFIG_PCI_IOV static inline bool pci_device_can_probe(struct pci_dev *pdev) { - return (!pdev->is_virtfn || pdev->physfn->sriov->drivers_autoprobe || + return (!pci_is_sriov_virtfn(pdev) || pdev->physfn->sriov->drivers_autopr= obe || device_has_driver_override(&pdev->dev)); } #else diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/p= ci_stub.c index 79a2b5dfd694..fd5a13f79fcf 100644 --- a/drivers/xen/xen-pciback/pci_stub.c +++ b/drivers/xen/xen-pciback/pci_stub.c @@ -1695,7 +1695,7 @@ static int pci_stub_notifier(struct notifier_block *n= b, if (action !=3D BUS_NOTIFY_UNBIND_DRIVER) return NOTIFY_DONE; =20 - if (!pdev->is_physfn) + if (!pci_is_sriov_physfn(pdev)) return NOTIFY_DONE; =20 for (;;) { --=20 2.52.0 From nobody Mon Jun 8 08:54:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585726; cv=none; d=zohomail.com; s=zohoarc; b=TFD3aYZyV1re5fCVtVMoWwC4KPXh4+r4vNcsrqgKvRTA4AAa43DA6xvM2UiJTMRfLYgt3SMjw23RaGC1i/LNGjZEoPaxmYmviuKeajGrH7azd5arDCmjbT+/A4SMPnjG9krGweO1XlIudPAV/cljGm1cDr/FoT0+EUF5Z0DFjn8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585726; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WoqDAswymnFuDctzAHclbYUv6AH/JbUjYrzVeObwiVA=; b=Z4HddvoQAJG11sgzPOV1AZxph6l0q0nhhHSY1uKlEdAjPvaSz32nJmUI1jB05DvfkCvzN/FVT31X3rfku0x1WuuNWhCm9wLPnF4TnOkK+XGAtHJCc5vd/W+uW4Yjoin1lggZD7od/0a6lLJVaFfYnfCmW7wz9pHsE1YRb0EOZOE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585726058123.47724335303587; Thu, 4 Jun 2026 08:08:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328034.1592733 (Exim 4.92) (envelope-from ) id 1wV9gD-0005qX-8R; Thu, 04 Jun 2026 15:08:21 +0000 Received: by outflank-mailman (output) from mailman id 1328034.1592733; Thu, 04 Jun 2026 15:08:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gC-0005ni-Pw; Thu, 04 Jun 2026 15:08:20 +0000 Received: by outflank-mailman (input) for mailman id 1328034; Thu, 04 Jun 2026 15:02:10 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9aE-00047V-OO for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:10 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9aE-00B95r-4e for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:10 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a219364-2eae-0a2a0a5409dd-0a2a4509e686-44 for ; Thu, 04 Jun 2026 17:02:10 +0200 Received: from [209.85.214.174] (helo=mail-pl1-f174.google.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a219370-2497-0a2a45090019-d155d6aea9d5-3 for ; Thu, 04 Jun 2026 17:02:09 +0200 Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2bf77d4a4e2so11468985ad.1 for ; Thu, 04 Jun 2026 08:02:09 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:4d::]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16629d042sm63879855ad.60.2026.06.04.08.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:02:06 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585328; x=1781190128; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WoqDAswymnFuDctzAHclbYUv6AH/JbUjYrzVeObwiVA=; b=jkGzUa7ya6kz419ZUmzAcQIQT2qYhnJm39MSBBSVdNsrHhfrpm/6gX3HqwQ+oUKgLw NNvjJXjASYCZdR+AHlAyhQhQG8r448Lh/TKF/TFUa8Hg8kH2SjR6WH67iXrb+yHrY1Io leATirggYiDe0BQU05MdXCeIGOxtlVjvR1yaYOkp9MMauAPqxf00PeEpIA7nx2jhPxIR Md88EqqKVKkdzMmosWaJDW44b07gF8UkNaVkbnBmGzqx0g3tGdqoAn+HDsHCwEMIeD8U moRemDlkaeWPGHH/9E4bz0rTickyh7nM/qjoIo0efqn9m84t0T6H/4hh74bixP3GWIvU 9bfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585328; x=1781190128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WoqDAswymnFuDctzAHclbYUv6AH/JbUjYrzVeObwiVA=; b=ZQkiUBZ0/bN1+BXZbDPkURIoyGjrVqinAM6XpBeFywpceqgWSdkUHt2UufT5F6K6rP zdrBsuDZj4/3Dc6y0SDykdYw2zjEjhrRxlbnn1HCdGyFAn+FhYWv+zXp56aRZ2BQYNJq 1+CRSHb5yOZSYcYri0eRFiQj7l5+Q2cAJaZnqHOjFLBwIbIIZZuVoGD/edPyixFS4fnt bahNfuust7Lx5ilfodHwW/6KzLJZdMBTAOwKYICVpU+mjQ0KtUPOQNcqtGZ/M/AIXnPF sW6lOHwNIFHE415TziSHtIHjiM6mNJcXRN4OwfgE4IFhdwTTePD5iSdeYVuX0PHXF9Yt oMJA== X-Forwarded-Encrypted: i=1; AFNElJ9F2TGTk0Ob9G3f9d9AZbPKfA1qA+Q9FZvpcHx+jursVZtyCCj54Ppw+3W9NPOirL96dh6JBaY2/kY=@lists.xenproject.org X-Gm-Message-State: AOJu0YyNe8l4Kzc7drv5/PDgps0Z7dkBtPtJtdCbQuVnuzcT/jVQJei2 pW0ZIatkBuXZQHznoKrWM40uxm0LlPFKFMaWeOxniAQOMLSAaX8kQz6m X-Gm-Gg: Acq92OGjvF4lW960fGlhRq+nLBAp1Nj2J04KcTBl8IT//p2bRiURZJ2ANIPTh7tFi3u ivUuzM1JtNRePcJjUZQI+imSDrrl6QleTAwuz5D1j5Njtn49uaca6NIMaUirCy4G9grZ1K7XARD ddObmNd/LmNBkFk36JDhKSBRzHAg9jlKSnhkFsfL+ZWAwAidJyTMau3MeWjjfIxiHofXRSXCfeX VBKwSTwx+713rFq0SdabhTDFtUfQMkUVKOPPbg5T8A4WjG7CtByAiMrRae+7/adCsGl7LEyZpwJ hhOBTGaH2BjXNZYnStF18qr8+fRjJds1dQrQiiz6SHsQUVbV9CRW5WFhMnjwyl4mkpV/s/EZv3C ST8DeCBUyHAZEeL0LIg/x3mDbFLDM8rs+BZKsXkGjPIUMa3PbUb/OVOQffOcUb3Fu3MLUE5X6ej 2bOk0Ir96TcUO7ytNhMRqVKIlYzk6aIZLlF7AbCJo= X-Received: by 2002:a17:902:820e:b0:2c0:a858:8128 with SMTP id d9443c01a7336-2c197b1805fmr25629535ad.1.1780585327615; Thu, 04 Jun 2026 08:02:07 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 08/12] PCI: Add is_sriov bit to struct pci_dev Date: Thu, 4 Jun 2026 08:01:49 -0700 Message-ID: <20260604150153.3619662-9-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1780585330-40F66A53-11CEE0FF/0/0 X-purgate-type: clean X-purgate-size: 3084 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585727178154100 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis We need a way to disambiguate the virtualization type of a PF/VF. PFs may support multiple types of virtualization, while a VF should only support one. Tighten pci_is_sriov_physfn() / pci_is_sriov_virtfn() to ensure the is_sriov bit is set. This allows the existing is_physfn/is_virtfn bits to be agnostic of virtualization type. No functional changes for SR-IOV. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- arch/s390/pci/pci_iov.c | 1 + drivers/pci/iov.c | 4 ++++ include/linux/pci.h | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/s390/pci/pci_iov.c b/arch/s390/pci/pci_iov.c index 13050ce5c3e9..82e9ef1f132f 100644 --- a/arch/s390/pci/pci_iov.c +++ b/arch/s390/pci/pci_iov.c @@ -53,6 +53,7 @@ static int zpci_iov_link_virtfn(struct pci_dev *pdev, str= uct pci_dev *virtfn, in return rc; =20 virtfn->is_virtfn =3D 1; + virtfn->is_sriov =3D 1; virtfn->multifunction =3D 0; virtfn->physfn =3D pci_dev_get(pdev); =20 diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 5de26057b99a..4aed4f6a42c3 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -326,6 +326,7 @@ static struct pci_dev *pci_iov_scan_device(struct pci_d= ev *dev, int id, virtfn->vendor =3D dev->vendor; virtfn->device =3D iov->vf_device; virtfn->is_virtfn =3D 1; + virtfn->is_sriov =3D 1; virtfn->physfn =3D pci_dev_get(dev); virtfn->no_command_memory =3D 1; =20 @@ -897,6 +898,7 @@ static int sriov_init(struct pci_dev *dev, int pos) iov->dev =3D dev; =20 dev->sriov =3D iov; + dev->is_sriov =3D 1; dev->is_physfn =3D 1; rc =3D compute_max_vf_buses(dev); if (rc) @@ -906,6 +908,7 @@ static int sriov_init(struct pci_dev *dev, int pos) =20 fail_max_buses: dev->sriov =3D NULL; + dev->is_sriov =3D 0; dev->is_physfn =3D 0; failed: for (i =3D 0; i < PCI_SRIOV_NUM_BARS; i++) { @@ -926,6 +929,7 @@ static void sriov_release(struct pci_dev *dev) =20 kfree(dev->sriov); dev->sriov =3D NULL; + dev->is_sriov =3D 0; } =20 static void sriov_restore_vf_rebar_state(struct pci_dev *dev) diff --git a/include/linux/pci.h b/include/linux/pci.h index 28892243f49f..ca84f66425b2 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -479,6 +479,7 @@ struct pci_dev { unsigned int state_saved:1; unsigned int is_physfn:1; unsigned int is_virtfn:1; + unsigned int is_sriov:1; /* SR-IOV is enabled on this device (PF or VF) = */ unsigned int is_hotplug_bridge:1; unsigned int is_pciehp:1; unsigned int shpc_managed:1; /* SHPC owned by shpchp */ @@ -606,12 +607,12 @@ static inline struct pci_dev *pci_physfn(struct pci_d= ev *dev) =20 static inline bool pci_is_sriov_physfn(const struct pci_dev *dev) { - return dev->is_physfn; + return dev->is_physfn && dev->is_sriov; } =20 static inline bool pci_is_sriov_virtfn(const struct pci_dev *dev) { - return dev->is_virtfn; + return dev->is_virtfn && dev->is_sriov; } =20 struct pci_dev *pci_alloc_dev(struct pci_bus *bus); --=20 2.52.0 From nobody Mon Jun 8 08:54:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585728; cv=none; d=zohomail.com; s=zohoarc; b=mbLOrKJTlCCZ3XQM5u4JxrgKfUMH6HXlIDsPaszsk8/DNTF4X7mxT+Kf18myb+7s9QDjbsRAEzdLq0AUN1KdQx/mm27vguQSzOrYKyMXfV6sPSJU6BQS5KinttY7+Wn97YioMwUB8nMDmlRq8z5bJGN+doHN2mPJLTygPIzxivY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585728; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DQ5QlRlqJf2BWfjEpgZtMhqYoBzzggdHeyuHigzWBDQ=; b=AwmI90LKtIBYGt/SVP2NhNjdXV6PIhdjjxmSNjaHdYnBuLskPvpcWncbuw4/n1M+J2CaZIo70YF0Pii6guJW9hfy8b9OE5gwdei80X+Y+CnCTpTfRB0LBgz5SN3iNpU7Lyo5r2j6JOhRJTGiuvyUB5QQftPJroMb7Ua2VHZKdME= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585728174289.18676606621807; Thu, 4 Jun 2026 08:08:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328041.1592742 (Exim 4.92) (envelope-from ) id 1wV9gD-00061X-U3; Thu, 04 Jun 2026 15:08:21 +0000 Received: by outflank-mailman (output) from mailman id 1328041.1592742; Thu, 04 Jun 2026 15:08:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gD-0005zn-7U; Thu, 04 Jun 2026 15:08:21 +0000 Received: by outflank-mailman (input) for mailman id 1328041; Thu, 04 Jun 2026 15:02:13 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9aH-0004B2-32 for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:13 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9aG-00ALgh-Fd for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:12 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a21936d-bab6-0a2a0a5309dd-0a2a45078eda-38 for ; Thu, 04 Jun 2026 17:02:12 +0200 Received: from [209.85.214.172] (helo=mail-pl1-f172.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a219373-229c-0a2a45070019-d155d6acb425-3 for ; Thu, 04 Jun 2026 17:02:12 +0200 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2c0c1e0b0faso6078675ad.0 for ; Thu, 04 Jun 2026 08:02:11 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:1::]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df79sm62219485ad.42.2026.06.04.08.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:02:08 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585330; x=1781190130; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DQ5QlRlqJf2BWfjEpgZtMhqYoBzzggdHeyuHigzWBDQ=; b=IOcZNkdmJQuDr7JHH+JExjDNRdKXBZJ6jbrpGw6VSMmEYZ95rilPkA7twiDZBzhxW+ Xbom02EC93Xf2KvYEGvMUnzHzqKZ/LY43Ea9RhNfVAZAon2U0Iz51kp6Mx4UamRNi94Y 7c37Fdxtwb4bVPo3NrNRiaDfnc062M1DPeOk2V6yInMIEKaSUePGKiNYinFRljjsqrtf xyPurDnKkZX8be1piPqCOFg+TCqc+fiJfuj5gU0RGrnivuX7xgHvJRzL8AzwzVNNliqn 9dXOSBNllP856xNPmc9TNN85E86sLHXmUdti2RUx+DgHEO52PXPqNwwK0VsFR1bzCOgM TnVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585330; x=1781190130; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DQ5QlRlqJf2BWfjEpgZtMhqYoBzzggdHeyuHigzWBDQ=; b=rvWqdHz6AM8hLj+zo/L0mM65sLKbaRX8CiL1pYkyyxBPM1Y679XlfogLDubRQ3Nk56 pwg5nQb/oGUJjo+4zGNzuhJ/vJhTIqdJqZvZx8d3F3qKchdLbJf7YOqoSXwD7l+QzajE XGNgOpfWBBIpKek42HsenG/A2mL16aE9iLTiEHfjJDyJMsCrGqIIXzWzcXZN3bnvdGc1 qIpwka+3PqgJzD0Y2F+CeiFeeHKPp8O8Vl8T3vXu5tt9Inyk/SYTuqc1ew0vdreMSYxX UHKhys5QSGXlbRkk1iQQcOVuZWDnBaGc/0rMwGHvpRb3XomxYx376Jik7LaEhzic96wO l2Qg== X-Forwarded-Encrypted: i=1; AFNElJ+hA32efAg5hUUQrcvCCO3eZwtgh6N+vFmJN3C2tBdN1iB+ak/6e2658Wvr5PmPg2XSehEIBJNUgyo=@lists.xenproject.org X-Gm-Message-State: AOJu0Ywc3HEGkPRKCPZHYxHugyddPnajmE4TnqbSiaNo1CX4xVHgAjNQ 6PtYHzQGvA4iHr2kI2XCrTB72LlfmnhMAZUHRJWg/hZljdcO/J3ZqoQU X-Gm-Gg: Acq92OEbBq5gP+3o7aJwYhYB5AFyBN5NT7ZgAFPTTMOXEKKT5iIMN9DzWuVBFMZze98 RRDw9dmsMSLqol07/sNl08Lq4pJEVvi+g+W4EwZuCVfst5o10ETpNeqJrlITnpf+9zB3/AcDm8g z+BcXY7+6m/atICO4bcvrj6S6ggN86zVpXRcAPAN255AlxtUsMXqDyelgsQhq9aDORwZY09LEpU a9VHD7j9+Uw8YvbexftAthsyY0f1mY9aGezBfb/yzx9bJOokBSHK9BafTXOStnzO5MOJ14IgF7p UfW9WHEt16WJwyxDH1/1eFBnv9PvyXMBnuWQ7krEb/lSTd4xpR1p7yMXn+uC9MF60RCv7R9xf5Z 6n8kH0DJtT/KmPpaao+tV1aQqZ7i9tAzWRCHTWB8AhQNTLIiiR1Ej8f2fjbAo8Eqi9o8wrw1qn2 kgM6lJEuCGSuvudBcHIDAwORhPwGuTuyWudqVtvIpnL/aSKxYQ X-Received: by 2002:a17:903:1b07:b0:2c0:eee2:fc45 with SMTP id d9443c01a7336-2c163a28b9fmr86640905ad.4.1780585329440; Thu, 04 Jun 2026 08:02:09 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 09/12] PCI: Add helper to compute VF Routing ID to pci.h Date: Thu, 4 Jun 2026 08:01:50 -0700 Message-ID: <20260604150153.3619662-10-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1780585332-08F66C48-6AC9C3F4/0/0 X-purgate-type: clean X-purgate-size: 2035 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585730156158500 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis The VF RID computation is identical for SR-IOV and SIOV. Add a common helper so we can share the logic across both. No functional changes. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- drivers/pci/iov.c | 8 ++++---- drivers/pci/pci.h | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 4aed4f6a42c3..5d65413ce98d 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -25,16 +25,16 @@ int pci_iov_virtfn_bus(struct pci_dev *dev, int vf_id) { if (!pci_is_sriov_physfn(dev)) return -EINVAL; - return dev->bus->number + ((dev->devfn + dev->sriov->offset + - dev->sriov->stride * vf_id) >> 8); + return pci_virtfn_routing_id(dev, dev->sriov->offset, + dev->sriov->stride, vf_id) >> 8; } =20 int pci_iov_virtfn_devfn(struct pci_dev *dev, int vf_id) { if (!pci_is_sriov_physfn(dev)) return -EINVAL; - return (dev->devfn + dev->sriov->offset + - dev->sriov->stride * vf_id) & 0xff; + return pci_virtfn_routing_id(dev, dev->sriov->offset, + dev->sriov->stride, vf_id) & 0xff; } EXPORT_SYMBOL_GPL(pci_iov_virtfn_devfn); =20 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 73b913bcb87a..45411960fd2e 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -1017,6 +1017,18 @@ static inline int pci_resource_num_to_vf_bar(int res= no) } #endif /* CONFIG_PCI_IOV */ =20 +#if defined(CONFIG_PCI_IOV) || defined(CONFIG_PCI_SIOV) +/* + * Compute the Routing ID (bus/devfn) for a VF or SDI under @pf, given the + * capability's offset and stride. + */ +static inline u16 pci_virtfn_routing_id(struct pci_dev *pf, u16 offset, + u16 stride, int id) +{ + return (pf->bus->number << 8) + pf->devfn + offset + stride * id; +} +#endif + #ifdef CONFIG_PCIE_TPH void pci_restore_tph_state(struct pci_dev *dev); void pci_save_tph_state(struct pci_dev *dev); --=20 2.52.0 From nobody Mon Jun 8 08:54:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585728; cv=none; d=zohomail.com; s=zohoarc; b=YevDZwwoVe8rDSKXaCmQmtkBOqqDPndfh5zhZw9sI6pOxZNNSl445NG/FvObT0hhPlbTZ/tUsq+en4bsHcq6TMhzLXBhO3Q5xErTJ9qlYXVlTbwnOfAf5AWUdamdXjyvxeZKAkr8Nnr5xP/xHz24NMczR11kkjC2j9wcSLBEgEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585728; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2Bo6bv9IyO26QNTtP+PpQ5foOOUKiHlTonbwk1FrZVg=; b=DTaOPnVJ6L/IsANEdYqS1Cm2Q7CNZykTOOSB+NM62vqQyz9po8HeiGktLvMIPy2HtwpY9AlIl8z+CWDG99dMGWl2t0kGAYZE7W+MXGV4beQwZDHYbTgnLhqXCKv9lCjy7Q49ASBK32ltcMICDIg2KBTYcuS5Ji5jmhuFVJl1gp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585728141913.8388052598646; Thu, 4 Jun 2026 08:08:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328043.1592745 (Exim 4.92) (envelope-from ) id 1wV9gE-0006AP-Cm; Thu, 04 Jun 2026 15:08:22 +0000 Received: by outflank-mailman (output) from mailman id 1328043.1592745; Thu, 04 Jun 2026 15:08:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gD-00065O-Nc; Thu, 04 Jun 2026 15:08:21 +0000 Received: by outflank-mailman (input) for mailman id 1328043; Thu, 04 Jun 2026 15:02:15 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9aJ-0004Cn-4y for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:15 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9aI-00AZZ2-Hf for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:14 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a21936e-e002-0a2a0a5209dd-0a2a4502ae98-10 for ; Thu, 04 Jun 2026 17:02:14 +0200 Received: from [209.85.214.176] (helo=mail-pl1-f176.google.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a219375-af86-0a2a45020019-d155d6b0d44d-3 for ; Thu, 04 Jun 2026 17:02:14 +0200 Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2bf3781ca51so9119965ad.0 for ; Thu, 04 Jun 2026 08:02:13 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:5::]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609df79sm62220215ad.42.2026.06.04.08.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:02:11 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585332; x=1781190132; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2Bo6bv9IyO26QNTtP+PpQ5foOOUKiHlTonbwk1FrZVg=; b=NGs/1A+cs2sIyLFDBz5fnQuvhzOYCo5ovnsB2+GRjMpsCskoXh5zthUxygX84zxquI TKq99qxiX+eOrRSmHLmbOaD2fnufyXXCHkgiy0Vrr8cNU3skBsXhOhozMa7Y9zC/SDwO PWmAMMYnTNAMXFCxJScwmzSOYQrsmlQMltnhsq5HAkKVedFhXeBQXyvaQoyPk/qKrfoN DP1ppDRlARPVFBFerxGqrjNw6X0XGuvefWXtMiVCXY71VXWjHP27YTvAv1DS4MpEoBWH uYIm0JqB7qjDGWw46aQVDMMY4dK+80CSQjTLNt7Lvn/AZ1WTRJD7sZ9sU8nyg7cdHs5f AlAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585332; x=1781190132; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=2Bo6bv9IyO26QNTtP+PpQ5foOOUKiHlTonbwk1FrZVg=; b=Ii6U0L7RYo2Z88crszAgSB3Hj4hXm68KNfJHlo8nTuqkpcn/hTx+0d0hD7VTICF+00 TTzfSxKXDJ1xio4+VsHS3yEjhVO+3dS/lrOqJWQCIJOxsAHmXfYxo6IkjLxOfHa+Vs83 OxOpxEb+ewjFjYjLDkOVORU/HqilUuMRw8gVzdiGgyW40RfWukDUzCcL4DNUW8x77zs/ 97f26WWnaPpJL+phwqFZCIBWuYnTI5jcQk8BmZxLDnsA5vullclpCjAWauf2ZUXeCsv/ wMVlxLKhNNjnWE+qIu5J4jN7v9WOtkA5SK1xeIqaDJCOjJS/52r+4peQtqUad0vvmhEv /p2Q== X-Forwarded-Encrypted: i=1; AFNElJ/IquKsMnZvNLbchlROiQ7uH0D516U8p8sIQ4eSuW96P8vsR4R1m9akMdfiB4TlqSXGPNlaquHDJkc=@lists.xenproject.org X-Gm-Message-State: AOJu0YzjZ7VrLYCTajLs1NJOrsBPaCPmS1DtkuhFjS5cDX2GTzOqfgXj VLMnkTODa/mXCXuccq/QDhDubwvD1/R5mLKO67b7+jGvTtUiTR3r64BI X-Gm-Gg: Acq92OF8E+WthHsVKST1npNG0nfJ2twhQlhLJkYWkMWujn8ZIU7h+sJ7BFKvc8Vox7U iLkEOCdpNE43lPXpHC0kCi4jcMKYsq2wsrCrzi98+8F9UiQPrqBIWTmw/hmXQ9gQF8UmhBMOtuU 8onPxAeBJoQ93C2ICLgOFKRghdC0OYah2oEhOwdABj3Mfvr3teTdejpMDZtHEB+jfa33OuDR4DD 7eXADouGlLtb55nfdfZaHEHl+oLmr01YvVIJSp7Bz50RZ7XXB/vt6xSYnI+hD76a/h/oaSCR3/O MKtfT+EPOUP9/OpwfZ9XfNPXKYvDHRCP64kdWV681M4/RWzKNtnqEiv4DLC/3XvvqN4qlAcO1NQ Ma1F33qwAOIM+pfUZVNBZC84nApVxnt5QKuvYsxv1dLPW2AtjQtH3cG0VYpmZNpgR66W5NBtVqv KQu2d/RRiniKgf6hbr7YDLfcLM3hoD7fMwwkYoQNJyf32JfUlX X-Received: by 2002:a17:902:ced1:b0:2bd:5ab:af95 with SMTP id d9443c01a7336-2c1634f9212mr84880605ad.0.1780585331912; Thu, 04 Jun 2026 08:02:11 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 10/12] PCI: Add Scalable I/O Virtualization data structure definitions Date: Thu, 4 Jun 2026 08:01:51 -0700 Message-ID: <20260604150153.3619662-11-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-720697/1780585334-83563161-2F912A0A/0/0 X-purgate-type: clean X-purgate-size: 5705 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585730269158500 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis Define the PCIe SIOV extended capability registers per the PCIe 7.0 spec, and introduce the kernel-internal data structures needed to track SIOV state on a Physical Function. PCI-SIG members can access the spec here https://members.pcisig.com/wg/PCI-SIG/document/previewpdf/22464. The PCI_SIOV kconfig selects PCI_ATS rather than attempting to decouple the sriov/physfn union within struct pci_dev from CONFIG_PCI_ATS. If desired this can be done in the future, since ATS is optional for SR-IOV and SIOV. Inspired by struct pci_sriov, struct pci_siov records the capability position, total SDI count, routing ID offset/stride, and driver-configurable limits. Add an is_siov bit to struct pci_dev along with helpers to identify SIOV PFs/VFs. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- drivers/pci/Kconfig | 11 +++++++++++ drivers/pci/pci.h | 13 +++++++++++++ include/linux/pci.h | 16 +++++++++++++++- include/uapi/linux/pci_regs.h | 12 +++++++++++- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 33c88432b728..930231835c40 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -164,6 +164,17 @@ config PCI_IOV =20 If unsure, say N. =20 +config PCI_SIOV + bool "PCI Scalable IOV support" + select PCI_ATS + help + Scalable I/O Virtualization is a PCIe feature that allows devices + to expose lightweight Scalable Device Interfaces (SDIs). Unlike + SR-IOV Virtual Functions, SDIs have no config space or BARs and + rely on software to compose the control path. + + If unsure, say N. + config PCI_NPEM bool "Native PCIe Enclosure Management" depends on LEDS_CLASS=3Dy diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 45411960fd2e..fd7c04e26c16 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -683,6 +683,19 @@ struct pci_sriov { bool drivers_autoprobe; /* Auto probing of VFs by driver */ }; =20 +/* Scalable I/O Virtualization */ +struct pci_siov { + struct pci_dev *self; /* This PF */ + u32 cap; /* SIOV Capabilities */ + u16 pos; /* Capability position */ + u16 total_SDIs; /* Total SDIs associated with the PF */ + u16 num_SDIs; /* Number of SDIs currently enabled */ + u16 offset; /* First SDI Routing ID offset */ + u16 stride; /* Following SDI stride */ + u16 driver_max_SDIs;/* Max num SDIs driver supports */ + u8 max_SDI_buses; /* Max buses consumed by SDIs */ +}; + #ifdef CONFIG_PCI_DOE void pci_doe_init(struct pci_dev *pdev); void pci_doe_destroy(struct pci_dev *pdev); diff --git a/include/linux/pci.h b/include/linux/pci.h index ca84f66425b2..eba562474017 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -480,6 +480,7 @@ struct pci_dev { unsigned int is_physfn:1; unsigned int is_virtfn:1; unsigned int is_sriov:1; /* SR-IOV is enabled on this device (PF or VF) = */ + unsigned int is_siov:1; /* SIOV is enabled on this device (PF or VF/SDI)= */ unsigned int is_hotplug_bridge:1; unsigned int is_pciehp:1; unsigned int shpc_managed:1; /* SHPC owned by shpchp */ @@ -549,6 +550,9 @@ struct pci_dev { u16 ats_cap; /* ATS Capability offset */ u8 ats_stu; /* ATS Smallest Translation Unit */ #endif +#ifdef CONFIG_PCI_SIOV + struct pci_siov *siov; /* PF: Scalable IOV info */ +#endif #ifdef CONFIG_PCI_PRI u16 pri_cap; /* PRI Capability offset */ u32 pri_reqs_alloc; /* Number of PRI requests allocated */ @@ -598,7 +602,7 @@ struct pci_dev { =20 static inline struct pci_dev *pci_physfn(struct pci_dev *dev) { -#ifdef CONFIG_PCI_IOV +#if defined(CONFIG_PCI_IOV) || defined(CONFIG_PCI_SIOV) if (dev->is_virtfn) dev =3D dev->physfn; #endif @@ -615,6 +619,16 @@ static inline bool pci_is_sriov_virtfn(const struct pc= i_dev *dev) return dev->is_virtfn && dev->is_sriov; } =20 +static inline bool pci_is_siov_physfn(const struct pci_dev *dev) +{ + return dev->is_physfn && dev->is_siov; +} + +static inline bool pci_is_siov_virtfn(const struct pci_dev *dev) +{ + return dev->is_virtfn && dev->is_siov; +} + struct pci_dev *pci_alloc_dev(struct pci_bus *bus); =20 #define to_pci_dev(n) container_of(n, struct pci_dev, dev) diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 14f634ab9350..0f81c8c72b05 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -763,7 +763,8 @@ #define PCI_EXT_CAP_ID_DEV3 0x2F /* Device 3 Capability/Control/Status */ #define PCI_EXT_CAP_ID_IDE 0x30 /* Integrity and Data Encryption */ #define PCI_EXT_CAP_ID_PL_64GT 0x31 /* Physical Layer 64.0 GT/s */ -#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PL_64GT +#define PCI_EXT_CAP_ID_SIOV 0x38 /* Scalable I/O Virtualization */ +#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_SIOV =20 #define PCI_EXT_CAP_DSN_SIZEOF 12 #define PCI_EXT_CAP_MCAST_ENDPOINT_SIZEOF 40 @@ -1005,6 +1006,15 @@ #define PCI_SRIOV_VFM_AV 0x3 /* Active.Available */ #define PCI_EXT_CAP_SRIOV_SIZEOF 0x40 =20 +/* Scalable I/O Virtualization */ +#define PCI_SIOV_CAP 0x04 /* SIOV Capabilities */ +#define PCI_SIOV_TOTAL_SDI 0x08 /* Total SDIs */ +#define PCI_SIOV_STATUS 0x0B /* SIOV Status */ +#define PCI_SIOV_STATUS_ENABLED 0x01 /* At least one SDI is enabled */ +#define PCI_SIOV_SDI_OFFSET 0x0C /* First SDI Offset */ +#define PCI_SIOV_SDI_STRIDE 0x0E /* SDI Stride */ +#define PCI_EXT_CAP_SIOV_SIZEOF 0x10 + #define PCI_LTR_MAX_SNOOP_LAT 0x4 #define PCI_LTR_MAX_NOSNOOP_LAT 0x6 #define PCI_LTR_VALUE_MASK 0x000003ff --=20 2.52.0 From nobody Mon Jun 8 08:54:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585736; cv=none; d=zohomail.com; s=zohoarc; b=QIpN7kxpCRzHBoBvxxferxS8pK16JmDT3WNLucLu6Ji2XXs/77DPg/WB3JpPkXrtnBczGZoCJxCuXQZ1+7r0mO1WF+auhFxnajXXUYWarVq9BlFp2DFJbHE99wJ0fsQoGSZ+U1G9PYckkQ0JHYLodMgaXACVPuCoYPev4kcqcjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585736; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PAIcBy7MNrXi3sYH0OZZ5XdCzjkRdcl8LnKIR3KqnsI=; b=VaVvvH401c0kJHVkXExzALenzaw2cjAwJMn7rCYSNPvtJu3H8p3QF1QOXUagH2xxDe6xUDCehjBR0Is/Ew30D+VsK0RS3WAfV1FLoE2WKxyKOmH4XAY6nwUR1vZ8YkDbKvCLg3NNp2iiyCsz6z4JuYOcgRy2wwU67hObEaGp1p0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585736365874.421742192382; Thu, 4 Jun 2026 08:08:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328045.1592753 (Exim 4.92) (envelope-from ) id 1wV9gE-0006JG-TQ; Thu, 04 Jun 2026 15:08:22 +0000 Received: by outflank-mailman (output) from mailman id 1328045.1592753; Thu, 04 Jun 2026 15:08:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gE-0006G2-Ak; Thu, 04 Jun 2026 15:08:22 +0000 Received: by outflank-mailman (input) for mailman id 1328045; Thu, 04 Jun 2026 15:02:19 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9aM-0004Dh-VW for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:19 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9aM-007kvE-C1 for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:18 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a219376-5cb7-0a2a0a5109dd-0a2a450bacc4-24 for ; Thu, 04 Jun 2026 17:02:18 +0200 Received: from [209.85.214.182] (helo=mail-pl1-f182.google.com) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a219378-212f-0a2a450b0019-d155d6b6c9cd-3 for ; Thu, 04 Jun 2026 17:02:18 +0200 Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2c0c3546924so5635035ad.3 for ; Thu, 04 Jun 2026 08:02:17 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:4a::]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c16609e05fsm64303575ad.54.2026.06.04.08.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:02:13 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585336; x=1781190136; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PAIcBy7MNrXi3sYH0OZZ5XdCzjkRdcl8LnKIR3KqnsI=; b=cV7sIslnzACQGmr1CjmlTFzTpG8lbNMQxIN+0d/Ue8iX1DEjH9HHUYFpDklRFgCMTA WFsbFqkltvv1FIKdB4Bkh4tmCTcdxGNkp8dWr384dnjJT6C+HtZ1ogXPi8Nu724Y6c7a JHz1wf+t7T1kVj1AMVJmlzNNjCc4T3ZvyCj8fur+W3QjYPDAVynvj6+S8sHNQVcR4lvT RAS49qEe1XVoH4yVKn1PNgM57/5QqrM3mpF208NhrPKmfJG6VnpnFI+BeA2K+cc8himx 0VickAoHJ4IW6SuC94jREbjiAr5i3uVs8RHSLeScEOX2nvGwOtSgdu6S5qKdIvPXI8++ R2QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585336; x=1781190136; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PAIcBy7MNrXi3sYH0OZZ5XdCzjkRdcl8LnKIR3KqnsI=; b=cewqeAWzE51NzXpDAekYXVL72uvaPI/Te4LIgL43SCBvdew4hEwvzRe/7KDnB2XJNN QtGnKwBhBnUDGOLA/IVqBo7zpsSeClli7atFZsXTIjZcS8F3Hd9azDlh/DDBFjfy5Gl2 xn05Af/dRr/FeitsaVuyKzoc4UGdElwcVwCqYWE2MrTxWyvySyScKmKNT85WStsEFD6L zorRh1s97/V/i4VK5B4KJYlsTZV+Nwbr8HDKCbjoBID8TIocwaFQyejL0ljvqWLLW+af wIZb0o+X1azklGDrY852OlIvsrCokhRGiovylllBozkvYgGLmBrcWn3uY2ds+oXwO8Fs C6PA== X-Forwarded-Encrypted: i=1; AFNElJ8jQqEhO2K6SkP3yfk/aJv8c//0cDhLw8sO/18BPt7rXA9ju3GEqzpqkZvChJqlbbl/+pAK4cYN2Ak=@lists.xenproject.org X-Gm-Message-State: AOJu0Yx/V7f5SlaYc5bugdv9MCCvdDnyoh8eYAUi6trWAc9CNlUJBGIk 8byPFMfI5/52Eh9oVWy6V3b7x2GSGYNgBZFHWTDgCyOz9iuAPW2QKLa4 X-Gm-Gg: Acq92OE6ruOTDoCPStM7zhNyaK6OgyMSiCbTBWhH9beCSustoQOxdo41GnXI/ULJllY K7aPWHYlilkRm+Jn9GtC7nloaPyyEYbXQVN8mjkmpcosWby7hRODOcE6HDxo/w+9NV7jCtHmty+ wbQ8O2Wtu9M/6Y9rt1X8aWjVyjSKoij85FlRmzk/0PQc30AFZSMsq8Rm0fPg3bg8cBXsXxxCnUg dagyLzkFGmQfBqiMMRJCQyEktOJW4NnxrHZ1sZH3O/A4n86RBC6horWSJ76wjV5mpN57/q8HtyL 95sbdz4G+kDLuf3WebrAWI9zo1z6HZKLzM1qKFnG/kmRvzrzD8u1YU+da0LDeeY/qqsUV4EjyT6 yjdCQJvhnCXboWVUFhZ21gw8xjvmiFnfOB0UG1jO77n67+smBYYf1+cprkmGrIusZM0cdOZMAbJ uc0HNxNs8VC0sf9Lpzykh7XTslTV6F1AOSnR7i+Sc= X-Received: by 2002:a17:903:3c45:b0:2c0:bb2d:a30b with SMTP id d9443c01a7336-2c1644ae17fmr84740035ad.32.1780585333563; Thu, 04 Jun 2026 08:02:13 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 11/12] PCI: Initialize and release SIOV capability Date: Thu, 4 Jun 2026 08:01:52 -0700 Message-ID: <20260604150153.3619662-12-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-42698a/1780585338-1B374F3B-71B85F5E/0/0 X-purgate-type: clean X-purgate-size: 6040 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585737360154100 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis Modify pci_init_capabilities() to discover the SIOV extended capability (cap ID 0x38). When present, allocate struct pci_siov that records the capability position, total SDI count, routing ID offset and stride, and the maximum bus range the SDIs can span. The init path mirrors sriov_init(): read the capability registers, compute the worst-case bus consumption from total_SDIs, and stash the result in the PF's pci_dev. Release frees the structure on teardown. If is_physfn was already set (by sriov_init), it will not be cleared if siov_init() fails. This prevents clobbering the flag for devices that enable both virtualization types. The SR-IOV code does not unset the is_physfn bit of a pci device when disabled, and the SIOV code follows that pattern. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- drivers/pci/Makefile | 1 + drivers/pci/pci.h | 16 ++++++ drivers/pci/probe.c | 2 + drivers/pci/siov.c | 113 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+) create mode 100644 drivers/pci/siov.c diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 41ebc3b9a518..a584cd1bf08a 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_PCI_QUIRKS) +=3D quirks.o obj-$(CONFIG_HOTPLUG_PCI) +=3D hotplug/ obj-$(CONFIG_PCI_ATS) +=3D ats.o obj-$(CONFIG_PCI_IOV) +=3D iov.o +obj-$(CONFIG_PCI_SIOV) +=3D siov.o obj-$(CONFIG_PCI_BRIDGE_EMUL) +=3D pci-bridge-emul.o obj-$(CONFIG_PCI_LABEL) +=3D pci-label.o obj-$(CONFIG_X86_INTEL_MID) +=3D pci-mid.o diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index fd7c04e26c16..a516db996aab 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -1042,6 +1042,22 @@ static inline u16 pci_virtfn_routing_id(struct pci_d= ev *pf, u16 offset, } #endif =20 +#ifdef CONFIG_PCI_SIOV +int pci_siov_init(struct pci_dev *dev); +void pci_siov_release(struct pci_dev *dev); +int pci_siov_bus_range(struct pci_bus *bus); +#else +static inline int pci_siov_init(struct pci_dev *dev) +{ + return -ENODEV; +} +static inline void pci_siov_release(struct pci_dev *dev) { } +static inline int pci_siov_bus_range(struct pci_bus *bus) +{ + return 0; +} +#endif + #ifdef CONFIG_PCIE_TPH void pci_restore_tph_state(struct pci_dev *dev); void pci_save_tph_state(struct pci_dev *dev); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index b63cd0c310bc..bebc32c8d374 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2473,6 +2473,7 @@ static void pci_release_capabilities(struct pci_dev *= dev) pci_aer_exit(dev); pci_rcec_exit(dev); pci_iov_release(dev); + pci_siov_release(dev); pci_free_cap_save_buffers(dev); } =20 @@ -2666,6 +2667,7 @@ static void pci_init_capabilities(struct pci_dev *dev) pci_vpd_init(dev); /* Vital Product Data */ pci_configure_ari(dev); /* Alternative Routing-ID Forwarding */ pci_iov_init(dev); /* Single Root I/O Virtualization */ + pci_siov_init(dev); /* Scalable I/O Virtualization */ pci_ats_init(dev); /* Address Translation Services */ pci_pri_init(dev); /* Page Request Interface */ pci_pasid_init(dev); /* Process Address Space ID */ diff --git a/drivers/pci/siov.c b/drivers/pci/siov.c new file mode 100644 index 000000000000..7372ce95714b --- /dev/null +++ b/drivers/pci/siov.c @@ -0,0 +1,113 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PCI Express Scalable I/O Virtualization (SIOV) support + */ + +#include +#include +#include +#include "pci.h" + +static int pci_siov_sdi_bus(struct pci_dev *dev, int sdi_id) +{ + if (!dev->siov) + return -EINVAL; + return pci_virtfn_routing_id(dev, dev->siov->offset, + dev->siov->stride, sdi_id) >> 8; +} + +static int compute_max_sdi_buses(struct pci_dev *dev) +{ + struct pci_siov *siov =3D dev->siov; + + if (!siov->offset || (siov->total_SDIs > 1 && !siov->stride)) + return -EIO; + + siov->max_SDI_buses =3D pci_siov_sdi_bus(dev, siov->total_SDIs - 1); + return 0; +} + +static int siov_init(struct pci_dev *dev, int pos) +{ + struct pci_siov *siov; + bool was_physfn; + u16 total; + u8 status; + int rc; + + pci_read_config_byte(dev, pos + PCI_SIOV_STATUS, &status); + if (status & PCI_SIOV_STATUS_ENABLED) + pci_warn(dev, "SIOV: SDIs active at init, FLR may be required\n"); + + pci_read_config_word(dev, pos + PCI_SIOV_TOTAL_SDI, &total); + if (!total) + return 0; + + siov =3D kzalloc_obj(*siov); + if (!siov) + return -ENOMEM; + + siov->pos =3D pos; + siov->total_SDIs =3D total; + siov->driver_max_SDIs =3D total; + siov->self =3D dev; + pci_read_config_dword(dev, pos + PCI_SIOV_CAP, &siov->cap); + pci_read_config_word(dev, pos + PCI_SIOV_SDI_OFFSET, &siov->offset); + pci_read_config_word(dev, pos + PCI_SIOV_SDI_STRIDE, &siov->stride); + + was_physfn =3D dev->is_physfn; + + dev->siov =3D siov; + dev->is_physfn =3D 1; + dev->is_siov =3D 1; + rc =3D compute_max_sdi_buses(dev); + if (rc) { + dev->siov =3D NULL; + dev->is_siov =3D 0; + if (!was_physfn) + dev->is_physfn =3D 0; + kfree(siov); + return rc; + } + + return 0; +} + +static void siov_release(struct pci_dev *dev) +{ + WARN_ON_ONCE(dev->siov->num_SDIs); + + kfree(dev->siov); + dev->siov =3D NULL; + dev->is_siov =3D 0; +} + +/** + * pci_siov_init - initialize the Scalable IOV capability + * @dev: the PCI device + * + * Returns 0 on success, or negative on failure. + */ +int pci_siov_init(struct pci_dev *dev) +{ + int pos; + + if (!pci_is_pcie(dev)) + return -ENODEV; + + pos =3D pci_find_ext_capability(dev, PCI_EXT_CAP_ID_SIOV); + if (pos) + return siov_init(dev, pos); + + return -ENODEV; +} + +/** + * pci_siov_release - release resources used by the SIOV capability + * @dev: the PCI device + */ +void pci_siov_release(struct pci_dev *dev) +{ + if (dev->siov) + siov_release(dev); +} --=20 2.52.0 From nobody Mon Jun 8 08:54:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585736; cv=none; d=zohomail.com; s=zohoarc; b=MLpoWiexoG/Nc4Ge3/zA2fJ9ZfBfEQDcOcd8zVkQ4+2s0FplZXK1WtrZfJIsk2e26DIyqdY26rDFSshsAvRzrYsPRotCP/S6YW5SUo5q0srpYv7oTjehb01vBf5clYKQxi1k4XOmWqSil2LcruXfWMD/Bwrc/r2AwV9oXJtxzwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585736; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xRdDzAJ66h/qKzlMtNZ7QYJac4Hlkm37yqxsR8KWCKU=; b=VQnSB+QSe6oasxV6hIobJd3XeAPexUTNEDkaCoUTUBNfsororATy/W1PyIZWLecVATkzfBKOQ9pYXqJTNRgJVyOnF7f3p71L5OM9dLy7CRGHRguPkl8TWay/2C/jbz3mhRioYoZn+wLa8vOqMyqBY5ci0qh5fzIxzieLFefFetY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585736899134.88275335204446; Thu, 4 Jun 2026 08:08:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328054.1592772 (Exim 4.92) (envelope-from ) id 1wV9gH-0006sG-18; Thu, 04 Jun 2026 15:08:25 +0000 Received: by outflank-mailman (output) from mailman id 1328054.1592772; Thu, 04 Jun 2026 15:08:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gG-0006ou-Bg; Thu, 04 Jun 2026 15:08:24 +0000 Received: by outflank-mailman (input) for mailman id 1328054; Thu, 04 Jun 2026 15:02:58 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9b0-0004G8-Qj for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:58 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9b0-007lC5-7F for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:58 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a21939b-bab6-0a2a0a5309dd-0a2a4505d594-24 for ; Thu, 04 Jun 2026 17:02:58 +0200 Received: from [209.85.221.171] (helo=mail-vk1-f171.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a2193a1-aaa8-0a2a45050019-d155ddabe126-3 for ; Thu, 04 Jun 2026 17:02:58 +0200 Received: by mail-vk1-f171.google.com with SMTP id 71dfb90a1353d-59c9b666822so552106e0c.3 for ; Thu, 04 Jun 2026 08:02:57 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:51::]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8428291a837sm6331464b3a.60.2026.06.04.08.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:02:15 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585377; x=1781190177; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xRdDzAJ66h/qKzlMtNZ7QYJac4Hlkm37yqxsR8KWCKU=; b=oUfZtYvKlpaVeaaEzGPr5Z5k9SglbnrqSdw0ipnhKlBApyFVl2MUGcu2F5K4jSpSug 6PEbkxcbUxOE+6DvX23RKjqh0Hx+pOHgBw9fjMpsqHoUw35Cs4/pr4dY9oQMo3iP3AP8 9X86AH7aJuAvX2q+BqmNN59e8TFAm7xOeagjaeTq/xTJhgrH9giDLpZFx0xH9CszJUni EJVL5U6GWCpRL7gj3aQYKSmoV+cHZ6qsemX+M3S+nBX2NQGkqNeh3e9lZH4KTf/tHxVc AQHiTpdyUUTr3lma23X/pQqzo5bLKCC3PJGMLlxgMSnKmAylGnh8sX+PBOxIBnV0hX9i EtXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585377; x=1781190177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xRdDzAJ66h/qKzlMtNZ7QYJac4Hlkm37yqxsR8KWCKU=; b=UR6FMUYn3QvgLbWfs9cLmIRPM8BihqpFXUJ6k4++iTutVz/25+yhXVvllt7V8bpETR FA8DcN6NNXk41kUwo+jcWaJ6YcfXor9I73xSHjm0OzzDZFJdOhusnRK3T36EONH2v7YE XewBQjLKf3iuYHUTZ8OtySgQj4MJzkNgTiDtvRDs3Fd2xpLZurPMA7veRGHENmTtXzzr MJaN6ehMPjUDfOB+zGmSdHCi+RI4wqnQL+kgf0JgvQuK4O2Hi8p0dOgsHE5LfhfM4MV2 4RHISHsfLk+27Wps66QGqhkMUZvsY/BWLYZ2twMyqNPt/2yXAIbHc6XzKPwP1PBXVjsj pOcA== X-Forwarded-Encrypted: i=1; AFNElJ+Bj0he9nrjQAT1Zrn9DO8liukS2lS1efS4DacKACjT81dZAqqZWqIOk4wifONAJZoLmyr+Bj+xsik=@lists.xenproject.org X-Gm-Message-State: AOJu0Ywxk0VFkllnSbUAEsyc600O/0xfwQNeM2NQXh9RQNfhyAxiaBqq h8TALIthS4tAp9pq9AHiBG+k2+BgOgJJiCOtm1uhTyixDz3014CI9/p90G2zkg== X-Gm-Gg: Acq92OFnAYgCrHmcdAw/51KgRbScroToyS1QlSKIp4+zb/hfByMaB4AvrXtjfvXhOvP UQu1KymD9uHbseKLRj9iV2D/8wH87CNc6yRJpSdjbdxaxz1RNUDoJB/B5+pddOhraWGAnvrzp/1 dRAYS2D/BwlmiaG8i8ML0/hffsV3z5Mqx7bQCKuBETdJ6/wG0oxFyclZTGlNRo1Hj9dGe9yDGFE xFlQM1pMENAH0cZTEZNz+arqbbzrRtDdlgSsA6bMTfHJoAP7xX1jpL7SJBj+d9jB4GVGGqb9UaR eqgbYiSpz4r2WFny0GtkbmAj0vAznWiwQEhxMb7zfu7cTyqfMCj/WrgVAB7OjbIHjg4uyXxsyRO VrGYulVPF/EkgJLtTWnGppuZPjvBguAsNVYWuVrzcJQp58meGEdJ6llP7Yh8FoAPEDXDSJipO7D wfMpBemskkxBGKcD3eNK0xv/lR/2pg8euYNeTxcKY= X-Received: by 2002:a05:6a00:218e:b0:842:5ad6:2d3 with SMTP id d2e1a72fcca58-84284ef2c41mr8159937b3a.38.1780585335784; Thu, 04 Jun 2026 08:02:15 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 12/12] PCI: Reserve bus range for SIOV devices Date: Thu, 4 Jun 2026 08:01:53 -0700 Message-ID: <20260604150153.3619662-13-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1780585378-D8F7E443-070AF77C/0/0 X-purgate-type: clean X-purgate-size: 2550 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585738274158500 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis SDI routing IDs are computed from the PF's devfn plus an offset and stride, exactly like SR-IOV VFs. When the stride pushes routing IDs past the current bus number, additional bus numbers must be reserved during PCI bus scanning to ensure the SDIs can be enumerated. Add pci_siov_bus_range(), which walks all SIOV-capable PFs on a bus and returns the maximum number of additional buses required. This parallels pci_iov_bus_range() for SR-IOV. The bus range is pre-computed during siov_init() by computing the bus number of the last valid SDI. Note: The PCIe 7.0 spec outlines an alternative RID assignment algorithm for SDIs. The spec states a Virtualization Intermediary (likely a hypervisor) after boot can compute the set of RIDs that are valid for SDIs. There is a six step algorithm to compute this RID allowlist. To keep things simple, we are only adding support for strided RID assignments. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- drivers/pci/probe.c | 4 ++-- drivers/pci/siov.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index bebc32c8d374..9ef6827ab345 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3100,8 +3100,8 @@ static unsigned int pci_scan_child_bus_extend(struct = pci_bus *bus, for (devnr =3D 0; devnr < PCI_MAX_NR_DEVS; devnr++) pci_scan_slot(bus, PCI_DEVFN(devnr, 0)); =20 - /* Reserve buses for SR-IOV capability */ - used_buses =3D pci_iov_bus_range(bus); + /* Reserve buses for SR-IOV and SIOV capability */ + used_buses =3D max(pci_iov_bus_range(bus), pci_siov_bus_range(bus)); max +=3D used_buses; =20 /* diff --git a/drivers/pci/siov.c b/drivers/pci/siov.c index 7372ce95714b..6405a8830052 100644 --- a/drivers/pci/siov.c +++ b/drivers/pci/siov.c @@ -111,3 +111,24 @@ void pci_siov_release(struct pci_dev *dev) if (dev->siov) siov_release(dev); } + +/** + * pci_siov_bus_range - find the max bus number consumed by SDIs + * @bus: the PCI bus + * + * Returns max additional buses consumed across all SIOV PFs on this bus. + */ +int pci_siov_bus_range(struct pci_bus *bus) +{ + int max =3D 0; + struct pci_dev *dev; + + list_for_each_entry(dev, &bus->devices, bus_list) { + if (!dev->siov) + continue; + if (dev->siov->max_SDI_buses > max) + max =3D dev->siov->max_SDI_buses; + } + + return max ? max - bus->number : 0; +} --=20 2.52.0