From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796001010; b=HtJYx8/TtYWy+oj+C0Hs77mKEDSL/ORK+pRCGF6rPILDFuqOJuFoq/lJ/Ezhh6JxLKpY hdfGFBp8lpSZDppmq49sXE7Na9BL3ofRrYCfX0fc3bKN5yJgiRlB4QIhDRNfiWGm3+Zqr lXqLn2/c67esJPpAh/dng7x2fIK4IID11wLAZ4OUa+NB654PYdoypzjEBwAFiCijXk7di 8jk3IeCWq+UTEx78vAnQwKjcI5ZZqt90z/0Xd7itNmJj0tCtKCTpce2HqBccNJr2/jiKr 8LMuwVB5OVxQSn2qAhPG1RE0cM8UBMeQt3diwYTFEKxBGBXFf2grrZMWCctZVQoUrTQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796001010; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:Content-Language:Autocrypt:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=7tLgjNTW6TIdQGCui4RMuFRv3Ud8OmRz/izeX77eo4E=; b=hJky1JRJi08V0JfxgDOqXi0pRuhcw0w8ZfiKjPxuXPg2Bn056xErHCKj5wKqGyeIFAa3 ylD9PUwCwnde6/tjQeOH+qtj3V3UicMI7XPcfFRPeHpd51f+lYde4Wfg62KdhqB+tzPpb 7l8ytZFc9KcSd9kMuDcgD2zn692CNiN+8Jrww3CWvQB1E845ZsN0qgg07usGqwEdXoMm5 9mj/jPpHTggncMcxdIJyzcV6x6DoBB1gJL71OUI59py+r6aoT81w1gfRJq102h+UX8Fo9 /zLj9rvV67LNhKN4CvbK+tyBoGcMe7QeXptBylUDb9VTmVZJYeiHH9RwSbMWowb+uZQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lI1NOrp0; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DE92606A325; Mon, 30 Nov 2026 01:10:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lI1NOrp0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 163561F000C1; Mon, 30 Nov 2026 01:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796001009; bh=7tLgjNTW6TIdQGCui4RMuFRv3Ud8OmRz/izeX77eo4E=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=lI1NOrp0TCrsVgFWA+ocdYivG6HyHbTJgEq6fK/hRQoOP/6HAvkR9DR60zWsWO2FT dtS8OGiluZ/fcgsFwXrXajD0LGOBAPI/2dVdiQyG2Y+fyibcVLjNONP8WtqKK+gNgm UI8hLNYFZ2HECxDeXm8CgPOZAIICNfWSczbEkdsNvWM5WQTN+cX3XGkjwMEKwrF+ut vChP9Y8dNUOteVY69EeG34/04sMryrNavwUsNBpLWPflJVnfzni1s1J3GksDwV0HPb ibSHJ0/MNMrJ3DBE1UoRKgZJL3FF2xhoI7wbiIr0TE/RYsefl4OH0DuVgAkQjNNvaF Urwu/bNEaJrBQ== Message-ID: <21a54a2a-9df8-49c7-a7a2-e0cadd075270@kernel.org> Date: Mon, 30 Nov 2026 01:10:03 +0000 X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/4] media: venus: use dma_iova_size() to check the reserved IOVA size To: Vikash Garodia , Jason Gunthorpe Cc: Marek Szyprowski , iommu@lists.linux.dev, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Robin Murphy , Joerg Roedel , Will Deacon , Leon Romanovsky , Sibi Sankar , Honglei Huang , prakash.gupta@oss.qualcomm.com, Alex Williamson , Dikshita Agarwal , Abhinav Kumar , Mauro Carvalho Chehab , Hans Verkuil , stable@vger.kernel.org References: <20261127115849.2780625-1-m.szyprowski@samsung.com> <20261127115849.2780625-2-m.szyprowski@samsung.com> <20261127142912.GK114472@nvidia.com> <20261127172626.GQ114472@nvidia.com> <0b76ccad-877d-41b9-a7a6-02266a7bfd56@oss.qualcomm.com> From: Bryan O'Donoghue Content-Language: en-GB Autocrypt: addr=bod@kernel.org; keydata= xsFNBGRJNSgBEADD7Vm2ZFa+v+JGJ2QYTJqQAkqis/uOHkhdFNXqpBarVBd47QU/DMNU5Rxg jedMQEmHoeDbJ6UOpjbrUQ63c5sgG1JbroHJJctwsEI75OOlekMuebEbjIJBLfgENGwPBMHv piv5TgCWr0VgYaXfp2eh2LINFywzqj823HiDPibQAXDrjzvF1ogksi/6cQZs8d4if8YQkLOr YISFouG+eR0nN1I7mUfIddXOWu6lJeTyqbWVurv58k2ekIXKaOC9ixLHFbcfYV0hOgRaTwQC B8CYF9nfqZla19iItfsN9QxN+ZdQjcRoYipp6HPCMfJlKH7GfaFcW93LKc4DKJ2lVL+pg/OQ lythZbjRPY492NG9kZ65aYstCs90uhMUEVVPuGUw7wBEku+6IEwZfrbMVKeWzLlPyM4Hv9hM 8ktxSmxWsPTPqpBC8eyeAQLalMELAyVcZlkaCtEcbj7w4l/JkYz+4l37obG8ZD+B34udBUUz MsAJ8foDFrBh2MOFA3hxD6G90D23mmWsri7pnKA2tZs92aQX7Ee+FbCyg6g5ln62Sq83ZDbf 53DdBs55EVp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7uCFzFqN6/qey X3oFfPgkULMdiHofPAL1OskZSTzGPSfTYRE46NCJw8yoZBQ/oOyWeqaUQbK0wmW/g81wm8p7 LKSGEglMpiX07M1AotgvylN5C8fjbouoK+/RAMsXkk8jba6rPfuuXPaDjCyyKn6zSVHETnHW 3AJbgVY50T8STpnxayBQvWbCvu+6NOEjXCbyaOJig+5l0zlGN9XHjdANXC5HnwmyaGRL9YDq Jh2nVXVJDincOdQRdKcJjYLqaOAoWrYWSDi1iZGspHBTDrnOvfMQzzHY In-Reply-To: <0b76ccad-877d-41b9-a7a6-02266a7bfd56@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 29/11/2026 14:19, Vikash Garodia wrote: > > On 11/27/2026 10:56 PM, Jason Gunthorpe wrote: >> On Fri, Nov 27, 2026 at 05:21:35PM +0000, Bryan O'Donoghue wrote: >>> On 27/11/2026 14:29, Jason Gunthorpe wrote: >>>> On Fri, Nov 27, 2026 at 12:58:45PM +0100, Marek Szyprowski wrote: >>>>> The IOVA reservation code compares dma_iova_state::__size directly with >>>>> the requested chunk size. __size is internal to the DMA IOVA API and may >>>>> carry flags in its upper bits, so use the dma_iova_size() accessor >>>>> instead. >>>> >>>> WTF is this even doing? >>>> >>>> Fix this by reserving the 0-600MB range, below the boundary the >>>> non-pixel stream cannot address, using dma_iova_try_alloc() so the >>>> IOMMU-DMA core never hands that range out to a real DMA mapping. This >>>> reserves only IOVA space, it does not allocate any physical memory. >>>> >>>> That isn't what this API is for, and it isn't how it even works! It is >>>> pure luck that the first call to it happens to take out the lower >>>> address space. >>>> >>>> We even had a long discussion about this driver and this need in >>>> another thread and this is the hack job you guys merged? >>> >>> Have to say I wasn't aware of an objection from you, I don't think I was on >>> that thread. >> >> Nobody ever shared this insane thing with us. Seriously, this isn't >> even remotely using these APIs for what they are for. Nobody thought >> "hey this seems like a creative use of APIs, lets ask someone" ? >> > > Sure, its a miss to add the maintainers of the file which defines the > api. Relying on b4 alone was not the right approach. Noted for any > future submissions. > >>> It would be possible to reserve this IOVA range in DT so given what you've >>> highlighted I think this and the Iris commit should be reverted and the DT >>> constraint implemented. >> >> That was the other thread, obviously using DT to describe a hardware >> issue is the correct choice. But there was some problem where they >> also wanted to split the SID space using DT and then the DT mechansim >> doesn't work because the whole thing becomes too hacky :\ >> > > We discussed this earlier here[1] and concluded DT as the right place to > address this. > The DT approach is waiting for the series [2] to land, which should take > care of the reservation in a definite way. > > [1] > https://lore.kernel.org/all/c7b956a9-d3e8-4e18-b780-5d08f5cd2ca1@kernel.org/ > > [2] > https://lore.kernel.org/all/20261120-add_iommu_ranges-v8-0-d90486973b73@oss.qualcomm.com/ The other direction is to have venus and iris register their own IOMMU domain and then the address allocator they will provide places the floor at 600MB for the SID. Jason, do you think this is the right approach ? drivers/media/platform/nvidia/tegra-vde/ vde->domain = iommu_paging_domain_alloc(dev); if (IS_ERR(vde->domain)) { err = PTR_ERR(vde->domain); vde->domain = NULL; goto put_group; } err = iova_cache_get(); if (err) goto free_domain; order = __ffs(vde->domain->pgsize_bitmap); init_iova_domain(&vde->iova, 1UL << order, 0); err = iommu_attach_group(vde->domain, vde->group); if (err) goto put_iova; /* * We're using some static addresses that are not accessible by VDE * to trap invalid memory accesses. */ shift = iova_shift(&vde->iova); iova = reserve_iova(&vde->iova, 0x60000000 >> shift, 0x70000000 >> shift); if (!iova) { err = -ENOMEM; goto detach_group; } Vikash I can prototype this up it, reverting Vishnu's patch will bring back the reset and the upstream code now relies on dodgy behaviours. If iommu-ranges lands, we can go back to using the default IOMMU domain and drop rolling our own allocations. --- bod