Re: Q: Does mass storage gadget use DMA ?

2018-02-28 Thread Oliver Neukum
Am Montag, den 26.02.2018, 18:09 +0200 schrieb Ran Shalit:
> On Mon, Feb 26, 2018 at 5:59 PM, Oliver Neukum  wrote:
> > 
> > Am Donnerstag, den 15.02.2018, 11:00 +0200 schrieb Ran Shalit:
> > > 
> > > I actually asked about DMA, because I see that it is possible to send
> > > urb using DMA allocated buffers or not (coherent and non-coherent)
> > > usb_buffer_alloc().
> > > So, How can we actually know if I should use this API with a device or
> > > not ? I mean, is it always possible to use the coherent buffer with
> > > the device ?
> > 
> > Hi,
> > 
> > it is always possible to use usb_alloc_coherent() on a host.
> > But it is generally not sensible. It is for buffers to be reused
> > many times. In general use kmalloc() [once per buffer. That is a rule.
> > You must not share them.]
> > 
> > HTH
> > Oliver
> > 
> Hi Oliver,
> 
> Is the dma engine which is responsible for the transaction is actually
> in the usb device (It's not dma controller in host) ?

OK, I think there is a fundamental misunderstanding here.
There are two sides: host and gadget
Either, both or no side may use DMA. The other side does
not learn of that.

In either case, however, you write a driver for a logical device
or a protocol, if you will. What we call a device driver on the host
(the gadget has its own equivalents) does not talk to hardware.
Essentially you allocate and manipulate URBs.

There is a driver for a host (respectively gadget) controller
which talks to hardware. It does DMA, not your driver.

> If I understand correctly in both ways (kmalloc or
> usb_alloc_coherent), then we are allocating buffers might be used for
> dma.

Yes. We must.

> Even if DMA is not used in the transaction, than is shall still be
> functional with the same DMA-allocated buffers.

Yes. It must.

HTH
Oliver

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Q: Does mass storage gadget use DMA ?

2018-02-26 Thread Ran Shalit
On Mon, Feb 26, 2018 at 5:59 PM, Oliver Neukum  wrote:
> Am Donnerstag, den 15.02.2018, 11:00 +0200 schrieb Ran Shalit:
>> I actually asked about DMA, because I see that it is possible to send
>> urb using DMA allocated buffers or not (coherent and non-coherent)
>> usb_buffer_alloc().
>> So, How can we actually know if I should use this API with a device or
>> not ? I mean, is it always possible to use the coherent buffer with
>> the device ?
>
> Hi,
>
> it is always possible to use usb_alloc_coherent() on a host.
> But it is generally not sensible. It is for buffers to be reused
> many times. In general use kmalloc() [once per buffer. That is a rule.
> You must not share them.]
>
> HTH
> Oliver
>
Hi Oliver,

Is the dma engine which is responsible for the transaction is actually
in the usb device (It's not dma controller in host) ?

If I understand correctly in both ways (kmalloc or
usb_alloc_coherent), then we are allocating buffers might be used for
dma.
Even if DMA is not used in the transaction, than is shall still be
functional with the same DMA-allocated buffers.

Thanks,
ranran
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Q: Does mass storage gadget use DMA ?

2018-02-26 Thread Oliver Neukum
Am Donnerstag, den 15.02.2018, 11:00 +0200 schrieb Ran Shalit:
> I actually asked about DMA, because I see that it is possible to send
> urb using DMA allocated buffers or not (coherent and non-coherent)
> usb_buffer_alloc().
> So, How can we actually know if I should use this API with a device or
> not ? I mean, is it always possible to use the coherent buffer with
> the device ?

Hi,

it is always possible to useĀ usb_alloc_coherent() on a host.
But it is generally not sensible. It is for buffers to be reused
many times. In general use kmalloc() [once per buffer. That is a rule.
You must not share them.]

HTH
Oliver

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Q: Does mass storage gadget use DMA ?

2018-02-15 Thread Ran Shalit
On Thu, Feb 15, 2018 at 10:56 AM, Ran Shalit  wrote:
> On Mon, Feb 12, 2018 at 2:39 PM, Oliver Neukum  wrote:
>> Am Sonntag, den 11.02.2018, 22:17 +0200 schrieb Ran Shalit:
>>> On Tue, Feb 6, 2018 at 8:55 AM, Felipe Balbi
>>>  wrote:
>>> >
>>> >
>>> > Hi,
>>> >
>>> > Ran Shalit  writes:
>>> > >
>>> > > Hello,
>>> > >
>>> > > I check code in:
>>> > > https://elixir.free-electrons.com/linux/v3.3/source/drivers/usb/gadget/f_mass_storage.c
>>> > > but I see no API usage of DMA, yet it is being mentioned as if it is 
>>> > > used.
>>> >
>>> > but it is used. It's just managed by the UDC driver (dwc3, musb,
>>> > chipidea, Renesas, etc)
>>> >
>>> Just to be sure,
>>> can I assume that other usb gadget drivers are using DMA (including
>>> gadgetfs for userspace driver) ?
>>> And it is also correct for host drivers  (such as camera device ) ?
>>
>> None of these drivers are for hardware. They implement a protocol.
>> On the host as well as on the gadget side there are driver for the
>> actual host controllers (EHCI, XHCI, ...) as well as their gadget
>> equivalents.
>>
>> Any of these drivers may or may not use DMA. Neither the assumption
>> that they use DMA or the assumption that they do not use DMA
>> is valid. In fact they may mix it.
>
Hi,

I actually asked about DMA, because I see that it is possible to send
urb using DMA allocated buffers or not (coherent and non-coherent)
usb_buffer_alloc().
So, How can we actually know if I should use this API with a device or
not ? I mean, is it always possible to use the coherent buffer with
the device ?

Sorry for the previous disrupted email, it was sent by mistake.
Thanks a lot,
Ran

that there is API for dma
>
>> Your code must be ready to cope with either usage.
>>
>> HTH
>> Oliver
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Q: Does mass storage gadget use DMA ?

2018-02-15 Thread Ran Shalit
On Mon, Feb 12, 2018 at 2:39 PM, Oliver Neukum  wrote:
> Am Sonntag, den 11.02.2018, 22:17 +0200 schrieb Ran Shalit:
>> On Tue, Feb 6, 2018 at 8:55 AM, Felipe Balbi
>>  wrote:
>> >
>> >
>> > Hi,
>> >
>> > Ran Shalit  writes:
>> > >
>> > > Hello,
>> > >
>> > > I check code in:
>> > > https://elixir.free-electrons.com/linux/v3.3/source/drivers/usb/gadget/f_mass_storage.c
>> > > but I see no API usage of DMA, yet it is being mentioned as if it is 
>> > > used.
>> >
>> > but it is used. It's just managed by the UDC driver (dwc3, musb,
>> > chipidea, Renesas, etc)
>> >
>> Just to be sure,
>> can I assume that other usb gadget drivers are using DMA (including
>> gadgetfs for userspace driver) ?
>> And it is also correct for host drivers  (such as camera device ) ?
>
> None of these drivers are for hardware. They implement a protocol.
> On the host as well as on the gadget side there are driver for the
> actual host controllers (EHCI, XHCI, ...) as well as their gadget
> equivalents.
>
> Any of these drivers may or may not use DMA. Neither the assumption
> that they use DMA or the assumption that they do not use DMA
> is valid. In fact they may mix it.

