From patchwork Thu Mar 29 10:01:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Dongsheng" X-Patchwork-Id: 10314829 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1178D6055B for ; Thu, 29 Mar 2018 10:01:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 053452A24A for ; Thu, 29 Mar 2018 10:01:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDC692A24F; Thu, 29 Mar 2018 10:01:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 109B22A2E5 for ; Thu, 29 Mar 2018 10:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751908AbeC2KBf (ORCPT ); Thu, 29 Mar 2018 06:01:35 -0400 Received: from mx01.hxt-semitech.com.96.203.223.in-addr.arpa ([223.203.96.7]:51302 "EHLO barracuda.hxt-semitech.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752553AbeC2KBe (ORCPT ); Thu, 29 Mar 2018 06:01:34 -0400 X-ASG-Debug-ID: 1522317692-093b7e77020c070001-I98ny2 Received: from HXTBJIDCEMVIW01.hxtcorp.net ([10.128.0.14]) by barracuda.hxt-semitech.com with ESMTP id o6JBGj2YbUvm1VDy (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 29 Mar 2018 18:01:32 +0800 (CST) X-Barracuda-Envelope-From: dongsheng.wang@hxt-semitech.com Received: from ubuntu.hxtcorp.net (10.5.21.103) by HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) with Microsoft SMTP Server (TLS) id 15.0.847.32; Thu, 29 Mar 2018 18:01:31 +0800 From: Wang Dongsheng To: , CC: , , , , , , Wang Dongsheng Subject: [RFC PATCH 2/2] ACPI/IORT: use swiotlb_dma_ops when smmu probe failed Date: Thu, 29 Mar 2018 03:01:00 -0700 X-ASG-Orig-Subj: [RFC PATCH 2/2] ACPI/IORT: use swiotlb_dma_ops when smmu probe failed Message-ID: <1522317660-11080-3-git-send-email-dongsheng.wang@hxt-semitech.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522317660-11080-1-git-send-email-dongsheng.wang@hxt-semitech.com> References: <1522317660-11080-1-git-send-email-dongsheng.wang@hxt-semitech.com> MIME-Version: 1.0 X-Originating-IP: [10.5.21.103] X-ClientProxiedBy: HXTBJIDCEMVIW02.hxtcorp.net (10.128.0.15) To HXTBJIDCEMVIW01.hxtcorp.net (10.128.0.14) X-Barracuda-Connect: UNKNOWN[10.128.0.14] X-Barracuda-Start-Time: 1522317692 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://192.168.50.101:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at hxt-semitech.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Bayes: SPAM GLOBAL 0.9567 1.0000 3.8473 X-Barracuda-Spam-Score: 3.85 X-Barracuda-Spam-Status: No, SCORE=3.85 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.49406 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If SMMU probe failed, master should use swiotlb as dma ops. SMMU may probe failed with specified environment, so there are not any iommu resources in iommu_device_list. The master will always get EPROBE_DEFER from really_probe (dma_configure) but in fact SMMU has probe failed. The issue causes all of masters failed to be driven. Signed-off-by: Wang Dongsheng --- drivers/acpi/arm64/iort.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c index e2f7bdd..a6f4c27 100644 --- a/drivers/acpi/arm64/iort.c +++ b/drivers/acpi/arm64/iort.c @@ -774,17 +774,45 @@ static int arm_smmu_iort_xlate(struct device *dev, u32 streamid, return ret; } -static inline bool iort_iommu_driver_enabled(u8 type) +static int iort_check_dev_dl_status(struct device *dev, void *data) { + struct fwnode_handle *fwnode = data; + + if (dev->fwnode != fwnode) + return 0; + + if (dev->links.status == DL_DEV_PROBE_FAILED) + return -ENODEV; + + return -EPROBE_DEFER; +} + +static int iort_iommu_driver_enabled(u8 type, struct fwnode_handle *fwnode) +{ + bool buildin; + int ret; + switch (type) { case ACPI_IORT_NODE_SMMU_V3: - return IS_BUILTIN(CONFIG_ARM_SMMU_V3); + buildin = IS_BUILTIN(CONFIG_ARM_SMMU_V3); + break; case ACPI_IORT_NODE_SMMU: - return IS_BUILTIN(CONFIG_ARM_SMMU); + buildin = IS_BUILTIN(CONFIG_ARM_SMMU); + break; default: pr_warn("IORT node type %u does not describe an SMMU\n", type); - return false; + buildin = false; } + + if (!buildin) + return -ENODEV; + + ret = bus_for_each_dev(&platform_bus_type, NULL, fwnode, + iort_check_dev_dl_status); + if (!ret) + return -EPROBE_DEFER; + + return ret; } #ifdef CONFIG_IOMMU_API @@ -919,8 +947,7 @@ static int iort_iommu_xlate(struct device *dev, struct acpi_iort_node *node, */ ops = iommu_ops_from_fwnode(iort_fwnode); if (!ops) - return iort_iommu_driver_enabled(node->type) ? - -EPROBE_DEFER : -ENODEV; + return iort_iommu_driver_enabled(node->type, iort_fwnode); return arm_smmu_iort_xlate(dev, streamid, iort_fwnode, ops); }