All of lore.kernel.org
 help / color / mirror / Atom feed
* Running multiple gadgets in mass storage mode?
@ 2020-06-15 23:06 Arpad Kun
  2020-06-16 11:06 ` Peter Chen
  0 siblings, 1 reply; 2+ messages in thread
From: Arpad Kun @ 2020-06-15 23:06 UTC (permalink / raw)
  To: linux-usb

Hi Everyone,

Seeking advice please on:   if it was possible to run multiple USB devices within the same Linux system in device mode and use g_mass_storage to emulate different "volumes" through each.

This is how far I got:
	- Have two  USB3380-EVB  boards hooked up in a Linux machine (x86)
	- I see both of them via `lspci`, net2280 module runs them.

		# lspci -nn |grep 3380
		04:00.0 USB controller [0c03]: PLX Technology, Inc. Device [10b5:3380] (rev ab)
		65:00.0 USB controller [0c03]: PLX Technology, Inc. Device [10b5:3380] (rev ab)


	- Loading the `g_mass_storage` to allow me to "insert" an image to to emulate:

		# modprobe g_mass_storage removable=y stall=0 nofua=1
		# find /sys/ -name "*gadget*" 
		[...]
		/sys/devices/pci0000:64/0000:64:00.0/0000:65:00.0/gadget
		/sys/devices/pci0000:00/0000:00:1c.5/0000:04:00.0/gadget


	- But when I look at sysfs, only one of them has `lun0/file` that I can echo into:

		# ls -1 /sys/devices/pci0000:00/0000:00:1c.5/0000:04:00.0/gadget
		lun0   <--- lun0 is here, looks good
		power
		suspended
		uevent

		# ls -1 /sys/devices/pci0000:64/0000:64:00.0/0000:65:00.0/gadget
		power
		uevent
		<-- lun0 is missing :(

	- The following works for one image, but I am trying to insert an another image to through the other controller:

		echo "/home/test.img" > /sys/devices/pci0000:00/0000:00:1c.5/0000:04:00.0/gadget/lun0/file


In the kernel documentation I found the following in the USB Controller Driver section:  "The controller driver can support any number of different gadget drivers, but only one of them can be used at a time."
It was not clear whether it means one driver at a time or one controller at a time.  (https://www.kernel.org/doc/html/latest/driver-api/usb/gadget.html)

Questions please:
- Is there something I missed or oversee?
- Would you have any suggestions how to make it work? Is it possible?
- Any advice on cards I could use in x86 machines other than this? I haven't found any other than the 3380, which is end of life now.

Really appreciate advice and direction.

Regards,
Arpad


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Running multiple gadgets in mass storage mode?
  2020-06-15 23:06 Running multiple gadgets in mass storage mode? Arpad Kun
@ 2020-06-16 11:06 ` Peter Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Chen @ 2020-06-16 11:06 UTC (permalink / raw)
  To: Arpad Kun; +Cc: linux-usb

On 20-06-15 16:06:12, Arpad Kun wrote:
> Hi Everyone,
> 
> Seeking advice please on:   if it was possible to run multiple USB devices within the same Linux system in device mode and use g_mass_storage to emulate different "volumes" through each.
> 
> This is how far I got:
> 	- Have two  USB3380-EVB  boards hooked up in a Linux machine (x86)
> 	- I see both of them via `lspci`, net2280 module runs them.
> 
> 		# lspci -nn |grep 3380
> 		04:00.0 USB controller [0c03]: PLX Technology, Inc. Device [10b5:3380] (rev ab)
> 		65:00.0 USB controller [0c03]: PLX Technology, Inc. Device [10b5:3380] (rev ab)
> 
> 
> 	- Loading the `g_mass_storage` to allow me to "insert" an image to to emulate:
> 
> 		# modprobe g_mass_storage removable=y stall=0 nofua=1
> 		# find /sys/ -name "*gadget*" 
> 		[...]
> 		/sys/devices/pci0000:64/0000:64:00.0/0000:65:00.0/gadget
> 		/sys/devices/pci0000:00/0000:00:1c.5/0000:04:00.0/gadget
> 
> 
> 	- But when I look at sysfs, only one of them has `lun0/file` that I can echo into:
> 
> 		# ls -1 /sys/devices/pci0000:00/0000:00:1c.5/0000:04:00.0/gadget
> 		lun0   <--- lun0 is here, looks good
> 		power
> 		suspended
> 		uevent
> 
> 		# ls -1 /sys/devices/pci0000:64/0000:64:00.0/0000:65:00.0/gadget
> 		power
> 		uevent
> 		<-- lun0 is missing :(
> 
> 	- The following works for one image, but I am trying to insert an another image to through the other controller:
> 
> 		echo "/home/test.img" > /sys/devices/pci0000:00/0000:00:1c.5/0000:04:00.0/gadget/lun0/file
> 
> 
> In the kernel documentation I found the following in the USB Controller Driver section:  "The controller driver can support any number of different gadget drivers, but only one of them can be used at a time."
> It was not clear whether it means one driver at a time or one controller at a time.  (https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kernel.org%2Fdoc%2Fhtml%2Flatest%2Fdriver-api%2Fusb%2Fgadget.html&amp;data=02%7C01%7Cpeter.chen%40nxp.com%7Ca4bb128d95ee4dd9a99708d81180b5e3%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C637278591787761356&amp;sdata=uief9JhZbeV693ROZL2Oa4NbX4o5mFV8cqYucj9PcpU%3D&amp;reserved=0)
> 
> Questions please:
> - Is there something I missed or oversee?

modprobe gadget module is legacy way, please use configfs:
Documentation/usb/gadget_configfs.rst

> - Would you have any suggestions how to make it work? Is it possible?

It should be possible. You could bind any UDCs to any gadget drivers,
For your case, you need to create
/sys/kernel/config/usb_gadget/g1
/sys/kernel/config/usb_gadget/g2

For your two UDCs.

-- 

Thanks,
Peter Chen

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-16 11:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 23:06 Running multiple gadgets in mass storage mode? Arpad Kun
2020-06-16 11:06 ` Peter Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.