mbox series

[0/5] PCI: functions/pci-epf-test: Add DMA data transfer

Message ID 20200225091130.29467-1-kishon@ti.com
Headers show
Series PCI: functions/pci-epf-test: Add DMA data transfer | expand

Message

Kishon Vijay Abraham I Feb. 25, 2020, 9:11 a.m. UTC
Patch series uses dma engine APIs in pci-epf-test to transfer data using
DMA. It also adds an option "-d" in pcitest for the user to indicate
whether DMA has to be used for data transfer. This also prints
throughput information for data transfer.

Kishon Vijay Abraham I (5):
  PCI: endpoint: functions/pci-epf-test: Add DMA support to transfer
    data
  PCI: endpoint: functions/pci-epf-test: Print throughput information
  misc: pci_endpoint_test: Use streaming DMA APIs for buffer allocation
  tools: PCI: Add 'd' command line option to support DMA
  misc: pci_endpoint_test: Add support to get DMA option from userspace

 drivers/misc/pci_endpoint_test.c              | 165 ++++++++++--
 drivers/pci/endpoint/functions/pci-epf-test.c | 253 +++++++++++++++++-
 include/uapi/linux/pcitest.h                  |   5 +
 tools/pci/pcitest.c                           |  20 +-
 4 files changed, 412 insertions(+), 31 deletions(-)

Comments

Alan Mikhak Feb. 25, 2020, 9:11 p.m. UTC | #1
@@ -380,6 +572,7 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
        int bar;

        cancel_delayed_work(&epf_test->cmd_handler);
+       pci_epf_clean_dma_chan(epf_test);
        pci_epc_stop(epc);
        for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
                epf_bar = &epf->bar[bar];
@@ -550,6 +743,12 @@ static int pci_epf_test_bind(struct pci_epf *epf)
                }
        }

