From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 5DCFFC43461 for ; Fri, 11 Sep 2020 17:29:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3281B22209 for ; Fri, 11 Sep 2020 17:29:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726100AbgIKR3g (ORCPT ); Fri, 11 Sep 2020 13:29:36 -0400 Received: from foss.arm.com ([217.140.110.172]:40348 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726504AbgIKR3d (ORCPT ); Fri, 11 Sep 2020 13:29:33 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F213E106F; Fri, 11 Sep 2020 10:29:32 -0700 (PDT) Received: from [10.57.40.122] (unknown [10.57.40.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E66493F68F; Fri, 11 Sep 2020 10:29:27 -0700 (PDT) Subject: Re: [PATCH v3 8/8] iommu/arm-smmu-qcom: Setup identity domain for boot mappings To: Bjorn Andersson , Will Deacon , Joerg Roedel , Sai Prakash Ranjan , Jordan Crouse , Rob Clark Cc: Sibi Sankar , linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <20200904155513.282067-1-bjorn.andersson@linaro.org> <20200904155513.282067-9-bjorn.andersson@linaro.org> From: Robin Murphy Message-ID: <34b1f9ea-fb16-faac-c288-627b51066968@arm.com> Date: Fri, 11 Sep 2020 18:29:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200904155513.282067-9-bjorn.andersson@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On 2020-09-04 16:55, Bjorn Andersson wrote: > With many Qualcomm platforms not having functional S2CR BYPASS a > temporary IOMMU domain, without translation, needs to be allocated in > order to allow these memory transactions. > > Unfortunately the boot loader uses the first few context banks, so > rather than overwriting a active bank the last context bank is used and > streams are diverted here during initialization. > > This also performs the readback of SMR registers for the Qualcomm > platform, to trigger the mechanism. > > This is based on prior work by Thierry Reding and Laurentiu Tudor. > > Signed-off-by: Bjorn Andersson > --- > > Changes since v2: > - Combined from pieces spread between the Qualcomm impl and generic code in v2. > - Moved to use the newly introduced inherit_mapping op. > > 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 70a1eaa52e14..a54302190932 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > @@ -12,6 +12,7 @@ > struct qcom_smmu { > struct arm_smmu_device smmu; > bool bypass_broken; > + struct iommu_domain *identity; > }; > > static struct qcom_smmu *to_qcom_smmu(struct arm_smmu_device *smmu) > @@ -228,6 +229,37 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu) > return 0; > } > > +static int qcom_smmu_inherit_mappings(struct arm_smmu_device *smmu) > +{ > + struct qcom_smmu *qsmmu = to_qcom_smmu(smmu); > + int cbndx; > + u32 smr; > + int i; > + > + qsmmu->identity = arm_smmu_alloc_identity_domain(smmu); > + if (IS_ERR(qsmmu->identity)) > + return PTR_ERR(qsmmu->identity); > + > + cbndx = to_smmu_domain(qsmmu->identity)->cfg.cbndx; I don't really get the point of going through the dance of allocating a whole iommu_domain() just to get a context. If you don't want to simply statically reserve a context at probe time, then just allocate from smmu->context_map here (where AFAICS "here" should be in cfg_probe anyway). This is entirely driver-internal, so there shouldn't be any need for IOMMU-API-level stuff to be involved. Robin. > + > + for (i = 0; i < smmu->num_mapping_groups; i++) { > + smr = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_SMR(i)); > + > + if (FIELD_GET(ARM_SMMU_SMR_VALID, smr)) { > + smmu->smrs[i].id = FIELD_GET(ARM_SMMU_SMR_ID, smr); > + smmu->smrs[i].mask = FIELD_GET(ARM_SMMU_SMR_MASK, smr); > + smmu->smrs[i].valid = true; > + > + smmu->s2crs[i].type = S2CR_TYPE_TRANS; > + smmu->s2crs[i].privcfg = S2CR_PRIVCFG_DEFAULT; > + smmu->s2crs[i].cbndx = cbndx; > + smmu->s2crs[i].count++; > + } > + } > + > + return 0; > +} > + > static int qcom_smmu_def_domain_type(struct device *dev) > { > const struct of_device_id *match = > @@ -270,6 +302,7 @@ static const struct arm_smmu_impl qcom_smmu_impl = { > .cfg_probe = qcom_smmu_cfg_probe, > .def_domain_type = qcom_smmu_def_domain_type, > .reset = qcom_smmu500_reset, > + .inherit_mappings = qcom_smmu_inherit_mappings, > }; > > static const struct arm_smmu_impl qcom_adreno_smmu_impl = { > From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 0ADCAC433E2 for ; Fri, 11 Sep 2020 17:29:39 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 56514221E7 for ; Fri, 11 Sep 2020 17:29:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56514221E7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id DBD492E2AB; Fri, 11 Sep 2020 17:29:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8tnc2kwaoJ92; Fri, 11 Sep 2020 17:29:35 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id BD5002E28C; Fri, 11 Sep 2020 17:29:35 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9E3C9C0859; Fri, 11 Sep 2020 17:29:35 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id E2559C0051 for ; Fri, 11 Sep 2020 17:29:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id CACBF87AE2 for ; Fri, 11 Sep 2020 17:29:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0n5KkCdgtOP7 for ; Fri, 11 Sep 2020 17:29:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by whitealder.osuosl.org (Postfix) with ESMTP id B697887ADB for ; Fri, 11 Sep 2020 17:29:33 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F213E106F; Fri, 11 Sep 2020 10:29:32 -0700 (PDT) Received: from [10.57.40.122] (unknown [10.57.40.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E66493F68F; Fri, 11 Sep 2020 10:29:27 -0700 (PDT) Subject: Re: [PATCH v3 8/8] iommu/arm-smmu-qcom: Setup identity domain for boot mappings To: Bjorn Andersson , Will Deacon , Joerg Roedel , Sai Prakash Ranjan , Jordan Crouse , Rob Clark References: <20200904155513.282067-1-bjorn.andersson@linaro.org> <20200904155513.282067-9-bjorn.andersson@linaro.org> From: Robin Murphy Message-ID: <34b1f9ea-fb16-faac-c288-627b51066968@arm.com> Date: Fri, 11 Sep 2020 18:29:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200904155513.282067-9-bjorn.andersson@linaro.org> Content-Language: en-GB Cc: linux-arm-msm@vger.kernel.org, iommu@lists.linux-foundation.org, Sibi Sankar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On 2020-09-04 16:55, Bjorn Andersson wrote: > With many Qualcomm platforms not having functional S2CR BYPASS a > temporary IOMMU domain, without translation, needs to be allocated in > order to allow these memory transactions. > > Unfortunately the boot loader uses the first few context banks, so > rather than overwriting a active bank the last context bank is used and > streams are diverted here during initialization. > > This also performs the readback of SMR registers for the Qualcomm > platform, to trigger the mechanism. > > This is based on prior work by Thierry Reding and Laurentiu Tudor. > > Signed-off-by: Bjorn Andersson > --- > > Changes since v2: > - Combined from pieces spread between the Qualcomm impl and generic code in v2. > - Moved to use the newly introduced inherit_mapping op. > > 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 70a1eaa52e14..a54302190932 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > @@ -12,6 +12,7 @@ > struct qcom_smmu { > struct arm_smmu_device smmu; > bool bypass_broken; > + struct iommu_domain *identity; > }; > > static struct qcom_smmu *to_qcom_smmu(struct arm_smmu_device *smmu) > @@ -228,6 +229,37 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu) > return 0; > } > > +static int qcom_smmu_inherit_mappings(struct arm_smmu_device *smmu) > +{ > + struct qcom_smmu *qsmmu = to_qcom_smmu(smmu); > + int cbndx; > + u32 smr; > + int i; > + > + qsmmu->identity = arm_smmu_alloc_identity_domain(smmu); > + if (IS_ERR(qsmmu->identity)) > + return PTR_ERR(qsmmu->identity); > + > + cbndx = to_smmu_domain(qsmmu->identity)->cfg.cbndx; I don't really get the point of going through the dance of allocating a whole iommu_domain() just to get a context. If you don't want to simply statically reserve a context at probe time, then just allocate from smmu->context_map here (where AFAICS "here" should be in cfg_probe anyway). This is entirely driver-internal, so there shouldn't be any need for IOMMU-API-level stuff to be involved. Robin. > + > + for (i = 0; i < smmu->num_mapping_groups; i++) { > + smr = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_SMR(i)); > + > + if (FIELD_GET(ARM_SMMU_SMR_VALID, smr)) { > + smmu->smrs[i].id = FIELD_GET(ARM_SMMU_SMR_ID, smr); > + smmu->smrs[i].mask = FIELD_GET(ARM_SMMU_SMR_MASK, smr); > + smmu->smrs[i].valid = true; > + > + smmu->s2crs[i].type = S2CR_TYPE_TRANS; > + smmu->s2crs[i].privcfg = S2CR_PRIVCFG_DEFAULT; > + smmu->s2crs[i].cbndx = cbndx; > + smmu->s2crs[i].count++; > + } > + } > + > + return 0; > +} > + > static int qcom_smmu_def_domain_type(struct device *dev) > { > const struct of_device_id *match = > @@ -270,6 +302,7 @@ static const struct arm_smmu_impl qcom_smmu_impl = { > .cfg_probe = qcom_smmu_cfg_probe, > .def_domain_type = qcom_smmu_def_domain_type, > .reset = qcom_smmu500_reset, > + .inherit_mappings = qcom_smmu_inherit_mappings, > }; > > static const struct arm_smmu_impl qcom_adreno_smmu_impl = { > _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 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 9C5DBC43461 for ; Fri, 11 Sep 2020 17:30:52 +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 3DDA6206E6 for ; Fri, 11 Sep 2020 17:30:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oDCXm9cx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3DDA6206E6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com 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-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CB1srwYtikVYMSrori32LiMv7GK7XLX+58bN/dm7o+o=; b=oDCXm9cxOYtTFiyiD+Fmb6UQ9 taUNJ6KjMKN7hF1doXEv26Nw9O+infN5WWHWfI/evu65ZvA0hZSi7ZRQai9DJnQDTZxu8IP7XLDw4 8Z89L2jXdDx7zRQKjJgh2G1puHdkxaJbgAX8A6GnPQR75IIBmHfzqqDQgjxuYtr5zRErn2zDKtm1O vIEpmP6wZBO4KQb8+F7d1n/TtiHj8eKDPbPueWwy+zoBdZbD9gLGikzKqqKJmIUK5z926/KdXQ7AA T/4+UCaln63XT9ph80tIZvGDUPJW/VOf1+mIRPjsAa/pETp0+vp1RZbbTr3+pmZL03KH053s6dHso O/iRyZvSA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGmrh-0002FO-Ev; Fri, 11 Sep 2020 17:29:37 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGmre-0002EW-5Z for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2020 17:29:35 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F213E106F; Fri, 11 Sep 2020 10:29:32 -0700 (PDT) Received: from [10.57.40.122] (unknown [10.57.40.122]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E66493F68F; Fri, 11 Sep 2020 10:29:27 -0700 (PDT) Subject: Re: [PATCH v3 8/8] iommu/arm-smmu-qcom: Setup identity domain for boot mappings To: Bjorn Andersson , Will Deacon , Joerg Roedel , Sai Prakash Ranjan , Jordan Crouse , Rob Clark References: <20200904155513.282067-1-bjorn.andersson@linaro.org> <20200904155513.282067-9-bjorn.andersson@linaro.org> From: Robin Murphy Message-ID: <34b1f9ea-fb16-faac-c288-627b51066968@arm.com> Date: Fri, 11 Sep 2020 18:29:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200904155513.282067-9-bjorn.andersson@linaro.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200911_132934_460260_3F12363F X-CRM114-Status: GOOD ( 31.55 ) 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, iommu@lists.linux-foundation.org, Sibi Sankar , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-09-04 16:55, Bjorn Andersson wrote: > With many Qualcomm platforms not having functional S2CR BYPASS a > temporary IOMMU domain, without translation, needs to be allocated in > order to allow these memory transactions. > > Unfortunately the boot loader uses the first few context banks, so > rather than overwriting a active bank the last context bank is used and > streams are diverted here during initialization. > > This also performs the readback of SMR registers for the Qualcomm > platform, to trigger the mechanism. > > This is based on prior work by Thierry Reding and Laurentiu Tudor. > > Signed-off-by: Bjorn Andersson > --- > > Changes since v2: > - Combined from pieces spread between the Qualcomm impl and generic code in v2. > - Moved to use the newly introduced inherit_mapping op. > > 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 70a1eaa52e14..a54302190932 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c > @@ -12,6 +12,7 @@ > struct qcom_smmu { > struct arm_smmu_device smmu; > bool bypass_broken; > + struct iommu_domain *identity; > }; > > static struct qcom_smmu *to_qcom_smmu(struct arm_smmu_device *smmu) > @@ -228,6 +229,37 @@ static int qcom_smmu_cfg_probe(struct arm_smmu_device *smmu) > return 0; > } > > +static int qcom_smmu_inherit_mappings(struct arm_smmu_device *smmu) > +{ > + struct qcom_smmu *qsmmu = to_qcom_smmu(smmu); > + int cbndx; > + u32 smr; > + int i; > + > + qsmmu->identity = arm_smmu_alloc_identity_domain(smmu); > + if (IS_ERR(qsmmu->identity)) > + return PTR_ERR(qsmmu->identity); > + > + cbndx = to_smmu_domain(qsmmu->identity)->cfg.cbndx; I don't really get the point of going through the dance of allocating a whole iommu_domain() just to get a context. If you don't want to simply statically reserve a context at probe time, then just allocate from smmu->context_map here (where AFAICS "here" should be in cfg_probe anyway). This is entirely driver-internal, so there shouldn't be any need for IOMMU-API-level stuff to be involved. Robin. > + > + for (i = 0; i < smmu->num_mapping_groups; i++) { > + smr = arm_smmu_gr0_read(smmu, ARM_SMMU_GR0_SMR(i)); > + > + if (FIELD_GET(ARM_SMMU_SMR_VALID, smr)) { > + smmu->smrs[i].id = FIELD_GET(ARM_SMMU_SMR_ID, smr); > + smmu->smrs[i].mask = FIELD_GET(ARM_SMMU_SMR_MASK, smr); > + smmu->smrs[i].valid = true; > + > + smmu->s2crs[i].type = S2CR_TYPE_TRANS; > + smmu->s2crs[i].privcfg = S2CR_PRIVCFG_DEFAULT; > + smmu->s2crs[i].cbndx = cbndx; > + smmu->s2crs[i].count++; > + } > + } > + > + return 0; > +} > + > static int qcom_smmu_def_domain_type(struct device *dev) > { > const struct of_device_id *match = > @@ -270,6 +302,7 @@ static const struct arm_smmu_impl qcom_smmu_impl = { > .cfg_probe = qcom_smmu_cfg_probe, > .def_domain_type = qcom_smmu_def_domain_type, > .reset = qcom_smmu500_reset, > + .inherit_mappings = qcom_smmu_inherit_mappings, > }; > > static const struct arm_smmu_impl qcom_adreno_smmu_impl = { > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel