Received: by 10.213.65.68 with SMTP id h4csp39415imn; Mon, 19 Mar 2018 18:50:19 -0700 (PDT) X-Google-Smtp-Source: AG47ELs5TFh0pfZqXkXBbFCw2UnyO9nMEtJi+TLfVUgrMPIxQw9lLyL0T+pHap92DErDlpfC7LEq X-Received: by 10.167.131.86 with SMTP id z22mr12034356pfm.185.1521510619936; Mon, 19 Mar 2018 18:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510619; cv=none; d=google.com; s=arc-20160816; b=qjwWR4aVZEa0ESlTDY0Tkq0qZSgUdFlOoCgXI3cb7Kbh6ABlE2Osvu6SvDJtN6ATYU keBA1jUrBtgugso47tFfr9kPqwllCu46lPDa+e6izScf2qRQc/Zgc28HiFb6n2fVcVhe 20fNc26JtvKGNZZigWPeiAn8s12xNT8rCDo0/QS4arbecCqW/ZwVQx0sarMn3M8gmnda SwJ7Qz/5R8rKMa/jIxCWrd9yVsmVlnqMQIOX9i2uEK5cMy75NXA/XcUn/phkpDOlECzR 2s3GCmaF8pmtr7+zWG4W6Dhn84f7c5fbcaET7a62Z26QJ6wamOrZX1zyPLPjtSVZ+2WY yErA== 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:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=On+xnC6IpuFdjf96sLAELIFOsym+ePDJ6Nq03oSCMEs=; b=NklbIj7pMccySC7h6t105KCKQK0iSedanOudHlGfXvvtchDIWRNhJyZ9J8CKx6r0Ja rCtcAx85DHSt1aGbdIfdHtJO1t1xDFL/5JPi6fRI2sO3bDuitrQF7ydxq0RpcjSbLLUc 9I5JUBzgHOW1Qp9w5CUwt7bBxz4RyrhOwdqIp7NI3thQ7uEwu62VeiIRJDMJZ3R9n8G9 pdNMWw/s85LNbtpfJyhGnxIW4r7WMjnUh6linuv4LScWBFEs9o6p5hhro5bHHXED2d6W iHX64vRYhI1zaE93LR0sRWvr9wGaJInNRQw+rpVE/I568TgEHMIm3nkunO6U9IUY32RP p9yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=RR8pWnOS; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2-v6si552163pli.242.2018.03.19.18.50.04; Mon, 19 Mar 2018 18:50:19 -0700 (PDT) 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; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=RR8pWnOS; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031326AbeCSUG2 (ORCPT + 99 others); Mon, 19 Mar 2018 16:06:28 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.7.4