Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2714755yba; Mon, 6 May 2019 10:23:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuRD3sInli6GYkJ91EH2UdWf2CP3UU/VaRUXPgwnzkUMdBNlnRbLKiHVMjsdqpF2gw1BgC X-Received: by 2002:a63:a1a:: with SMTP id 26mr32768685pgk.11.1557163426938; Mon, 06 May 2019 10:23:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557163426; cv=none; d=google.com; s=arc-20160816; b=xJT0K6yE18QMX0D/DEnSg/AcaRvLvHrHYIfmGHYb42QduUlVrHAlfZe0WMG1m/ZEtU PQ6LsrkDcFyYzyPuN+RuzVyJxsKNBlyuuBhwiBAJ7ZDMJ+4gsdh7dwagBYQuwk3+OOZ0 gOVLAy/DORYM65PdqQzIJkS8QJkDo27p+U1nNG5CWSmFo3+M2EV2PYdLJ08cfVpL6uSh 7GKhzy6cAzkxb9inSrbfdfG41oKK5Map+7vUvCZTxtyT5HHeY3JxXTDFM2b4+lD2cp2I b3rzyFa1DJWqS7PeZSKZeYgzsuiNfQkg6ZgTjbiOWHw8kKf7IRflV85uJ1yMIfxNJEZD 5ZcQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=36DHviWgWu0p2mf9A1vy2S3PzEYeDX+SKGf4AnCeYCY=; b=T1U15dDhaIyE55hQ0ubWbWCJz2l96+BsXDRb4vO1bQlNevlLcqtZo0pmDGx6QVungz XwJIZobxPQ+CcVJISAluylY0drG5dHURjG7xFUzlsKSfEulranG8wfwFa6jQq1g60Avh ofe4uJUvtMDfabOoCu11F+z63nV7HG2j7jaDFBJ3NU8/DIVmDZ6dCSDHm05d6Rn086Qq 02IZqOXKM8vDtkgJMExgqESRSKhBQTJgoQisIwigpZqgaBNtxNk/Ka6BMwd2JIb9kmuE eab2dfFuSkT3fe5WpApsEYc+fjTyXFZH6Yw4QFMLn6MTWM6OLi9at6JmReCI3HrXof61 VuDA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc8si14495950plb.169.2019.05.06.10.23.31; Mon, 06 May 2019 10:23:46 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726827AbfEFRWU (ORCPT + 99 others); Mon, 6 May 2019 13:22:20 -0400 Received: from mga07.intel.com ([134.134.136.100]:31140 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726747AbfEFRWR (ORCPT ); Mon, 6 May 2019 13:22:17 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 May 2019 10:22:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,438,1549958400"; d="scan'208";a="230014473" Received: from skuppusw-desk.jf.intel.com ([10.54.74.33]) by orsmga001.jf.intel.com with ESMTP; 06 May 2019 10:22:15 -0700 From: sathyanarayanan.kuppuswamy@linux.intel.com To: bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, ashok.raj@intel.com, keith.busch@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: [PATCH v2 3/5] PCI/ATS: Skip VF ATS initialization if PF does not implement it Date: Mon, 6 May 2019 10:20:05 -0700 Message-Id: <21d93b3312418c1e28aeec238ef855c72efeb96a.1557162861.git.sathyanarayanan.kuppuswamy@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kuppuswamy Sathyanarayanan If PF does not implement ATS and VF implements/uses it, it might lead to runtime issues. Also, as per spec r4.0, sec 9.3.7.8, PF should implement ATS if VF implements it. So add additional check to confirm given device aligns with the spec. Cc: Ashok Raj Cc: Keith Busch Suggested-by: Ashok Raj Reviewed-by: Keith Busch Signed-off-by: Kuppuswamy Sathyanarayanan --- drivers/pci/ats.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c index e7a904e347c3..718e6f414680 100644 --- a/drivers/pci/ats.c +++ b/drivers/pci/ats.c @@ -19,6 +19,7 @@ void pci_ats_init(struct pci_dev *dev) { int pos; + struct pci_dev *pdev; if (pci_ats_disabled()) return; @@ -27,6 +28,17 @@ void pci_ats_init(struct pci_dev *dev) if (!pos) return; + /* + * Per PCIe r4.0, sec 9.3.7.8, if VF implements Address Translation + * Services (ATS) Extended Capability then corresponding PF should + * also implement it. + */ + if (dev->is_virtfn) { + pdev = pci_physfn(dev); + if (!pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ATS)) + return; + } + dev->ats_cap = pos; } -- 2.20.1