Received: by 10.223.185.116 with SMTP id b49csp5992820wrg; Wed, 28 Feb 2018 02:02:58 -0800 (PST) X-Google-Smtp-Source: AH8x227Jqfn9dGKv4F1/6cBOmcfwUWFVf7Ss6TKJJmZdDY6zo3BfnZZx511WexkbcpQPx45PVn5x X-Received: by 10.99.150.2 with SMTP id c2mr14072639pge.424.1519812177922; Wed, 28 Feb 2018 02:02:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519812177; cv=none; d=google.com; s=arc-20160816; b=TtIzqwtqkJed5VeXIHD8pvMmW2PBeY/I4hES9JzQbXRBkWYBnwh7e8uZ85JbwPK2Gw t+T2/+MDcUlYkgZncs9v09vbxOT0raAbiBLh9gbv5MkOCjoaooX7u9BkBT+7NBUydVIa xIWdWgrH9GvYiB84FzYAICvjrbtEXA65H1ZotVndxDXCEkc7H7ryI+uozS32TeBf881W 57JQcsGIPGmefOFqFfZ7OHoMF2aKIJ74w/cP+OY5DtZ4kjhBzSNKjdHb4kNBQ4u3iwPT KvGZ4xgx928Ckjn2ojDvYFhgnknJ1JRRp5wCyG0fk+rzm3ooz79K3ZTgkUZYQ5DwE66C bKZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=AQXQSwfa10moszF6XPk8pz6sQNGM2lvQqJlqPkQKSog=; b=Z/9JGRASSrAFhhIb+6PlqF+ihTiiMqQnbWc6jQxSKD07uViyCim0BHa+NQCheddRDh uPeh210vMcQdCX+oWsi+8VQEWHLZKTO7TOPjI1dkKU/KXvNqfEc2WCr8GK3NkmgV4b3L +cJ27QJTEgl3/HZNa2JTdIlW/wcE52l0zCiyaJMvk9E7N+jzPrezs+LJRIlf5+AqzVsr g22gdGSSTZBeMxIfXcMPW9c2GZZl7deX/GL0smqWIz3tZHI5sD6O3XIDUsOpf1XNjO+E /DKzH9cIoNo+mrpyceLHBkxgD4tJebZBlCPIFH7HOH/benMG3UtJWBA/HZjpYvMOo8Z0 DQeA== 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 i22-v6si1052697pll.175.2018.02.28.02.02.40; Wed, 28 Feb 2018 02:02:57 -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 S1752440AbeB1KB2 (ORCPT + 99 others); Wed, 28 Feb 2018 05:01:28 -0500 Received: from goliath.siemens.de ([192.35.17.28]:35429 "EHLO goliath.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752150AbeB1KB1 (ORCPT ); Wed, 28 Feb 2018 05:01:27 -0500 Received: from mail2.siemens.de (mail2.siemens.de [139.25.208.11]) by goliath.siemens.de (8.15.2/8.15.2) with ESMTPS id w1SA16g8008968 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Feb 2018 11:01:06 +0100 Received: from [139.25.68.37] (md1q0hnc.ad001.siemens.net [139.25.68.37] (may be forged)) by mail2.siemens.de (8.15.2/8.15.2) with ESMTP id w1SA15ca015048; Wed, 28 Feb 2018 11:01:05 +0100 Subject: Re: [PATCH v2 2/6] PCI: Scan all functions when running over Jailhouse To: Thomas Gleixner 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 References: <021d3dde4276c9bf4325f7bdc37e3c47069e48fc.1519799691.git.jan.kiszka@siemens.com> From: Jan Kiszka Message-ID: <8adf7f98-3b05-2a76-48ec-111921219920@siemens.com> Date: Wed, 28 Feb 2018 11:01:05 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-02-28 09:44, Thomas Gleixner wrote: > 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. Good point, and it also applies to pci_scan_child_bus_extend. Will add some filters. Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux