summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2026-02-06 17:09:17 -0600
committerBjorn Helgaas <bhelgaas@google.com>2026-02-06 17:09:17 -0600
commit26cc2bd5aa82085e82ca3cd7e1298d9128248c19 (patch)
tree0f0a9cee48341faa68aaf87381c5319525a2e89a
parent1cb15d2054064b554e31993fe72b9e93233cb10a (diff)
parent83014d82a1100abc89f7712ad67c3e5accaddc43 (diff)
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
-rw-r--r--drivers/pci/p2pdma.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c
index 4a2fc7ab42c3..79a414fd6623 100644
--- a/drivers/pci/p2pdma.c
+++ b/drivers/pci/p2pdma.c
@@ -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);