diff mbox series

[v11,02/13] PCI: endpoint: functions/pci-epf-test: Fix dma_chan direction

Message ID 20230310123510.675685-3-yoshihiro.shimoda.uh@renesas.com
State New
Headers show
Series PCI: rcar-gen4: Add R-Car Gen4 PCIe support | expand

Commit Message

Yoshihiro Shimoda March 10, 2023, 12:34 p.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>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/pci/endpoint/functions/pci-epf-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kunihiko Hayashi April 12, 2023, 4:23 a.m. UTC | #1
Hi Shimoda-san,

On 2023/03/10 21:34, Yoshihiro Shimoda wrote:
> 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.

I also encounted this issue and found this patch before sending my fixes patch
for the same diff as this one.
And I confirmed the issue is fixed using pcitest with eDMA on UniPhier SoCs.

For 02/13 patch if not already merged:

Tested-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>

Thank you,

> 
> 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>
> ---
>   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 0f9d2ec822ac..172e5ac0bd96 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;

---
Best Regards
Kunihiko Hayashi
Yoshihiro Shimoda April 12, 2023, 5:22 a.m. UTC | #2
Hi Hayashi-san,

> From: Kunihiko Hayashi, Sent: Wednesday, April 12, 2023 1:23 PM
> 
> Hi Shimoda-san,
> 
> On 2023/03/10 21:34, Yoshihiro Shimoda wrote:
> > 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.
> 
> I also encounted this issue and found this patch before sending my fixes patch
> for the same diff as this one.
> And I confirmed the issue is fixed using pcitest with eDMA on UniPhier SoCs.
> 
> For 02/13 patch if not already merged:
> 
> Tested-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>

Thank you very much for your Tested-by!
Since I need more time to fix v12 patch series for some reasons,
I'll send this patch independently.

Best regards,
Yoshihiro Shimoda

> Thank you,
> 
> >
> > 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>
> > ---
> >   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 0f9d2ec822ac..172e5ac0bd96 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;
> 
> ---
> Best Regards
> Kunihiko Hayashi
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 0f9d2ec822ac..172e5ac0bd96 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;