page_pool: fragment API support for 32-bit arch with 64-bit DMA 07/309707/1
authorYunsheng Lin <linyunsheng@huawei.com>
Fri, 13 Oct 2023 06:48:21 +0000 (14:48 +0800)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 16 Apr 2024 02:24:33 +0000 (11:24 +0900)
commitce215a3a795e5338ae28ce422bb24df544d9d539
tree5a154ff59488bd0a11cf23ecc195e6745e865a87
parent00b1553bfef2822db5333175f001d5425ab3d9b8
page_pool: fragment API support for 32-bit arch with 64-bit DMA

Currently page_pool_alloc_frag() is not supported in 32-bit
arch with 64-bit DMA because of the overlap issue between
pp_frag_count and dma_addr_upper in 'struct page' for those
arches, which seems to be quite common, see [1], which means
driver may need to handle it when using fragment API.

It is assumed that the combination of the above arch with an
address space >16TB does not exist, as all those arches have
64b equivalent, it seems logical to use the 64b version for a
system with a large address space. It is also assumed that dma
address is page aligned when we are dma mapping a page aligned
buffer, see [2].

That means we're storing 12 bits of 0 at the lower end for a
dma address, we can reuse those bits for the above arches to
support 32b+12b, which is 16TB of memory.

If we make a wrong assumption, a warning is emitted so that
user can report to us.

1. https://lore.kernel.org/all/20211117075652.58299-1-linyunsheng@huawei.com/
2. https://lore.kernel.org/all/20230818145145.4b357c89@kernel.org/

Tested-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
CC: Lorenzo Bianconi <lorenzo@kernel.org>
CC: Alexander Duyck <alexander.duyck@gmail.com>
CC: Liang Chen <liangchen.linux@gmail.com>
CC: Guillaume Tucker <guillaume.tucker@collabora.com>
CC: Matthew Wilcox <willy@infradead.org>
CC: Linux-MM <linux-mm@kvack.org>
Link: https://lore.kernel.org/r/20231013064827.61135-2-linyunsheng@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 90de47f020db086f7929e09f64efd0cf627d6869)
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Change-Id: I9fdea00f780aac6bd06c2099a590790ed66aea54
include/linux/mm_types.h
include/net/page_pool/helpers.h
net/core/page_pool.c