Received: by 10.223.185.116 with SMTP id b49csp5926171wrg; Wed, 28 Feb 2018 00:45:16 -0800 (PST) X-Google-Smtp-Source: AH8x224J96uiBvrnLa0e7eUo5BxKHPwnTV8shEs/4UB42VMC0E4oPFOWnEHQxzK0g//5c3K/O52o X-Received: by 10.98.219.129 with SMTP id f123mr17152868pfg.195.1519807516116; Wed, 28 Feb 2018 00:45:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519807516; cv=none; d=google.com; s=arc-20160816; b=zT56EKlkEpgGztkKtwoGeGN/fHQWz7kFsThIPsihrZCMLx5fLJH4Yk17rFq4giMg6K mM0ctY9r+5TQU0EG7afwQmjlFdHJTr+pbMSd3EbCZPNRZAiVFqRltikfCuTAUkZ7HdNz y3W4vr0FE79xC3S+OMMUKQjsF1ARXqCbUFZUJeVO0cvol2Jshhx8SUaYU8gtXxqVmhVQ zNjrSs8AHIixV5FQ44YxqEKtcnaTesT25ue88UrAj+2w3X1VpVX1wB/Qi3eEb//X78nM 2qeG83cR/7+MW9nDlgAdnTyPNgJOvMixMQ8Ewji7jM/TSgEoLERGtw9SOSbZ9v802Nzo o8+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=hNwIu5dtUW0gDluFo1xbSgKQHrl4QsYLrZVM4D1Z3kY=; b=hjYdTn2aUcoNoZAfPdwATZeWN8O9kzw9DLhGpt9A3ZbyJDw9Qtv55IYinEahYiXP7m cTqaI6UkfPvepO5wOAERxhApR+uwfI9emz5mP7XIbxb36wKncs6ZEeQP1kXsDedj4JrP /Em3SEmOvmwjCTrCWkLh803aU1oJ8zESu/Ov2EKdQLzbRsKYl5NyR7mGX4TlJYoBNZDB CBmleXlwe0xVqy9aPa9+nVi7J9hvdiCsHpVnaYKz63Mz+ZvdsuFToMnsYvMU/0D/LMJY zMvgZm8HJ5d/1w1U6MnAgwglIzxsiQJ4WP8cvnzXp6Mw2koXW/jsbsC+jLRLb+9uP8Fd ZyMQ== 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 n6-v6si932803pla.619.2018.02.28.00.45.01; Wed, 28 Feb 2018 00:45:16 -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 S1752159AbeB1IoK (ORCPT + 99 others); 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 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1eqxHg-0000dQ-97; Wed, 28 Feb 2018 09:40:20 +0100 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 Precedence: bulk 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