Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6004368ybi; Wed, 12 Jun 2019 12:13:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnDSlDTqAZo9sBVyvOHxNyRN0kfCNLk+sXyRItKuVc64FpgWVz7SB1yeTUbxi4gon+H0hR X-Received: by 2002:a62:e315:: with SMTP id g21mr39468099pfh.225.1560366807217; Wed, 12 Jun 2019 12:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560366807; cv=none; d=google.com; s=arc-20160816; b=G4gHBRedcEwTwqmDoR6BygDir8h9Mb8a7ftz5EljOLgsfLiR6qXt3BB8pBaC4LVRu4 APGq/xi8uez9qz3nHdvZkG4XgvFW4PCopX9eMjs7Zv/Bn7ysdhCGeOQTw7pM7MDSFJV8 ZNyuSd5oCwAW3LKvLJXxQJMtHO4T32WiBIRPoM1rYVG45jlVqz4Uck+T0ynVpAsGTwKo Nk/fAh5ZYR0mCCNpcaZ5BAYpk1u4pv7ALCYfQE1luZgifxU2bNxmMkaP88K+KPc2praO 9FKQJLyW8Yk/lWZsUVio3o9akW74Py+5WyBQUK+KcbptKLZUguXpktvCWYn+JRjBye/l ss8A== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=ZfFjA5GSnk780HAW2Q47LTO7rsPdwJNVAi676SXdw5E=; b=EtdTvX1LLb0LUX+5hNJIF2+nH2ZoIThKDi6utWuTNMY1JqDtkIzfcUyJ/HbH32/TUY uUecu1nRTienAhmRPo4gXXfLCAq35C3GSykL94u0FN4Kj1uBJ71g3BPx1ma1wnilE9zG gL39LcO64UL1Jc+obMBc7Pz2YEm1Ul6nUthzAlmmymrC7A8sOWrlLZW4rW4TXTk3pESq gosgoDJoIcKByN0d3AJgiHd0oh6AX6ek5YACEXSxxqcMyo6FhwQQmQJHhm7X3gQaudnP uWqn7UIp2S/0cg+E0negL03Ge63WyXDSQRL82o2MnSkZgRWWUEib+Eauit1oF/KJmjm/ AGxw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i22si563398pju.59.2019.06.12.12.13.12; Wed, 12 Jun 2019 12:13:27 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728271AbfFLTM3 (ORCPT + 99 others); Wed, 12 Jun 2019 15:12:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59198 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728147AbfFLTM2 (ORCPT ); Wed, 12 Jun 2019 15:12:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 323497FDF0; Wed, 12 Jun 2019 19:12:23 +0000 (UTC) Received: from x1.home (ovpn-116-190.phx2.redhat.com [10.3.116.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E8AC1001B13; Wed, 12 Jun 2019 19:12:22 +0000 (UTC) Date: Wed, 12 Jun 2019 13:12:22 -0600 From: Alex Williamson To: "Raj, Ashok" Cc: sathyanarayanan kuppuswamy , bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, keith.busch@intel.com, mike.campin@intel.com, KarimAllah Ahmed Subject: Re: [PATCH v2 1/1] PCI/IOV: Fix incorrect cfg_size for VF > 0 Message-ID: <20190612131222.56f99944@x1.home> In-Reply-To: <20190612190303.GA29348@otc-nc-03> References: <20190612170647.43220-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20190612121910.231368e2@x1.home> <0b21c76e-53f3-c35e-cebf-00719e451b11@linux.intel.com> <20190612125817.42909d83@x1.home> <20190612190303.GA29348@otc-nc-03> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 12 Jun 2019 19:12:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 12 Jun 2019 12:03:03 -0700 "Raj, Ashok" wrote: > On Wed, Jun 12, 2019 at 12:58:17PM -0600, Alex Williamson wrote: > > On Wed, 12 Jun 2019 11:41:36 -0700 > > sathyanarayanan kuppuswamy > > wrote: > > > > > On 6/12/19 11:19 AM, Alex Williamson wrote: > > > > On Wed, 12 Jun 2019 10:06:47 -0700 > > > > sathyanarayanan.kuppuswamy@linux.intel.com wrote: > > > > > > > >> From: Kuppuswamy Sathyanarayanan > > > >> > > > >> Commit 975bb8b4dc93 ("PCI/IOV: Use VF0 cached config space size for > > > >> other VFs") calculates and caches the cfg_size for VF0 device before > > > >> initializing the pcie_cap of the device which results in using incorrect > > > >> cfg_size for all VF devices > 0. So set pcie_cap of the device before > > > >> calculating the cfg_size of VF0 device. > > > >> > > > >> Fixes: 975bb8b4dc93 ("PCI/IOV: Use VF0 cached config space size for > > > >> other VFs") > > > >> Cc: Ashok Raj > > > >> Suggested-by: Mike Campin > > > >> Signed-off-by: Kuppuswamy Sathyanarayanan > > > >> --- > > > >> > > > >> Changes since v1: > > > >> * Fixed a typo in commit message. > > > >> > > > >> drivers/pci/iov.c | 1 + > > > >> 1 file changed, 1 insertion(+) > > > >> > > > >> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c > > > >> index 3aa115ed3a65..2869011c0e35 100644 > > > >> --- a/drivers/pci/iov.c > > > >> +++ b/drivers/pci/iov.c > > > >> @@ -160,6 +160,7 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id) > > > >> virtfn->device = iov->vf_device; > > > >> virtfn->is_virtfn = 1; > > > >> virtfn->physfn = pci_dev_get(dev); > > > >> + virtfn->pcie_cap = pci_find_capability(virtfn, PCI_CAP_ID_EXP); > > > >> > > > >> if (id == 0) > > > >> pci_read_vf_config_common(virtfn); > > > > Why not re-order until after we've setup pcie_cap? > > > > > > > > https://lore.kernel.org/linux-pci/20190604143617.0a226555@x1.home/T/# > > > > > > pci_read_vf_config_common() also caches values for properties like > > > class, hdr_type, susbsystem_vendor/device. These values are read/used in > > > pci_setup_device(). So if we can use cached values in > > > pci_setup_device(), we don't have to read them from registers twice for > > > each device. > > > > Sorry, I missed that dependency, a bit too subtle. It's still pretty > > ugly that pci_setup_device()->set_pcie_port_type() is the canonical > > location for setting pcie_cap and now we need to kludge it earlier. > > What about the question in the self follow-up to my patch in the link > > above, can we simply assume 4K config space on a VF? Thanks, > > There should be no issue simply reading them once? I don't know > what that exact optimization saves, unless some broken VFs didn't > actually expose all the capabilities in config space and this happens > to workaround the problem. AIUI the original commit only saves us a few config space reads for VFs after the first where we test that extended config space is available and not simply an alias of standard config space. Thanks, Alex