I asked about DMA

> Your code must be ready to cope with either usage.
>
> HTH
> Oliver
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Q: Does mass storage gadget use DMA ?

2018-02-12 Thread Oliver Neukum
Am Sonntag, den 11.02.2018, 22:17 +0200 schrieb Ran Shalit:
> On Tue, Feb 6, 2018 at 8:55 AM, Felipe Balbi
>  wrote:
> > 
> > 
> > Hi,
> > 
> > Ran Shalit  writes:
> > > 
> > > Hello,
> > > 
> > > I check code in:
> > > https://elixir.free-electrons.com/linux/v3.3/source/drivers/usb/gadget/f_mass_storage.c
> > > but I see no API usage of DMA, yet it is being mentioned as if it is used.
> > 
> > but it is used. It's just managed by the UDC driver (dwc3, musb,
> > chipidea, Renesas, etc)
> > 
> Just to be sure,
> can I assume that other usb gadget drivers are using DMA (including
> gadgetfs for userspace driver) ?
> And it is also correct for host drivers  (such as camera device ) ?

None of these drivers are for hardware. They implement a protocol.
On the host as well as on the gadget side there are driver for the
actual host controllers (EHCI, XHCI, ...) as well as their gadget
equivalents.

Any of these drivers may or may not use DMA. Neither the assumption
that they use DMA or the assumption that they do not use DMA
is valid. In fact they may mix it.
Your code must be ready to cope with either usage.

HTH
Oliver

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Q: Does mass storage gadget use DMA ?

2018-02-11 Thread Ran Shalit
On Tue, Feb 6, 2018 at 8:55 AM, Felipe Balbi
 wrote:
>
> Hi,
>
> Ran Shalit  writes:
>> Hello,
>>
>> I check code in:
>> https://elixir.free-electrons.com/linux/v3.3/source/drivers/usb/gadget/f_mass_storage.c
>> but I see no API usage of DMA, yet it is being mentioned as if it is used.
>
> but it is used. It's just managed by the UDC driver (dwc3, musb,
> chipidea, Renesas, etc)
>
Just to be sure,
can I assume that other usb gadget drivers are using DMA (including
gadgetfs for userspace driver) ?
And it is also correct for host drivers  (such as camera device ) ?

Thanks,
Ran

> --
> balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Q: Does mass storage gadget use DMA ?

2018-02-05 Thread Felipe Balbi

Hi,

Ran Shalit  writes:
> Hello,
>
> I check code in:
> https://elixir.free-electrons.com/linux/v3.3/source/drivers/usb/gadget/f_mass_storage.c
> but I see no API usage of DMA, yet it is being mentioned as if it is used.

but it is used. It's just managed by the UDC driver (dwc3, musb,
chipidea, Renesas, etc)

-- 
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Q: Does mass storage gadget use DMA ?

2018-02-05 Thread Felipe Balbi

Hi,

Felipe Balbi  writes:
>> I check code in:
>> https://elixir.free-electrons.com/linux/v3.3/source/drivers/usb/gadget/f_mass_storage.c

ps: v3.3 realy??? You really need to upgrade that :-)

-- 
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html