From patchwork Fri Oct 21 16:55:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13015166 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A74FC433FE for ; Fri, 21 Oct 2022 16:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/IISqye9n6io3ELplTLRFiE3iivEHqb99iONf2T6OoA=; b=iwSdQY7OZ5Ywk5 9zc37ve4S51x0VCWrRtTBITgh+zTlVyuAPffjEV5C6tFctOg1wiRA9l2zm5cZd/SLaG0eCf5ZaQW+ G36OivCF8rhgVLk7GYdd5kKTVLRPwNSMudxf+jWxhNyJOd25XNpCeGifrnixSm+RRfkfK0pyTtZCy 0Z+2j6j26DG2/DtYC1U/397axDL2iafoZKzp06D5chgu+9/qjs64tPMUkZLpCz5eUxAOJn5A88FEm gU4bzgU8jkYfaFKY2W9g4c8ta2QpEOm+wURHXOfu+LqEw/6mZnUxOLebgJAOdAAFnnUle01QGhda3 N10Z+wxTKuRY/J8tsx3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1olvKh-0093vM-T1; Fri, 21 Oct 2022 16:57:20 +0000 Received: from mail-lf1-f42.google.com ([209.85.167.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1olvJE-0093Da-Iq for linux-arm-kernel@lists.infradead.org; Fri, 21 Oct 2022 16:55:52 +0000 Received: by mail-lf1-f42.google.com with SMTP id be13so6184847lfb.4 for ; Fri, 21 Oct 2022 09:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BHK2YnMn+PvfYswOSFncK4QS54g29samxTkRB76ABgU=; b=QhBDQ5kK1j897lvFrRw+svqzCraAat7SwGd6nZ5bUJsOOM15yQry1i8t4HINEftYdn CRcKGGE8vlKC3OUlPPySwl/t0pv3Rh8PigCRlkn0hU/SPQ6i0DtAs/zVMG++gandxo98 54DfmclbE+zdcmqEYfieFfyKUz1zHEG2liSHfFfe4HJgi4+nkvDse1Bsu88oEWDTudWR vxzi6iGoszEU5cCuUHadXJYacqx3sm+O3eJ4F1aAHA2ij9P31bfQxFgQuDbgqToM9aTA PnSp8G00mc9IkM6ydU1vjU/l8FJMbVRplTNNGT9a8yc6WysG7KA0Slp0O5VcyZOgm69d VdTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BHK2YnMn+PvfYswOSFncK4QS54g29samxTkRB76ABgU=; b=N8DsoqB7tlzAaeohuQ0wEZma0T+ez3JBvfABrvmKGxSBUKPiXQjbLYq+JshYLrvG/8 nf17s26IGFRVm8G/+s7i0fsWgTKn4+SMb/DouyZbwP8JcKvLZ623XR4WYf6hxSmwpkLF wxNNwKsY4KDVljcWIjk29QY2AtPO1c8mYYp+ZaJu7OWT2VJhD5/CsEnNkeREENpP0l0S DaAIdXFl5y4cPpxs4uqAQkqhCGCeh6P2i9+M8O+7aoWXgBNb+ORjn0kmMI/5dmAWI0ag hEAYHqmFiSZqTWtHjjXMA2rtkrIKdpNI8h1uE/ZJcDOO2yiYmmVOoxoYeTt2jTVNdq1s k60A== X-Gm-Message-State: ACrzQf3PikZgy44Bbzk/S2vgFz7rqMtTY3Fg71amew/4cQOGCvhu5BQK AiRgDDJ45Sg3do1XyM+LJrX7iA== X-Google-Smtp-Source: AMsMyM6wHuY/ytAg/rjQO4U4UWUT0S893/0vkKSHnk2BTfoAuGoidZH8mtag8Fw8V2bqSjRtIqVSwg== X-Received: by 2002:a05:6512:c29:b0:4a2:5c6c:8b50 with SMTP id z41-20020a0565120c2900b004a25c6c8b50mr7091025lfu.499.1666371346222; Fri, 21 Oct 2022 09:55:46 -0700 (PDT) Received: from eriador.unikie.fi ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id x4-20020a056512078400b004946e72711bsm3218532lfr.76.2022.10.21.09.55.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 09:55:45 -0700 (PDT) From: Dmitry Baryshkov To: Will Deacon , Robin Murphy , Joerg Roedel , Rob Herring , Krzysztof Kozlowski , Bjorn Andersson , Konrad Dybcio , Rob Clark Cc: Vinod Koul , Sai Prakash Ranjan , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, iommu@lists.linux.dev, devicetree@vger.kernel.org, freedreno@lists.freedesktop.org Subject: [RFC PATCH 5/9] iommu/arm-smmu-qcom: Move the qcom,adreno-smmu check into qcom_smmu_create Date: Fri, 21 Oct 2022 19:55:30 +0300 Message-Id: <20221021165534.2334329-6-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221021165534.2334329-1-dmitry.baryshkov@linaro.org> References: <20221021165534.2334329-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221021_095548_690408_866375C2 X-CRM114-Status: GOOD ( 18.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move special handling of qcom,adreno-smmu into qcom_smmu_create() function. This allows us to further customize the Adreno SMMU implementation. Note, this also adds two entries to the qcom_smmu_impl_of_match table. They were used with the qcom,adreno-smmu compat and were handled by the removed clause. Signed-off-by: Dmitry Baryshkov Reviewed-by: Sai Prakash Ranjan Tested-by: Sai Prakash Ranjan --- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 32 ++++++++++++---------- drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h | 1 + 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c index bd228b7d6817..c3bcd6eb2f42 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c @@ -407,13 +407,18 @@ static const struct arm_smmu_impl qcom_adreno_smmu_impl = { static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu, const struct qcom_smmu_match_data *data) { + const struct device_node *np = smmu->dev->of_node; const struct arm_smmu_impl *impl; struct qcom_smmu *qsmmu; if (!data) return ERR_PTR(-EINVAL); - impl = data->impl; + if (np && of_device_is_compatible(np, "qcom,adreno-smmu")) + impl = data->adreno_impl; + else + impl = data->impl; + if (!impl) return smmu; @@ -431,15 +436,22 @@ static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu, return &qsmmu->smmu; } -static const struct qcom_smmu_match_data qcom_smmu_data = { - .impl = &qcom_smmu_impl, +/* + * It is not yet possible to use MDP SMMU with the bypass quirk on the msm8996, + * there are not enough context banks. + */ +static const struct qcom_smmu_match_data msm8996_smmu_data = { + .impl = NULL, + .adreno_impl = &qcom_adreno_smmu_impl, }; -static const struct qcom_smmu_match_data qcom_adreno_smmu_data = { - .impl = &qcom_adreno_smmu_impl, +static const struct qcom_smmu_match_data qcom_smmu_data = { + .impl = &qcom_smmu_impl, + .adreno_impl = &qcom_adreno_smmu_impl, }; static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match[] = { + { .compatible = "qcom,msm8996-smmu-v2", .data = &msm8996_smmu_data }, { .compatible = "qcom,msm8998-smmu-v2", .data = &qcom_smmu_data }, { .compatible = "qcom,qcm2290-smmu-500", .data = &qcom_smmu_data }, { .compatible = "qcom,sc7180-smmu-500", .data = &qcom_smmu_data }, @@ -447,6 +459,7 @@ static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match[] = { { .compatible = "qcom,sc8180x-smmu-500", .data = &qcom_smmu_data }, { .compatible = "qcom,sc8280xp-smmu-500", .data = &qcom_smmu_data }, { .compatible = "qcom,sdm630-smmu-v2", .data = &qcom_smmu_data }, + { .compatible = "qcom,sdm845-smmu-v2", .data = &qcom_smmu_data }, { .compatible = "qcom,sdm845-smmu-500", .data = &qcom_smmu_data }, { .compatible = "qcom,sm6125-smmu-500", .data = &qcom_smmu_data }, { .compatible = "qcom,sm6350-smmu-500", .data = &qcom_smmu_data }, @@ -479,15 +492,6 @@ struct arm_smmu_device *qcom_smmu_impl_init(struct arm_smmu_device *smmu) } #endif - /* - * Do not change this order of implementation, i.e., first adreno - * smmu impl and then apss smmu since we can have both implementing - * arm,mmu-500 in which case we will miss setting adreno smmu specific - * features if the order is changed. - */ - if (of_device_is_compatible(np, "qcom,adreno-smmu")) - return qcom_smmu_create(smmu, &qcom_adreno_smmu_data); - match = of_match_node(qcom_smmu_impl_of_match, np); if (match) return qcom_smmu_create(smmu, match->data); diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h index 2424f10b7110..424d8d342ce0 100644 --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.h @@ -16,6 +16,7 @@ struct qcom_smmu { struct qcom_smmu_match_data { const struct arm_smmu_impl *impl; + const struct arm_smmu_impl *adreno_impl; }; #ifdef CONFIG_ARM_SMMU_QCOM_DEBUG