From patchwork Mon Mar 19 20:06:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KarimAllah Ahmed X-Patchwork-Id: 10294725 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3339F60385 for ; Mon, 19 Mar 2018 20:06:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 215632920C for ; Mon, 19 Mar 2018 20:06:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 160D1294A4; Mon, 19 Mar 2018 20:06:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74F982920C for ; Mon, 19 Mar 2018 20:06:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031268AbeCSUGX (ORCPT ); Mon, 19 Mar 2018 16:06:23 -0400 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:15187 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031261AbeCSUGS (ORCPT ); Mon, 19 Mar 2018 16:06:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1521489978; x=1553025978; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=On+xnC6IpuFdjf96sLAELIFOsym+ePDJ6Nq03oSCMEs=; b=RR8pWnOSl2LHlgbFUxGZM9vMXQjL6y5y+gleWNMwDLql4Ipxq362/I7H 5xCQfwxvnm3QfnJ3uRGOq/6sPleTAloCQLsTSkCc1SQfCzmywBTeCSTeP Lu58TH1NuAHxQ1/eowoVmrE88tklRVty+HTw+vUGXhmgA4uc9vtgYZJ6k s=; X-IronPort-AV: E=Sophos;i="5.48,331,1517875200"; d="scan'208";a="600999172" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-2c-5f221cf9.us-west-2.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 19 Mar 2018 20:06:15 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2c-5f221cf9.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w2JK6BCr053831 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 19 Mar 2018 20:06:13 GMT Received: from u54e1ad5160425a4b64ea.ant.amazon.com (localhost [127.0.0.1]) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id w2JK6ANF018448; Mon, 19 Mar 2018 21:06:11 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id w2JK6AvO018447; Mon, 19 Mar 2018 21:06:10 +0100 From: KarimAllah Ahmed To: linux-kernel@vger.kernel.org Cc: KarimAllah Ahmed , Bjorn Helgaas , linux-pci@vger.kernel.org Subject: [PATCH v4 2/2] PCI/IOV: Use VF0 cached config space size for other VFs Date: Mon, 19 Mar 2018 21:06:01 +0100 Message-Id: <1521489961-18291-2-git-send-email-karahmed@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521489961-18291-1-git-send-email-karahmed@amazon.de> References: <1521489961-18291-1-git-send-email-karahmed@amazon.de> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cache the config space size from VF0 and use it for all other VFs instead of reading it from the config space of each VF. We assume that it will be the same across all associated VFs. This is an optimization when enabling SR-IOV on a device with many VFs. Cc: Bjorn Helgaas Cc: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: KarimAllah Ahmed --- drivers/pci/iov.c | 3 +++ drivers/pci/pci.h | 1 + drivers/pci/probe.c | 11 ++++++++++- include/linux/pci.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index 30bf8f7..046e0d3 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -135,6 +135,9 @@ static void pci_read_vf_config_common(struct pci_dev *virtfn) &physfn->sriov->subsystem_vendor); pci_read_config_word(virtfn, PCI_SUBSYSTEM_ID, &physfn->sriov->subsystem_device); + + virtfn->class = physfn->sriov->class; + physfn->sriov->cfg_size = __pci_cfg_space_size(virtfn); } int pci_iov_add_virtfn(struct pci_dev *dev, int id) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index bdb4ba2..69da57b 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -271,6 +271,7 @@ struct pci_sriov { u16 driver_max_VFs; /* Max num VFs driver supports */ struct pci_dev *dev; /* Lowest numbered PF */ struct pci_dev *self; /* This PF */ + u32 cfg_size; /* VF config space size */ u32 class; /* VF device */ u8 hdr_type; /* VF header type */ u16 subsystem_vendor; /* VF subsystem vendor */ diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 21ee1c3..fd21e2b 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1365,7 +1365,7 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev) return PCI_CFG_SPACE_EXP_SIZE; } -int pci_cfg_space_size(struct pci_dev *dev) +int __pci_cfg_space_size(struct pci_dev *dev) { int pos; u32 status; @@ -1389,6 +1389,15 @@ int pci_cfg_space_size(struct pci_dev *dev) return PCI_CFG_SPACE_SIZE; } +int pci_cfg_space_size(struct pci_dev *dev) +{ +#ifdef CONFIG_PCI_ATS + if (dev->is_virtfn) + return dev->physfn->sriov->cfg_size; +#endif + return __pci_cfg_space_size(dev); +} + static int pci_cfg_space_class(struct pci_dev *dev) { int class; diff --git a/include/linux/pci.h b/include/linux/pci.h index 024a1be..fcd5d88 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1290,6 +1290,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *), void *userdata); +int __pci_cfg_space_size(struct pci_dev *dev); int pci_cfg_space_size(struct pci_dev *dev); unsigned char pci_bus_max_busnr(struct pci_bus *bus); void pci_setup_bridge(struct pci_bus *bus);