PCI/P2PDMA: Introduce configfs/sysfs enable attribute helpers
Users of the P2PDMA infrastructure will typically need a way for the user to tell the kernel to use P2P resources. Typically this will be a simple on/off boolean operation but sometimes it may be desirable for the user to specify the exact device to use for the P2P operation. Add new helpers for attributes which take a boolean or a PCI device. Any boolean as accepted by strtobool() turn P2P on or off (such as 'y', 'n', '1', '0', etc). Specifying a full PCI device name/BDF will select the specific device. Signed-off-by: Logan Gunthorpe <logang@deltatee.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:

committed by
Bjorn Helgaas

parent
977196b8c5
commit
2d7bc010f4
@@ -32,6 +32,10 @@ void pci_p2pmem_free_sgl(struct pci_dev *pdev, struct scatterlist *sgl);
|
||||
void pci_p2pmem_publish(struct pci_dev *pdev, bool publish);
|
||||
int pci_p2pdma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
|
||||
enum dma_data_direction dir);
|
||||
int pci_p2pdma_enable_store(const char *page, struct pci_dev **p2p_dev,
|
||||
bool *use_p2pdma);
|
||||
ssize_t pci_p2pdma_enable_show(char *page, struct pci_dev *p2p_dev,
|
||||
bool use_p2pdma);
|
||||
#else /* CONFIG_PCI_P2PDMA */
|
||||
static inline int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar,
|
||||
size_t size, u64 offset)
|
||||
@@ -82,6 +86,17 @@ static inline int pci_p2pdma_map_sg(struct device *dev,
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static inline int pci_p2pdma_enable_store(const char *page,
|
||||
struct pci_dev **p2p_dev, bool *use_p2pdma)
|
||||
{
|
||||
*use_p2pdma = false;
|
||||
return 0;
|
||||
}
|
||||
static inline ssize_t pci_p2pdma_enable_show(char *page,
|
||||
struct pci_dev *p2p_dev, bool use_p2pdma)
|
||||
{
|
||||
return sprintf(page, "none\n");
|
||||
}
|
||||
#endif /* CONFIG_PCI_P2PDMA */
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user