OSDN Git Service

PCI/P2PDMA: Collect acs list in stack buffer to avoid sleeping
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 10 Jun 2021 16:06:05 +0000 (10:06 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 10 Jun 2021 23:01:41 +0000 (18:01 -0500)
commite4ece59abd70d8f54e2163274dc996bb442832a6
tree9b8c0159fbd6f5a66a2ac779752ea052344d36e5
parent6389d43745228de128e7b1a66eb18c0ccf43e6b4
PCI/P2PDMA: Collect acs list in stack buffer to avoid sleeping

In order to call the calc_map_type_and_dist_warn() function from a dma_map
operation, the function must not sleep. The only reason it sleeps is to
allocate memory for the seq_buf to print a verbose warning telling the user
how to disable ACS for that path.

Instead of allocating the memory with kmalloc(), allocate a smaller buffer
on the stack. A 128 byte buffer is enough to print 10 PCI device names. A
system with 10 bridge ports between two devices that have ACS enabled would
be unusually large, so this should still be a reasonable limit.

This also cleans up the awkward (and broken) return with -ENOMEM which
contradicts the return type and the caller was not prepared for.

Link: https://lore.kernel.org/r/20210610160609.28447-3-logang@deltatee.com
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/p2pdma.c