From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752161AbeB1IoK (ORCPT ); Wed, 28 Feb 2018 03:44:10 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:48153 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751646AbeB1IoJ (ORCPT ); Wed, 28 Feb 2018 03:44:09 -0500 Date: Wed, 28 Feb 2018 09:44:12 +0100 (CET) From: Thomas Gleixner To: Jan Kiszka cc: Ingo Molnar , "H . Peter Anvin" , Bjorn Helgaas , x86@kernel.org, Linux Kernel Mailing List , jailhouse-dev@googlegroups.com, linux-pci@vger.kernel.org, virtualization@lists.linux-foundation.org, Benedikt Spranger Subject: Re: [PATCH v2 2/6] PCI: Scan all functions when running over Jailhouse In-Reply-To: <021d3dde4276c9bf4325f7bdc37e3c47069e48fc.1519799691.git.jan.kiszka@siemens.com> Message-ID: References: <021d3dde4276c9bf4325f7bdc37e3c47069e48fc.1519799691.git.jan.kiszka@siemens.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 28 Feb 2018, Jan Kiszka wrote: > From: Jan Kiszka > > Per PCIe r4.0, sec 7.5.1.1.9, multi-function devices are required to > have a function 0. Therefore, Linux scans for devices at function 0 > (devfn 0/8/16/...) and only scans for other functions if function 0 > has its Multi-Function Device bit set or ARI or SR-IOV indicate > there are more functions. > > The Jailhouse hypervisor may pass individual functions of a > multi-function device to a guest without passing function 0, which > means a Linux guest won't find them. > > Change Linux PCI probing so it scans all function numbers when > running as a guest over Jailhouse. > 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); Shouldn't that take the situation into account where the MFD bit is set on a regular devfn, i.e. (devfn % 8) == 0? In that case you'd scan the subfunctions twice. Thanks, tglx