* [PATCH v2] PCI: endpoint: Use DMA channel's 'dev' for dma_map_single()
@ 2021-11-16 14:23 Kishon Vijay Abraham I
2022-01-04 9:04 ` Kishon Vijay Abraham I
0 siblings, 1 reply; 2+ messages in thread
From: Kishon Vijay Abraham I @ 2021-11-16 14:23 UTC (permalink / raw)
To: Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński, Bjorn Helgaas
Cc: linux-pci, linux-kernel, Kishon Vijay Abraham I
For the case where the pci-epf-test driver uses DMA for transferring
data to the root complex device, dma_map_single() is used to map virtual
address to a physical address (address accessible by DMA controller) and
provided to the DMAengine API for transferring data. Here instead of
using the PCIe endpoint controller's 'dev' for dma_map_single(), provide
DMA channel's 'dev' for dma_map_single() since the data transfer is
actually done by DMA.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
Changes from v1:
Use dmaengine_get_dma_device() to get dma device from channel
V1: https://lore.kernel.org/r/20211115044944.31103-1-kishon@ti.com
drivers/pci/endpoint/functions/pci-epf-test.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index 90d84d3bc868..51f5b0b7b225 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -314,12 +314,12 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test)
u32 crc32;
bool use_dma;
phys_addr_t phys_addr;
+ struct device *dma_dev;
phys_addr_t dst_phys_addr;
struct timespec64 start, end;
struct pci_epf *epf = epf_test->epf;
struct device *dev = &epf->dev;
struct pci_epc *epc = epf->epc;
- struct device *dma_dev = epf->epc->dev.parent;
enum pci_barno test_reg_bar = epf_test->test_reg_bar;
struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar];
@@ -353,6 +353,7 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test)
goto err_dma_map;
}
+ dma_dev = dmaengine_get_dma_device(epf_test->dma_chan);
dst_phys_addr = dma_map_single(dma_dev, buf, reg->size,
DMA_FROM_DEVICE);
if (dma_mapping_error(dma_dev, dst_phys_addr)) {
@@ -402,12 +403,12 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test)
void *buf;
bool use_dma;
phys_addr_t phys_addr;
+ struct device *dma_dev;
phys_addr_t src_phys_addr;
struct timespec64 start, end;
struct pci_epf *epf = epf_test->epf;
struct device *dev = &epf->dev;
struct pci_epc *epc = epf->epc;
- struct device *dma_dev = epf->epc->dev.parent;
enum pci_barno test_reg_bar = epf_test->test_reg_bar;
struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar];
@@ -444,6 +445,7 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test)
goto err_map_addr;
}
+ dma_dev = dmaengine_get_dma_device(epf_test->dma_chan);
src_phys_addr = dma_map_single(dma_dev, buf, reg->size,
DMA_TO_DEVICE);
if (dma_mapping_error(dma_dev, src_phys_addr)) {
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] PCI: endpoint: Use DMA channel's 'dev' for dma_map_single()
2021-11-16 14:23 [PATCH v2] PCI: endpoint: Use DMA channel's 'dev' for dma_map_single() Kishon Vijay Abraham I
@ 2022-01-04 9:04 ` Kishon Vijay Abraham I
0 siblings, 0 replies; 2+ messages in thread
From: Kishon Vijay Abraham I @ 2022-01-04 9:04 UTC (permalink / raw)
To: Lorenzo Pieralisi
Cc: linux-pci, linux-kernel, Rob Herring, Krzysztof Wilczyński,
Bjorn Helgaas
Hi Lorenzo,
On 16/11/21 7:53 pm, Kishon Vijay Abraham I wrote:
> For the case where the pci-epf-test driver uses DMA for transferring
> data to the root complex device, dma_map_single() is used to map virtual
> address to a physical address (address accessible by DMA controller) and
> provided to the DMAengine API for transferring data. Here instead of
> using the PCIe endpoint controller's 'dev' for dma_map_single(), provide
> DMA channel's 'dev' for dma_map_single() since the data transfer is
> actually done by DMA.
>
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Can this patch be merged?
Thanks,
Kishon
> ---
> Changes from v1:
> Use dmaengine_get_dma_device() to get dma device from channel
> V1: https://lore.kernel.org/r/20211115044944.31103-1-kishon@ti.com
> drivers/pci/endpoint/functions/pci-epf-test.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
> index 90d84d3bc868..51f5b0b7b225 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> @@ -314,12 +314,12 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test)
> u32 crc32;
> bool use_dma;
> phys_addr_t phys_addr;
> + struct device *dma_dev;
> phys_addr_t dst_phys_addr;
> struct timespec64 start, end;
> struct pci_epf *epf = epf_test->epf;
> struct device *dev = &epf->dev;
> struct pci_epc *epc = epf->epc;
> - struct device *dma_dev = epf->epc->dev.parent;
> enum pci_barno test_reg_bar = epf_test->test_reg_bar;
> struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar];
>
> @@ -353,6 +353,7 @@ static int pci_epf_test_read(struct pci_epf_test *epf_test)
> goto err_dma_map;
> }
>
> + dma_dev = dmaengine_get_dma_device(epf_test->dma_chan);
> dst_phys_addr = dma_map_single(dma_dev, buf, reg->size,
> DMA_FROM_DEVICE);
> if (dma_mapping_error(dma_dev, dst_phys_addr)) {
> @@ -402,12 +403,12 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test)
> void *buf;
> bool use_dma;
> phys_addr_t phys_addr;
> + struct device *dma_dev;
> phys_addr_t src_phys_addr;
> struct timespec64 start, end;
> struct pci_epf *epf = epf_test->epf;
> struct device *dev = &epf->dev;
> struct pci_epc *epc = epf->epc;
> - struct device *dma_dev = epf->epc->dev.parent;
> enum pci_barno test_reg_bar = epf_test->test_reg_bar;
> struct pci_epf_test_reg *reg = epf_test->reg[test_reg_bar];
>
> @@ -444,6 +445,7 @@ static int pci_epf_test_write(struct pci_epf_test *epf_test)
> goto err_map_addr;
> }
>
> + dma_dev = dmaengine_get_dma_device(epf_test->dma_chan);
> src_phys_addr = dma_map_single(dma_dev, buf, reg->size,
> DMA_TO_DEVICE);
> if (dma_mapping_error(dma_dev, src_phys_addr)) {
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-04 9:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 14:23 [PATCH v2] PCI: endpoint: Use DMA channel's 'dev' for dma_map_single() Kishon Vijay Abraham I
2022-01-04 9:04 ` Kishon Vijay Abraham I
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).