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: 12108867 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 7A18AC433DB for ; Mon, 1 Mar 2021 07:42:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 187FE64D8F for ; Mon, 1 Mar 2021 07:42:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 187FE64D8F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=8WiA6PPR3MsWj+JYiONeo02I4Ke6CdnBiYGjG/Eg6Io=; b=mV9H/+65L+K8U28oxUv5G73AD/ D3L2saNG0/2bCLdmLx6a3lX3EcHRDaGihNu0J8MBGrz1TchkA0fOQ92CnRx9E/gQMcPQFDoAo/hhV 2HujyjtOgxwiY9qHiVQT0LkG9L3mHjpJl/H4cMEjdD7LMQGpmbYk4fmkv65DA1+vro3YBpZWjFshb nOdnmApG8ri7/5dSWqQcuTHOSFdNKH/d5sidUzZXLSh2ELl9P7avh9et4YcswrhvRQn0JTqlJ7x+O ty/MuqjUv6UQrBuuE2D+l6adzyosxQGCC22IX/8CFPI0ebsaU9QscPGHCe6xMFoVp8vwRiqWOSI/9 leXKp+CA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lGdAU-0003Za-OG; Mon, 01 Mar 2021 07:40:38 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lGdAQ-0003Yt-TX for linux-arm-kernel@lists.infradead.org; Mon, 01 Mar 2021 07:40:36 +0000 Received: by mail-pj1-x1036.google.com with SMTP id d13-20020a17090abf8db02900c0590648b1so1994245pjs.1 for ; Sun, 28 Feb 2021 23:40:31 -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=e1Rax1c3bIVW+qQ6TBVlzqUCUHTRoCdIxInAzhcySa66oeTzw2FNQMK3shFgJutrME nQ8C9SO4LBMowjgwG1IIP1ijTrNIxbn7XsvaR2Vb8x28X8NtJNBOp1B03VDwqU2aqzbF UDYx2RJdizx4O1zOGrwTMMzrSjlxAdNN9theDM/xlmiyDIbfEPuPuNTiXx63XnCaLlvP yG+uuZl0fxkeKNqlHN9zqVZrccrlacjPlEv1BeIieWAPI4YigKsKDqhWJtOPlOYbLXTa ZfNvxT/Zt+JWcsrbUYOUtAoaweGDGXMsLRJiGEUHLhIVEFyc19K3uTAYvB8BQ8AVOn30 ESnw== X-Gm-Message-State: AOAM533bVYvA82I13k1Wk7EzlA30gAvc/nVcDL+DF5u3HeljeUcGi88M aRBzi3FsUFPZQtZ4+eZ0XSHSCw== X-Google-Smtp-Source: ABdhPJwmn7Yt2qQ/FjR4R62H2dp1v7EH6erGPRR9C3XMgQrZM+NxNLsfwIKPIFlp9cPlaF8ynjskqw== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210301_024035_279996_6C57127F X-CRM114-Status: GOOD ( 14.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, Shawn Guo , Robin Murphy , linux-arm-kernel@lists.infradead.org, Bjorn Andersson MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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(+) 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);