Merge branch 'pci/p2pdma'

- Release per-CPU pgmap ref when vm_insert_page() fails so we don't hang
  when removing the PCI device (Hou Tao)

- Remove incorrect p2pmem_alloc_mmap() warning about page refcount (Hou
  Tao)

- Reset page reference count when page mapping fails (Alistair Popple)

* pci/p2pdma:
  PCI/P2PDMA: Reset page reference count when page mapping fails
  PCI/P2PDMA: Fix p2pmem_alloc_mmap() warning condition
  PCI/P2PDMA: Release per-CPU pgmap ref when vm_insert_page() fails
This commit is contained in:
Bjorn Helgaas 2026-02-06 17:09:17 -06:00
commit 26cc2bd5aa

View file

@ -147,11 +147,19 @@ static int p2pmem_alloc_mmap(struct file *filp, struct kobject *kobj,
* we have just allocated the page no one else should be
* using it.
*/
VM_WARN_ON_ONCE_PAGE(!page_ref_count(page), page);
VM_WARN_ON_ONCE_PAGE(page_ref_count(page), page);
set_page_count(page, 1);
ret = vm_insert_page(vma, vaddr, page);
if (ret) {
gen_pool_free(p2pdma->pool, (uintptr_t)kaddr, len);
/*
* Reset the page count. We don't use put_page()
* because we don't want to trigger the
* p2pdma_folio_free() path.
*/
set_page_count(page, 0);
percpu_ref_put(ref);
return ret;
}
percpu_ref_get(ref);