Q: Does mass storage gadget use DMA ?
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. Is it that DMA used in this driver ? Why can't I find any DMA APIs inside? Thank you, Ran -- 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
usb drivers in userspace
Hello, Is it possible to write a usb driver in userspace ? I see that for peripheral/gadget, there is gadgetfs which can be used for that. What about host drivers ? Can we use for example vfio (seems to be used with pci so I'm not sure) ? Or is there another way ? Thank you, Ran -- 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: usb drivers in userspace
On Tue, Feb 6, 2018 at 1:35 PM, Felipe Balbi wrote: > > Hi, > > Ran Shalit writes: >> Hello, >> >> Is it possible to write a usb driver in userspace ? >> I see that for peripheral/gadget, there is gadgetfs which can be used for >> that. >> >> What about host drivers ? >> Can we use for example vfio (seems to be used with pci so I'm not >> sure) ? Or is there another way ? > > Have a look at libusb (libusb.info, IIRC). It's probably what you're > looking for. > Right! I see now that there are 2 main solution nowadays for userspace usb drivers: 1. libusb - for host driver 2. libusb-gadget ( or gadgetfs) - for gadget drivers > good luck Thanks ! > > -- > 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 ?
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 ?
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 ?
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
Q: usb_control_msg() parameters
Hello, I am trying to understand article on reverse engineering usb driver, published in http://www.linuxjournal.com/node/7353/print (2004) I have difficulties understanding the input to the function usb_control_msg() especially the 0x12, 0xc8 numbers. I could not find them in the article, then tried even in the delcom datasheet, but did not find it there too. These numbers refer to __u8 request, __u8 requesttype , value, and index, but I could not understand how they are figured it out in the article. usb_control_msg(led->udev, usb_sndctrlpipe(led->udev, 0), 0x12, <<--- ? 0xc8, <<-- ? (0x02 * 0x100) + 0x0a, <-- ? (0x00 * 0x100) + color, <-- ? buffer, 8, 2 * HZ); Thanks for any comment, Ran -- 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: usb_control_msg() parameters
On Fri, Feb 16, 2018 at 8:54 AM, Greg KH wrote: > On Fri, Feb 16, 2018 at 01:00:06AM +0200, Ran Shalit wrote: >> Hello, >> >> I am trying to understand article on reverse engineering usb driver, >> published in >> http://www.linuxjournal.com/node/7353/print (2004) > > That article was written a _long_ time ago :( > >> I have difficulties understanding the input to the function usb_control_msg() >> especially the 0x12, 0xc8 numbers. >> I could not find them in the article, then tried even in the delcom >> datasheet, but did not find it there too. >> These numbers refer to __u8 request, __u8 requesttype , value, and >> index, but I could not understand how they are figured it out in the >> article. >> >> usb_control_msg(led->udev, >> usb_sndctrlpipe(led->udev, 0), >> 0x12, <<--- ? >> 0xc8, <<-- ? >> (0x02 * 0x100) + 0x0a, <-- ? >> (0x00 * 0x100) + color, <-- ? >> buffer, >> 8, >> 2 * HZ); > > I thought I got them from the data sheet for the device, but that was > over a decade ago, so I really don't remember, sorry. > My question can be more of a general question. I am trying to understand how I should set these arguments (in general) with another device for example. I did not find any complete example/documentation which gives more details as to how to set these arguments: request - USB message request value requesttype - USB message request type value value - USB message value index - USB message index value Thanks for the comments, Ran > greg k-h -- 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
www.linux-usb.org is offline
Hello, I am trying to open http://www.linux-usb.org/ for several days now, but I get the following message: "Project web is currently offline pending the final migration of its data to our new datacenter." Is the information available meantime in another site ? Thank you, 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
Host & gadget transparent driver
Hello, I am facing the following challenge: We have a camera device, and a ready drivers in the following configuration: (1) host <--> camera The drivers for host is a binary, i.e. source code is probably not available, and also the protocol datasheet is probably not available. But we need to use the camera in the following configuration: (2) host <---> embedded board <--> camera In other words, there is a transparent medium in between the host and device. I would like to ask what is the general concept for implementing the drivers in the embedded board ? Does these task requires reverse engineering ? Is there any known example or driver which does something similar ? Thanks a lot, 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: Host & gadget transparent driver
On Thu, Feb 22, 2018 at 10:46 AM, Krzysztof Opasiak wrote: > > > On 02/22/2018 07:53 AM, Greg KH wrote: >> >> On Wed, Feb 21, 2018 at 11:23:26PM +0200, Ran Shalit wrote: >>> >>> Hello, >>> >>> I am facing the following challenge: >>> >>> We have a camera device, and a ready drivers in the following >>> configuration: >>> >>> (1) host <--> camera >>> >>> The drivers for host is a binary, i.e. source code is probably not >>> available, and also the protocol datasheet is probably not available. >> >> >> Really? A USB host driver that is not released under the GPL? That's >> really difficult to imagine, but you are on your own here as that's an >> obvious license violation. Please go talk to your lawyers about this >> problem, or you will have bigger problems if you try to rely on this. >> It is using FLIR camera, a vision camera (FLIR) which uses generic Linux driver (Yet, I am not sure yet which because I don't have that camera with me yet) maybe it's uvc drivers ( do they support vision usb3 ?) , I also see usb3vision git, but didn't find it in mainline (?). https://github.com/ni/usb3vision/blob/master/u3v.h I know that it use standard GenICam (which kernel driver support it?) Yet, My question was more as a general question about if such "transparent drivers" exist and if not what the general concept of writing such driver. As Krzysztof said, it can actually be a userspace driver. > > I don't know the exact case nor I'm license specialist but I think it's > doable without license violation. Take a look at official displaylink > drivers[1]... They consist of two parts. First one is Kernel GPL code[2] > which is obviously published to not violate the license and second part is > userspace binary blob that receives video stream from this "open source > driver" and then uses libusb to communicate with the device... > > Footnotes: > 1 - http://www.displaylink.com/downloads/ubuntu > 2 - https://github.com/DisplayLink/evdi > Best regards, > Krzysztof , I will check the proxy git . What's the difference between the proxy you've given before to the DisplayLink? Thanks, Ran > -- > Krzysztof Opasiak > Samsung R&D Institute Poland > Samsung Electronics -- 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
usb transfer length
Hello, When performing usb transfer we request for maximum size of transfer, yet another size of message (shorter or longer) might be sent from device to host. Are both cases (shorter/longer) legal in usb standard ? In case both are legal: If it is shorter, I guess there is no issue at all. If it is longer - the host must perform transfer for the remaining of the message. Is that correct ? Thank you, 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 ?
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
Q: How does gadgetfs knows that host initiated IN transfer ?
Hello, I am developing simple loopback using gadgetfs, but I am a bit confused as to how gadgefs knows that host initiated IN transfer. Gadgetfs use read/write on endpoints, so as to my understanding, it can only: 1. When using "read" on OUT endpoint - accept a new transfer from host to device. 2. When using "write" on IN endpoint - start transfer from device to host . (1) above seems to be simple to understand, but I have misunderstanding about (2): Isn't it that a write into IN endpoint should be accepted only when host initiated a transaction (device should not initiate transaction by itself) ? If it must , than How does gadget knows that host initiated a transaction in the IN endpoint ? (it probably need to be checked before doing the write in the IN transaction) Thank you, 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
Delayed "registered new interface driver snd-usb-audio"
Hello, I have a strange behabiour with sound card usb. I use kernel 3.18.11-rt7 (real-time kernel ) It takes 10 (!) seconds between detection of usb device till it is registered ("registered new interface driver snd-usb-audio") in kernel. We take the usb device out of reset using another HW. See below dmesg: [7.911220] ixgbe :01:00.1: registered PHC device on eth1 [8.186213] ixgbe :01:00.1 eth1: NIC Link is Up 1 Gbps, Flow Control: RX/TX [8.218386] NET: Registered protocol family 10 [8.691077] ixgbe :01:00.0 eth0: NIC Link is Down [9.090808] ixgbe :01:00.1 eth1: NIC Link is Down [9.893587] ixgbe :01:00.0 eth0: NIC Link is Up 1 Gbps, Flow Control: RX/TX [ 10.317939] ixgbe :01:00.1 eth1: NIC Link is Up 1 Gbps, Flow Control: RX/TX [ 38.171328] random: nonblocking pool is initialized [ 260.380461] usb 1-2: new full-speed USB device number 2 using xhci_hcd [ 260.545907] usb 1-2: config 1 has an invalid descriptor of length 0, skipping remainder of the config [ 260.546471] usb 1-2: New USB device found, idVendor=0451, idProduct=9010 [ 260.546478] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 260.546484] usb 1-2: Product: TI C55 Ver 6.00 [ 260.546488] usb 1-2: Manufacturer: Texas Instruments [ 260.546491] usb 1-2: SerialNumber: 320001 [ 260.594916] input: Texas Instruments TI C55 Ver 6.00 as /devices/pci:00/:00:14.0/usb1/1-2/1-2:1.3/0003:0451:9010.0001/input/input3 [ 260.595084] hid-generic 0003:0451:9010.0001: input,hidraw0: USB HID v1.11 Device [Texas Instruments TI C55 Ver 6.00] on usb-:00:14.0-2/input3 [ 260.595153] usbcore: registered new interface driver usbhid [ 260.595157] usbhid: USB HID core driver [ 345.706843] usbcore: registered new interface driver snd-usb-audio Is there any idea what can cause this delay ? Regards, Ran
Re: Delayed "registered new interface driver snd-usb-audio"
On Mon, Aug 13, 2018 at 9:57 PM, Greg KH wrote: > On Mon, Aug 13, 2018 at 09:34:37PM +0300, Ran Shalit wrote: >> Hello, >> >> I have a strange behabiour with sound card usb. >> I use kernel 3.18.11-rt7 (real-time kernel ) > > Ugh, please go get support from whomever is forcing you to use such an > old and obsolete kernel version. You are paying them for support, > there's nothing that we can do about this :( > >> It takes 10 (!) seconds between detection of usb device till it is >> registered ("registered new interface driver snd-usb-audio") in >> kernel. >> We take the usb device out of reset using another HW. >> >> See below dmesg: >> >> [7.911220] ixgbe :01:00.1: registered PHC device on eth1 >> [8.186213] ixgbe :01:00.1 eth1: NIC Link is Up 1 Gbps, Flow >> Control: RX/TX >> [8.218386] NET: Registered protocol family 10 >> [8.691077] ixgbe :01:00.0 eth0: NIC Link is Down >> [9.090808] ixgbe :01:00.1 eth1: NIC Link is Down >> [9.893587] ixgbe :01:00.0 eth0: NIC Link is Up 1 Gbps, Flow >> Control: RX/TX >> [ 10.317939] ixgbe :01:00.1 eth1: NIC Link is Up 1 Gbps, Flow >> Control: RX/TX >> [ 38.171328] random: nonblocking pool is initialized >> [ 260.380461] usb 1-2: new full-speed USB device number 2 using xhci_hcd >> [ 260.545907] usb 1-2: config 1 has an invalid descriptor of length >> 0, skipping remainder of the config >> [ 260.546471] usb 1-2: New USB device found, idVendor=0451, idProduct=9010 >> [ 260.546478] usb 1-2: New USB device strings: Mfr=1, Product=2, >> SerialNumber=3 >> [ 260.546484] usb 1-2: Product: TI C55 Ver 6.00 >> [ 260.546488] usb 1-2: Manufacturer: Texas Instruments >> [ 260.546491] usb 1-2: SerialNumber: 320001 >> [ 260.594916] input: Texas Instruments TI C55 Ver 6.00 as >> /devices/pci:00/:00:14.0/usb1/1-2/1-2:1.3/0003:0451:9010.0001/input/input3 >> [ 260.595084] hid-generic 0003:0451:9010.0001: input,hidraw0: USB HID >> v1.11 Device [Texas Instruments TI C55 Ver 6.00] on >> usb-:00:14.0-2/input3 >> [ 260.595153] usbcore: registered new interface driver usbhid >> [ 260.595157] usbhid: USB HID core driver >> [ 345.706843] usbcore: registered new interface driver snd-usb-audio >> >> Is there any idea what can cause this delay ? > > You are loading a new driver from somewhere, that takes time. Odds are > this is a userspace issue. > Thanks for the hint, which print did you refer to about the loading module ? I will try to build the modules into kernel and see if it changes. We also noticed that in another kernel (and different ditribution too) the time is immediate, but it could be that the module was build inside kernel in that distribution. we also noticed that in the other distribution it is ehci_hcd, while in this (the slower) it is xhci_hcd. So that also might explain, right ? Thanks, ran > good luck! > > greg k-h
Re: Delayed "registered new interface driver snd-usb-audio"
On Tue, Aug 14, 2018 at 9:36 AM, Greg KH wrote: > On Tue, Aug 14, 2018 at 09:29:26AM +0300, Ran Shalit wrote: >> On Mon, Aug 13, 2018 at 9:57 PM, Greg KH wrote: >> > On Mon, Aug 13, 2018 at 09:34:37PM +0300, Ran Shalit wrote: >> >> Hello, >> >> >> >> I have a strange behabiour with sound card usb. >> >> I use kernel 3.18.11-rt7 (real-time kernel ) >> > >> > Ugh, please go get support from whomever is forcing you to use such an >> > old and obsolete kernel version. You are paying them for support, >> > there's nothing that we can do about this :( >> > >> >> It takes 10 (!) seconds between detection of usb device till it is >> >> registered ("registered new interface driver snd-usb-audio") in >> >> kernel. >> >> We take the usb device out of reset using another HW. >> >> >> >> See below dmesg: >> >> >> >> [7.911220] ixgbe :01:00.1: registered PHC device on eth1 >> >> [8.186213] ixgbe :01:00.1 eth1: NIC Link is Up 1 Gbps, Flow >> >> Control: RX/TX >> >> [8.218386] NET: Registered protocol family 10 >> >> [8.691077] ixgbe :01:00.0 eth0: NIC Link is Down >> >> [9.090808] ixgbe :01:00.1 eth1: NIC Link is Down >> >> [9.893587] ixgbe :01:00.0 eth0: NIC Link is Up 1 Gbps, Flow >> >> Control: RX/TX >> >> [ 10.317939] ixgbe :01:00.1 eth1: NIC Link is Up 1 Gbps, Flow >> >> Control: RX/TX >> >> [ 38.171328] random: nonblocking pool is initialized >> >> [ 260.380461] usb 1-2: new full-speed USB device number 2 using xhci_hcd >> >> [ 260.545907] usb 1-2: config 1 has an invalid descriptor of length >> >> 0, skipping remainder of the config >> >> [ 260.546471] usb 1-2: New USB device found, idVendor=0451, >> >> idProduct=9010 >> >> [ 260.546478] usb 1-2: New USB device strings: Mfr=1, Product=2, >> >> SerialNumber=3 >> >> [ 260.546484] usb 1-2: Product: TI C55 Ver 6.00 >> >> [ 260.546488] usb 1-2: Manufacturer: Texas Instruments >> >> [ 260.546491] usb 1-2: SerialNumber: 320001 >> >> [ 260.594916] input: Texas Instruments TI C55 Ver 6.00 as >> >> /devices/pci:00/:00:14.0/usb1/1-2/1-2:1.3/0003:0451:9010.0001/input/input3 >> >> [ 260.595084] hid-generic 0003:0451:9010.0001: input,hidraw0: USB HID >> >> v1.11 Device [Texas Instruments TI C55 Ver 6.00] on >> >> usb-:00:14.0-2/input3 >> >> [ 260.595153] usbcore: registered new interface driver usbhid >> >> [ 260.595157] usbhid: USB HID core driver >> >> [ 345.706843] usbcore: registered new interface driver snd-usb-audio >> >> >> >> Is there any idea what can cause this delay ? >> > >> > You are loading a new driver from somewhere, that takes time. Odds are >> > this is a userspace issue. >> > >> Thanks for the hint, which print did you refer to about the loading module ? > > Your last one, that happens when the snd-usb-audio driver is loaded into > the kernel, it was not present before that. Go read up on how kernel > modules are automatically loaded when hardware is found, it's a long > kernel->userspace->kernel chain of events that happens. > >> I will try to build the modules into kernel and see if it changes. > > It will. But again, go bug the vendor that is forcing you to use such > an old ad obsolete kernel version for a new device please. That should > not be happening. > One last thing. The kernel is RT linux, I also suspected that there might be some rt thread that *always* gets inside just before the module is loaded (the last delay message), and that's always takes 10 seconds. But using top/htop I haven't find any special thread which gets in in this 10 seconds. I'm not sure I can update kernel now, so I'll have to try the other suggestions. Thanks a lot, ranran >> We also noticed that in another kernel (and different ditribution too) >> the time is immediate, but it could be that the module was build >> inside kernel in that distribution. we also noticed that in the other >> distribution it is ehci_hcd, while in this (the slower) it is >> xhci_hcd. So that also might explain, right ? > > No, the host controller driver should not matter at all. > > good luck! > > greg k-h