Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp776954ybt; Fri, 19 Jun 2020 13:29:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR2GVfMCk39fR9Gp9iU1YiHDb8CwRFPob5V0eQrw1OaCL/1T4OjDYLzgh4IRmEJdAXwaTl X-Received: by 2002:a17:906:1d5b:: with SMTP id o27mr5226039ejh.344.1592598588712; Fri, 19 Jun 2020 13:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592598588; cv=none; d=google.com; s=arc-20160816; b=VKk8Z0dcaXUV9gsMWMn8X2coBcsDYK83Wv0vyOkzpJBZiKj+FG3DG5AIlXJ9Y08f1j yoj9nhmaYaZ8XcqNVk83RZw8sY76NwWPKHnwuCAz78XeF554AYpx2b7iNplnwhLQ49W4 vS0sQRkZgYUUEfAzxL3kMo0OKA2YPgfkx99SZAFMacMPIrTuBTnxbqgW0iQpZ2zpdROe jsDWh+wfC7K0Wcbc4dCJ3qk+OiVnPjEef0caWDNz02ovHu773RAPJQ52DtOdLocrdP4o ym7JBL1zfmpYsJNWc5zrgnlnbQdu9sN+HXegP8LZyvTH81PZ2uFivb1cchj50XFmStqb E9Lw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Bc33JbJ3DCRl4H8c3wpSltOOHXNSi9CcyEf27l/J5YY=; b=izPXohiOX2Sl5VC+6kctwt6oKnmEb4vD6XHUMWEhS4tEpBRckO3P3pEsvRDOmHoZOJ CWDCwuVQZ/U7nRXrnTkT1Aq3t8qM39DgDi7xyvbsapO7ye6vxyX54D/fVLXeXu93nNgv 0ecR8ruav4PrW/2FEzHNXm3ByUk6lrPK08a/NU9i4fU0SX3M7KoScQ16RISetBVbSaCQ jkmGrDN4HbXfCR0aJ0ZN9UVnhT0FNataHFw7M5LZ7AFdXOiFzF+dExa281NFD1jHBfFj Ufu1ph0zUsRihU0kSe3dGBRYwgc5p2LffybQzsUDTxiZOr3ebk8c+n6xqE7S5HjuLnWt JLng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LIzintNE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b10si4348699edx.469.2020.06.19.13.29.26; Fri, 19 Jun 2020 13:29:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LIzintNE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388707AbgFSPER (ORCPT + 99 others); Fri, 19 Jun 2020 11:04:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:60980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390621AbgFSPEI (ORCPT ); Fri, 19 Jun 2020 11:04:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 4373121D7D; Fri, 19 Jun 2020 15:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592579046; bh=seEWA6TD6thz/bf8AymmfY2DgRiKDddkUcwLl6ycTeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LIzintNEKSt0sq+v/WBbFM/+UTEJlXy9Cmz6oBsi8DvIzzfzTq8ZrFLb1yW2KpcHe i897lWHzZLD3NJScqU/eCK5QxaqSnqv7Osp+BFQ1+peelQyY6gcdxJLjAsC8NMsFXY 0TI11hQ/nFh77b8cW/j1BlPO9BavOpLBFFgxqWKE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bjorn Helgaas , Logan Gunthorpe , Alex Williamson , Sasha Levin Subject: [PATCH 4.19 225/267] PCI: Make ACS quirk implementations more uniform Date: Fri, 19 Jun 2020 16:33:30 +0200 Message-Id: <20200619141659.498894885@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bjorn Helgaas [ Upstream commit c8de8ed2dcaac82e5d76d467dc0b02e0ee79809b ] The ACS quirks differ in needless ways, which makes them look more different than they really are. Reorder the ACS flags in order of definitions in the spec: PCI_ACS_SV Source Validation PCI_ACS_TB Translation Blocking PCI_ACS_RR P2P Request Redirect PCI_ACS_CR P2P Completion Redirect PCI_ACS_UF Upstream Forwarding PCI_ACS_EC P2P Egress Control PCI_ACS_DT Direct Translated P2P (PCIe r5.0, sec 7.7.8.2) and use similar code structure in all. No functional change intended. Signed-off-by: Bjorn Helgaas Reviewed-by: Logan Gunthorpe Reviewed-by: Alex Williamson Signed-off-by: Sasha Levin --- drivers/pci/quirks.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 502dca568d6c..ae62c0b058dd 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -4333,18 +4333,18 @@ static bool pci_quirk_cavium_acs_match(struct pci_dev *dev) static int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags) { + if (!pci_quirk_cavium_acs_match(dev)) + return -ENOTTY; + /* - * Cavium root ports don't advertise an ACS capability. However, + * Cavium Root Ports don't advertise an ACS capability. However, * the RTL internally implements similar protection as if ACS had - * Request Redirection, Completion Redirection, Source Validation, + * Source Validation, Request Redirection, Completion Redirection, * and Upstream Forwarding features enabled. Assert that the * hardware implements and enables equivalent ACS functionality for * these flags. */ - acs_flags &= ~(PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_SV | PCI_ACS_UF); - - if (!pci_quirk_cavium_acs_match(dev)) - return -ENOTTY; + acs_flags &= ~(PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); return acs_flags ? 0 : 1; } @@ -4362,7 +4362,7 @@ static int pci_quirk_xgene_acs(struct pci_dev *dev, u16 acs_flags) } /* - * Many Intel PCH root ports do provide ACS-like features to disable peer + * Many Intel PCH Root Ports do provide ACS-like features to disable peer * transactions and validate bus numbers in requests, but do not provide an * actual PCIe ACS capability. This is the list of device IDs known to fall * into that category as provided by Intel in Red Hat bugzilla 1037684. @@ -4410,37 +4410,34 @@ static bool pci_quirk_intel_pch_acs_match(struct pci_dev *dev) return false; } -#define INTEL_PCH_ACS_FLAGS (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV) +#define INTEL_PCH_ACS_FLAGS (PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF) static int pci_quirk_intel_pch_acs(struct pci_dev *dev, u16 acs_flags) { - u16 flags = dev->dev_flags & PCI_DEV_FLAGS_ACS_ENABLED_QUIRK ? - INTEL_PCH_ACS_FLAGS : 0; - if (!pci_quirk_intel_pch_acs_match(dev)) return -ENOTTY; - return acs_flags & ~flags ? 0 : 1; + if (dev->dev_flags & PCI_DEV_FLAGS_ACS_ENABLED_QUIRK) + acs_flags &= ~(INTEL_PCH_ACS_FLAGS); + + return acs_flags ? 0 : 1; } /* - * These QCOM root ports do provide ACS-like features to disable peer + * These QCOM Root Ports do provide ACS-like features to disable peer * transactions and validate bus numbers in requests, but do not provide an * actual PCIe ACS capability. Hardware supports source validation but it * will report the issue as Completer Abort instead of ACS Violation. - * Hardware doesn't support peer-to-peer and each root port is a root - * complex with unique segment numbers. It is not possible for one root - * port to pass traffic to another root port. All PCIe transactions are - * terminated inside the root port. + * Hardware doesn't support peer-to-peer and each Root Port is a Root + * Complex with unique segment numbers. It is not possible for one Root + * Port to pass traffic to another Root Port. All PCIe transactions are + * terminated inside the Root Port. */ static int pci_quirk_qcom_rp_acs(struct pci_dev *dev, u16 acs_flags) { - u16 flags = (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV); - int ret = acs_flags & ~flags ? 0 : 1; - - pci_info(dev, "Using QCOM ACS Quirk (%d)\n", ret); + acs_flags &= ~(PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); - return ret; + return acs_flags ? 0 : 1; } /* -- 2.25.1