From patchwork Mon Mar 1 07:40:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 388623 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3145203jap; Sun, 28 Feb 2021 23:41:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFPG2dDTnvQeeeySz2NUGtKCQVccjhYdWcE2JOkVHqOFSY8TLmSdH5jxWr5V9MWxN/xfDQ X-Received: by 2002:a17:906:dfcc:: with SMTP id jt12mr14839893ejc.31.1614584498186; Sun, 28 Feb 2021 23:41:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614584498; cv=none; d=google.com; s=arc-20160816; b=aKdhUzx3T5ZMC2SQv4RcxZ8sOirOvlZOG2k7NL92pfZfEgD2rmzldSn7Lsl2gcGAPG 1JcD9HY0aBePxogm8m7nuL8IvpdkeWeULDQYOpNCHreGeYP6XKQ119LhxAJbCjXrx53r PQgePPHbqxqBemIcK/mw6rNHrn79Hhfd4Sw2/sV1M8z1Yu6ngBRxSvbyN7FGJRD5ukkf y70kUoSPkpfTT2n7pMPITZD7p4Fb4UgEbyggkDjU8FLd8vaZ2/WaavKkd4qbjrG5iNWu TP+H/WwRytg3j5qt46vGo/JaH7qTl30PlwE7dGgZ8suOW5FIRYKm1DmRoPbQ+71WgAXO nqIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=U1gpWsvGyBC5E6Jh4WcIRAYp0x0ZA6uSR3HnwYKMrgg=; b=xLxSBgHX2zoqMbYfxdGstrscigckS495ZTJzzNbGZUD4ZWJEWSZ+iI5l6sl054nlqr 1mP8M2W4N04+gKESgsn8t03cQJpWpwC6YyfvutFG6l2w92yFu/mAybu8eQObmnxhM9uA amoJxcV4/yu1rldXhKGvkWVxRHglqloR4+CUk6X98ryetHDPLIY3cLQHyn1l+QNmD+UZ 7da1oXJf9l4SDnGNUtASFYoIFmmmWvA6J/FaYSZVLi3rr5hrcNvKlagfdi7u6T9WPTpe 0i90Ii5skpu0Z6OyX6zZ6wbUzgaEqP/CzNajDzTrDoDKLRH67/lb6GRTpjDBVFCepC/n hsJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iX1ByBKQ; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si10716150ejo.123.2021.02.28.23.41.37; Sun, 28 Feb 2021 23:41:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-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=@linaro.org header.s=google header.b=iX1ByBKQ; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232481AbhCAHkG (ORCPT + 16 others); Mon, 1 Mar 2021 02:40:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232539AbhCAHjv (ORCPT ); Mon, 1 Mar 2021 02:39:51 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 756AFC06178B for ; Sun, 28 Feb 2021 23:40:30 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id g20so9329312plo.2 for ; Sun, 28 Feb 2021 23:40:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=U1gpWsvGyBC5E6Jh4WcIRAYp0x0ZA6uSR3HnwYKMrgg=; b=iX1ByBKQaJbVS89EmpIaqn6Jn+50kfPrUmnYX93T/Oao91ktUiEPoNVmoiS3mzMly3 iDeXtXmASnToxBa+Zx4Yb/Sz5ZNZMyiV625hv74V7QAzhSKf43vTYo23di+aN3F5a7DQ DZ8rqOPUdFUiMP2uNSvsW/rYWGMuHJB3lI9rNCpO/5CHB1mvIMIgAEhAZ6/odfAY90Ku rU3cKAOzN9AM92xc3ltY8mJ73NkfxwqUecl+4pSsms7O227mUBMoD5ZzlS6YnHDfTELj 9xjN2AHp34Nnkr3VTCUdjidJwY9lahOxS0tCZ/3ljvW9H+yrYVtTaW+0Uo5xAp9SgzyH Q/cA== 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; bh=U1gpWsvGyBC5E6Jh4WcIRAYp0x0ZA6uSR3HnwYKMrgg=; b=DrdXANuCfAUOQpxaO/660HR1WOuErlk3yDDyYmlvPWTWiY1FEbRKfg//E0gYa4GMwa 0kq8lCQctGX2QcIpjWcihdmC3JyRK+t8uy85uZOflXRn0691/On5nhXOWE6ob2S2ffAl v4x+xjOrjklcjYTEHTC/WtkbaMSi7PK2W3QuAsnzM+BTde/ZmmMPXnFKLUQnY4pffiVT lhfOBgrMCDRUFcYHQ44bKZKJgO8p9GxwgWho4/dNU+xrQDBmptagvIVFzOsWG6T1AsWK uqZAzBAopsrWQ4xs4pPazoV0qCw9Yexg5JXd/lIZog0sQmxjlN4FpdE7Ohkgw22ul2SX Pkdw== X-Gm-Message-State: AOAM532Qfo9tLlzXQmJdsigUhZiiyQlEy+qqXWlFpQYr26ewhx/qOQ92 uDqL4CLEDoiv085rN715LM/4cg== X-Received: by 2002:a17:90b:4a89:: with SMTP id lp9mr16249508pjb.170.1614584430113; Sun, 28 Feb 2021 23:40:30 -0800 (PST) Received: from localhost.localdomain (80.251.214.228.16clouds.com. [80.251.214.228]) by smtp.gmail.com with ESMTPSA id z3sm4203566pfn.7.2021.02.28.23.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Feb 2021 23:40:29 -0800 (PST) From: Shawn Guo To: Will Deacon Cc: Robin Murphy , Bjorn Andersson , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Shawn Guo Subject: [PATCH] iommu/arm-smmu-qcom: create qcom_smmu_impl for ACPI boot Date: Mon, 1 Mar 2021 15:40:21 +0800 Message-Id: <20210301074021.20059-1-shawn.guo@linaro.org> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Though qcom_adreno_smmu_impl is not used by ACPI boot right now, qcom_smmu_impl is already required at least to boot up Lenovo Flex 5G laptop. Let's check asl_compiler_id in IORT header to ensure we are running a QCOM SMMU and create qcom_smmu_impl for it. !np is used to check ACPI boot, because fwnode of SMMU device is a static allocation and thus has_acpi_companion() doesn't work here. Signed-off-by: Shawn Guo --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) -- 2.17.1 diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index 98b3a1c2a181..5e8779483367 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -3,6 +3,7 @@ * Copyright (c) 2019, The Linux Foundation. All rights reserved. */ +#include #include #include #include @@ -339,10 +340,42 @@ static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match[] = { { } }; +#ifdef CONFIG_ACPI +static bool is_qcom_iort(struct arm_smmu_device *smmu) +{ + struct acpi_table_header *iort; + acpi_status status; + bool ret = false; + + status = acpi_get_table(ACPI_SIG_IORT, 0, &iort); + if (ACPI_FAILURE(status)) { + dev_err(smmu->dev, "failed to get IORT\n"); + goto done; + } + + if (strncmp(iort->asl_compiler_id, "QCOM", 4) == 0) { + ret = true; + goto done; + } + +done: + acpi_put_table(iort); + return ret; +} +#else +static bool is_qcom_iort(struct arm_smmu_device *smmu) +{ + return false; +} +#endif + struct arm_smmu_device *qcom_smmu_impl_init(struct arm_smmu_device *smmu) { const struct device_node *np = smmu->dev->of_node; + if (!np && is_qcom_iort(smmu)) + return qcom_smmu_create(smmu, &qcom_smmu_impl); + if (of_match_node(qcom_smmu_impl_of_match, np)) return qcom_smmu_create(smmu, &qcom_smmu_impl);