From patchwork Wed Jun 9 03:36:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 12308777 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2267C47095 for ; Wed, 9 Jun 2021 03:38:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2FB8611BF for ; Wed, 9 Jun 2021 03:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236501AbhFIDkO (ORCPT ); Tue, 8 Jun 2021 23:40:14 -0400 Received: from mail-pj1-f50.google.com ([209.85.216.50]:34464 "EHLO mail-pj1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236516AbhFIDkN (ORCPT ); Tue, 8 Jun 2021 23:40:13 -0400 Received: by mail-pj1-f50.google.com with SMTP id g6-20020a17090adac6b029015d1a9a6f1aso2864636pjx.1 for ; Tue, 08 Jun 2021 20:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x3db9pjXA84h01LUCZq4pwVqoTgwPoimoEKIvQtDJvk=; b=s3V6CA1Q+zfQZbBHuh+ry0GiiD2rW9uQwZJKsA2r5UK9Zi5cmy/cFoyzFSd1RmHB33 wbiNzflsUiCzNJxn6GOWqLZI6oR+315jeguEQ3ACLJnG0R2SHPwLW4N8cGVOd6bpvzFG ANFe/y6t1ITumv6sFdK13Ic6NqfnreSEaoWkY0ooYFGMAOvoQbiojm0Lo7KK0flOWNxn z7F3YhrvPj3l1FRR/HXQphTPFEMj0OQjLOFO8BlAsIKrfVINAkI0uIqOheLLf6fEkwLb BNHZwZWKDpQQuSH0i3Q90HL+xNciqAvTe4qnzTdvby9EljaDe8/nw1b3Ell+HBNAipEU IL0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=x3db9pjXA84h01LUCZq4pwVqoTgwPoimoEKIvQtDJvk=; b=jFjwlFvxblNXkFWPUD8atfl8Nt9vm7lpgrIh1Im/ewkUWNmU89NXukAlIcT6mj75SQ KbD2kgCbWx8uYw02p8OlnYCb/shT7dzVanrcIOd2em2bNKUfoRqSQB2QD/ChIdnlu6Uy AAD/ddYzGtnIGROLIkoFKoE6VfC+8ViXvnCdL1pxoXJ4Vl+ulPFBEi2mAkbvcDFidp3p 8qyVJpLZz839njaUbaFSFL1phEpkk5yWrJo7QvZhQ5SQR3mg5LFT7Vguy/RwK1lkGwbp ujYy1l0eQmNvo6ahRlrBYa0qFgCVSlJAlNHuT6LPwiHSI/qdN75RvdQ8b3k9b9LKAlG2 Kiqg== X-Gm-Message-State: AOAM530qWCCGv8/d35QvfI5AkhgQO04gyj7FKoJN+IqFWMGMDHNaKApo KsfSS9d6DcSclxnLezbG+DUFjg== X-Google-Smtp-Source: ABdhPJx457xWbtIJl1QI/e6/0sC+r5W336CMwB2P1zazGuA+tmNS0WIHnBG+CI10KF4l8b/CDGaJlQ== X-Received: by 2002:a17:90a:16c2:: with SMTP id y2mr29428390pje.236.1623209823962; Tue, 08 Jun 2021 20:37:03 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.135]) by smtp.gmail.com with ESMTPSA id t24sm3473904pji.56.2021.06.08.20.36.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 20:37:03 -0700 (PDT) From: Zhangfei Gao To: Bjorn Helgaas , Greg Kroah-Hartman , Arnd Bergmann , jean-philippe , kenneth-lee-2012@foxmail.com, Wangzhou Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zhangfei Gao Subject: [PATCH v4 1/3] PCI: PASID can be enabled without TLP prefix Date: Wed, 9 Jun 2021 11:36:39 +0800 Message-Id: <1623209801-1709-2-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623209801-1709-1-git-send-email-zhangfei.gao@linaro.org> References: <1623209801-1709-1-git-send-email-zhangfei.gao@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org A PASID-like feature is implemented on AMBA without using TLP prefixes and these devices have PASID capability though not supporting TLP. Adding a pasid_no_tlp bit for "PASID works without TLP prefixes" and pci_enable_pasid() checks pasid_no_tlp as well as eetlp_prefix_path. Suggested-by: Bjorn Helgaas Signed-off-by: Zhangfei Gao --- drivers/pci/ats.c | 2 +- include/linux/pci.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c index 6d7d649..c967ad6 100644 --- a/drivers/pci/ats.c +++ b/drivers/pci/ats.c @@ -376,7 +376,7 @@ int pci_enable_pasid(struct pci_dev *pdev, int features) if (WARN_ON(pdev->pasid_enabled)) return -EBUSY; - if (!pdev->eetlp_prefix_path) + if (!pdev->eetlp_prefix_path && !pdev->pasid_no_tlp) return -EINVAL; if (!pasid) diff --git a/include/linux/pci.h b/include/linux/pci.h index c20211e..766dca1 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -388,6 +388,7 @@ struct pci_dev { supported from root to here */ u16 l1ss; /* L1SS Capability pointer */ #endif + unsigned int pasid_no_tlp:1; /* PASID works without TLP Prefix */ unsigned int eetlp_prefix_path:1; /* End-to-End TLP Prefix */ pci_channel_state_t error_state; /* Current connectivity state */ From patchwork Wed Jun 9 03:36:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 12308775 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A694C47095 for ; Wed, 9 Jun 2021 03:37:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E2EC0611BF for ; Wed, 9 Jun 2021 03:37:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236440AbhFIDjS (ORCPT ); Tue, 8 Jun 2021 23:39:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232900AbhFIDjR (ORCPT ); Tue, 8 Jun 2021 23:39:17 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6AE6C061574 for ; Tue, 8 Jun 2021 20:37:10 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id k7so548281pjf.5 for ; Tue, 08 Jun 2021 20:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BgTgfv/nbAL6AaANvS5S9avysGK7LQx6xjZbQt/4m4U=; b=eP6KFjinoup+SnZrZQPiI5JxLEpYOFmbZHru2ThiWgVWQwWHjLlk/hnIcLGe6TIeZZ d8v+tHTXq1b2IV5ugjljh/Z4OztWDDnXwgrEBYfaf4A+rPuV7tPJ5McchX2Ft9+n4WBi QvTc9sHOX681fEnMHo1gueI6zK77i2hkVz/A9QuFWNZjjxk0UP5OY5ZUwDlnrRVLxV4S AuzrfBv860JsyHussb1qcZFL/+HcPWxuTHGBZ2JpxyrmehpQryV9K9KZsNHgWryUHNNc ZyTjNsDSGB/kMtqcMLfqrCEgmvkmK0fgQFZimzyPhNJxK+X2W39AQaax54SMCLOgS1G1 0e5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BgTgfv/nbAL6AaANvS5S9avysGK7LQx6xjZbQt/4m4U=; b=Ipczw+7WeX5i0blpH9jtK/Yk+6an4zjfdolPC7NjYAXKhyUhOx4GTdcixSdCAQbEr1 +ePsMsXXFTV5hL+e/k2F6u5sigesbsrrzgVwyyNRkZPGzw4Zc/5493JFHI5wKU1O7n1e pw3XV5O1NoAF5cJUNfloertuxXoEQbkcNY/OYJxsi74og67EwxZZAO0TV7QoZE3kgD+4 ZMfa3t9KgyGTyxcCDgtBrfTEQpi2fYUWYXvqSz7MEc1JrBjeOujCDjr90yCrXQOto9hE e4nUjuK9AlIRaQqrn+aLa4RVCN0g897vORx+CJclEAVJ4vwfIyPWY6FPsK1/odrIq8yV qEBw== X-Gm-Message-State: AOAM530eOZFa5U8PJV4CoeQKhZFqlNJEI50xPHIkO8PIh2PlQKgRss2Q ZhyTQPzbyPzG5DefobQxOsG5AA== X-Google-Smtp-Source: ABdhPJz7Re/hjduCZ651NbV8lcM94Ct6gHgCDhyDNxGsi7hEVb9iiXPgrjZHKpctznB+tUR1C5KEow== X-Received: by 2002:a17:90a:df13:: with SMTP id gp19mr29763761pjb.11.1623209830357; Tue, 08 Jun 2021 20:37:10 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.135]) by smtp.gmail.com with ESMTPSA id t24sm3473904pji.56.2021.06.08.20.37.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 20:37:10 -0700 (PDT) From: Zhangfei Gao To: Bjorn Helgaas , Greg Kroah-Hartman , Arnd Bergmann , jean-philippe , kenneth-lee-2012@foxmail.com, Wangzhou Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zhangfei Gao Subject: [PATCH v4 2/3] PCI: Add a quirk to set pasid_no_tlp for HiSilicon chips Date: Wed, 9 Jun 2021 11:36:40 +0800 Message-Id: <1623209801-1709-3-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623209801-1709-1-git-send-email-zhangfei.gao@linaro.org> References: <1623209801-1709-1-git-send-email-zhangfei.gao@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org HiSilicon KunPeng920 and KunPeng930 have devices appear as PCI but are actually on the AMBA bus. These fake PCI devices have PASID capability though not supporting TLP. Add a quirk to set pasid_no_tlp for these devices. Signed-off-by: Zhangfei Gao Signed-off-by: Jean-Philippe Brucker Signed-off-by: Zhou Wang --- drivers/pci/quirks.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index dcb229d..9331113 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -1820,6 +1820,20 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, quir DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1610, PCI_CLASS_BRIDGE_PCI, 8, quirk_pcie_mch); +static void quirk_huawei_pcie_sva(struct pci_dev *pdev) +{ + if (pdev->revision != 0x21 && pdev->revision != 0x30) + return; + + pdev->pasid_no_tlp = 1; +} +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0xa250, quirk_huawei_pcie_sva); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0xa251, quirk_huawei_pcie_sva); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0xa255, quirk_huawei_pcie_sva); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0xa256, quirk_huawei_pcie_sva); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0xa258, quirk_huawei_pcie_sva); +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0xa259, quirk_huawei_pcie_sva); + /* * It's possible for the MSI to get corrupted if SHPC and ACPI are used * together on certain PXH-based systems. From patchwork Wed Jun 9 03:36:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 12308779 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21CA0C47095 for ; Wed, 9 Jun 2021 03:38:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03DF5611BF for ; Wed, 9 Jun 2021 03:38:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236513AbhFIDk0 (ORCPT ); Tue, 8 Jun 2021 23:40:26 -0400 Received: from mail-pj1-f41.google.com ([209.85.216.41]:42728 "EHLO mail-pj1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236529AbhFIDkZ (ORCPT ); Tue, 8 Jun 2021 23:40:25 -0400 Received: by mail-pj1-f41.google.com with SMTP id md2-20020a17090b23c2b029016de4440381so567377pjb.1 for ; Tue, 08 Jun 2021 20:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6zXMN5ll7TqYL0aplhePUX2gZ+E/gbqQqmdmCua20NM=; b=UZyWz51Rvms6N+ygB3kUxZtGt095CvNlartmipzWktYJkX6mhk2UUYkFSIt3/zA/54 rBtSPHOfB3zEgZpzeHHFpHUwQ6ymdsyMzMlXyDv9xJzwa4yTID9WTr1bj8wFcc9p2ujO MoCIEC28IQg1q/tLpq2rfmJTSBAhoka7P+hEEfLb0F00cegQaoxPsr2DWXE+YWYvs2R/ xNFZME+bxCcb3psEc3YuUpt12MNhcFxHOE0r2PG03NTBb0OA3QkcI7wgR/Ig8PeEaSJo Q7u7nNhSeWXckY3D8p/emX5k0sNEaGinWv+7i2bC3rkK2rc38wMCWbHQPZxFqEvSj7BX xopw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6zXMN5ll7TqYL0aplhePUX2gZ+E/gbqQqmdmCua20NM=; b=Yv/XJp6MU7oXr+kV63LLr2y0nE88VsKY0EJVawRSKQP4t6ktL1LOW8IR4EVRQ3AUru gDvu4NS7GdqQEKhWHY89Jh6KPkuqipHu5QqyrN1CgtQpxPDeszLeRhsUa694Av0Mxcq8 gYwcfqrVLj9+dq8qRRSxsjgMcuIKImn5UMi3461nIfykXnyGeySObMZr0RrctG++b2ey MxXR6WtQYy0SmAX+vDE37r9CPcvf/bWeGxE5zo3X/FuBQIpGtQ9997bz1uPC8ugnTuAz ykWcQLvlrUHDug1E6/Jo/K83MqIF55QFjXJSFUi+Fu9vRU+9PZgzfhSOQWdqg26Ktbs1 PswA== X-Gm-Message-State: AOAM5303ehbuMDHJop2D2c3rPWx4el4yQhFhAf7OK4KavKHfwMtTHqui enr4ujIkbIfQNCbInMyhTvdyJw== X-Google-Smtp-Source: ABdhPJxBIQALUt+JU3tbbDF+75RfxEJQGypdU7Til5HLLfgC9LGuKID8h9Yzu36B9UQoUZd+dNbHFw== X-Received: by 2002:a17:902:9042:b029:10f:c864:6090 with SMTP id w2-20020a1709029042b029010fc8646090mr3393800plz.39.1623209836798; Tue, 08 Jun 2021 20:37:16 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.135]) by smtp.gmail.com with ESMTPSA id t24sm3473904pji.56.2021.06.08.20.37.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 20:37:16 -0700 (PDT) From: Zhangfei Gao To: Bjorn Helgaas , Greg Kroah-Hartman , Arnd Bergmann , jean-philippe , kenneth-lee-2012@foxmail.com, Wangzhou Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zhangfei Gao Subject: [PATCH v4 3/3] PCI: Set dma-can-stall for HiSilicon chips Date: Wed, 9 Jun 2021 11:36:41 +0800 Message-Id: <1623209801-1709-4-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1623209801-1709-1-git-send-email-zhangfei.gao@linaro.org> References: <1623209801-1709-1-git-send-email-zhangfei.gao@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org HiSilicon KunPeng920 and KunPeng930 have devices appear as PCI but are actually on the AMBA bus. These fake PCI devices can support SVA via SMMU stall feature, by setting dma-can-stall for ACPI platforms. Property dma-can-stall depends on patchset https://lore.kernel.org/linux-iommu/162314710744.3707892.6632600736379822229.b4-ty@kernel.org/ Signed-off-by: Zhangfei Gao Signed-off-by: Jean-Philippe Brucker Signed-off-by: Zhou Wang --- drivers/pci/quirks.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 9331113..c1643ce 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -1822,10 +1822,23 @@ DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1610, PCI_CLASS_BRIDGE_PCI static void quirk_huawei_pcie_sva(struct pci_dev *pdev) { + struct property_entry properties[] = { + PROPERTY_ENTRY_BOOL("dma-can-stall"), + {}, + }; + if (pdev->revision != 0x21 && pdev->revision != 0x30) return; pdev->pasid_no_tlp = 1; + + /* + * Set the dma-can-stall property on ACPI platforms. Device tree + * can set it directly. + */ + if (!pdev->dev.of_node && + device_add_properties(&pdev->dev, properties)) + pci_warn(pdev, "could not add stall property"); } DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0xa250, quirk_huawei_pcie_sva); DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_HUAWEI, 0xa251, quirk_huawei_pcie_sva);