Linux IOMMU Development
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
	Thierry Reding <thierry.reding@gmail.com>
Cc: Robin Murphy <robin.murphy@arm.com>,
	Andy Gross <agross@kernel.org>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Bjorn Andersson <andersson@kernel.org>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Heiko Stuebner <heiko@sntech.de>,
	iommu@lists.linux.dev, Jernej Skrabec <jernej.skrabec@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Joerg Roedel <joro@8bytes.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	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,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Orson Zhai <orsonzhai@gmail.com>, Rob Clark <robdclark@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Niklas Schnelle <schnelle@linux.ibm.com>,
	Krishna Reddy <vdumpa@nvidia.com>, Chen-Yu Tsai <wens@csie.org>,
	Will Deacon <will@kernel.org>, Yong Wu <yong.wu@mediatek.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Kevin Tian <kevin.tian@intel.com>,
	Nicolin Chen <nicolinc@nvidia.com>,
	Steven Price <steven.price@arm.com>
Subject: Re: [PATCH 02/20] iommu/terga-gart: Replace set_platform_dma_ops() with IOMMU_DOMAIN_PLATFORM
Date: Fri, 12 May 2023 05:55:23 +0300	[thread overview]
Message-ID: <4a5ebc65-a384-a8df-c692-ca114f1a018d@gmail.com> (raw)
In-Reply-To: <ZFKXz/HWFkYOJrgT@nvidia.com>

