Received: by 10.213.65.68 with SMTP id h4csp139610imn; Fri, 30 Mar 2018 16:24:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx484r6lpPtVk0aDBEYBh9EGIjxnXxYyGxg5wA/ja1cJNztPlrNSErJX2KFqmOBvx8zYSDryO X-Received: by 10.99.96.210 with SMTP id u201mr579032pgb.124.1522452270696; Fri, 30 Mar 2018 16:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522452270; cv=none; d=google.com; s=arc-20160816; b=UQOYXv7tsrXr0zxC2VPzdapmY8RsP61XRzvTXtN6RjruRndNRDDTsHdzRMIiZ5T7kM TdhMokmwmhoMoTdkkuefnGlr7Jc+nJqHSHd9aO4Y0Npa/KRgZNS9gwmFdbvzl2+NqFOj qaLA+z7AWrqT0jPHoOHlGf+9BPKzEFNT5MoXt3H0h2Hv0B8F3wX7IhMJ068pE8JjQETq BNS5VcJKhmg0rpodwvLGK7+MxlKX3s8k8ItgHLfYDcKBVunwH+syeLNhxhTLZOD/AlYv FPMhVQryw48uRyRwBRqKCrDFcnwZtYPu6lg+sLEo0PEQuQ8OlthSAobV5/rjxFIItTg3 17mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=3q0uBVv8Vcb4Fq228A+LJN+rc1kQGim2xhGzesvc8Og=; b=GBMkSypX1G/nvijnFH3m76HvYtFhSXf9/IhUFYgSHKz3Sm1d92NULNSASCOGUJIdFT lLKYgqmpMoE5DMO3KfjasOoCrKJSsQ1+8qvCRTZjBFxDGmNWz3r01F5JwgCWXWVjwlhD KgQK8xc7enyL2qjbKte7NzdUZ6C3R34g1gxKH/IEeg8NtGhB5VVrj42FzzYpO9t5lFY1 ffHn8NmDaChOYP7BB3TCaO9CB3YHAOGePdtm21cttFbtZ6zvjATOhB3CY/LKhPB3S1sI Z1SKk7zJT9R7kKRNk9MmCS6uRKWsXvppnIayfQHIYr7mxM8uh3gm8fzODnsTVY8gpWch Z6rg== 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 p4-v6si10023263plr.424.2018.03.30.16.24.05; Fri, 30 Mar 2018 16:24:30 -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; 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 S1752732AbeC3XWS (ORCPT + 99 others); Fri, 30 Mar 2018 19:22:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:42832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752357AbeC3XWR (ORCPT ); Fri, 30 Mar 2018 19:22:17 -0400 Received: from localhost (unknown [69.71.5.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8957D217D2; Fri, 30 Mar 2018 23:22:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8957D217D2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=helgaas@kernel.org Date: Fri, 30 Mar 2018 18:22:15 -0500 From: Bjorn Helgaas To: KarimAllah Ahmed Cc: linux-kernel@vger.kernel.org, Bjorn Helgaas , linux-pci@vger.kernel.org Subject: Re: [PATCH v4 2/2] PCI/IOV: Use VF0 cached config space size for other VFs Message-ID: <20180330232215.GJ9322@bhelgaas-glaptop.roam.corp.google.com> References: <1521489961-18291-1-git-send-email-karahmed@amazon.de> <1521489961-18291-2-git-send-email-karahmed@amazon.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1521489961-18291-2-git-send-email-karahmed@amazon.de> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 19, 2018 at 09:06:01PM +0100, KarimAllah Ahmed wrote: > 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 I didn't apply this one because: - I don't like the "add two leading underscores to the name" disease. I'd really like pci_cfg_space_size() to be able to figure out whether this is VF0 and do the right thing. But I don't know if we can tell from the pci_dev whether it is VF0. We do know that every VF is a PCIe device; maybe that's useful somehow. - Whatever the name ends up being, it should be declared in drivers/pci/pci.h, not include/linux/pci.h, because it shouldn't be used outside the PCI core. > --- > 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; Oops, where did this come from? It looks like this belongs in a different patch because this patch doesn't do anything else with virtfn->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 >