+       epf_test->dma_supported = true;
+
+       ret = pci_epf_init_dma_chan(epf_test);
+       if (ret)
+               epf_test->dma_supported = false;
+
        if (linkup_notifier) {
                epf->nb.notifier_call = pci_epf_test_notifier;
                pci_epc_register_notifier(epc, &epf->nb);

Hi Kishon,

Looking forward to building and trying this patch series on
a platform I work on.

Would you please point me to where I can find the patches
which add pci_epf_init_dma_chan() and pci_epf_clean_dma_chan()
to Linux PCI Endpoint Framework?

Regards,
Alan Mikhak
Kishon Vijay Abraham I Feb. 26, 2020, 5:09 a.m. UTC | #2
Hi Alan,

On 26/02/20 2:41 am, Alan Mikhak wrote:
> @@ -380,6 +572,7 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
>         int bar;
> 
>         cancel_delayed_work(&epf_test->cmd_handler);
> +       pci_epf_clean_dma_chan(epf_test);
>         pci_epc_stop(epc);
>         for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
>                 epf_bar = &epf->bar[bar];
> @@ -550,6 +743,12 @@ static int pci_epf_test_bind(struct pci_epf *epf)
>                 }
>         }
> 
> +       epf_test->dma_supported = true;
> +
> +       ret = pci_epf_init_dma_chan(epf_test);
> +       if (ret)
> +               epf_test->dma_supported = false;
> +
>         if (linkup_notifier) {
>                 epf->nb.notifier_call = pci_epf_test_notifier;
>                 pci_epc_register_notifier(epc, &epf->nb);
> 
> Hi Kishon,
> 
> Looking forward to building and trying this patch series on
> a platform I work on.
> 
> Would you please point me to where I can find the patches
> which add pci_epf_init_dma_chan() and pci_epf_clean_dma_chan()
> to Linux PCI Endpoint Framework?

I've added these functions in pci-epf-test itself instead of adding in
the core files. I realized adding it in core files may not be helpful if
the endpoint function decides to use more number of DMA channels etc.,

Thanks
Kishon
Alan Mikhak Feb. 26, 2020, 5:39 p.m. UTC | #3
On Tue, Feb 25, 2020 at 9:27 PM Kishon Vijay Abraham I <kishon@ti.com> wrote:
>
> Hi Alan,
>
> On 26/02/20 2:41 am, Alan Mikhak wrote:
> > @@ -380,6 +572,7 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
> >         int bar;
> >
> >         cancel_delayed_work(&epf_test->cmd_handler);
> > +       pci_epf_clean_dma_chan(epf_test);
> >         pci_epc_stop(epc);
> >         for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
> >                 epf_bar = &epf->bar[bar];
> > @@ -550,6 +743,12 @@ static int pci_epf_test_bind(struct pci_epf *epf)
> >                 }
> >         }
> >
> > +       epf_test->dma_supported = true;
> > +
> > +       ret = pci_epf_init_dma_chan(epf_test);
> > +       if (ret)
> > +               epf_test->dma_supported = false;
> > +
> >         if (linkup_notifier) {
> >                 epf->nb.notifier_call = pci_epf_test_notifier;
> >                 pci_epc_register_notifier(epc, &epf->nb);
> >
> > Hi Kishon,
> >
> > Looking forward to building and trying this patch series on
> > a platform I work on.
> >
> > Would you please point me to where I can find the patches
> > which add pci_epf_init_dma_chan() and pci_epf_clean_dma_chan()
> > to Linux PCI Endpoint Framework?
>
> I've added these functions in pci-epf-test itself instead of adding in
> the core files. I realized adding it in core files may not be helpful if
> the endpoint function decides to use more number of DMA channels etc.,

Thanks Kishon,

I now realize they are in [PATCH 1/5] of this series. May I suggest renaming
them to pci_epf_test_init_dma_chan() and pci_epf_test_cleanup_dma_chan()?
With just pci_epf in their name, I was looking for them in pci-epf-core.c.

Regards,
Alan

>
> Thanks
> Kishon
Alan Mikhak March 3, 2020, 11:57 p.m. UTC | #4
On Wed, Feb 26, 2020 at 9:39 AM Alan Mikhak <alan.mikhak@sifive.com> wrote:
>
> On Tue, Feb 25, 2020 at 9:27 PM Kishon Vijay Abraham I <kishon@ti.com> wrote:
> >
> > Hi Alan,
> >
> > On 26/02/20 2:41 am, Alan Mikhak wrote:
> > > @@ -380,6 +572,7 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
> > >         int bar;
> > >
> > >         cancel_delayed_work(&epf_test->cmd_handler);
> > > +       pci_epf_clean_dma_chan(epf_test);
> > >         pci_epc_stop(epc);
> > >         for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
> > >                 epf_bar = &epf->bar[bar];
> > > @@ -550,6 +743,12 @@ static int pci_epf_test_bind(struct pci_epf *epf)
> > >                 }
> > >         }
> > >
> > > +       epf_test->dma_supported = true;
> > > +
> > > +       ret = pci_epf_init_dma_chan(epf_test);
> > > +       if (ret)
> > > +               epf_test->dma_supported = false;
> > > +
> > >         if (linkup_notifier) {
> > >                 epf->nb.notifier_call = pci_epf_test_notifier;
> > >                 pci_epc_register_notifier(epc, &epf->nb);
> > >
> > > Hi Kishon,
> > >
> > > Looking forward to building and trying this patch series on
> > > a platform I work on.

Hi Kishon,

I applied this v1 patch series to kernel.org linux 5.6-rc3 and built for
x86_64 Debian and riscv. I verified that when I execute the pcitest
command on the x86_64 host with -d flag, the riscv endpoint performs
the transfer by using an available dma channel.

Regards,
Alan

> > >
> > > Would you please point me to where I can find the patches
> > > which add pci_epf_init_dma_chan() and pci_epf_clean_dma_chan()
> > > to Linux PCI Endpoint Framework?
> >
> > I've added these functions in pci-epf-test itself instead of adding in
> > the core files. I realized adding it in core files may not be helpful if
> > the endpoint function decides to use more number of DMA channels etc.,
>
> Thanks Kishon,
>
> I now realize they are in [PATCH 1/5] of this series. May I suggest renaming
> them to pci_epf_test_init_dma_chan() and pci_epf_test_cleanup_dma_chan()?
> With just pci_epf in their name, I was looking for them in pci-epf-core.c.
>
> Regards,
> Alan
>
> >
> > Thanks
> > Kishon
Kishon Vijay Abraham I March 4, 2020, 5:15 a.m. UTC | #5
Hi Alan,

On 04/03/20 5:27 am, Alan Mikhak wrote:
> On Wed, Feb 26, 2020 at 9:39 AM Alan Mikhak <alan.mikhak@sifive.com> wrote:
>>
>> On Tue, Feb 25, 2020 at 9:27 PM Kishon Vijay Abraham I <kishon@ti.com> wrote:
>>>
>>> Hi Alan,
>>>
>>> On 26/02/20 2:41 am, Alan Mikhak wrote:
>>>> @@ -380,6 +572,7 @@ static void pci_epf_test_unbind(struct pci_epf *epf)
>>>>         int bar;
>>>>
>>>>         cancel_delayed_work(&epf_test->cmd_handler);
>>>> +       pci_epf_clean_dma_chan(epf_test);
>>>>         pci_epc_stop(epc);
>>>>         for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
>>>>                 epf_bar = &epf->bar[bar];
>>>> @@ -550,6 +743,12 @@ static int pci_epf_test_bind(struct pci_epf *epf)
>>>>                 }
>>>>         }
>>>>
>>>> +       epf_test->dma_supported = true;
>>>> +
>>>> +       ret = pci_epf_init_dma_chan(epf_test);
>>>> +       if (ret)
>>>> +               epf_test->dma_supported = false;
>>>> +
>>>>         if (linkup_notifier) {
>>>>                 epf->nb.notifier_call = pci_epf_test_notifier;
>>>>                 pci_epc_register_notifier(epc, &epf->nb);
>>>>
>>>> Hi Kishon,
>>>>
>>>> Looking forward to building and trying this patch series on
>>>> a platform I work on.
> 
> Hi Kishon,
> 
> I applied this v1 patch series to kernel.org linux 5.6-rc3 and built for
> x86_64 Debian and riscv. I verified that when I execute the pcitest
> command on the x86_64 host with -d flag, the riscv endpoint performs
> the transfer by using an available dma channel.

Thank you for testing this.
I've posted a new version after renaming the function names to
pci_epf_test_init_dma_chan() and pci_epf_test_cleanup_dma_chan() [1]
Can you add your "Tested-by: " tag in that series so that Lorenzo can
pick it up?

Thanks
Kishon

[1] -> http://lore.kernel.org/r/20200303103752.13076-1-kishon@ti.com

> 
> Regards,
> Alan
> 
>>>>
>>>> Would you please point me to where I can find the patches
>>>> which add pci_epf_init_dma_chan() and pci_epf_clean_dma_chan()
>>>> to Linux PCI Endpoint Framework?
>>>
>>> I've added these functions in pci-epf-test itself instead of adding in
>>> the core files. I realized adding it in core files may not be helpful if
>>> the endpoint function decides to use more number of DMA channels etc.,
>>
>> Thanks Kishon,
>>
>> I now realize they are in [PATCH 1/5] of this series. May I suggest renaming
>> them to pci_epf_test_init_dma_chan() and pci_epf_test_cleanup_dma_chan()?
>> With just pci_epf in their name, I was looking for them in pci-epf-core.c.
>>
>> Regards,
>> Alan
>>
>>>
>>> Thanks
>>> Kishon