Przeglądaj źródła

PCI: endpoint: functions: Use dma channel device while map/unmap for devices using system DMA

Use dma channel device while map/unmap for devices using system DMA.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Kishon Vijay Abraham I 6 lat temu
rodzic
commit
af1926e75f
1 zmienionych plików z 7 dodań i 0 usunięć
  1. 7 0
      drivers/pci/endpoint/functions/pci-epf-test.c

+ 7 - 0
drivers/pci/endpoint/functions/pci-epf-test.c

@@ -8,6 +8,7 @@
 
 #include <linux/crc32.h>
 #include <linux/delay.h>
+#include <linux/dmaengine.h>
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -177,6 +178,9 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test)
 		goto err_map_addr;
 	}
 
+	if (epf->dma_chan)
+		dma_dev = epf->dma_chan->device->dev;
+
 	dst_addr = dma_map_single(dma_dev, buf, reg->size, DMA_FROM_DEVICE);
 	if (dma_mapping_error(dma_dev, dst_addr)) {
 		dev_err(dev, "failed to map destination buffer address\n");
@@ -251,6 +255,9 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test)
 	get_random_bytes(buf, reg->size);
 	reg->checksum = crc32_le(~0, buf, reg->size);
 
+	if (epf->dma_chan)
+		dma_dev = epf->dma_chan->device->dev;
+
 	src_addr = dma_map_single(dma_dev, buf, reg->size, DMA_TO_DEVICE);
 	if (dma_mapping_error(dma_dev, src_addr)) {
 		dev_err(dev, "failed to map source buffer address\n");