PCI/P2PDMA: Attempt to set map_type if it has not been set
authorLogan Gunthorpe <logang@deltatee.com>
Fri, 8 Jul 2022 16:50:53 +0000 (10:50 -0600)
committerChristoph Hellwig <hch@lst.de>
Tue, 26 Jul 2022 11:27:47 +0000 (07:27 -0400)
commit719c98658058f4aca0f7663ff11f2606e99cce4f
tree3a3a2958e31eec420872bbec0b1feef1bf0f8977
parent42399301203e3cddef36cde457228f9247618313
PCI/P2PDMA: Attempt to set map_type if it has not been set

Attempt to find the mapping type for P2PDMA pages on the first
DMA map attempt if it has not been done ahead of time.

Previously, the mapping type was expected to be calculated ahead of
time, but if pages are to come from userspace then there's no
way to ensure the path was checked ahead of time.

This change will calculate the mapping type if it hasn't pre-calculated
so it is no longer invalid to call pci_p2pdma_map_sg() before the mapping
type is calculated, so drop the WARN_ON when that is the case.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/pci/p2pdma.c