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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 464D1C04A6A for ; Mon, 14 Aug 2023 04:33:28 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=fLwqjgxu; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RPM3B5Bswz30g8 for ; Mon, 14 Aug 2023 14:33:26 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=fLwqjgxu; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.intel.com (client-ip=192.55.52.136; helo=mgamail.intel.com; envelope-from=baolu.lu@linux.intel.com; receiver=lists.ozlabs.org) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RPM2C3lY5z2yWD for ; Mon, 14 Aug 2023 14:32:33 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691987555; x=1723523555; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=fWPuhgNRuF9EDk2VHIj6Dav1o+mGAtD4mz3RnQYAh5c=; b=fLwqjgxuIA+U7PSwCD3WpZBAThXt3zLw4GU8Pk2pdfJZnyerNY33Nruo e3mguuyuU9OSX1vcMvZeRGnzw/E9/apPEoHojiWWNueRoEUvfdJrCaM1U 0LzOcn5bRppCHHPZPtjH8K6fMzi3JPhYZ2nv6+lI0iBEr+/bDLWeAoveW B18H9KXPfj40n2sZvXVFwQU2hSLmcKbFdkjDRMMU9gW8xEnPEFjtLPOen 9L8CxfEbazIXdlmTPDtFt0JAIt+ZzZB+PhAAtgIUvC72lSkS0/PClZBOZ 2AQYcK+Eyqv1G9tjABMXpBgOfQ1qzsZPdINyBYT8FfVTlfR01Yn4xwQwm Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="351560050" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="351560050" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2023 21:32:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="736407734" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="736407734" Received: from blu2-mobl.ccr.corp.intel.com (HELO [10.255.29.49]) ([10.255.29.49]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2023 21:32:17 -0700 Message-ID: <875b8f32-55ca-d2b4-dd0e-f2b7818dfa41@linux.intel.com> Date: Mon, 14 Aug 2023 12:32:14 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH v6 09/25] iommu: Allow an IDENTITY domain as the default_domain in ARM32 Content-Language: en-US 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 References: <9-v6-e8114faedade+425-iommu_all_defdom_jgg@nvidia.com> From: Baolu Lu In-Reply-To: <9-v6-e8114faedade+425-iommu_all_defdom_jgg@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thierry Reding , Niklas Schnelle , Steven Price , Nicolin Chen , Dmitry Osipenko , baolu.lu@linux.intel.com, Marek Szyprowski Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 2023/8/3 8:07, Jason Gunthorpe wrote: > Even though dma-iommu.c and CONFIG_ARM_DMA_USE_IOMMU do approximately the > same stuff, the way they relate to the IOMMU core is quiet different. > > dma-iommu.c expects the core code to setup an UNMANAGED domain (of type > IOMMU_DOMAIN_DMA) and then configures itself to use that domain. This > becomes the default_domain for the group. > > ARM_DMA_USE_IOMMU does not use the default_domain, instead it directly > allocates an UNMANAGED domain and operates it just like an external > driver. In this case group->default_domain is NULL. > > If the driver provides a global static identity_domain then automatically > use it as the default_domain when in ARM_DMA_USE_IOMMU mode. > > This allows drivers that implemented default_domain == NULL as an IDENTITY > translation to trivially get a properly labeled non-NULL default_domain on > ARM32 configs. > > With this arrangment when ARM_DMA_USE_IOMMU wants to disconnect from the > device the normal detach_domain flow will restore the IDENTITY domain as > the default domain. Overall this makes attach_dev() of the IDENTITY domain > called in the same places as detach_dev(). > > This effectively migrates these drivers to default_domain mode. For > drivers that support ARM64 they will gain support for the IDENTITY > translation mode for the dma_api and behave in a uniform way. > > Drivers use this by setting ops->identity_domain to a static singleton > iommu_domain that implements the identity attach. If the core detects > ARM_DMA_USE_IOMMU mode then it automatically attaches the IDENTITY domain > during probe. > > Drivers can continue to prevent the use of DMA translation by returning > IOMMU_DOMAIN_IDENTITY from def_domain_type, this will completely prevent > IOMMU_DMA from running but will not impact ARM_DMA_USE_IOMMU. > > This allows removing the set_platform_dma_ops() from every remaining > driver. > > Remove the set_platform_dma_ops from rockchip and mkt_v1 as all it does > is set an existing global static identity domain. mkt_v1 does not support > IOMMU_DOMAIN_DMA and it does not compile on ARM64 so this transformation > is safe. > > Tested-by: Steven Price > Tested-by: Marek Szyprowski > Tested-by: Nicolin Chen > Signed-off-by: Jason Gunthorpe > --- > drivers/iommu/iommu.c | 26 +++++++++++++++++++++++--- > drivers/iommu/mtk_iommu_v1.c | 12 ------------ > drivers/iommu/rockchip-iommu.c | 10 ---------- > 3 files changed, 23 insertions(+), 25 deletions(-) Reviewed-by: Lu Baolu Best regards, baolu