From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 0D17341E6C5 for ; Mon, 24 Aug 2026 13:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787576853; cv=none; b=ts62IinBPQhFvlIhpRNYWns4XxWghfZuElAmTDUjrlAqE9Czk4fvedy6hzI6/qLYNLVTjnYKcJ5v2Sd4EcE6/6MGRdh+UF49ap2ihYFZNcWl0B6sMOBJTcjOCSL0eqJzzd2KMEVWX6qFxeRInlNsTxszST0uvTkFlQuqkukSYvg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787576853; c=relaxed/simple; bh=u5ihNkizXxWzyF5GSE/VjUlcZrXmF+6zr4JEzwJ38CA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Tr09R+3Yp4+U2TcCtAKSaH/MWkskNN2pthPwDtZwHFitrUUggAtYxdg7aXPT/ukrxOckyJ4ZwuH4NO8xe2jshWE0Bjm3Q/PHl0LDEph3RoQK1BokpGJM/Gc/ueSWEFnPwJRkFTKqZuSDGv771IoVzwdTfhvd5NlpyKa5/woFtP0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=VasDoPJ+; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VasDoPJ+" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4953de5be0aso21663875e9.0 for ; Mon, 24 Aug 2026 06:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1787576849; x=1788181649; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=II0EHdpiWVifHn+uIz31c6Jp5mdC3hunRFCnEAwNy/g=; b=VasDoPJ+9W3n6kop+crjHXP7TptzbDGsgfbm9Uk4NKXGd6OGSugla7VlitMZw98TK9 NVgdy1g8rya6Yqv+lAwmQAA7dqQjHTRt75BtuIha0W9mgx+ggKWWMmmUisJSlAMrinEf e3/R/ELvI9YYRlq7rCg1cATN/Ub4gE0rcWwcfO9hgfAQupcKHPbzKdmaIZZ0D9++h+oY dgvGtWeYGOvPvZVQeL6A7w6M0zsypu09XmYrqR3Iwv/cCfnEnCvT+xc+/+KUwzYHtU8o EpfP/3KzoKSiw0GhTSCSkj4lZZjidkJLF+3SH2bAzDuzawyPRDr7Y4fQ0iJXmjmixqg9 8Dog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787576849; x=1788181649; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=II0EHdpiWVifHn+uIz31c6Jp5mdC3hunRFCnEAwNy/g=; b=WkX6nd3tvSxuFlKNQMP8cDODDRDJTai8otqtztFTdlLsjc/fvZsy1nc60a2ACUiwPN L1Dzq0+GukC/uVNOwi50uCAI0z9UbayZNhQBcxwCVoSxBCcz8E3+hjQc5kAmYgZ7pCwp /vhS+pLGryRZzXyuabkm5Vk1jGzgA49pNmKG11kxaU9lHuMrgIxp56ynjqW16+NFqEF+ hoUnaT3xXmuk/HoUqU2F8xMv+n/7zBfbm4jQNhYmGHr5IfhUGUX32MkXvN2UffzlTFUV MYEuFjm/BGe2X7+S03J6gU9iRrii7z/sDYBJ+vz6urTmXwmGaP2G+90myk8VVvpmxWdl QZAw== X-Forwarded-Encrypted: i=1; AHgh+RpLWqfyC17IBIw5/o3N7QzCNNMCA187nRh08zNnjVgPA1vMYFw5VJzgbqB+Wg+JXnosjCqzSRmx6T4Iqw==@vger.kernel.org X-Gm-Message-State: AFuF++kFZix5rdwbvjuXcdVj5z6iVsMP5LzPfww2XUqrAtW+olwgxjvN wg1fs40rOAW12ZJXzxyOHnddWqvNLb9DEmmAXE1NFS4FSGwNmBOKcnXCff3JEEqAHg== X-Gm-Gg: AR+sD13z5e8grO9dpj+jRhzJ3WyLIg/y/IArPT6pEWa3gW6T+RzrtyGvTd9zWORhwMC IiYGWEdbk6i+en52bok+lTMBNKcg/koMRi0ucsqAdyP/bPvqdY7aImrXvLTNrtPkVVd/zqCJin6 USUdnoxYhZmN5ZvxjWUNwzzR1fuCG7PR2utbPO+E/V2it//H0HuJHaQ7k1IKAiFRyk4JrCeyQkl nRFF12Y/Xl7mTezzSpfB6cw1h8kH9QiEZ/NjNASa2JgVbQC6lm284jOPdQEhEYCaXuqqw/R8OLm gR/PIGIiw/FacWoN8WSdlF6hKj0/+tjGLZvkuNFAZiWnSN50+HOOpqjP5sIH4wptpaOOQTINKXv k8JvL9eLLtq7E7/QQSU1KBhQ8q1W76AfjWza8EiGLHUVVpUSELJQdjsLPLaSXwArOPA0gW+UGZu qW1l/EKABplB18u9iMIuoLlswDQeLAdS+EaVJ5aKrDsknvz7hCokZ4MZgC8naM1elU1QMQLL6hG M6RJwyLvNoOFLV+F0vQ6S+Wp6+N81Rr X-Received: by 2002:a05:600c:8b76:b0:499:8c68:a3aa with SMTP id 5b1f17b1804b1-499b8475133mr350361245e9.13.1787576848494; Mon, 24 Aug 2026 06:07:28 -0700 (PDT) Received: from google.com (135.91.155.104.bc.googleusercontent.com. [104.155.91.135]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499c355e1ddsm85389525e9.5.2026.08.24.06.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2026 06:07:27 -0700 (PDT) Date: Mon, 24 Aug 2026 14:07:23 +0100 From: Vincent Donnefort To: Thierry Reding Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Hunter , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Sowjanya Komatineni , Luca Ceresoli , Mikko Perttunen , Yury Norov , Rasmus Villemoes , Russell King , Alexander Gordeev , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Marek Szyprowski , Robin Murphy , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Christian =?iso-8859-1?Q?K=F6nig?= , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Catalin Marinas , Will Deacon , Chun Ng , Thierry Reding , devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux.dev, linaro-mm-sig@lists.linaro.org, linux-trace-kernel@vger.kernel.org, Thierry Reding , pavan.kondeti@oss.qualcomm.com Subject: Re: [PATCH v4 07/10] dma-buf: heaps: Add support for Tegra VPR Message-ID: References: <20260807-tegra-vpr-v4-0-5510d16af89e@nvidia.com> <20260807-tegra-vpr-v4-7-5510d16af89e@nvidia.com> Precedence: bulk X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Aug 21, 2026 at 09:44:49PM +0100, Vincent Donnefort wrote: > [...] > > > > > Interesting. I had been thinking more along the lines of adding this > > > > directly into memblock using a new entry in enum memblock_flags. None of > > > > the existing ones seem to do what we need here, though some are closely > > > > related. MEMBLOCK_SECURE or MEMBLOCK_PROTECTED are quite specific and > > > > don't necessarily mean that we need the mapping to be page-granular, so > > > > MEMBLOCK_PAGE_GRANULAR is perhaps clearer. > > > > > > I thought it would be interesting to not have to modify memblock since it is > > > used for all architectures, while the DT is at least slightly less widespread. > > > > This isn't something that is DT specific. On the Tegra side, I suspect > > we might need this on ACPI platforms eventually, too. And it's not an > > ARM specific feature either. Other platforms could use shared carveouts, > > too. > > Agreed, and actually I have tried the memblock version and it looks quite neat! > > I will share what I have after the merge-window. > > > > > > Also, cma_init_reserved_mem() could use an order 9. In that case PTE-level isn't > > > necessary and we could just use PMD-level. Extending that support would be more > > > cumbersome with a memblock flag than with a callback. > > > > > > rmem_cma_setup() hardcoding an order 0, perhaps this isn't really a problem at > > > the moment? > > > > How so? memblock is really just used as a way of backing the CMA. How > > CMA subdivides it doesn't really matter, right? > > > > Or are you suggesting that if we use an entire PMD as granularity, we > > could equally well remove the entire PMD from the linear mapping instead > > of doing it page-by-page? I think that'd work really well for at least > > VPR, since it is 1 MiB aligned anyway. Using a granularity of 2 MiB is > > easily doable. > > Yes, that is what I meant. We could easily force a PMD-level mapping instead of > PTE-level one. But then that means declaring another memblock flag. > > > > > For anything that doesn't require a single contiguous area to be > > protected this might be a bit more challenging since it potentially > > wastes a lot of memory. On the other hand, a lot of this is heavily > > custom code anyway, so the entire stack could be modified to make > > efficient use of this (i.e. userspace could allocate a larger chunk > > for a pool of buffers, etc.). > > > > > But yeah, the alternative is to create a "memblock_mark_forcepte" (it seems > > > memblock_setclr_flag does split memblocks) and let of_reserved_mem call that > > > function. Finally the arm64 mmu code can simply check for the flag before > > > calling __map_memblock. Perhaps it isn't that bad in the end? > > > > It sounds like the right level of abstraction to me. But I'm not too > > familiar with this code, so it'd be good to hear from the MM and/or ARM > > maintainers what they think about this. > > > > [...] > > > I had in mind to extend "shared-dma-pool" to handle > > > set_direct_map_invalid_noflush()/set_direct_map_default_noflush() based on an > > > option. But perhaps it is better to create another separate driver. And VPR > > > needing a specific dma-heap driver anyway, it could call the direct-map > > > functions there too without relying on CMA to do anything? > > > > I think it'd be nice to have separate APIs for this case where we know > > the memory region is already page-granular (or, I suppose, PMD granular) > > and removing from (or adding back to) the linear mapping is safe. That > > way we could avoid the checks for can_set_direct_map() for each page. > > > > It'd also be nice to have a version that can update the protection bits > > for a range of pages (would map directly to update_range_prot()) instead > > of having to manually iterate over each page in a range. > > > > How about? > > /* True if can_set_direct_map() or [start, end) is mapped at PTE-level */ > can_set_direct_map_range(phys_addr_t start, phys_addr_t end); > > /* Must check can_set_direct_map() or can_set_direct_map_range() first */ > __set_direct_map_invalid_noflush(phys_addr_t start, phys_addr_t end) > __set_direct_map_default_noflush(phys_addr_t start, phys_addr_t end) > > > A good middle-ground might be to have helpers that do the grunt work and > > they can then be called from VPR and the shared-dma-pool drivers to have > > pages removed from the linear mapping. VPR and similar can then perform > > the hardware protection bits on top of that. > > I believe between the reserved-memory attribute to force the last-level mappings > and the direct map functions above, there's enough for the VPR driver? > > -- > Vincent > > > > > Thierry I have pushed a first version here [1]. I am waiting for the merge window to end before posting anything on the list, but let me know if you have any comment. [1] https://android-kvm.googlesource.com/linux/+/refs/heads/vdonnefort/ffa-lend-pool -- Vincent