Thread (43 messages) 43 messages, 3 authors, 7h ago

Re: [PATCH v8 01/23] dma-direct: return struct page from dma_direct_alloc_from_pool()

From: Jason Gunthorpe <jgg@ziepe.ca>
Date: 2026-07-25 14:34:25
Also in: linux-arm-kernel, linux-coco, linux-iommu, linux-s390, lkml, stable

On Thu, Jul 23, 2026 at 10:57:04AM +0300, Leon Romanovsky wrote:
On Wed, Jul 22, 2026 at 04:59:12PM -0300, Jason Gunthorpe wrote:
quoted
On Tue, Jul 21, 2026 at 06:33:21PM +0300, Leon Romanovsky wrote:
quoted
Something like, but probably void* needs to be phys_addr_t:

static inline struct page *dma_phys_to_page(void *addr)
{
#ifdef CONFIG_DMA_DIRECT_REMAP
	return vmalloc_to_page(addr);
#else
	return virt_to_page(addr);
#endif
}
I don't like this, we don't know for sure the addr will be in a vmap
and this will fail if it isn't.
Of course we know. The existing "#ifdef CONFIG_DMA_DIRECT_REMAP" is
relevant for addresses acquired from pool.
Yeah, but I still don't like it :) It is hard to follow if you make
those kinds of leaps, someone will call this new helper on something
they shouldn't
dma_phys_to_page() is a bad name for some low-level conversion function.
It needs to be internal to DMA logic, in the level when we convert from
phys to page.
I think we should not convert from phys to page, that's also easy to
do wrong

Jason
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help