From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31EDA125B4 for ; Mon, 24 Jul 2023 22:22:14 +0000 (UTC) Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-4faaaa476a9so7505100e87.2 for ; Mon, 24 Jul 2023 15:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690237333; x=1690842133; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=358vZqiTvej61X45civfUiKJd7hpr9GfM3mB5tO/1oY=; b=CWyKsn+fyo8A461uDHxlWqqNhJomz0p6jdiOowLbkzTOopNmfoNhBambSUtyEO5LNP 8ZQxB7OKJaeWWTdMhye3/FhUuSUb6YLLGS6tLS8eTeyjps6Os2KMTEOOdQUN1ADiCs3y tA0O7NC2tWbxVi7BepJAcNSNZkhixC7NKrkyP0vhsnEwjCiYipyYGlcql329pVK4BS47 IfmJj/dcHadTRR7pUVMVGXVFDeOJiREG11Vvrqk5HFB7zqjuhkzKS+VYHT76+UwT2Gws qaFPHFJZm9lmjfRt0gfHRI/55a+4obs2xjmHv1pvycZ69nHjRtSM9uYLS680TirWHpGK c0cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690237333; x=1690842133; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=358vZqiTvej61X45civfUiKJd7hpr9GfM3mB5tO/1oY=; b=YQDCIy1OY0IlUNClqy7hi6XlpJHDcuUxvhNQqu/SqEa/7qJeMedR6G4qs2DW7m9CI5 OBCwTA71FTmQ3/+7vAGwnxnrHkP6ohekSXuZp9b+XxmSvu38A2VmO14NoklQtZ+plqbg u9llwN2z0oBria32QYr8dDnvktwvQ3pJrJwbqIkhw6UYN5mQp1YbZMPXh+Z6WwZysPOo vPwNKK3a+I6Pd3e6ERkyLhRKVDBnk9+nMatNj8wrMP0sqa7NjcRGt9wlU/Uqz3fgRx7H kstDUmRuUup+jyz3UfBQKDjQIRDPKQsZENuOKRotn682yDMn4id9GzWxcXjdlaOayjQS Z7ig== X-Gm-Message-State: ABy/qLYpkMN2CPdekldd/TsKzFa1P9zcKF6o+NQ405aFP4aeOUwmP2dC DfPeEsAr09YonjmrXlK+9zJyjQ== X-Google-Smtp-Source: APBJJlGRGPfacjmUq1tdWpenzld24E4eJsyR1C29jO0mKIDTugwb8qJZ+ixEzpUc6MmlTv/TGWeMgQ== X-Received: by 2002:a05:6512:2036:b0:4f6:d7b:2f19 with SMTP id s22-20020a056512203600b004f60d7b2f19mr5787071lfs.24.1690237332390; Mon, 24 Jul 2023 15:22:12 -0700 (PDT) Received: from ?IPV6:2001:14ba:a0db:1f00::8a5? (dzdqv0yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a0db:1f00::8a5]) by smtp.gmail.com with ESMTPSA id x27-20020ac25ddb000000b004fbb69d8791sm2391586lfq.79.2023.07.24.15.22.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jul 2023 15:22:11 -0700 (PDT) Message-ID: <7b250095-8245-53be-e593-cecbc3cc6763@linaro.org> Date: Tue, 25 Jul 2023 01:22:11 +0300 Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v5 14/25] iommu/msm: Implement an IDENTITY domain Content-Language: en-GB To: Jason Gunthorpe , Andy Gross , Alim Akhtar , Bjorn Andersson , AngeloGioacchino Del Regno , Baolin Wang , Christophe Leroy , Gerald Schaefer , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , Kevin Tian , Konrad Dybcio , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, Russell King , linuxppc-dev@lists.ozlabs.org, Matthias Brugger , Matthew Rosato , Michael Ellerman , Nicholas Piggin , Orson Zhai , Rob Clark , Robin Murphy , Samuel Holland , Thierry Reding , Krishna Reddy , Chen-Yu Tsai , Will Deacon , Yong Wu , Chunyan Zhang Cc: Lu Baolu , Dmitry Osipenko , Marek Szyprowski , Nicolin Chen , Niklas Schnelle , Steven Price , Thierry Reding References: <14-v5-d0a204c678c7+3d16a-iommu_all_defdom_jgg@nvidia.com> From: Dmitry Baryshkov In-Reply-To: <14-v5-d0a204c678c7+3d16a-iommu_all_defdom_jgg@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 24/07/2023 20:22, Jason Gunthorpe wrote: > What msm does during omap_iommu_set_platform_dma() is actually putting the typo: msm driver doesn't use/provide omap_iommu_set_platform_dma(). > iommu into identity mode. > > Move to the new core support for ARM_DMA_USE_IOMMU by defining > ops->identity_domain. > > This driver does not support IOMMU_DOMAIN_DMA, however it cannot be > compiled on ARM64 either. Most likely it is fine to support dma-iommu.c > > Signed-off-by: Jason Gunthorpe > --- > drivers/iommu/msm_iommu.c | 23 +++++++++++++++++++---- > 1 file changed, 19 insertions(+), 4 deletions(-) > > diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c > index 79d89bad5132b7..26ed81cfeee897 100644 > --- a/drivers/iommu/msm_iommu.c > +++ b/drivers/iommu/msm_iommu.c > @@ -443,15 +443,20 @@ static int msm_iommu_attach_dev(struct iommu_domain *domain, struct device *dev) > return ret; > } > > -static void msm_iommu_set_platform_dma(struct device *dev) > +static int msm_iommu_identity_attach(struct iommu_domain *identity_domain, > + struct device *dev) > { > struct iommu_domain *domain = iommu_get_domain_for_dev(dev); > - struct msm_priv *priv = to_msm_priv(domain); > + struct msm_priv *priv; > unsigned long flags; > struct msm_iommu_dev *iommu; > struct msm_iommu_ctx_dev *master; > - int ret; > + int ret = 0; > > + if (domain == identity_domain || !domain) > + return 0; > + > + priv = to_msm_priv(domain); > free_io_pgtable_ops(priv->iop); > > spin_lock_irqsave(&msm_iommu_lock, flags); > @@ -468,8 +473,18 @@ static void msm_iommu_set_platform_dma(struct device *dev) > } > fail: > spin_unlock_irqrestore(&msm_iommu_lock, flags); > + return ret; > } > > +static struct iommu_domain_ops msm_iommu_identity_ops = { > + .attach_dev = msm_iommu_identity_attach, > +}; > + > +static struct iommu_domain msm_iommu_identity_domain = { > + .type = IOMMU_DOMAIN_IDENTITY, > + .ops = &msm_iommu_identity_ops, > +}; > + > static int msm_iommu_map(struct iommu_domain *domain, unsigned long iova, > phys_addr_t pa, size_t pgsize, size_t pgcount, > int prot, gfp_t gfp, size_t *mapped) > @@ -675,10 +690,10 @@ irqreturn_t msm_iommu_fault_handler(int irq, void *dev_id) > } > > static struct iommu_ops msm_iommu_ops = { > + .identity_domain = &msm_iommu_identity_domain, > .domain_alloc = msm_iommu_domain_alloc, > .probe_device = msm_iommu_probe_device, > .device_group = generic_device_group, > - .set_platform_dma_ops = msm_iommu_set_platform_dma, > .pgsize_bitmap = MSM_IOMMU_PGSIZES, > .of_xlate = qcom_iommu_of_xlate, > .default_domain_ops = &(const struct iommu_domain_ops) { -- With best wishes Dmitry