diff mbox series

[v2] PCI: endpoint: functions/pci-epf-test: Fix dma_chan direction

Message ID 20230222015327.3585691-1-yoshihiro.shimoda.uh@renesas.com
State New
Headers show
Series [v2] PCI: endpoint: functions/pci-epf-test: Fix dma_chan direction | expand

Commit Message

Yoshihiro Shimoda Feb. 22, 2023, 1:53 a.m. UTC
In the pci_epf_test_init_dma_chan(), epf_test->dma_chan_rx
is assigned from dma_request_channel() with DMA_DEV_TO_MEM as
filter.dma_mask. However, in the pci_epf_test_data_transfer(),
if the dir is DMA_DEV_TO_MEM, it should use epf->dma_chan_rx,
but it used epf_test->dma_chan_tx. So, fix it. Otherwise,
results of pcitest with enabled DMA will be "NOT OKAY" on eDMA
environment.

Fixes: 8353813c88ef ("PCI: endpoint: Enable DMA tests for endpoints with DMA capabilities")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
Changes from v1:
https://lore.kernel.org/linux-pci/20230221100949.3530608-1-yoshihiro.shimoda.uh@renesas.com/
https://lore.kernel.org/linux-pci/20230221101706.3530869-1-yoshihiro.shimoda.uh@renesas.com/
 - Fix a condition for "chan" to match following check "dma_local".
 - Fix a commit description about the results.
   "NOT OKAY" is the correct result.

 drivers/pci/endpoint/functions/pci-epf-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Frank Li Feb. 22, 2023, 3:52 a.m. UTC | #1
> -----Original Message-----
> From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> Sent: Tuesday, February 21, 2023 7:53 PM
> To: lpieralisi@kernel.org; kw@linux.com; mani@kernel.org;
> kishon@kernel.org; bhelgaas@google.com; Frank Li <frank.li@nxp.com>
> Cc: linux-pci@vger.kernel.org; Yoshihiro Shimoda
> <yoshihiro.shimoda.uh@renesas.com>
> Subject: [EXT] [PATCH v2] PCI: endpoint: functions/pci-epf-test: Fix dma_chan
> direction
> 
> Caution: EXT Email
> 
> In the pci_epf_test_init_dma_chan(), epf_test->dma_chan_rx
> is assigned from dma_request_channel() with DMA_DEV_TO_MEM as
> filter.dma_mask. However, in the pci_epf_test_data_transfer(),
> if the dir is DMA_DEV_TO_MEM, it should use epf->dma_chan_rx,
> but it used epf_test->dma_chan_tx. So, fix it. Otherwise,
> results of pcitest with enabled DMA will be "NOT OKAY" on eDMA
> environment.
> 
> Fixes: 8353813c88ef ("PCI: endpoint: Enable DMA tests for endpoints with
> DMA capabilities")
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> Changes from v1:
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.k
> ernel.org%2Flinux-pci%2F20230221100949.3530608-1-
> yoshihiro.shimoda.uh%40renesas.com%2F&data=05%7C01%7CFrank.Li%40n
> xp.com%7Cf725e4559e7e470a2b7008db14779a20%7C686ea1d3bc2b4c6fa92
> cd99c5c301635%7C0%7C0%7C638126276145239757%7CUnknown%7CTWFp
> bGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI
> 6Mn0%3D%7C3000%7C%7C%7C&sdata=5QXtwk7UxBs0WnwILTPgGeSbmUBI
> XCB9yj9DxVSf7I8%3D&reserved=0
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.k
> ernel.org%2Flinux-pci%2F20230221101706.3530869-1-
> yoshihiro.shimoda.uh%40renesas.com%2F&data=05%7C01%7CFrank.Li%40n
> xp.com%7Cf725e4559e7e470a2b7008db14779a20%7C686ea1d3bc2b4c6fa92
> cd99c5c301635%7C0%7C0%7C638126276145239757%7CUnknown%7CTWFp
> bGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI
> 6Mn0%3D%7C3000%7C%7C%7C&sdata=5w8fkXes5CvaLP8NgI7X7Mlxhvg%2Ff
> iUhEG4D8wnoANc%3D&reserved=0
>  - Fix a condition for "chan" to match following check "dma_local".
>  - Fix a commit description about the results.
>    "NOT OKAY" is the correct result.
> 
>  drivers/pci/endpoint/functions/pci-epf-test.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c
> b/drivers/pci/endpoint/functions/pci-epf-test.c
> index 55283d2379a6..f0c4d0f77453 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-test.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-test.c
> @@ -112,7 +112,7 @@ static int pci_epf_test_data_transfer(struct
> pci_epf_test *epf_test,
>                                       size_t len, dma_addr_t dma_remote,
>                                       enum dma_transfer_direction dir)
>  {
> -       struct dma_chan *chan = (dir == DMA_DEV_TO_MEM) ?
> +       struct dma_chan *chan = (dir == DMA_MEM_TO_DEV) ?
>                                  epf_test->dma_chan_tx : epf_test->dma_chan_rx;
>         dma_addr_t dma_local = (dir == DMA_MEM_TO_DEV) ? dma_src :
> dma_dst;
>         enum dma_ctrl_flags flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
> --
> 2.25.1
diff mbox series

Patch

diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c
index 55283d2379a6..f0c4d0f77453 100644
--- a/drivers/pci/endpoint/functions/pci-epf-test.c
+++ b/drivers/pci/endpoint/functions/pci-epf-test.c
@@ -112,7 +112,7 @@  static int pci_epf_test_data_transfer(struct pci_epf_test *epf_test,
 				      size_t len, dma_addr_t dma_remote,
 				      enum dma_transfer_direction dir)
 {
-	struct dma_chan *chan = (dir == DMA_DEV_TO_MEM) ?
+	struct dma_chan *chan = (dir == DMA_MEM_TO_DEV) ?
 				 epf_test->dma_chan_tx : epf_test->dma_chan_rx;
 	dma_addr_t dma_local = (dir == DMA_MEM_TO_DEV) ? dma_src : dma_dst;
 	enum dma_ctrl_flags flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;