03.05.2023 20:20, Jason Gunthorpe пишет:
> On Wed, May 03, 2023 at 04:43:53PM +0200, Thierry Reding wrote:
> 
>>> The only thing it does is cause dma-iommu.c in ARM64 to use the
>>> dma-ranges from OF instead of the domain aperture. sprd has no
>>> dma-ranges in arch/arm64/boot/dts/sprd.
>>>
>>> Further, sprd hard fails any map attempt outside the aperture, so it
>>> looks like a bug if the OF somehow chooses a wider aperture as
>>> dma-iommu.c will start failing maps.
>>
>> That all sounds odd. of_dma_configure_id() already sets up the DMA mask
>> based on dma-ranges and the DMA API uses that to restrict what IOVA any
>> buffers can get mapped to for a given device.
> 
> Yes, and after it sets up the mask it also passes that range down like this:
> 
>  of_dma_configure_id():
> 	end = dma_start + size - 1;
> 	mask = DMA_BIT_MASK(ilog2(end) + 1);
> 	dev->coherent_dma_mask &= mask;
> 
> 	arch_setup_dma_ops(dev, dma_start, size, iommu, coherent);
> 
> Which eventually goes to:
> 
>  iommu_setup_dma_ops()
>  iommu_dma_init_domain()
> 
> Which then does:
> 
> 	if (domain->geometry.force_aperture) {
> 
> And if not set uses the dma_start/size parameter as the actual
> aperture. (!?)
> 
> Since sprd does this in the iommu driver:
> 
> 	dom->domain.geometry.aperture_start = 0;
> 	dom->domain.geometry.aperture_end = SZ_256M - 1;
> 
> And it is serious about enforcing it during map:
> 
> 	unsigned long start = domain->geometry.aperture_start;
> 	unsigned long end = domain->geometry.aperture_end;
> 
> 	if (iova < start || (iova + size) > (end + 1)) {
> 			return -EINVAL;
> 
> We must see the dma_start/size parameter be a subset of the aperture
> or eventually dma-iommu.c will see map failures.
> 
> I can't see how this is can happen, so it looks like omitting
> force_aperture is a mistake not a deliberate choice. I'll make a patch
> and see if the SPRD folks have any comment. If there is no reason I
> can go ahead and purge force_aperture and all the dma_start/size
> passing through arch_setup_dma_ops().
> 
>>> Thus, I propose we just remove the whole thing. All drivers must set
>>> an aperture and the aperture is the pure HW capability to map an
>>> IOPTE at that address. ie it reflects the design of the page table
>>> itself and nothing else.
>>
>> Yeah, that sounds reasonable. If the aperture represents what the IOMMU
>> supports. Together with each device's DMA mask we should have everything
>> we need.
> 
> Arguably we should respect the dma-ranges as well, but I think that
> should come up from the iommu driver via the get_resv_regions() which
> is the usual place we return FW originated information.
> 
>> For Tegra GART I think there's indeed no use-cases at the moment. Dmitry
>> had at one point tried to make use of it because it can be helpful on
>> some of the older devices that were very memory-constrained. That
>> support never made it upstream because it required significant changes
>> in various places, if I recall correctly. For anything with a decent
>> enough amount of RAM, CMA is usually a better option.
> 
> So the actual use case of this HW is to linearize buffers? ie it is a
> general scatter/gather engine?
> 
>> This has occasionally come up in the past and I seem to remember that it
>> had once been proposed to simply remove tegra-gart and there had been no
>> objections. Adding Dmitry, if he doesn't have objections to remaving it,
>> neither do I.
> 
> Dmitry, please say yes and I will remove it instead of trying to carry
> it. The driver is almost 10 years old at this point, I'm skeptical
> anyone will need it on a 6.2 era kernel..

You probably missed that support for many of 10 years old Tegra2/3
devices was added to kernel during last years.

This GART isn't used by upstream DRM driver, but it's used by downstream
kernel which uses alternative Tegra DRM driver that works better for
older hardware.

If it's too much burden to maintain this driver, then feel free to
remove it and I'll continue maintaining it in downstream myself.
Otherwise I can test your changes if needed.


  reply	other threads:[~2023-05-12  2:55 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-01 18:02 [PATCH 00/20] iommu: Make default_domain's mandatory Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 01/20] iommu: Add IOMMU_DOMAIN_PLATFORM Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 02/20] iommu/terga-gart: Replace set_platform_dma_ops() with IOMMU_DOMAIN_PLATFORM Jason Gunthorpe
2023-05-03  9:17   ` Robin Murphy
2023-05-03 11:01     ` Jason Gunthorpe
2023-05-03 12:01       ` Robin Murphy
2023-05-03 13:45         ` Jason Gunthorpe
2023-05-03 14:43           ` Thierry Reding
2023-05-03 17:20             ` Jason Gunthorpe
2023-05-12  2:55               ` Dmitry Osipenko [this message]
2023-05-12 16:49                 ` Jason Gunthorpe
2023-05-12 18:12                   ` Robin Murphy
2023-05-12 20:52                     ` Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 03/20] iommu/s390: " Jason Gunthorpe
2023-05-02 17:57   ` Niklas Schnelle
2023-05-01 18:02 ` [PATCH 04/20] iommu/fsl_pamu: " Jason Gunthorpe
2023-05-03 10:57   ` Robin Murphy
2023-05-03 12:54     ` Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 05/20] iommu: Allow an IDENTITY domain as the default_domain in ARM32 Jason Gunthorpe
2023-05-03 13:50   ` Robin Murphy
2023-05-03 14:23     ` Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 06/20] iommu/exynos: Implement an IDENTITY domain Jason Gunthorpe
2023-05-03 15:31   ` Robin Murphy
2023-05-04 14:19     ` Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 07/20] iommu/tegra-smmu: " Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 08/20] iommu/tegra-smmu: Support DMA domains in tegra Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 09/20] iommu/omap: Implement an IDENTITY domain Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 10/20] iommu/msm: " Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 11/20] iommu/mtk_iommu_v1: " Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 12/20] iommu: Remove ops->set_platform_dma_ops() Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 13/20] iommu/qcom_iommu: Add an IOMMU_IDENTITIY_DOMAIN Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 14/20] iommu/ipmmu: " Jason Gunthorpe
2023-05-01 18:02 ` [PATCH 15/20] iommu/mtk_iommu: " Jason Gunthorpe
2023-05-01 18:03 ` [PATCH 16/20] iommu/sun50i: " Jason Gunthorpe
2023-05-03 15:54   ` Robin Murphy
2023-05-03 16:49     ` Jason Gunthorpe
2023-05-01 18:03 ` [PATCH 17/20] iommu: Require a default_domain for all iommu drivers Jason Gunthorpe
2023-05-01 18:03 ` [PATCH 18/20] iommu: Add ops->domain_alloc_paging() Jason Gunthorpe
2023-05-03 17:17   ` Robin Murphy
2023-05-03 19:35     ` Jason Gunthorpe
2023-05-04 12:35       ` Niklas Schnelle
2023-05-04 13:14         ` Jason Gunthorpe
2023-05-01 18:03 ` [PATCH 19/20] iommu: Convert simple drivers with DOMAIN_DMA to domain_alloc_paging() Jason Gunthorpe
2023-05-01 18:03 ` [PATCH 20/20] iommu: Convert remaining simple drivers " Jason Gunthorpe
2023-05-02 14:52   ` Niklas Schnelle
2023-05-02 15:25     ` Jason Gunthorpe
2023-05-02 18:02       ` Niklas Schnelle
2023-05-01 21:34 ` [PATCH 00/20] iommu: Make default_domain's mandatory Heiko Stübner
2023-05-01 22:40   ` Jason Gunthorpe
2023-05-01 22:10 ` Heiko Stübner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a5ebc65-a384-a8df-c692-ca114f1a018d@gmail.com \
    --to=digetx@gmail.com \
    --cc=agross@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=andersson@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=heiko@sntech.de \
    --cc=iommu@lists.linux.dev \
    --cc=jernej.skrabec@gmail.com \
    --cc=jgg@nvidia.com \
    --cc=jonathanh@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux-tegra@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=nicolinc@nvidia.com \
    --cc=orsonzhai@gmail.com \
    --cc=robdclark@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=samuel@sholland.org \
    --cc=schnelle@linux.ibm.com \
    --cc=steven.price@arm.com \
    --cc=thierry.reding@gmail.com \
    --cc=vdumpa@nvidia.com \
    --cc=wens@csie.org \
    --cc=will@kernel.org \
    --cc=yong.wu@mediatek.com \
    --cc=zhang.lyra@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox