[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <33c4a321-0e5c-4090-be2c-4bfbee603f5a@deltatee.com>
Date: Mon, 22 Dec 2025 10:10:49 -0700
From: Logan Gunthorpe <logang@...tatee.com>
To: Hou Tao <houtao@...weicloud.com>, linux-kernel@...r.kernel.org
Cc: linux-pci@...r.kernel.org, linux-mm@...ck.org,
linux-nvme@...ts.infradead.org, Bjorn Helgaas <bhelgaas@...gle.com>,
Alistair Popple <apopple@...dia.com>, Leon Romanovsky <leonro@...dia.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Tejun Heo <tj@...nel.org>,
"Rafael J . Wysocki" <rafael@...nel.org>, Danilo Krummrich
<dakr@...nel.org>, Andrew Morton <akpm@...ux-foundation.org>,
David Hildenbrand <david@...nel.org>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, Keith Busch
<kbusch@...nel.org>, Jens Axboe <axboe@...nel.dk>,
Christoph Hellwig <hch@....de>, Sagi Grimberg <sagi@...mberg.me>,
houtao1@...wei.com
Subject: Re: [PATCH 13/13] PCI/P2PDMA: enable compound page support for p2pdma
memory
On 2025-12-19 21:04, Hou Tao wrote:
> From: Hou Tao <houtao1@...wei.com>
>
> Compound page support for P2PDMA memory in both kernel and user space is
> now in place. Enable it by allowing PUD_SIZE and PMD_SIZE alignment.
>
> Signed-off-by: Hou Tao <houtao1@...wei.com>
> ---
> drivers/pci/p2pdma.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
> index 4a133219ac43..969bdacdcf8b 100644
> --- a/drivers/pci/p2pdma.c
> +++ b/drivers/pci/p2pdma.c
> @@ -452,9 +452,19 @@ static inline int pci_p2pdma_check_pagemap_align(struct pci_dev *pdev, int bar,
> u64 size, size_t align,
> u64 offset)
> {
> + if (has_transparent_pud_hugepage() && align == PUD_SIZE)
> + goto more_check;
> + if (has_transparent_hugepage() && align == PMD_SIZE)
> + goto more_check;
> if (align == PAGE_SIZE)
> return 0;
> return -EINVAL;
> +
> +more_check:
> + if (IS_ALIGNED(pci_resource_start(pdev, bar), align) &&
> + IS_ALIGNED(size, align) && IS_ALIGNED(offset, align))
> + return 0;
> + return -EINVAL;
> }
Again this seems strange. It's a bit unlikely to have a large BAR that
wouldn't be well aligned, but this change is now requiring all P2P
memory to be aligned to 1GB if the CPU supports PUDs. So if a particular
device only has a small (say 256MB) imperfectly aligned bar it may now
fail to be registered.
I don't think the alignment should be a property of the device. When a
mapping is created, if everything is aligned appropriately, and there is
enough free aligned P2PDMA memory, then it should map a full PUD page.
There shouldn't be other restrictions placed on the hardware to make
this work.
Logan
Powered by blists - more mailing lists