Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp359583iob; Thu, 28 Apr 2022 04:11:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQtfELZP5r9F11nHoifg4gwmUqt1ZYDEh3YjOZwAYa6yzyLdjqCweFq36czHXtNvSqXSVV X-Received: by 2002:aa7:da4a:0:b0:425:d676:9684 with SMTP id w10-20020aa7da4a000000b00425d6769684mr26503610eds.248.1651144314577; Thu, 28 Apr 2022 04:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651144314; cv=none; d=google.com; s=arc-20160816; b=z+abJC2mLWwmVoq7D7hYLuPNd3RDrfY3wWX8QAPyjtgNQ6tcCLmEuZkq8VFwmY3dBC hb13QC8WUgAXDCtFI0tafXrlKVxMQnU2faqFknUrnEf0VguHEntWtb5OYZMoK0UPwNMp N7HKA3ptWon780o1AZxoFy79b/+2hdVAublV/TOvVS0EvjCiC3sK0JTDDcvfB4ZOOXCg /E8YQx8GTEcN2CIOn+yGPrE+BwcFKBsUIm7E4FC1di8Y1LleirWoWigdkwyuxOYv1Jmf Xlnb8jK0vwznFGg3aftFdWIF1R6V98RBqfeBj/4HjLKX23w4dW77V19n82OUAYPatzvZ 5htw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BUKnHMMtJlhw8wLxcVR6t/uKudxySSsONcFK+URS3a0=; b=FgZwGVZh1NRw/qUfeAChMpLZ7O6G/emat6vNtfGdNU1M5H0yD4fWz1d1ASILY+UPjO /dNWbf+vbDu6ccxyljDWrdXK+Td79zKDS2lGASUnd/cmtzkDnOtsursoB1pT/3VnQfdr xYKliJctNkqAYIrNbKTepl+8BqwA9u1JDPZDadacxGa2BCTgkc/kgYtfHDJzMU9RppuM Q/FMv3eVREVk+NH+Y4SWZqlDs0UuiAuqEVF/zoISqzIdqwj6W1nrVaxuuW8QuB5yQWyZ t9hTVyRXcWSORzINEvFZhgfhxCJsdmkSQzPz3AtQ8Jlak73wTDN3CLeHWD1Tjx+bMZpk G1Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BL1kipiD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji17-20020a170907981100b006dff4dd30f9si4390162ejc.862.2022.04.28.04.11.30; Thu, 28 Apr 2022 04:11:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BL1kipiD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343968AbiD1ILh (ORCPT + 99 others); Thu, 28 Apr 2022 04:11:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343833AbiD1IKs (ORCPT ); Thu, 28 Apr 2022 04:10:48 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA9B9612A7; Thu, 28 Apr 2022 01:07:29 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 23S7fSIA031365; Thu, 28 Apr 2022 08:07:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=BUKnHMMtJlhw8wLxcVR6t/uKudxySSsONcFK+URS3a0=; b=BL1kipiDd8zjOWETYOfIT9JACUTUx5NHGthf3sggXxWjTFcH0di+ExSq/mnpDVE4fLhr xyv/4nACfqGkyo6Hoa/C1rZxsklC4RJiuC+amFg2aP9J3spghlq5kOWFlQvC4sqUulWS TAsKS0x94O5pvPUaAVlH8lRmFxaX5lxXejo2cVU7przUoPQ634GDaEs2pGQFw7QhN1Aq GnmkbVyXM1UkTEmUAyM79Ucd2ZBqXZiAByr+D+3Ku3qYYhx5dh6IwH4U1RXlv/MO4Vn+ znJvykrJ5bdKreNv53AoWhyqLKUkT3RrxClilACAk2VAh0OiptYY7QALjDI077v+TJbM 2w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3fqnfga2s8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Apr 2022 08:07:25 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 23S7hYJ5025154; Thu, 28 Apr 2022 08:07:24 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3fqnfga2rc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Apr 2022 08:07:24 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23S7wldN005960; Thu, 28 Apr 2022 08:07:22 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04ams.nl.ibm.com with ESMTP id 3fm938y3km-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Apr 2022 08:07:22 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23S87Jq647120794 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Apr 2022 08:07:19 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6EB4C4C040; Thu, 28 Apr 2022 08:07:19 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E2054C044; Thu, 28 Apr 2022 08:07:19 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 28 Apr 2022 08:07:19 +0000 (GMT) From: Niklas Schnelle To: Bjorn Helgaas , Jan Kiszka , Matthew Rosato , Pierre Morel Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-s390@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH v5 2/4] PCI: Move jailhouse's isolated function handling to pci_scan_slot() Date: Thu, 28 Apr 2022 10:07:16 +0200 Message-Id: <20220428080718.3094464-3-schnelle@linux.ibm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220428080718.3094464-1-schnelle@linux.ibm.com> References: <20220428080718.3094464-1-schnelle@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: h3vu6NpiKc1Lkc7QlOOnoNIOtdGxAevY X-Proofpoint-ORIG-GUID: NWJDT8M5a_TtT6KVhxO0PWnDXrjZIFJg Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-27_04,2022-04-27_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 mlxscore=0 adultscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204280049 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The special case of the jailhouse hypervisor passing through individual PCI functions handles scanning for PCI functions even if function 0 does not exist. Currently this is done with an extra loop duplicating the one in pci_scan_slot(). By incorporating the check for jailhouse_paravirt() into pci_scan_slot() we can instead do this as part of the normal slot scan. Note that with the assignment of dev->multifunction gated by fn > 0 we set dev->multifunction unconditionally for all functions if function 0 is missing just as in the existing jailhouse loop. The only functional change is that we now call pcie_aspm_init_link_state() for these functions but this already happened if function 0 was passed through and should not be a problem. Cc: Jan Kiszka Link: https://lore.kernel.org/linux-pci/20220408224514.GA353445@bhelgaas/ Suggested-by: Bjorn Helgaas Signed-off-by: Niklas Schnelle --- drivers/pci/probe.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 78aa1bccab2f..3029edc68ff7 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2658,8 +2658,13 @@ int pci_scan_slot(struct pci_bus *bus, int devfn) if (fn > 0) dev->multifunction = 1; } else if (fn == 0) { - /* function 0 is required */ - break; + /* + * function 0 is required unless we are running on + * a hypervisor which passes through individual PCI + * functions. + */ + if (!jailhouse_paravirt()) + break; } fn = next_fn(bus, dev, fn); } while (fn >= 0); @@ -2858,29 +2863,14 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, { unsigned int used_buses, normal_bridges = 0, hotplug_bridges = 0; unsigned int start = bus->busn_res.start; - unsigned int devfn, fn, cmax, max = start; + unsigned int devfn, cmax, max = start; struct pci_dev *dev; - int nr_devs; dev_dbg(&bus->dev, "scanning bus\n"); /* Go find them, Rover! */ - for (devfn = 0; devfn < 256; devfn += 8) { - nr_devs = pci_scan_slot(bus, devfn); - - /* - * The Jailhouse hypervisor may pass individual functions of a - * multi-function device to a guest without passing function 0. - * Look for them as well. - */ - if (jailhouse_paravirt() && nr_devs == 0) { - for (fn = 1; fn < 8; fn++) { - dev = pci_scan_single_device(bus, devfn + fn); - if (dev) - dev->multifunction = 1; - } - } - } + for (devfn = 0; devfn < 256; devfn += 8) + pci_scan_slot(bus, devfn); /* Reserve buses for SR-IOV capability */ used_buses = pci_iov_bus_range(bus); -- 2.32.0