Received: by 10.223.176.46 with SMTP id f43csp2524587wra; Sun, 21 Jan 2018 22:14:23 -0800 (PST) X-Google-Smtp-Source: AH8x225K6UQCs61Z29sIbzvSVZxo87T7nABWtrng4FYfBYV16g5iKYKuACTg4CobjijJ/EqSoE+h X-Received: by 10.99.182.75 with SMTP id v11mr1839769pgt.158.1516601663282; Sun, 21 Jan 2018 22:14:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516601663; cv=none; d=google.com; s=arc-20160816; b=cVTVuUPMDUnNhBxHVVnC6loknRgN+sPcK6F+Mni1/KhlXgqJ+6VnV04TDyEnKIBci1 gKANrPkmNx5zCVhHxo7T+Zi2RwBhe8oWcOzb5hX22N2Z2oq94XQSU9+f6i0YS3jRM+CW rd0/mfWeg7Ca5j70+/HQxUgO7eohVCwVgi0WwBWKYcU3KmSLtin1jpQA2CqS9VbTtGVN 7DUsZ9TxUAS8nMWGg9Z3fXVOvMc6GHes2AcLZDtIQNAlH43eS9wlbyjFgCbF3OmD3CCg 9KtphOQnf3QGG2VVobGjKsPXCknDKR3jgvnTaNuFHtzAj0yZDgtXOZqYNWYo6jcHfXis 0nTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=2sJL3js+FZVCpl6KdicAdG9Vqdm8mA6lbQarcjibzqU=; b=wUp10aeAYKhaSSbPkbsfG35d/c7lih5Zis/4Trzd5++S5jcXNuuZ98ChTTCLGYU84s 8QvwRyk7OCwAhOFQ0Al12aXDbmUzUVTp9hykgOfBolsgOWc0eAmCnTvd9N5aTr6FqRaU ryHHb2lJwhgk3diMnR4D+uegHfmZkcCdkGUXZiEO/O7XuC4e1SLXRBtLFB1stiXSVQ4w E3CeI0yjR0TM0g37s6lXzxa/LpeyLXPoGmZGZEhcJthHuG3nL0668zHTEPWJ/NRS1E8F lU8vJXN2RUxUh6Uhuc8erILWIPfmjZaio7BZ8hgtc0dPNgW49pNYqm6GBJUMG/J6wcHB xiNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k83si15240427pfa.246.2018.01.21.22.14.09; Sun, 21 Jan 2018 22:14:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751208AbeAVGNe (ORCPT + 99 others); Mon, 22 Jan 2018 01:13:34 -0500 Received: from david.siemens.de ([192.35.17.14]:38102 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124AbeAVGNO (ORCPT ); Mon, 22 Jan 2018 01:13:14 -0500 Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id w0M6CuSS016960 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Jan 2018 07:12:56 +0100 Received: from md1f2u6c.ww002.siemens.net ([167.87.15.170]) by mail1.siemens.de (8.15.2/8.15.2) with ESMTP id w0M6Cq6j008276; Mon, 22 Jan 2018 07:12:55 +0100 From: Jan Kiszka To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Bjorn Helgaas Cc: x86@kernel.org, Linux Kernel Mailing List , jailhouse-dev@googlegroups.com, linux-pci@vger.kernel.org, virtualization@lists.linux-foundation.org, Benedikt Spranger Subject: [PATCH 2/6] pci: Scan all functions when probing while running over Jailhouse Date: Mon, 22 Jan 2018 07:12:46 +0100 Message-Id: <66bfcfc6dc1832baa3fbd8e4879764d36aa9c1e7.1516601570.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kiszka PCI and PCIBIOS probing only scans devices at function number 0/8/16/... Subdevices (e.g. multiqueue) have function numbers which are not a multiple of 8. The simple hypervisor Jailhouse passes subdevices directly w/o providing a virtual PCI topology like KVM. As a consequence a PCI passthrough from Jailhouse to a guest will not be detected by Linux. Based on patch by Benedikt Spranger, adding Jailhouse probing to avoid changing the behavior in the absence of the hypervisor. CC: Benedikt Spranger Signed-off-by: Jan Kiszka --- arch/x86/pci/legacy.c | 4 +++- drivers/pci/probe.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/pci/legacy.c b/arch/x86/pci/legacy.c index 1cb01abcb1be..a7b0476b4f44 100644 --- a/arch/x86/pci/legacy.c +++ b/arch/x86/pci/legacy.c @@ -5,6 +5,7 @@ #include #include #include +#include /* * Discover remaining PCI buses in case there are peer host bridges. @@ -34,13 +35,14 @@ int __init pci_legacy_init(void) void pcibios_scan_specific_bus(int busn) { + int stride = jailhouse_paravirt() ? 1 : 8; int devfn; u32 l; if (pci_find_bus(0, busn)) return; - for (devfn = 0; devfn < 256; devfn += 8) { + for (devfn = 0; devfn < 256; devfn += stride) { if (!raw_pci_read(0, busn, devfn, PCI_VENDOR_ID, 2, &l) && l != 0x0000 && l != 0xffff) { DBG("Found device at %02x:%02x [%04x]\n", busn, devfn, l); diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 14e0ea1ff38b..60ad14c8245f 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "pci.h" #define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */ @@ -2454,6 +2455,7 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, unsigned int available_buses) { unsigned int used_buses, normal_bridges = 0, hotplug_bridges = 0; + unsigned int stride = jailhouse_paravirt() ? 1 : 8; unsigned int start = bus->busn_res.start; unsigned int devfn, cmax, max = start; struct pci_dev *dev; @@ -2461,7 +2463,7 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, dev_dbg(&bus->dev, "scanning bus\n"); /* Go find them, Rover! */ - for (devfn = 0; devfn < 0x100; devfn += 8) + for (devfn = 0; devfn < 0x100; devfn += stride) pci_scan_slot(bus, devfn); /* Reserve buses for SR-IOV capability. */ -- 2.13.6