usb: gadget: nokia: Add mass storage driver to g_nokia
PATCH 1/1 usb: gadget: nokia: Add mass storage driver to g_nokia
This patch adds removable mass storage support to g_nokia gadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...
--- drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102 ++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)
drivers/usb/gadget/legacy/Kconfig +1 -0
@@ -345,6 +345,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGE help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.
drivers/usb/gadget/legacy/nokia.c +101 -1
194 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Hello Pali,
W dniu 31.01.2015 o 10:53, Pali Rohár pisze:
Quoted 2 lines
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported.
For a hint please see this thread:
http://www.spinics.net/lists/linux-usb/msg119669.html
Hi,
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>
thanks, but no thanks. Build your own using configfs.
Signature · 1 line
balbi
Quoted 9 lines · On Monday 02 February 2015 19:54:58 Felipe Balbi wrote:
Hi,
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...
Quoted 3 lines
Quoted 1 line
Signed-off-by Pali Rohár <[email protected]>thanks, but no thanks. Build your own using configfs.
But it needs some userspace interaction right?
Then its not possible for nfsboot.
Signature · 2 lines
Pali Rohár [email protected]
Hi,
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Monday 02 February 2015 19:54:58 Felipe Balbi wrote:
Hi,
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Pali Rohár <[email protected]>thanks, but no thanks. Build your own using configfs.
But it needs some userspace interaction right?
Then its not possible for nfsboot.
oh, right... you're using nfsboot through g_nokia. Hmm, sounds like you need initramfs.
Signature · 1 line
balbi
Quoted 15 lines · On Monday 02 February 2015 20:01:11 Felipe Balbi wrote:
Hi,
Quoted 12 lines · Pali Rohár
Quoted 11 lines · On Monday 02 February 2015 19:54:58 Felipe Balbi wrote:
Hi,
Quoted 7 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
thanks, but no thanks. Build your own using configfs.
But it needs some userspace interaction right?
Then its not possible for nfsboot.oh, right... you're using nfsboot through
g_nokia. Hmm, sounds like you need initramfs.
Also compiling usb gadgets as external .ko modules is broken. So I cannot use configfs, when I compile g_nokia even if I use initramfs...
Signature · 2 lines
Pali Rohár [email protected]
Quoted 21 lines · Pali Rohár
Quoted 20 lines · On Monday 02 February 2015 20:01:11 Felipe Balbi wrote:
Hi,
Quoted 16 lines · Pali Rohár
Quoted 9 lines · On Monday 02 February 2015 19:54:58 Felipe Balbi wrote:
Hi,
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Quoted 3 lines
Quoted 1 line
Signed-off-by Pali Rohár <[email protected]>thanks, but no thanks. Build your own using configfs.
But it needs some userspace interaction right?
Then its not possible for nfsboot.
Quoted 6 lines
Quoted 2 lines
oh, right... you're using nfsboot through
g_nokia. Hmm, sounds like you need initramfs.Also compiling usb gadgets as external .ko modules is broken. So I cannot use configfs, when I compile
g_nokiaeven if I use initramfs...
yeah, there are people working on that and some patches already flying around for it. Meanwhile, you can make it built-in and use initramfs to add mass_storage through configfs to g_nokia, no issues.
Signature · 1 line
balbi
Quoted 9 lines · On Monday 02 February 2015 20:14:35 Felipe Balbi wrote:
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Monday 02 February 2015 20:01:11 Felipe Balbi wrote:
Hi,
Quoted 4 lines · Pali Rohár
Quoted 3 lines · On Monday 02 February 2015 19:54:58 Felipe Balbi wrote:
Hi,
On Sat, Jan 31, 2015 at 10:53:30AM +0100, Pali Rohár
Quoted 16 lines · wrote:
Quoted 16 lines
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Pali Rohár <[email protected]>thanks, but no thanks. Build your own using configfs.
But it needs some userspace interaction right?
Then its not possible for nfsboot.oh, right... you're using nfsboot through
g_nokia. Hmm, sounds like you need initramfs.
Quoted 8 lines
Quoted 3 lines
Also compiling usb gadgets as external .ko modules is broken. So I cannot use configfs, when I compile
g_nokiaeven if I use initramfs...yeah, there are people working on that and some patches already flying around for it. Meanwhile, you can make it built-in and use initramfs to add
mass_storagethrough configfs tog_nokia, no issues.
Sorry but nfsboot is used without initramfs. I do not need to use any initramfs and I do not see reason for it because of kernel usb bugs...
My patch for mass storage mode in g_nokia.ko driver (which is used for Nokia N900 only) fix usage of both g_nokia functions and mass storage functions.
Because in current state on N900 this is easy and *working* solution (g_nokia static linked into zImage). So I do not see reason why not to include my patch into upstream. Driver g_nokia is N900 specific and all developers can benefit this patch, because they would be able to use *both* usb networking and mass storage mode *without* need to recompile kernel and restart n900 device!
And please do not tell me that either usb network or mass storage support is deprecated or so and nobody should not use it! This is only way how to develop & debug n900 device without any other Nokia (TM) equipment which is not available for non Nokias...
Signature · 2 lines
Pali Rohár [email protected]
Quoted 25 lines · Felipe Balbi
Quoted 24 lines · Pali Rohár
Quoted 22 lines · On Monday 02 February 2015 20:01:11 Felipe Balbi wrote:
Hi,
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Monday 02 February 2015 19:54:58 Felipe Balbi wrote:
Hi,
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Pali Rohár <[email protected]>thanks, but no thanks. Build your own using configfs.
But it needs some userspace interaction right?
Then its not possible for nfsboot.oh, right... you're using nfsboot through
g_nokia. Hmm, sounds like you need initramfs.
Quoted 8 lines
Quoted 3 lines
Also compiling usb gadgets as external .ko modules is broken. So I cannot use configfs, when I compile
g_nokiaeven if I use initramfs...yeah, there are people working on that and some patches already flying around for it. Meanwhile, you can make it built-in and use initramfs to add
mass_storagethrough configfs tog_nokia, no issues.
Bellow is the bactrace of the crash when g_nokia is modprobed. Any hint on where to look for is appreciated.
<0>[ 33.751983] Kernel panic - not syncing: Fatal exception ÿÿT!19\00]\00]<6>[ 59.570159] bq2415x-charger 2-006b: automode enabled <1>[ 59.597534] [bf286014] *pgd=8eda8811, *pte=00000000, *ppte=00000000 <6>[ 59.609405] bq2415x-charger 2-006b: driver registered <0>[ 59.640472] Internal error: Oops: 80000007 [#1] PREEMPT ARM <4>[ 59.650421] Modules linked in: ipv6(+) bq2415x_charger(+) g_mass_storage usb_f_mass_storage libcomposite configfs uinput adp1653 ad5820 et8ek8 smiaregs hsi_char radio_platform_si4713 joydev omap_ssi_port wl1251_spi wl1251 rx51_battery mac80211 isp1704_charger smc91x mii cfg80211 si4713 v4l2_common crc7 videodev tsc2005 media tsl2563 twl4030_vibra ff_memless lis3lv02d_i2c lis3lv02d omap_ssi input_polldev hsi twl4030_wdt omap_wdt rtc_twl leds_lp5523 leds_lp55xx_common <4>[ 59.715332] CPU: 0 PID: 13 Comm: kworker/0:1 Not tainted 3.19.0-rc5+ #2 <4>[ 59.726501] Hardware name: Nokia RX-51 board <4>[ 59.735168] Workqueue: events usb_gadget_work <4>[ 59.743896] task: cf8ab900 ti: cf992000 task.ti: cf992000 <4>[ 59.753692] PC is at 0xbf286014 <4>[ 59.761108] LR is at try_get_usb_function_instance+0x90/0x9c [libcomposite] <4>[ 59.772613] pc : [<bf286014>] lr : [<bf2640c8>] psr: 80000113 <4>[ 59.772613] sp : cf993e50 ip : 0000001c fp : 00000000 <4>[ 59.793060] r10: 00000000 r9 : 00000000 r8 : cfcad600 <4>[ 59.802581] r7 : cedaab80 r6 : 00000000 r5 : bf28444c r4 : cedaab80 <4>[ 59.813476] r3 : cedd8f38 r2 : 00000001 r1 : 00000000 r0 : cedd8f04 <4>[ 59.824310] Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel <4>[ 59.836090] Control: 10c5387d Table: 8e970019 DAC: 00000015 <0>[ 59.846252] Process kworker/0:1 (pid: 13, stack limit = 0xcf992238) <0>[ 59.857086] Stack: (0xcf993e50 to 0xcf994000) <0>[ 59.865814] 3e40: c03fb2d8 bf266e68 cf1fdf00 c015d0dc <0>[ 59.878723] 3e60: 92000000 00001000 00000000 c015d8d8 00001000 00000000 c03fb2d8 bf266e68 <0>[ 59.891693] 3e80: 00000000 00000001 00000000 c00f58f8 cf801c80 cedaab80 cf03b0b8 cedaac00 <0>[ 59.904663] 3ea0: bf284424 c015d980 00000000 bf266e68 00000000 cedaab80 bf28444c 00000000 <0>[ 59.917572] 3ec0: cf03b0b8 cfcad600 00000000 bf263dd8 cf03b0b8 bf28444c cf03b0b8 cf1fea00 <0>[ 59.930450] 3ee0: c0620cd8 bf28444c c0609868 cfcad600 00000000 00000000 00000000 c02c5478 <0>[ 59.943420] 3f00: bf284470 c0620cd8 c0606ff8 c02c5f54 cf98d080 bf284470 c0606ff8 c0047288 <0>[ 59.956390] 3f20: cf98d080 bf284470 00000001 cf98d080 c0606ff8 c0607008 c0609868 cf98d098 <0>[ 59.969360] 3f40: 00000008 00000000 00000000 c00477ec cf98a580 00000000 cf98d080 c00474c4 <0>[ 59.982330] 3f60: 00000000 00000000 00000000 c004b148 22000000 00000000 11880000 cf98d080 <0>[ 59.995208] 3f80: 00000000 cf993f84 cf993f84 00000000 cf993f90 cf993f90 cf993fac cf98a580 <0>[ 60.008026] 3fa0: c004b07c 00000000 00000000 c000e058 00000000 00000000 00000000 00000000 <0>[ 60.020782] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <0>[ 60.033355] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 40000500 04000401 <4>[ 60.045867] [<bf2640c8>] (try_get_usb_function_instance [libcomposite]) from [<c015d0dc>] (__kernfs_create_file+0x7c/0xa0) <4>[ 60.065155] [<c015d0dc>] (__kernfs_create_file) from [<c015d8d8>] (sysfs_add_file_mode_ns+0x134/0x1ac) <4>[ 60.082977] [<c015d8d8>] (sysfs_add_file_mode_ns) from [<c015d980>] (sysfs_create_file_ns+0x30/0x44) <4>[ 60.100952] [<c015d980>] (sysfs_create_file_ns) from [<cedaab80>] (0xcedaab80) <0>[ 60.112884] Code: bad PC value <6>[ 60.210144] NET: Registered protocol family 10 <6>[ 60.671600] bq27x00-battery 2-0055: support ver. 1.2.0 enabled <6>[ 60.832885] bq27x00-battery 2-0055: battery is not calibrated! ignoring capacity values <6>[ 63.788269] Adding 786428k swap on /dev/mmcblk0p3. Priority:-1 extents:1 across:786428k SS <5>[ 64.057617] random: nonblocking pool is initialized <6>[ 64.554016] NET: Registered protocol family 35 <4>[ 65.667510] ---[ end trace 85b8d26ec312a8c1 ]---
Regards,
Ivo
Hi,
Quoted 121 lines · Ivaylo Dimitrov
Quoted 25 lines · Felipe Balbi
Quoted 24 lines · Pali Rohár
Quoted 22 lines · On Monday 02 February 2015 20:01:11 Felipe Balbi wrote:
Hi,
Quoted 10 lines · Pali Rohár
Quoted 9 lines · On Monday 02 February 2015 19:54:58 Felipe Balbi wrote:
Hi,
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Pali Rohár <[email protected]>thanks, but no thanks. Build your own using configfs.
But it needs some userspace interaction right?
Then its not possible for nfsboot.oh, right... you're using nfsboot through
g_nokia. Hmm, sounds like you need initramfs.Quoted 8 lines
Quoted 3 lines
Also compiling usb gadgets as external .ko modules is broken. So I cannot use configfs, when I compile
g_nokiaeven if I use initramfs...yeah, there are people working on that and some patches already flying around for it. Meanwhile, you can make it built-in and use initramfs to add
mass_storagethrough configfs tog_nokia, no issues.Bellow is the bactrace of the crash when
g_nokiais modprobed. Any hint on where to look for is appreciated.<0>[ 33.751983] Kernel panic - not syncing: Fatal exception ÿÿT!19\00]\00]<6>[ 59.570159] bq2415x-charger 2-006b: automode enabled <1>[ 59.597534] [bf286014] *pgd=8eda8811, *pte=00000000, *ppte=00000000 <6>[ 59.609405] bq2415x-charger 2-006b: driver registered <0>[ 59.640472] Internal error: Oops: 80000007 [#1] PREEMPT ARM <4>[ 59.650421] Modules linked in: ipv6(+) bq2415x_charger(+)
g_mass_storageusb_f_mass_storagelibcomposite configfs uinput adp1653 ad5820 et8ek8 smiaregshsi_charradio_platform_si4713joydevomap_ssi_portwl1251_spiwl1251rx51_batterymac80211isp1704_chargersmc91x mii cfg80211 si4713v4l2_commoncrc7 videodev tsc2005 media tsl2563twl4030_vibraff_memlesslis3lv02d_i2clis3lv02domap_ssiinput_polldevhsitwl4030_wdtomap_wdtrtc_twlleds_lp5523leds_lp55xx_common<4>[ 59.715332] CPU: 0 PID: 13 Comm: kworker/0:1 Not tainted 3.19.0-rc5+ #2 <4>[ 59.726501] Hardware name: Nokia RX-51 board <4>[ 59.735168] Workqueue: events usb_gadget_work <4>[ 59.743896] task: cf8ab900 ti: cf992000 task.ti: cf992000 <4>[ 59.753692] PC is at 0xbf286014 <4>[ 59.761108] LR is at try_get_usb_function_instance+0x90/0x9c [libcomposite] <4>[ 59.772613] pc : [<bf286014>] lr : [<bf2640c8>] psr: 80000113 <4>[ 59.772613] sp : cf993e50 ip : 0000001c fp : 00000000 <4>[ 59.793060] r10: 00000000 r9 : 00000000 r8 : cfcad600 <4>[ 59.802581] r7 : cedaab80 r6 : 00000000 r5 : bf28444c r4 : cedaab80 <4>[ 59.813476] r3 : cedd8f38 r2 : 00000001 r1 : 00000000 r0 : cedd8f04 <4>[ 59.824310] Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel <4>[ 59.836090] Control: 10c5387d Table: 8e970019 DAC: 00000015 <0>[ 59.846252] Process kworker/0:1 (pid: 13, stack limit = 0xcf992238) <0>[ 59.857086] Stack: (0xcf993e50 to 0xcf994000) <0>[ 59.865814] 3e40: c03fb2d8 bf266e68 cf1fdf00 c015d0dc <0>[ 59.878723] 3e60: 92000000 00001000 00000000 c015d8d8 00001000 00000000 c03fb2d8 bf266e68 <0>[ 59.891693] 3e80: 00000000 00000001 00000000 c00f58f8 cf801c80 cedaab80 cf03b0b8 cedaac00 <0>[ 59.904663] 3ea0: bf284424 c015d980 00000000 bf266e68 00000000 cedaab80 bf28444c 00000000 <0>[ 59.917572] 3ec0: cf03b0b8 cfcad600 00000000 bf263dd8 cf03b0b8 bf28444c cf03b0b8 cf1fea00 <0>[ 59.930450] 3ee0: c0620cd8 bf28444c c0609868 cfcad600 00000000 00000000 00000000 c02c5478 <0>[ 59.943420] 3f00: bf284470 c0620cd8 c0606ff8 c02c5f54 cf98d080 bf284470 c0606ff8 c0047288 <0>[ 59.956390] 3f20: cf98d080 bf284470 00000001 cf98d080 c0606ff8 c0607008 c0609868 cf98d098 <0>[ 59.969360] 3f40: 00000008 00000000 00000000 c00477ec cf98a580 00000000 cf98d080 c00474c4 <0>[ 59.982330] 3f60: 00000000 00000000 00000000 c004b148 22000000 00000000 11880000 cf98d080 <0>[ 59.995208] 3f80: 00000000 cf993f84 cf993f84 00000000 cf993f90 cf993f90 cf993fac cf98a580 <0>[ 60.008026] 3fa0: c004b07c 00000000 00000000 c000e058 00000000 00000000 00000000 00000000 <0>[ 60.020782] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <0>[ 60.033355] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 40000500 04000401 <4>[ 60.045867] [<bf2640c8>] (try_get_usb_function_instance [libcomposite]) from [<c015d0dc>] (__kernfs_create_file+0x7c/0xa0) <4>[ 60.065155] [<c015d0dc>] (__kernfs_create_file) from [<c015d8d8>] (sysfs_add_file_mode_ns+0x134/0x1ac) <4>[ 60.082977] [<c015d8d8>] (sysfs_add_file_mode_ns) from [<c015d980>] (sysfs_create_file_ns+0x30/0x44) <4>[ 60.100952] [<c015d980>] (sysfs_create_file_ns) from [<cedaab80>] (0xcedaab80) <0>[ 60.112884] Code: bad PC value <6>[ 60.210144] NET: Registered protocol family 10 <6>[ 60.671600] bq27x00-battery 2-0055: support ver. 1.2.0 enabled <6>[ 60.832885] bq27x00-battery 2-0055: battery is not calibrated! ignoring capacity values <6>[ 63.788269] Adding 786428k swap on /dev/mmcblk0p3. Priority:-1 extents:1 across:786428k SS <5>[ 64.057617] random: nonblocking pool is initialized <6>[ 64.554016] NET: Registered protocol family 35 <4>[ 65.667510] ---[ end trace 85b8d26ec312a8c1 ]---
Quoted 2 lines
Regards,
Ivo
Removing __init from nokia_bind declaration makes g_nokia working again. I guess someone who knows better than me that sections magic should take it from here.
Ivo
Quoted 9 lines · On Saturday 07 February 2015 19:33:53 Ivaylo Dimitrov wrote:
Hi,
Quoted 6 lines · Ivaylo Dimitrov
Quoted 5 lines · Felipe Balbi
Quoted 4 lines · Pali Rohár
Quoted 3 lines · On Monday 02 February 2015 20:01:11 Felipe Balbi wrote:
Hi,
On Mon, Feb 02, 2015 at 07:58:59PM +0100, Pali Rohár
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines · On Monday 02 February 2015 19:54:58 Felipe Balbi wrote:
Quoted 3 lines
Hi,
On Sat, Jan 31, 2015 at 10:53:30AM +0100, Pali Rohár
Quoted 113 lines · wrote:
Quoted 113 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Pali Rohár <[email protected]>thanks, but no thanks. Build your own using configfs.
But it needs some userspace interaction right?
Then its not possible for nfsboot.oh, right... you're using nfsboot through
g_nokia. Hmm, sounds like you need initramfs.Quoted 8 lines
Quoted 3 lines
Also compiling usb gadgets as external .ko modules is broken. So I cannot use configfs, when I compile
g_nokiaeven if I use initramfs...yeah, there are people working on that and some patches already flying around for it. Meanwhile, you can make it built-in and use initramfs to add
mass_storagethrough configfs tog_nokia, no issues.Bellow is the bactrace of the crash when
g_nokiais modprobed. Any hint on where to look for is appreciated.<0>[ 33.751983] Kernel panic - not syncing: Fatalexception ÿÿT!19\00]\00]<6>[ 59.570159] bq2415x-charger
2-006b: automode enabled <1>[ 59.597534] [bf286014]
*pgd=8eda8811, *pte=00000000, *ppte=00000000 <6>[ 59.609405] bq2415x-charger 2-006b: driver registered <0>[ 59.640472] Internal error: Oops: 80000007 [#1] PREEMPT ARM<4>[ 59.650421] Modules linked in: ipv6(+)
bq2415x_charger(+)g_mass_storageusb_f_mass_storagelibcomposite configfs uinput adp1653 ad5820 et8ek8 smiaregshsi_charradio_platform_si4713joydevomap_ssi_portwl1251_spiwl1251rx51_batterymac80211isp1704_chargersmc91x mii cfg80211 si4713v4l2_commoncrc7 videodev tsc2005 media tsl2563twl4030_vibraff_memlesslis3lv02d_i2clis3lv02domap_ssiinput_polldevhsitwl4030_wdtomap_wdtrtc_twlleds_lp5523leds_lp55xx_common<4>[ 59.715332] CPU: 0 PID: 13 Comm: kworker/0:1 Not tainted 3.19.0-rc5+ #2 <4>[ 59.726501] Hardware name: Nokia RX-51 board <4>[ 59.735168] Workqueue: events usb_gadget_work <4>[ 59.743896] task: cf8ab900 ti: cf992000 task.ti: cf992000 <4>[ 59.753692] PC is at 0xbf286014 <4>[ 59.761108] LR is at try_get_usb_function_instance+0x90/0x9c [libcomposite] <4>[ 59.772613] pc : [<bf286014>] lr : [<bf2640c8>]psr: 80000113 <4>[ 59.772613] sp :
cf993e50ip :0000001cfp : 00000000 <4>[ 59.793060] r10: 00000000 r9
: 00000000 r8 :cfcad600<4>[ 59.802581] r7 :cedaab80
r6 : 00000000 r5 :bf28444cr4 :cedaab80<4>[ 59.813476] r3 : cedd8f38 r2 : 00000001 r1 : 00000000 r0 : cedd8f04 <4>[ 59.824310] Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel <4>[ 59.836090] Control: 10c5387d Table: 8e970019 DAC: 00000015 <0>[ 59.846252] Process kworker/0:1 (pid: 13, stack limit = 0xcf992238) <0>[ 59.857086] Stack: (0xcf993e50 to 0xcf994000) <0>[ 59.865814] 3e40: c03fb2d8 bf266e68 cf1fdf00 c015d0dc <0>[ 59.878723] 3e60: 92000000 00001000 00000000 c015d8d8 00001000 00000000 c03fb2d8 bf266e68 <0>[ 59.891693] 3e80: 00000000 00000001 00000000 c00f58f8 cf801c80 cedaab80 cf03b0b8 cedaac00 <0>[ 59.904663] 3ea0: bf284424 c015d980 00000000 bf266e68 00000000 cedaab80 bf28444c 00000000 <0>[ 59.917572] 3ec0: cf03b0b8 cfcad600 00000000 bf263dd8 cf03b0b8 bf28444c cf03b0b8 cf1fea00 <0>[ 59.930450] 3ee0: c0620cd8 bf28444c c0609868 cfcad600 00000000 00000000 00000000 c02c5478 <0>[ 59.943420] 3f00: bf284470 c0620cd8 c0606ff8 c02c5f54 cf98d080 bf284470 c0606ff8 c0047288 <0>[ 59.956390] 3f20: cf98d080 bf284470 00000001 cf98d080 c0606ff8 c0607008 c0609868 cf98d098 <0>[ 59.969360] 3f40: 00000008 00000000 00000000 c00477ec cf98a580 00000000 cf98d080 c00474c4 <0>[ 59.982330] 3f60: 00000000 00000000 00000000 c004b148 22000000 00000000 11880000 cf98d080 <0>[ 59.995208] 3f80: 00000000 cf993f84 cf993f84 00000000 cf993f90 cf993f90 cf993fac cf98a580 <0>[ 60.008026] 3fa0: c004b07c 00000000 00000000 c000e058 00000000 00000000 00000000 00000000 <0>[ 60.020782] 3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 <0>[ 60.033355] 3fe0: 00000000 00000000 00000000 00000000 00000013 00000000 40000500 04000401 <4>[ 60.045867] [<bf2640c8>](
try_get_usb_function_instance[libcomposite]) from [<c015d0dc>] (__kernfs_create_file+0x7c/0xa0) <4>[ 60.065155] [<c015d0dc>] (__kernfs_create_file) from [<c015d8d8>] (sysfs_add_file_mode_ns+0x134/0x1ac)<4>[ 60.082977] [<c015d8d8>] (sysfs_add_file_mode_ns) from [<c015d980>] (sysfs_create_file_ns+0x30/0x44) <4>[ 60.100952] [<c015d980>] (sysfs_create_file_ns) from [<cedaab80>] (0xcedaab80) <0>[ 60.112884] Code: bad PC value <6>[ 60.210144] NET: Registered protocol family 10 <6>[ 60.671600] bq27x00-battery 2-0055: support ver. 1.2.0 enabled <6>[ 60.832885] bq27x00-battery 2-0055: battery is not calibrated! ignoring capacity values <6>[ 63.788269] Adding 786428k swap on /dev/mmcblk0p3. Priority:-1 extents:1 across:786428k SS <5>[ 64.057617] random: nonblocking pool is initialized <6>[ 64.554016] NET: Registered protocol family 35 <4>[ 65.667510] ---[ end trace 85b8d26ec312a8c1 ]---
Quoted 8 lines
Quoted 2 lines
Regards,
IvoRemoving
__initfromnokia_binddeclaration makesg_nokiaworking again. I guess someone who knows better than me that sections magic should take it from here.Ivo
No, it is not working on my devices. kernel does not crash, but usb communication does not work. all usb networking packets are lost.
Signature · 2 lines
Pali Rohár [email protected]
Quoted 5 lines · On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...
Quoted 7 lines
Signed-off-by Pali Rohár <[email protected]>--- drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)
Compiling gadgets as external .ko modules is still broken and also for nfs boot, external modules are useless. So I would propose my solution for usb mass storage in g_nokia again.
Signature · 2 lines
Pali Rohár [email protected]
Quoted 223 lines · On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>--- drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102 ++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)drivers/usb/gadget/legacy/Kconfig +1
-0@@ -345,6 +345,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGE help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.drivers/usb/gadget/legacy/nokia.c +98
-1@@ -24,6 +24,7 @@#include "u_phonet.h" #include "u_ecm.h" #include "gadget_chips.h" +#include "f_mass_storage.h" /* Defines */ @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();USB_ETHERNET_MODULE_PARAMETERS (); +static struct fsg_module_parameters fsg_mod_data = { + .stall =0 , + .luns =2 , + .removable_count =2 , + .removable = {1 ,1 , }, +}; + +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); + +#ifdef CONFIG_USB_GADGET_DEBUG_FILES + +static unsigned int fsg_num_buffers =CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS ; + +#else + +/* +* Number of buffers we will use. +* 2 is usually enough for good buffering pipeline +*/ +#define fsg_num_buffers CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS + +#endif /* CONFIG_USB_DEBUG */ +#define NOKIA_VENDOR_ID 0x0421/* Nokia */ #define NOKIA_PRODUCT_ID 0x01c8/* Nokia Gadget */ @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;static struct usb_function *f_obex2_cfg2;static struct usb_function *f_phonet_cfg1;static struct usb_function *f_phonet_cfg2; +static struct usb_function *f_msg_cfg1; +static struct usb_function *f_msg_cfg2;static struct usb_configuration nokia_config_500ma_driver = {@@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;static struct usb_function_instance *fi_obex1;static struct usb_function_instance *fi_obex2;static struct usb_function_instance *fi_phonet; +static struct usb_function_instance *fi_msg;static int __init nokia_bind_config (struct usb_configuration *c) {@@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct usb_configuration *c)struct usb_function *f_obex1 =NULL ;struct usb_function *f_ecm;struct usb_function *f_obex2 =NULL ; +struct usb_function *f_msg; +struct fsg_opts *fsg_opts;int status =0 ;int obex1_stat =-1 ;int obex2_stat =-1 ;@@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct usb_configuration *c) goto err_get_ecm; } + f_msg =usb_get_function (fi_msg); +if (IS_ERR (f_msg)) { + status =PTR_ERR (f_msg); + goto err_get_msg; + } +if (!IS_ERR_OR_NULL (f_phonet)) { phonet_stat =usb_add_function (c, f_phonet);if (phonet_stat)@@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct usb_configuration *c)pr_debug ("could not bind ecm config %d\n" , status); goto err_ecm; } + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + + status =fsg_common_run_thread (fsg_opts->common); +if (status) + goto err_msg; + + status =usb_add_function (c, f_msg); +if (status) + goto err_msg; +if (c == &nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; f_ecm_cfg1 = f_ecm; f_phonet_cfg1 = f_phonet; f_obex1_cfg1 = f_obex1; f_obex2_cfg1 = f_obex2; + f_msg_cfg1 = f_msg; }else { f_acm_cfg2 = f_acm; f_ecm_cfg2 = f_ecm; f_phonet_cfg2 = f_phonet; f_obex1_cfg2 = f_obex1; f_obex2_cfg2 = f_obex2; + f_msg_cfg2 = f_msg; }return status; +err_msg: +usb_remove_function (c, f_ecm); err_ecm:usb_remove_function (c, f_acm); err_conf:@@ -211,6 +261,8 @@ err_conf:usb_remove_function (c, f_obex1);if (!phonet_stat)usb_remove_function (c, f_phonet); +usb_put_function (f_msg); +err_get_msg:usb_put_function (f_ecm); err_get_ecm:usb_put_function (f_acm);@@ -227,6 +279,8 @@ err_get_acm:static int __init nokia_bind (struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; +struct fsg_opts *fsg_opts; +struct fsg_config fsg_config;int status; status =usb_string_ids_tab (cdev, strings_dev);@@ -267,11 +321,46 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) goto err_acm_inst; } + fi_msg =usb_get_function_instance ("mass_storage" ); +if (IS_ERR (fi_msg)) { + status =PTR_ERR (fi_msg); + goto err_ecm_inst; + } + +/* set up mass storage function */ +fsg_config_from_params (&fsg_config, &fsg_mod_data, fsg_num_buffers); + fsg_config.vendor_name ="Nokia" ; + fsg_config.product_name ="N900" ; + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + fsg_opts->no_configfs = true; + + status =fsg_common_set_num_buffers (fsg_opts->common, fsg_num_buffers); +if (status) + goto err_msg_inst; + + status =fsg_common_set_nluns (fsg_opts->common, fsg_config.nluns); +if (status) + goto err_msg_buf; + + status =fsg_common_set_cdev (fsg_opts->common, cdev, fsg_config.can_stall); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_sysfs (fsg_opts->common, true); + + status =fsg_common_create_luns (fsg_opts->common, &fsg_config); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_inquiry_string (fsg_opts->common, fsg_config.vendor_name, + fsg_config.product_name); +/* finally register the configuration */ status =usb_add_config (cdev, &nokia_config_500ma_driver, nokia_bind_config);if (status <0 ) - goto err_ecm_inst; + goto err_msg_set_cdev; status =usb_add_config (cdev, &nokia_config_100ma_driver, nokia_bind_config);@@ -292,6 +381,14 @@ err_put_cfg1:if (!IS_ERR_OR_NULL (f_phonet_cfg1))usb_put_function (f_phonet_cfg1);usb_put_function (f_ecm_cfg1); +err_msg_set_cdev: +fsg_common_remove_luns (fsg_opts->common); +err_msg_set_nluns: +fsg_common_free_luns (fsg_opts->common); +err_msg_buf: +fsg_common_free_buffers (fsg_opts->common); +err_msg_inst: +usb_put_function_instance (fi_msg); err_ecm_inst:usb_put_function_instance (fi_ecm); err_acm_inst:
drivers/usb/gadget/legacy/nokia.c static int __exit nokia_unbind(struct usb_composite_dev *cdev) · line 431
Quoted 10 lines
drivers/usb/gadget/legacy/nokia.c +3
-0@@ -325,7 +422,10 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev)usb_put_function (f_acm_cfg2);usb_put_function (f_ecm_cfg1);usb_put_function (f_ecm_cfg2); +usb_put_function (f_msg_cfg1); +usb_put_function (f_msg_cfg2); +usb_put_function_instance (fi_msg);usb_put_function_instance (fi_ecm);if (!IS_ERR (fi_obex2))usb_put_function_instance (fi_obex2);
Opening discussion about this patch again as this is still only one solution how to use use mass storage without breaking other stuff...
Please understand finally that usb networking is very very important for development on this device and usb mass storage is needed for transferring bigger data.
Also to clarify potential regressions: This patch adds *optional* usb mass storage support and block device can be attached/detached to driver at runtime. It does *not* enforce to export some (mmc) device automatically. It is optional and userspace can decide...
So MyDocs N900 partition is not automatically enforced to be exported via usb (as some people thought) and so it does not break usb networking or mass storage mode or MyDocs parition on N900 with Maemo system.
Signature · 2 lines
Pali Rohár [email protected]
Quoted 242 lines · Pali Rohár
Quoted 223 lines · On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>--- drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102 ++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)drivers/usb/gadget/legacy/Kconfig +1
-0@@ -345,6 +345,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGE help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.drivers/usb/gadget/legacy/nokia.c +98
-1@@ -24,6 +24,7 @@#include "u_phonet.h" #include "u_ecm.h" #include "gadget_chips.h" +#include "f_mass_storage.h" /* Defines */ @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();USB_ETHERNET_MODULE_PARAMETERS (); +static struct fsg_module_parameters fsg_mod_data = { + .stall =0 , + .luns =2 , + .removable_count =2 , + .removable = {1 ,1 , }, +}; + +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); + +#ifdef CONFIG_USB_GADGET_DEBUG_FILES + +static unsigned int fsg_num_buffers =CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS ; + +#else + +/* +* Number of buffers we will use. +* 2 is usually enough for good buffering pipeline +*/ +#define fsg_num_buffers CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS + +#endif /* CONFIG_USB_DEBUG */ +#define NOKIA_VENDOR_ID 0x0421/* Nokia */ #define NOKIA_PRODUCT_ID 0x01c8/* Nokia Gadget */ @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;static struct usb_function *f_obex2_cfg2;static struct usb_function *f_phonet_cfg1;static struct usb_function *f_phonet_cfg2; +static struct usb_function *f_msg_cfg1; +static struct usb_function *f_msg_cfg2;static struct usb_configuration nokia_config_500ma_driver = {@@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;static struct usb_function_instance *fi_obex1;static struct usb_function_instance *fi_obex2;static struct usb_function_instance *fi_phonet; +static struct usb_function_instance *fi_msg;static int __init nokia_bind_config (struct usb_configuration *c) {@@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct usb_configuration *c)struct usb_function *f_obex1 =NULL ;struct usb_function *f_ecm;struct usb_function *f_obex2 =NULL ; +struct usb_function *f_msg; +struct fsg_opts *fsg_opts;int status =0 ;int obex1_stat =-1 ;int obex2_stat =-1 ;@@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct usb_configuration *c) goto err_get_ecm; } + f_msg =usb_get_function (fi_msg); +if (IS_ERR (f_msg)) { + status =PTR_ERR (f_msg); + goto err_get_msg; + } +if (!IS_ERR_OR_NULL (f_phonet)) { phonet_stat =usb_add_function (c, f_phonet);if (phonet_stat)@@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct usb_configuration *c)pr_debug ("could not bind ecm config %d\n" , status); goto err_ecm; } + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + + status =fsg_common_run_thread (fsg_opts->common); +if (status) + goto err_msg; + + status =usb_add_function (c, f_msg); +if (status) + goto err_msg; +if (c == &nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; f_ecm_cfg1 = f_ecm; f_phonet_cfg1 = f_phonet; f_obex1_cfg1 = f_obex1; f_obex2_cfg1 = f_obex2; + f_msg_cfg1 = f_msg; }else { f_acm_cfg2 = f_acm; f_ecm_cfg2 = f_ecm; f_phonet_cfg2 = f_phonet; f_obex1_cfg2 = f_obex1; f_obex2_cfg2 = f_obex2; + f_msg_cfg2 = f_msg; }return status; +err_msg: +usb_remove_function (c, f_ecm); err_ecm:usb_remove_function (c, f_acm); err_conf:@@ -211,6 +261,8 @@ err_conf:usb_remove_function (c, f_obex1);if (!phonet_stat)usb_remove_function (c, f_phonet); +usb_put_function (f_msg); +err_get_msg:usb_put_function (f_ecm); err_get_ecm:usb_put_function (f_acm);@@ -227,6 +279,8 @@ err_get_acm:static int __init nokia_bind (struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; +struct fsg_opts *fsg_opts; +struct fsg_config fsg_config;int status; status =usb_string_ids_tab (cdev, strings_dev);@@ -267,11 +321,46 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) goto err_acm_inst; } + fi_msg =usb_get_function_instance ("mass_storage" ); +if (IS_ERR (fi_msg)) { + status =PTR_ERR (fi_msg); + goto err_ecm_inst; + } + +/* set up mass storage function */ +fsg_config_from_params (&fsg_config, &fsg_mod_data, fsg_num_buffers); + fsg_config.vendor_name ="Nokia" ; + fsg_config.product_name ="N900" ; + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + fsg_opts->no_configfs = true; + + status =fsg_common_set_num_buffers (fsg_opts->common, fsg_num_buffers); +if (status) + goto err_msg_inst; + + status =fsg_common_set_nluns (fsg_opts->common, fsg_config.nluns); +if (status) + goto err_msg_buf; + + status =fsg_common_set_cdev (fsg_opts->common, cdev, fsg_config.can_stall); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_sysfs (fsg_opts->common, true); + + status =fsg_common_create_luns (fsg_opts->common, &fsg_config); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_inquiry_string (fsg_opts->common, fsg_config.vendor_name, + fsg_config.product_name); +/* finally register the configuration */ status =usb_add_config (cdev, &nokia_config_500ma_driver, nokia_bind_config);if (status <0 ) - goto err_ecm_inst; + goto err_msg_set_cdev; status =usb_add_config (cdev, &nokia_config_100ma_driver, nokia_bind_config);@@ -292,6 +381,14 @@ err_put_cfg1:if (!IS_ERR_OR_NULL (f_phonet_cfg1))usb_put_function (f_phonet_cfg1);usb_put_function (f_ecm_cfg1); +err_msg_set_cdev: +fsg_common_remove_luns (fsg_opts->common); +err_msg_set_nluns: +fsg_common_free_luns (fsg_opts->common); +err_msg_buf: +fsg_common_free_buffers (fsg_opts->common); +err_msg_inst: +usb_put_function_instance (fi_msg); err_ecm_inst:usb_put_function_instance (fi_ecm); err_acm_inst:drivers/usb/gadget/legacy/nokia.c static int __exit nokia_unbind(struct usb_composite_dev *cdev) · line 431
Quoted 10 lines
drivers/usb/gadget/legacy/nokia.c +3
-0@@ -325,7 +422,10 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev)usb_put_function (f_acm_cfg2);usb_put_function (f_ecm_cfg1);usb_put_function (f_ecm_cfg2); +usb_put_function (f_msg_cfg1); +usb_put_function (f_msg_cfg2); +usb_put_function_instance (fi_msg);usb_put_function_instance (fi_ecm);if (!IS_ERR (fi_obex2))usb_put_function_instance (fi_obex2);Opening discussion about this patch again as this is still only one solution how to use use mass storage without breaking other stuff...
Please understand finally that usb networking is very very important for development on this device and usb mass storage is needed for transferring bigger data.
Quoted 9 lines
Also to clarify potential regressions: This patch adds *optional* usb mass storage support and block device can be attached/detached to driver at runtime. It does *not* enforce to export some (mmc) device automatically. It is optional and userspace can decide...
So MyDocs N900 partition is not automatically enforced to be exported via usb (as some people thought) and so it does not break usb networking or mass storage mode or MyDocs parition on N900 with Maemo system.
Instead of adding mass storage to legacy gadget you may switch to configfs interface and compose equivalent of g_nokia + mass storage without any changes in kernel.
Best regards,
Signature · 3 lines
Krzysztof Opasiak Samsung R&D Institute Poland Samsung Electronics
Quoted 255 lines · On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:
Quoted 242 lines · Pali Rohár
Quoted 223 lines · On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>--- drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102 ++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)drivers/usb/gadget/legacy/Kconfig +1
-0@@ -345,6 +345,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGE help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.drivers/usb/gadget/legacy/nokia.c +98
-1@@ -24,6 +24,7 @@#include "u_phonet.h" #include "u_ecm.h" #include "gadget_chips.h" +#include "f_mass_storage.h" /* Defines */ @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();USB_ETHERNET_MODULE_PARAMETERS (); +static struct fsg_module_parameters fsg_mod_data = { + .stall =0 , + .luns =2 , + .removable_count =2 , + .removable = {1 ,1 , }, +}; + +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); + +#ifdef CONFIG_USB_GADGET_DEBUG_FILES + +static unsigned int fsg_num_buffers =CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS ; + +#else + +/* +* Number of buffers we will use. +* 2 is usually enough for good buffering pipeline +*/ +#define fsg_num_buffers CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS + +#endif /* CONFIG_USB_DEBUG */ +#define NOKIA_VENDOR_ID 0x0421/* Nokia */ #define NOKIA_PRODUCT_ID 0x01c8/* Nokia Gadget */ @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;static struct usb_function *f_obex2_cfg2;static struct usb_function *f_phonet_cfg1;static struct usb_function *f_phonet_cfg2; +static struct usb_function *f_msg_cfg1; +static struct usb_function *f_msg_cfg2;static struct usb_configuration nokia_config_500ma_driver = {@@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;static struct usb_function_instance *fi_obex1;static struct usb_function_instance *fi_obex2;static struct usb_function_instance *fi_phonet; +static struct usb_function_instance *fi_msg;static int __init nokia_bind_config (struct usb_configuration *c) {@@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct usb_configuration *c)struct usb_function *f_obex1 =NULL ;struct usb_function *f_ecm;struct usb_function *f_obex2 =NULL ; +struct usb_function *f_msg; +struct fsg_opts *fsg_opts;int status =0 ;int obex1_stat =-1 ;int obex2_stat =-1 ;@@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct usb_configuration *c) goto err_get_ecm; } + f_msg =usb_get_function (fi_msg); +if (IS_ERR (f_msg)) { + status =PTR_ERR (f_msg); + goto err_get_msg; + } +if (!IS_ERR_OR_NULL (f_phonet)) { phonet_stat =usb_add_function (c, f_phonet);if (phonet_stat)@@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct usb_configuration *c)pr_debug ("could not bind ecm config %d\n" , status); goto err_ecm; } + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + + status =fsg_common_run_thread (fsg_opts->common); +if (status) + goto err_msg; + + status =usb_add_function (c, f_msg); +if (status) + goto err_msg; +if (c == &nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; f_ecm_cfg1 = f_ecm; f_phonet_cfg1 = f_phonet; f_obex1_cfg1 = f_obex1; f_obex2_cfg1 = f_obex2; + f_msg_cfg1 = f_msg; }else { f_acm_cfg2 = f_acm; f_ecm_cfg2 = f_ecm; f_phonet_cfg2 = f_phonet; f_obex1_cfg2 = f_obex1; f_obex2_cfg2 = f_obex2; + f_msg_cfg2 = f_msg; }return status; +err_msg: +usb_remove_function (c, f_ecm); err_ecm:usb_remove_function (c, f_acm); err_conf:@@ -211,6 +261,8 @@ err_conf:usb_remove_function (c, f_obex1);if (!phonet_stat)usb_remove_function (c, f_phonet); +usb_put_function (f_msg); +err_get_msg:usb_put_function (f_ecm); err_get_ecm:usb_put_function (f_acm);@@ -227,6 +279,8 @@ err_get_acm:static int __init nokia_bind (struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; +struct fsg_opts *fsg_opts; +struct fsg_config fsg_config;int status; status =usb_string_ids_tab (cdev, strings_dev);@@ -267,11 +321,46 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) goto err_acm_inst; } + fi_msg =usb_get_function_instance ("mass_storage" ); +if (IS_ERR (fi_msg)) { + status =PTR_ERR (fi_msg); + goto err_ecm_inst; + } + +/* set up mass storage function */ +fsg_config_from_params (&fsg_config, &fsg_mod_data, fsg_num_buffers); + fsg_config.vendor_name ="Nokia" ; + fsg_config.product_name ="N900" ; + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + fsg_opts->no_configfs = true; + + status =fsg_common_set_num_buffers (fsg_opts->common, fsg_num_buffers); +if (status) + goto err_msg_inst; + + status =fsg_common_set_nluns (fsg_opts->common, fsg_config.nluns); +if (status) + goto err_msg_buf; + + status =fsg_common_set_cdev (fsg_opts->common, cdev, fsg_config.can_stall); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_sysfs (fsg_opts->common, true); + + status =fsg_common_create_luns (fsg_opts->common, &fsg_config); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_inquiry_string (fsg_opts->common, fsg_config.vendor_name, + fsg_config.product_name); +/* finally register the configuration */ status =usb_add_config (cdev, &nokia_config_500ma_driver, nokia_bind_config);if (status <0 ) - goto err_ecm_inst; + goto err_msg_set_cdev; status =usb_add_config (cdev, &nokia_config_100ma_driver, nokia_bind_config);@@ -292,6 +381,14 @@ err_put_cfg1:if (!IS_ERR_OR_NULL (f_phonet_cfg1))usb_put_function (f_phonet_cfg1);usb_put_function (f_ecm_cfg1); +err_msg_set_cdev: +fsg_common_remove_luns (fsg_opts->common); +err_msg_set_nluns: +fsg_common_free_luns (fsg_opts->common); +err_msg_buf: +fsg_common_free_buffers (fsg_opts->common); +err_msg_inst: +usb_put_function_instance (fi_msg); err_ecm_inst:usb_put_function_instance (fi_ecm); err_acm_inst:drivers/usb/gadget/legacy/nokia.c static int __exit nokia_unbind(struct usb_composite_dev *cdev) · line 431
Quoted 10 lines
drivers/usb/gadget/legacy/nokia.c +3
-0@@ -325,7 +422,10 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev)usb_put_function (f_acm_cfg2);usb_put_function (f_ecm_cfg1);usb_put_function (f_ecm_cfg2); +usb_put_function (f_msg_cfg1); +usb_put_function (f_msg_cfg2); +usb_put_function_instance (fi_msg);usb_put_function_instance (fi_ecm);if (!IS_ERR (fi_obex2))usb_put_function_instance (fi_obex2);Opening discussion about this patch again as this is still only one solution how to use use mass storage without breaking other stuff...
Please understand finally that usb networking is very very important for development on this device and usb mass storage is needed for transferring bigger data.
Quoted 9 lines
Also to clarify potential regressions: This patch adds *optional* usb mass storage support and block device can be attached/detached to driver at runtime. It does *not* enforce to export some (mmc) device automatically. It is optional and userspace can decide...
So MyDocs N900 partition is not automatically enforced to be exported via usb (as some people thought) and so it does not break usb networking or mass storage mode or MyDocs parition on N900 with Maemo system.
Quoted 6 lines
Instead of adding mass storage to legacy gadget you may switch to configfs interface and compose equivalent of
g_nokia+ mass storage without any changes in kernel.Best regards,
That requires userspace. And there are developers who use nfsroot via usb networking and so userspace will be there after properly initializing usb gadget... So it is not easy and reason why I'm opening this discussion again.
Signature · 2 lines
Pali Rohár [email protected]
Quoted 260 lines · Pali Rohár
Quoted 259 lines · On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:
Quoted 242 lines · Pali Rohár
Quoted 223 lines · On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>--- drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102 ++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)drivers/usb/gadget/legacy/Kconfig +1
-0@@ -345,6 +345,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGE help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.drivers/usb/gadget/legacy/nokia.c +98
-1@@ -24,6 +24,7 @@#include "u_phonet.h" #include "u_ecm.h" #include "gadget_chips.h" +#include "f_mass_storage.h" /* Defines */ @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();USB_ETHERNET_MODULE_PARAMETERS (); +static struct fsg_module_parameters fsg_mod_data = { + .stall =0 , + .luns =2 , + .removable_count =2 , + .removable = {1 ,1 , }, +}; + +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); + +#ifdef CONFIG_USB_GADGET_DEBUG_FILES + +static unsigned int fsg_num_buffers =CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS ; + +#else + +/* +* Number of buffers we will use. +* 2 is usually enough for good buffering pipeline +*/ +#define fsg_num_buffers CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS + +#endif /* CONFIG_USB_DEBUG */ +#define NOKIA_VENDOR_ID 0x0421/* Nokia */ #define NOKIA_PRODUCT_ID 0x01c8/* Nokia Gadget */ @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;static struct usb_function *f_obex2_cfg2;static struct usb_function *f_phonet_cfg1;static struct usb_function *f_phonet_cfg2; +static struct usb_function *f_msg_cfg1; +static struct usb_function *f_msg_cfg2;static struct usb_configuration nokia_config_500ma_driver = {@@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;static struct usb_function_instance *fi_obex1;static struct usb_function_instance *fi_obex2;static struct usb_function_instance *fi_phonet; +static struct usb_function_instance *fi_msg;static int __init nokia_bind_config (struct usb_configuration *c) {@@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct usb_configuration *c)struct usb_function *f_obex1 =NULL ;struct usb_function *f_ecm;struct usb_function *f_obex2 =NULL ; +struct usb_function *f_msg; +struct fsg_opts *fsg_opts;int status =0 ;int obex1_stat =-1 ;int obex2_stat =-1 ;@@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct usb_configuration *c) goto err_get_ecm; } + f_msg =usb_get_function (fi_msg); +if (IS_ERR (f_msg)) { + status =PTR_ERR (f_msg); + goto err_get_msg; + } +if (!IS_ERR_OR_NULL (f_phonet)) { phonet_stat =usb_add_function (c, f_phonet);if (phonet_stat)@@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct usb_configuration *c)pr_debug ("could not bind ecm config %d\n" , status); goto err_ecm; } + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + + status =fsg_common_run_thread (fsg_opts->common); +if (status) + goto err_msg; + + status =usb_add_function (c, f_msg); +if (status) + goto err_msg; +if (c == &nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; f_ecm_cfg1 = f_ecm; f_phonet_cfg1 = f_phonet; f_obex1_cfg1 = f_obex1; f_obex2_cfg1 = f_obex2; + f_msg_cfg1 = f_msg; }else { f_acm_cfg2 = f_acm; f_ecm_cfg2 = f_ecm; f_phonet_cfg2 = f_phonet; f_obex1_cfg2 = f_obex1; f_obex2_cfg2 = f_obex2; + f_msg_cfg2 = f_msg; }return status; +err_msg: +usb_remove_function (c, f_ecm); err_ecm:usb_remove_function (c, f_acm); err_conf:@@ -211,6 +261,8 @@ err_conf:usb_remove_function (c, f_obex1);if (!phonet_stat)usb_remove_function (c, f_phonet); +usb_put_function (f_msg); +err_get_msg:usb_put_function (f_ecm); err_get_ecm:usb_put_function (f_acm);@@ -227,6 +279,8 @@ err_get_acm:static int __init nokia_bind (struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; +struct fsg_opts *fsg_opts; +struct fsg_config fsg_config;int status; status =usb_string_ids_tab (cdev, strings_dev);@@ -267,11 +321,46 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) goto err_acm_inst; } + fi_msg =usb_get_function_instance ("mass_storage" ); +if (IS_ERR (fi_msg)) { + status =PTR_ERR (fi_msg); + goto err_ecm_inst; + } + +/* set up mass storage function */ +fsg_config_from_params (&fsg_config, &fsg_mod_data, fsg_num_buffers); + fsg_config.vendor_name ="Nokia" ; + fsg_config.product_name ="N900" ; + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + fsg_opts->no_configfs = true; + + status =fsg_common_set_num_buffers (fsg_opts->common, fsg_num_buffers); +if (status) + goto err_msg_inst; + + status =fsg_common_set_nluns (fsg_opts->common, fsg_config.nluns); +if (status) + goto err_msg_buf; + + status =fsg_common_set_cdev (fsg_opts->common, cdev, fsg_config.can_stall); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_sysfs (fsg_opts->common, true); + + status =fsg_common_create_luns (fsg_opts->common, &fsg_config); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_inquiry_string (fsg_opts->common, fsg_config.vendor_name, + fsg_config.product_name); +/* finally register the configuration */ status =usb_add_config (cdev, &nokia_config_500ma_driver, nokia_bind_config);if (status <0 ) - goto err_ecm_inst; + goto err_msg_set_cdev; status =usb_add_config (cdev, &nokia_config_100ma_driver, nokia_bind_config);@@ -292,6 +381,14 @@ err_put_cfg1:if (!IS_ERR_OR_NULL (f_phonet_cfg1))usb_put_function (f_phonet_cfg1);usb_put_function (f_ecm_cfg1); +err_msg_set_cdev: +fsg_common_remove_luns (fsg_opts->common); +err_msg_set_nluns: +fsg_common_free_luns (fsg_opts->common); +err_msg_buf: +fsg_common_free_buffers (fsg_opts->common); +err_msg_inst: +usb_put_function_instance (fi_msg); err_ecm_inst:usb_put_function_instance (fi_ecm); err_acm_inst:drivers/usb/gadget/legacy/nokia.c static int __exit nokia_unbind(struct usb_composite_dev *cdev) · line 431
Quoted 10 lines
drivers/usb/gadget/legacy/nokia.c +3
-0@@ -325,7 +422,10 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev)usb_put_function (f_acm_cfg2);usb_put_function (f_ecm_cfg1);usb_put_function (f_ecm_cfg2); +usb_put_function (f_msg_cfg1); +usb_put_function (f_msg_cfg2); +usb_put_function_instance (fi_msg);usb_put_function_instance (fi_ecm);if (!IS_ERR (fi_obex2))usb_put_function_instance (fi_obex2);Opening discussion about this patch again as this is still only one solution how to use use mass storage without breaking other stuff...
Please understand finally that usb networking is very very important for development on this device and usb mass storage is needed for transferring bigger data.
Quoted 9 lines
Also to clarify potential regressions: This patch adds *optional* usb mass storage support and block device can be attached/detached to driver at runtime. It does *not* enforce to export some (mmc) device automatically. It is optional and userspace can decide...
So MyDocs N900 partition is not automatically enforced to be exported via usb (as some people thought) and so it does not break usb networking or mass storage mode or MyDocs parition on N900 with Maemo system.
Instead of adding mass storage to legacy gadget you may switch to configfs interface and compose equivalent of
g_nokia+ mass storage without any changes in kernel.
Quoted 8 lines
Quoted 2 lines
Best regards,
That requires userspace. And there are developers who use nfsroot via usb networking and so userspace will be there after properly initializing usb gadget... So it is not easy and reason why I'm opening this discussion again.
Couldn't you simply use initramfs to compose your gadget?
Signature · 3 lines
Krzysztof Opasiak Samsung R&D Institute Poland Samsung Electronics
Quoted 266 lines · On Thursday 28 May 2015 16:51:07 Krzysztof Opasiak wrote:
Quoted 263 lines · Pali Rohár
Quoted 261 lines · On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:
Quoted 242 lines · Pali Rohár
Quoted 223 lines · On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>--- drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102 ++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)drivers/usb/gadget/legacy/Kconfig +1
-0@@ -345,6 +345,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGE help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.drivers/usb/gadget/legacy/nokia.c +98
-1@@ -24,6 +24,7 @@#include "u_phonet.h" #include "u_ecm.h" #include "gadget_chips.h" +#include "f_mass_storage.h" /* Defines */ @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();USB_ETHERNET_MODULE_PARAMETERS (); +static struct fsg_module_parameters fsg_mod_data = { + .stall =0 , + .luns =2 , + .removable_count =2 , + .removable = {1 ,1 , }, +}; + +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); + +#ifdef CONFIG_USB_GADGET_DEBUG_FILES + +static unsigned int fsg_num_buffers =CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS ; + +#else + +/* +* Number of buffers we will use. +* 2 is usually enough for good buffering pipeline +*/ +#define fsg_num_buffers CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS + +#endif /* CONFIG_USB_DEBUG */ +#define NOKIA_VENDOR_ID 0x0421/* Nokia */ #define NOKIA_PRODUCT_ID 0x01c8/* Nokia Gadget */ @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;static struct usb_function *f_obex2_cfg2;static struct usb_function *f_phonet_cfg1;static struct usb_function *f_phonet_cfg2; +static struct usb_function *f_msg_cfg1; +static struct usb_function *f_msg_cfg2;static struct usb_configuration nokia_config_500ma_driver = {@@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;static struct usb_function_instance *fi_obex1;static struct usb_function_instance *fi_obex2;static struct usb_function_instance *fi_phonet; +static struct usb_function_instance *fi_msg;static int __init nokia_bind_config (struct usb_configuration *c) {@@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct usb_configuration *c)struct usb_function *f_obex1 =NULL ;struct usb_function *f_ecm;struct usb_function *f_obex2 =NULL ; +struct usb_function *f_msg; +struct fsg_opts *fsg_opts;int status =0 ;int obex1_stat =-1 ;int obex2_stat =-1 ;@@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct usb_configuration *c) goto err_get_ecm; } + f_msg =usb_get_function (fi_msg); +if (IS_ERR (f_msg)) { + status =PTR_ERR (f_msg); + goto err_get_msg; + } +if (!IS_ERR_OR_NULL (f_phonet)) { phonet_stat =usb_add_function (c, f_phonet);if (phonet_stat)@@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct usb_configuration *c)pr_debug ("could not bind ecm config %d\n" , status); goto err_ecm; } + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + + status =fsg_common_run_thread (fsg_opts->common); +if (status) + goto err_msg; + + status =usb_add_function (c, f_msg); +if (status) + goto err_msg; +if (c == &nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; f_ecm_cfg1 = f_ecm; f_phonet_cfg1 = f_phonet; f_obex1_cfg1 = f_obex1; f_obex2_cfg1 = f_obex2; + f_msg_cfg1 = f_msg; }else { f_acm_cfg2 = f_acm; f_ecm_cfg2 = f_ecm; f_phonet_cfg2 = f_phonet; f_obex1_cfg2 = f_obex1; f_obex2_cfg2 = f_obex2; + f_msg_cfg2 = f_msg; }return status; +err_msg: +usb_remove_function (c, f_ecm); err_ecm:usb_remove_function (c, f_acm); err_conf:@@ -211,6 +261,8 @@ err_conf:usb_remove_function (c, f_obex1);if (!phonet_stat)usb_remove_function (c, f_phonet); +usb_put_function (f_msg); +err_get_msg:usb_put_function (f_ecm); err_get_ecm:usb_put_function (f_acm);@@ -227,6 +279,8 @@ err_get_acm:static int __init nokia_bind (struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; +struct fsg_opts *fsg_opts; +struct fsg_config fsg_config;int status; status =usb_string_ids_tab (cdev, strings_dev);@@ -267,11 +321,46 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) goto err_acm_inst; } + fi_msg =usb_get_function_instance ("mass_storage" ); +if (IS_ERR (fi_msg)) { + status =PTR_ERR (fi_msg); + goto err_ecm_inst; + } + +/* set up mass storage function */ +fsg_config_from_params (&fsg_config, &fsg_mod_data, fsg_num_buffers); + fsg_config.vendor_name ="Nokia" ; + fsg_config.product_name ="N900" ; + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + fsg_opts->no_configfs = true; + + status =fsg_common_set_num_buffers (fsg_opts->common, fsg_num_buffers); +if (status) + goto err_msg_inst; + + status =fsg_common_set_nluns (fsg_opts->common, fsg_config.nluns); +if (status) + goto err_msg_buf; + + status =fsg_common_set_cdev (fsg_opts->common, cdev, fsg_config.can_stall); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_sysfs (fsg_opts->common, true); + + status =fsg_common_create_luns (fsg_opts->common, &fsg_config); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_inquiry_string (fsg_opts->common, fsg_config.vendor_name, + fsg_config.product_name); +/* finally register the configuration */ status =usb_add_config (cdev, &nokia_config_500ma_driver, nokia_bind_config);if (status <0 ) - goto err_ecm_inst; + goto err_msg_set_cdev; status =usb_add_config (cdev, &nokia_config_100ma_driver, nokia_bind_config);@@ -292,6 +381,14 @@ err_put_cfg1:if (!IS_ERR_OR_NULL (f_phonet_cfg1))usb_put_function (f_phonet_cfg1);usb_put_function (f_ecm_cfg1); +err_msg_set_cdev: +fsg_common_remove_luns (fsg_opts->common); +err_msg_set_nluns: +fsg_common_free_luns (fsg_opts->common); +err_msg_buf: +fsg_common_free_buffers (fsg_opts->common); +err_msg_inst: +usb_put_function_instance (fi_msg); err_ecm_inst:usb_put_function_instance (fi_ecm); err_acm_inst:drivers/usb/gadget/legacy/nokia.c static int __exit nokia_unbind(struct usb_composite_dev *cdev) · line 431
Quoted 10 lines
drivers/usb/gadget/legacy/nokia.c +3
-0@@ -325,7 +422,10 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev)usb_put_function (f_acm_cfg2);usb_put_function (f_ecm_cfg1);usb_put_function (f_ecm_cfg2); +usb_put_function (f_msg_cfg1); +usb_put_function (f_msg_cfg2); +usb_put_function_instance (fi_msg);usb_put_function_instance (fi_ecm);if (!IS_ERR (fi_obex2))usb_put_function_instance (fi_obex2);Opening discussion about this patch again as this is still only one solution how to use use mass storage without breaking other stuff...
Please understand finally that usb networking is very very important for development on this device and usb mass storage is needed for transferring bigger data.
Quoted 9 lines
Also to clarify potential regressions: This patch adds *optional* usb mass storage support and block device can be attached/detached to driver at runtime. It does *not* enforce to export some (mmc) device automatically. It is optional and userspace can decide...
So MyDocs N900 partition is not automatically enforced to be exported via usb (as some people thought) and so it does not break usb networking or mass storage mode or MyDocs parition on N900 with Maemo system.
Instead of adding mass storage to legacy gadget you may switch to configfs interface and compose equivalent of
g_nokia+ mass storage without any changes in kernel.Best regards,
Quoted 8 lines
Quoted 5 lines
That requires userspace. And there are developers who use nfsroot via usb networking and so userspace will be there after properly initializing usb gadget... So it is not easy and reason why I'm opening this discussion again.
Couldn't you simply use initramfs to compose your gadget?
This is another next complication... I could spend time on hacking serious problems on Nokia N900 (camera not working, bluetooth not working, improving cellular audio/voice calls) or start playing with initramfs and other kernel infrastructure just because usb is broken and small fix which enable all needed usb functionality (usb networking, usb TTY, usb phonet, usb mass storage) cannot be accepted and merged because it really helps people to develop... :-( I see that it is under legacy drivers, but without it is hard (and maybe not possible) to develop for Nokia N900 device. Nobody until now proposed any other patch which fix our problems and provide working usb functionality for mass storage, network, TTY and phonet.
Signature · 2 lines
Pali Rohár [email protected]
Quoted 276 lines · Pali Rohár
Quoted 266 lines · On Thursday 28 May 2015 16:51:07 Krzysztof Opasiak wrote:
Quoted 263 lines · Pali Rohár
Quoted 261 lines · On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:
Quoted 242 lines · Pali Rohár
Quoted 223 lines · On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>--- drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102 ++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)drivers/usb/gadget/legacy/Kconfig +1
-0@@ -345,6 +345,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGE help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.drivers/usb/gadget/legacy/nokia.c +98
-1@@ -24,6 +24,7 @@#include "u_phonet.h" #include "u_ecm.h" #include "gadget_chips.h" +#include "f_mass_storage.h" /* Defines */ @@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();USB_ETHERNET_MODULE_PARAMETERS (); +static struct fsg_module_parameters fsg_mod_data = { + .stall =0 , + .luns =2 , + .removable_count =2 , + .removable = {1 ,1 , }, +}; + +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); + +#ifdef CONFIG_USB_GADGET_DEBUG_FILES + +static unsigned int fsg_num_buffers =CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS ; + +#else + +/* +* Number of buffers we will use. +* 2 is usually enough for good buffering pipeline +*/ +#define fsg_num_buffers CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS + +#endif /* CONFIG_USB_DEBUG */ +#define NOKIA_VENDOR_ID 0x0421/* Nokia */ #define NOKIA_PRODUCT_ID 0x01c8/* Nokia Gadget */ @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;static struct usb_function *f_obex2_cfg2;static struct usb_function *f_phonet_cfg1;static struct usb_function *f_phonet_cfg2; +static struct usb_function *f_msg_cfg1; +static struct usb_function *f_msg_cfg2;static struct usb_configuration nokia_config_500ma_driver = {@@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;static struct usb_function_instance *fi_obex1;static struct usb_function_instance *fi_obex2;static struct usb_function_instance *fi_phonet; +static struct usb_function_instance *fi_msg;static int __init nokia_bind_config (struct usb_configuration *c) {@@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct usb_configuration *c)struct usb_function *f_obex1 =NULL ;struct usb_function *f_ecm;struct usb_function *f_obex2 =NULL ; +struct usb_function *f_msg; +struct fsg_opts *fsg_opts;int status =0 ;int obex1_stat =-1 ;int obex2_stat =-1 ;@@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct usb_configuration *c) goto err_get_ecm; } + f_msg =usb_get_function (fi_msg); +if (IS_ERR (f_msg)) { + status =PTR_ERR (f_msg); + goto err_get_msg; + } +if (!IS_ERR_OR_NULL (f_phonet)) { phonet_stat =usb_add_function (c, f_phonet);if (phonet_stat)@@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct usb_configuration *c)pr_debug ("could not bind ecm config %d\n" , status); goto err_ecm; } + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + + status =fsg_common_run_thread (fsg_opts->common); +if (status) + goto err_msg; + + status =usb_add_function (c, f_msg); +if (status) + goto err_msg; +if (c == &nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; f_ecm_cfg1 = f_ecm; f_phonet_cfg1 = f_phonet; f_obex1_cfg1 = f_obex1; f_obex2_cfg1 = f_obex2; + f_msg_cfg1 = f_msg; }else { f_acm_cfg2 = f_acm; f_ecm_cfg2 = f_ecm; f_phonet_cfg2 = f_phonet; f_obex1_cfg2 = f_obex1; f_obex2_cfg2 = f_obex2; + f_msg_cfg2 = f_msg; }return status; +err_msg: +usb_remove_function (c, f_ecm); err_ecm:usb_remove_function (c, f_acm); err_conf:@@ -211,6 +261,8 @@ err_conf:usb_remove_function (c, f_obex1);if (!phonet_stat)usb_remove_function (c, f_phonet); +usb_put_function (f_msg); +err_get_msg:usb_put_function (f_ecm); err_get_ecm:usb_put_function (f_acm);@@ -227,6 +279,8 @@ err_get_acm:static int __init nokia_bind (struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; +struct fsg_opts *fsg_opts; +struct fsg_config fsg_config;int status; status =usb_string_ids_tab (cdev, strings_dev);@@ -267,11 +321,46 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) goto err_acm_inst; } + fi_msg =usb_get_function_instance ("mass_storage" ); +if (IS_ERR (fi_msg)) { + status =PTR_ERR (fi_msg); + goto err_ecm_inst; + } + +/* set up mass storage function */ +fsg_config_from_params (&fsg_config, &fsg_mod_data, fsg_num_buffers); + fsg_config.vendor_name ="Nokia" ; + fsg_config.product_name ="N900" ; + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + fsg_opts->no_configfs = true; + + status =fsg_common_set_num_buffers (fsg_opts->common, fsg_num_buffers); +if (status) + goto err_msg_inst; + + status =fsg_common_set_nluns (fsg_opts->common, fsg_config.nluns); +if (status) + goto err_msg_buf; + + status =fsg_common_set_cdev (fsg_opts->common, cdev, fsg_config.can_stall); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_sysfs (fsg_opts->common, true); + + status =fsg_common_create_luns (fsg_opts->common, &fsg_config); +if (status) + goto err_msg_set_nluns; + +fsg_common_set_inquiry_string (fsg_opts->common, fsg_config.vendor_name, + fsg_config.product_name); +/* finally register the configuration */ status =usb_add_config (cdev, &nokia_config_500ma_driver, nokia_bind_config);if (status <0 ) - goto err_ecm_inst; + goto err_msg_set_cdev; status =usb_add_config (cdev, &nokia_config_100ma_driver, nokia_bind_config);@@ -292,6 +381,14 @@ err_put_cfg1:if (!IS_ERR_OR_NULL (f_phonet_cfg1))usb_put_function (f_phonet_cfg1);usb_put_function (f_ecm_cfg1); +err_msg_set_cdev: +fsg_common_remove_luns (fsg_opts->common); +err_msg_set_nluns: +fsg_common_free_luns (fsg_opts->common); +err_msg_buf: +fsg_common_free_buffers (fsg_opts->common); +err_msg_inst: +usb_put_function_instance (fi_msg); err_ecm_inst:usb_put_function_instance (fi_ecm); err_acm_inst:drivers/usb/gadget/legacy/nokia.c static int __exit nokia_unbind(struct usb_composite_dev *cdev) · line 431
Quoted 10 lines
drivers/usb/gadget/legacy/nokia.c +3
-0@@ -325,7 +422,10 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev)usb_put_function (f_acm_cfg2);usb_put_function (f_ecm_cfg1);usb_put_function (f_ecm_cfg2); +usb_put_function (f_msg_cfg1); +usb_put_function (f_msg_cfg2); +usb_put_function_instance (fi_msg);usb_put_function_instance (fi_ecm);if (!IS_ERR (fi_obex2))usb_put_function_instance (fi_obex2);Opening discussion about this patch again as this is still only one solution how to use use mass storage without breaking other stuff...
Please understand finally that usb networking is very very important for development on this device and usb mass storage is needed for transferring bigger data.
Quoted 9 lines
Also to clarify potential regressions: This patch adds *optional* usb mass storage support and block device can be attached/detached to driver at runtime. It does *not* enforce to export some (mmc) device automatically. It is optional and userspace can decide...
So MyDocs N900 partition is not automatically enforced to be exported via usb (as some people thought) and so it does not break usb networking or mass storage mode or MyDocs parition on N900 with Maemo system.
Instead of adding mass storage to legacy gadget you may switch to configfs interface and compose equivalent of
g_nokia+ mass storage without any changes in kernel.Best regards,
Quoted 8 lines
Quoted 5 lines
That requires userspace. And there are developers who use nfsroot via usb networking and so userspace will be there after properly initializing usb gadget... So it is not easy and reason why I'm opening this discussion again.
Couldn't you simply use initramfs to compose your gadget?
Quoted 11 lines
This is another next complication... I could spend time on hacking serious problems on Nokia N900 (camera not working, bluetooth not working, improving cellular audio/voice calls) or start playing with initramfs and other kernel infrastructure just because usb is broken and small fix which enable all needed usb functionality (usb networking, usb TTY, usb phonet, usb mass storage) cannot be accepted and merged because it really helps people to develop... :-( I see that it is under legacy drivers, but without it is hard (and maybe not possible) to develop for Nokia N900 device. Nobody until now proposed any other patch which fix our problems and provide working usb functionality for mass storage, network, TTY and phonet.
Sure this causes no problems to original Maemo userland ? Also, IIRC, we were running out of both FIFO space and physical endpoints with g_nokia already. Do all functions still work if used all at once ?
If you can confirm these two questions I'll take this patch. As long as there are no regressions with original userland from Nokia, it should be fine.
cheers
Signature · 1 line
balbi
Quoted 252 lines · On Thursday 28 May 2015 18:34:31 Felipe Balbi wrote:
Quoted 251 lines · Pali Rohár
Quoted 250 lines · On Thursday 28 May 2015 16:51:07 Krzysztof Opasiak wrote:
Quoted 249 lines · Pali Rohár
Quoted 248 lines · On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:
Quoted 247 lines · Pali Rohár
Quoted 246 lines · On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>---
drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)
(quoted diff) +0
-0b/drivers/usb/gadget/legacy/Kconfig index fd48ef3..36f6ba4 100644
drivers/usb/gadget/legacy/Kconfig +1
-0@@ -345,6 +345,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGEdrivers/usb/gadget/legacy/Kconfig +0
-0help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.(quoted diff) +0
-0
b/drivers/usb/gadget/legacy/nokia.cindex 9b8fd70..a09bb50 100644drivers/usb/gadget/legacy/nokia.c +1
-0@@ -24,6 +24,7 @@#include "u_phonet.h" #include "u_ecm.h" #include "gadget_chips.h" +#include "f_mass_storage.h" /* Defines */
drivers/usb/gadget/legacy/nokia.c +12
-0@@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();USB_ETHERNET_MODULE_PARAMETERS (); +static struct fsg_module_parameters fsg_mod_data = { + .stall =0 , + .luns =2 , + .removable_count =2 , + .removable = {1 ,1 , }, +}; + +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); + +#ifdef CONFIG_USB_GADGET_DEBUG_FILES + +static unsigned int fsg_num_buffers =
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS; +drivers/usb/gadget/legacy/nokia.c +7
-0+#else + +/* +* Number of buffers we will use. +* 2 is usually enough for good buffering pipeline +*/ +#define
fsg_num_buffersCONFIG_USB_GADGET_STORAGE_NUM_BUFFERS+drivers/usb/gadget/legacy/nokia.c +4
-0+#endif /* CONFIG_USB_DEBUG */ +#define NOKIA_VENDOR_ID 0x0421/* Nokia */ #define NOKIA_PRODUCT_ID 0x01c8/* Nokia Gadget */ @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;static struct usb_function *f_obex2_cfg2;static struct usb_function *f_phonet_cfg1;static struct usb_function *f_phonet_cfg2; +static struct usb_function *f_msg_cfg1; +static struct usb_function *f_msg_cfg2;static struct
usb_configurationnokia_config_500ma_driver= {drivers/usb/gadget/legacy/nokia.c +1
-0@@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;static struct usb_function_instance *fi_obex1;static struct usb_function_instance *fi_obex2;static struct usb_function_instance *fi_phonet; +static struct usb_function_instance *fi_msg;static int
__initnokia_bind_config(struct
usb_configuration*c) {drivers/usb/gadget/legacy/nokia.c +2
-0@@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct usb_configuration *c) struct usb_function *f_obex1 = NULL;struct usb_function *f_ecm;struct usb_function *f_obex2 =NULL ; +struct usb_function *f_msg; +struct fsg_opts *fsg_opts;drivers/usb/gadget/legacy/nokia.c +6
-0int status =0 ;int obex1_stat =-1 ;int obex2_stat =-1 ;@@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct usb_configuration *c) goto err_get_ecm; } + f_msg =usb_get_function (fi_msg); +if (IS_ERR (f_msg)) { + status =PTR_ERR (f_msg); + goto err_get_msg; + } +drivers/usb/gadget/legacy/nokia.c +19
-0if (!IS_ERR_OR_NULL (f_phonet)) { phonet_stat =usb_add_function (c, f_phonet);if (phonet_stat)@@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct usb_configuration *c) pr_debug("could not bind ecm config %d\n", status); goto err_ecm; } + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + + status =fsg_common_run_thread (fsg_opts->common); +if (status) + goto err_msg; + + status =usb_add_function (c, f_msg); +if (status) + goto err_msg; +if (c == &nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; f_ecm_cfg1 = f_ecm; f_phonet_cfg1 = f_phonet; f_obex1_cfg1 = f_obex1; f_obex2_cfg1 = f_obex2; + f_msg_cfg1 = f_msg; }else { f_acm_cfg2 = f_acm; f_ecm_cfg2 = f_ecm; f_phonet_cfg2 = f_phonet; f_obex1_cfg2 = f_obex1; f_obex2_cfg2 = f_obex2; + f_msg_cfg2 = f_msg; }return status; +err_msg: +usb_remove_function (c, f_ecm); err_ecm:usb_remove_function (c, f_acm); err_conf:@@ -211,6 +261,8 @@ err_conf:usb_remove_function (c, f_obex1);if (!phonet_stat)usb_remove_function (c, f_phonet); +usb_put_function (f_msg); +err_get_msg:usb_put_function (f_ecm); err_get_ecm:usb_put_function (f_acm);@@ -227,6 +279,8 @@ err_get_acm:static int __init nokia_bind (struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; +struct fsg_opts *fsg_opts; +struct fsg_config fsg_config;drivers/usb/gadget/legacy/nokia.c +22
-0int status; status =usb_string_ids_tab (cdev, strings_dev);@@ -267,11 +321,46 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) goto err_acm_inst; } + fi_msg =usb_get_function_instance ("mass_storage" ); +if (IS_ERR (fi_msg)) { + status =PTR_ERR (fi_msg); + goto err_ecm_inst; + } + +/* set up mass storage function */ +fsg_config_from_params (&fsg_config, &fsg_mod_data, fsg_num_buffers); + fsg_config.vendor_name ="Nokia" ; + fsg_config.product_name ="N900" ; + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + fsg_opts->no_configfs = true; + + status =fsg_common_set_num_buffers (fsg_opts->common, fsg_num_buffers); + if (status) + goto err_msg_inst; + + status =fsg_common_set_nluns (fsg_opts->common, fsg_config.nluns); + if (status) + goto err_msg_buf; + + status =fsg_common_set_cdev (fsg_opts->common, cdev, fsg_config.can_stall); + if (status) + goto err_msg_set_nluns; +
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/usb/gadget/legacy/nokia.c +6
-0+fsg_common_set_sysfs (fsg_opts->common, true); + + status =fsg_common_create_luns (fsg_opts->common, &fsg_config); + if (status) + goto err_msg_set_nluns; + + fsg_common_set_inquiry_string(fsg_opts->common,fsg_config.vendor_name, +
fsg_config.product_name);
Quoted 102 lines
Quoted 85 lines
Quoted 76 lines
Quoted 76 lines
Quoted 76 lines
Quoted 67 lines
Quoted 48 lines
drivers/usb/gadget/legacy/nokia.c +10
-1+/* finally register the configuration */ status =usb_add_config (cdev, &nokia_config_500ma_driver, nokia_bind_config);if (status <0 ) - goto err_ecm_inst; + goto err_msg_set_cdev; status =usb_add_config (cdev, &nokia_config_100ma_driver, nokia_bind_config);@@ -292,6 +381,14 @@ err_put_cfg1:if (!IS_ERR_OR_NULL (f_phonet_cfg1))usb_put_function (f_phonet_cfg1);usb_put_function (f_ecm_cfg1); +err_msg_set_cdev: +fsg_common_remove_luns (fsg_opts->common); +err_msg_set_nluns: +fsg_common_free_luns (fsg_opts->common); +err_msg_buf: +fsg_common_free_buffers (fsg_opts->common); +err_msg_inst: +usb_put_function_instance (fi_msg);
err_ecm_inst:drivers/usb/gadget/legacy/nokia.c +3
-0usb_put_function_instance (fi_ecm); err_acm_inst:@@ -325,7 +422,10 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev)usb_put_function (f_acm_cfg2 );usb_put_function (f_ecm_cfg1);usb_put_function (f_ecm_cfg2); +usb_put_function (f_msg_cfg1); +usb_put_function (f_msg_cfg2); +usb_put_function_instance (fi_msg);drivers/usb/gadget/legacy/nokia.c
Quoted 4 lines
drivers/usb/gadget/legacy/nokia.c +0
-0usb_put_function_instance (fi_ecm);if (!IS_ERR (fi_obex2))usb_put_function_instance (fi_obex2);Opening discussion about this patch again as this is still only one solution how to use use mass storage without breaking other stuff...
Please understand finally that usb networking is very very important for development on this device and usb mass storage is needed for transferring bigger data.
Also to clarify potential regressions: This patch adds *optional* usb mass storage support and block device can be attached/detached to driver at runtime. It does *not* enforce to export some (mmc) device automatically. It is optional and userspace can decide...
Quoted 4 lines
So MyDocs N900 partition is not automatically enforced to be exported via usb (as some people thought) and so it does not break usb networking or mass storage mode or MyDocs parition on N900 with Maemo system.
Instead of adding mass storage to legacy gadget you may switch to configfs interface and compose equivalent of
g_nokia+ mass storage without any changes in kernel.Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Best regards,
That requires userspace. And there are developers who use nfsroot via usb networking and so userspace will be there after properly initializing usb gadget... So it is not easy and reason why I'm opening this discussion again.
Couldn't you simply use initramfs to compose your gadget?
Quoted 12 lines
This is another next complication... I could spend time on hacking serious problems on Nokia N900 (camera not working, bluetooth not working, improving cellular audio/voice calls) or start playing with initramfs and other kernel infrastructure just because usb is broken and small fix which enable all needed usb functionality (usb networking, usb TTY, usb phonet, usb mass storage) cannot be accepted and merged because it really helps people to develop... :-( I see that it is under legacy drivers, but without it is hard (and maybe not possible) to develop for Nokia N900 device. Nobody until now proposed any other patch which fix our problems and provide working usb functionality for mass storage, network, TTY and phonet.
Sure this causes no problems to original Maemo userland ? Also, IIRC, we were running out of both FIFO space and physical endpoints with
g_nokiaalready. Do all functions still work if used all at once ?
Quoted 5 lines
If you can confirm these two questions I'll take this patch. As long as there are no regressions with original userland from Nokia, it should be fine.
cheers
In this my patch usb gadget support is removable (see fsg_mod_data). It means that at runtime (when module is already loaded and initialized!) userspace can decide to export some block device via usb. And unexport it at every time. Also this patch does not export any device by default. So it does not lock any block device (like MyDocs), so there is really no regressions like you though about MyDocs. usb networking, tty and also phone will still work via g_nokia. And if you do not export block device MyDocs it will stay normally mounted in N900 VFS.
Signature · 2 lines
Pali Rohár [email protected]
Quoted 370 lines · Pali Rohár
Quoted 252 lines · On Thursday 28 May 2015 18:34:31 Felipe Balbi wrote:
Quoted 251 lines · Pali Rohár
Quoted 250 lines · On Thursday 28 May 2015 16:51:07 Krzysztof Opasiak wrote:
Quoted 249 lines · Pali Rohár
Quoted 248 lines · On Thursday 28 May 2015 16:27:44 Krzysztof Opasiak wrote:
Quoted 247 lines · Pali Rohár
Quoted 246 lines · On Saturday 31 January 2015 10:53:30 Pali Rohár wrote:
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>---
drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)
(quoted diff) +0
-0b/drivers/usb/gadget/legacy/Kconfig index fd48ef3..36f6ba4 100644
drivers/usb/gadget/legacy/Kconfig +1
-0@@ -345,6 +345,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGEdrivers/usb/gadget/legacy/Kconfig +0
-0help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.(quoted diff) +0
-0
b/drivers/usb/gadget/legacy/nokia.cindex 9b8fd70..a09bb50 100644drivers/usb/gadget/legacy/nokia.c +1
-0@@ -24,6 +24,7 @@#include "u_phonet.h" #include "u_ecm.h" #include "gadget_chips.h" +#include "f_mass_storage.h" /* Defines */
drivers/usb/gadget/legacy/nokia.c +12
-0@@ -34,6 +35,29 @@ USB_GADGET_COMPOSITE_OPTIONS();USB_ETHERNET_MODULE_PARAMETERS (); +static struct fsg_module_parameters fsg_mod_data = { + .stall =0 , + .luns =2 , + .removable_count =2 , + .removable = {1 ,1 , }, +}; + +FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); + +#ifdef CONFIG_USB_GADGET_DEBUG_FILES + +static unsigned int fsg_num_buffers =
CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS; +drivers/usb/gadget/legacy/nokia.c +7
-0+#else + +/* +* Number of buffers we will use. +* 2 is usually enough for good buffering pipeline +*/ +#define
fsg_num_buffersCONFIG_USB_GADGET_STORAGE_NUM_BUFFERS+drivers/usb/gadget/legacy/nokia.c +4
-0+#endif /* CONFIG_USB_DEBUG */ +#define NOKIA_VENDOR_ID 0x0421/* Nokia */ #define NOKIA_PRODUCT_ID 0x01c8/* Nokia Gadget */ @@ -94,6 +118,8 @@ static struct usb_function *f_obex1_cfg2;static struct usb_function *f_obex2_cfg2;static struct usb_function *f_phonet_cfg1;static struct usb_function *f_phonet_cfg2; +static struct usb_function *f_msg_cfg1; +static struct usb_function *f_msg_cfg2;static struct
usb_configurationnokia_config_500ma_driver= {drivers/usb/gadget/legacy/nokia.c +1
-0@@ -117,6 +143,7 @@ static struct usb_function_instance *fi_ecm;static struct usb_function_instance *fi_obex1;static struct usb_function_instance *fi_obex2;static struct usb_function_instance *fi_phonet; +static struct usb_function_instance *fi_msg;static int
__initnokia_bind_config(struct
usb_configuration*c) {drivers/usb/gadget/legacy/nokia.c +2
-0@@ -125,6 +152,8 @@ static int __init nokia_bind_config(struct usb_configuration *c) struct usb_function *f_obex1 = NULL;struct usb_function *f_ecm;struct usb_function *f_obex2 =NULL ; +struct usb_function *f_msg; +struct fsg_opts *fsg_opts;drivers/usb/gadget/legacy/nokia.c +6
-0int status =0 ;int obex1_stat =-1 ;int obex2_stat =-1 ;@@ -160,6 +189,12 @@ static int __init nokia_bind_config(struct usb_configuration *c) goto err_get_ecm; } + f_msg =usb_get_function (fi_msg); +if (IS_ERR (f_msg)) { + status =PTR_ERR (f_msg); + goto err_get_msg; + } +drivers/usb/gadget/legacy/nokia.c +19
-0if (!IS_ERR_OR_NULL (f_phonet)) { phonet_stat =usb_add_function (c, f_phonet);if (phonet_stat)@@ -187,21 +222,36 @@ static int __init nokia_bind_config(struct usb_configuration *c) pr_debug("could not bind ecm config %d\n", status); goto err_ecm; } + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + + status =fsg_common_run_thread (fsg_opts->common); +if (status) + goto err_msg; + + status =usb_add_function (c, f_msg); +if (status) + goto err_msg; +if (c == &nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; f_ecm_cfg1 = f_ecm; f_phonet_cfg1 = f_phonet; f_obex1_cfg1 = f_obex1; f_obex2_cfg1 = f_obex2; + f_msg_cfg1 = f_msg; }else { f_acm_cfg2 = f_acm; f_ecm_cfg2 = f_ecm; f_phonet_cfg2 = f_phonet; f_obex1_cfg2 = f_obex1; f_obex2_cfg2 = f_obex2; + f_msg_cfg2 = f_msg; }return status; +err_msg: +usb_remove_function (c, f_ecm); err_ecm:usb_remove_function (c, f_acm); err_conf:@@ -211,6 +261,8 @@ err_conf:usb_remove_function (c, f_obex1);if (!phonet_stat)usb_remove_function (c, f_phonet); +usb_put_function (f_msg); +err_get_msg:usb_put_function (f_ecm); err_get_ecm:usb_put_function (f_acm);@@ -227,6 +279,8 @@ err_get_acm:static int __init nokia_bind (struct usb_composite_dev *cdev) {struct usb_gadget *gadget = cdev->gadget; +struct fsg_opts *fsg_opts; +struct fsg_config fsg_config;drivers/usb/gadget/legacy/nokia.c +22
-0int status; status =usb_string_ids_tab (cdev, strings_dev);@@ -267,11 +321,46 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) goto err_acm_inst; } + fi_msg =usb_get_function_instance ("mass_storage" ); +if (IS_ERR (fi_msg)) { + status =PTR_ERR (fi_msg); + goto err_ecm_inst; + } + +/* set up mass storage function */ +fsg_config_from_params (&fsg_config, &fsg_mod_data, fsg_num_buffers); + fsg_config.vendor_name ="Nokia" ; + fsg_config.product_name ="N900" ; + + fsg_opts =fsg_opts_from_func_inst (fi_msg); + fsg_opts->no_configfs = true; + + status =fsg_common_set_num_buffers (fsg_opts->common, fsg_num_buffers); + if (status) + goto err_msg_inst; + + status =fsg_common_set_nluns (fsg_opts->common, fsg_config.nluns); + if (status) + goto err_msg_buf; + + status =fsg_common_set_cdev (fsg_opts->common, cdev, fsg_config.can_stall); + if (status) + goto err_msg_set_nluns; +Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/usb/gadget/legacy/nokia.c +6
-0+fsg_common_set_sysfs (fsg_opts->common, true); + + status =fsg_common_create_luns (fsg_opts->common, &fsg_config); + if (status) + goto err_msg_set_nluns; + + fsg_common_set_inquiry_string(fsg_opts->common,fsg_config.vendor_name, +
fsg_config.product_name);
Quoted 102 lines
Quoted 85 lines
Quoted 76 lines
Quoted 76 lines
Quoted 76 lines
Quoted 67 lines
Quoted 48 lines
drivers/usb/gadget/legacy/nokia.c +10
-1+/* finally register the configuration */ status =usb_add_config (cdev, &nokia_config_500ma_driver, nokia_bind_config);if (status <0 ) - goto err_ecm_inst; + goto err_msg_set_cdev; status =usb_add_config (cdev, &nokia_config_100ma_driver, nokia_bind_config);@@ -292,6 +381,14 @@ err_put_cfg1:if (!IS_ERR_OR_NULL (f_phonet_cfg1))usb_put_function (f_phonet_cfg1);usb_put_function (f_ecm_cfg1); +err_msg_set_cdev: +fsg_common_remove_luns (fsg_opts->common); +err_msg_set_nluns: +fsg_common_free_luns (fsg_opts->common); +err_msg_buf: +fsg_common_free_buffers (fsg_opts->common); +err_msg_inst: +usb_put_function_instance (fi_msg);
err_ecm_inst:drivers/usb/gadget/legacy/nokia.c +3
-0usb_put_function_instance (fi_ecm); err_acm_inst:@@ -325,7 +422,10 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev)usb_put_function (f_acm_cfg2 );usb_put_function (f_ecm_cfg1);usb_put_function (f_ecm_cfg2); +usb_put_function (f_msg_cfg1); +usb_put_function (f_msg_cfg2); +usb_put_function_instance (fi_msg);drivers/usb/gadget/legacy/nokia.c
Quoted 4 lines
drivers/usb/gadget/legacy/nokia.c +0
-0usb_put_function_instance (fi_ecm);if (!IS_ERR (fi_obex2))usb_put_function_instance (fi_obex2);Opening discussion about this patch again as this is still only one solution how to use use mass storage without breaking other stuff...
Please understand finally that usb networking is very very important for development on this device and usb mass storage is needed for transferring bigger data.
Also to clarify potential regressions: This patch adds *optional* usb mass storage support and block device can be attached/detached to driver at runtime. It does *not* enforce to export some (mmc) device automatically. It is optional and userspace can decide...
Quoted 4 lines
So MyDocs N900 partition is not automatically enforced to be exported via usb (as some people thought) and so it does not break usb networking or mass storage mode or MyDocs parition on N900 with Maemo system.
Instead of adding mass storage to legacy gadget you may switch to configfs interface and compose equivalent of
g_nokia+ mass storage without any changes in kernel.Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Best regards,
That requires userspace. And there are developers who use nfsroot via usb networking and so userspace will be there after properly initializing usb gadget... So it is not easy and reason why I'm opening this discussion again.
Couldn't you simply use initramfs to compose your gadget?
Quoted 12 lines
This is another next complication... I could spend time on hacking serious problems on Nokia N900 (camera not working, bluetooth not working, improving cellular audio/voice calls) or start playing with initramfs and other kernel infrastructure just because usb is broken and small fix which enable all needed usb functionality (usb networking, usb TTY, usb phonet, usb mass storage) cannot be accepted and merged because it really helps people to develop... :-( I see that it is under legacy drivers, but without it is hard (and maybe not possible) to develop for Nokia N900 device. Nobody until now proposed any other patch which fix our problems and provide working usb functionality for mass storage, network, TTY and phonet.
Sure this causes no problems to original Maemo userland ? Also, IIRC, we were running out of both FIFO space and physical endpoints with
g_nokiaalready. Do all functions still work if used all at once ?Quoted 5 lines
If you can confirm these two questions I'll take this patch. As long as there are no regressions with original userland from Nokia, it should be fine.
cheers
Quoted 8 lines
In this my patch usb gadget support is removable (see
fsg_mod_data). It means that at runtime (when module is already loaded and initialized!) userspace can decide to export some block device via usb. And unexport it at every time. Also this patch does not export any device by default. So it does not lock any block device (like MyDocs), so there is really no regressions like you though about MyDocs. usb networking, tty and also phone will still work viag_nokia. And if you do not export block device MyDocs it will stay normally mounted in N900 VFS.
All right, I tried merging it and it added build breaks to the tree. I'll wait for another version for v4.3 merge window.
cheers
Signature · 1 line
balbi
Quoted 4 lines · On Friday 29 May 2015 18:57:06 Felipe Balbi wrote:
All right, I tried merging it and it added build breaks to the tree. I'll wait for another version for v4.3 merge window.
cheers
Hello, version below compiles fine on top of linus tree. Please apply:
drivers/usb/gadget/legacy/Kconfig +1 -0
@@ -346,6 +346,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGE help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.
drivers/usb/gadget/legacy/nokia.c +101 -1
194 lines not on this page · raw message
Signature · 2 lines
Pali Rohár [email protected]
Hi,
Quoted 7 lines · Pali Rohár
Quoted 4 lines · On Friday 29 May 2015 18:57:06 Felipe Balbi wrote:
All right, I tried merging it and it added build breaks to the tree. I'll wait for another version for v4.3 merge window.
cheers
Hello, version below compiles fine on top of linus tree. Please apply:
no signed-off-by, not commit log. Sorry, can't apply.
Signature · 1 line
balbi
Quoted 7 lines · On Friday 05 June 2015 22:17:09 Felipe Balbi wrote:
Hi,
Quoted 4 lines · Pali Rohár
Quoted 3 lines · On Friday 29 May 2015 18:57:06 Felipe Balbi wrote:
All right, I tried merging it and it added build breaks to the tree. I'll wait for another version for v4.3 merge window.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
cheers
Hello, version below compiles fine on top of linus tree. Please apply:
no signed-off-by,
Quoted 1 line
not commit log.
This patch adds removable mass storage support to g_nokia gadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...
Quoted 1 line
Sorry, can't apply.
Signature · 2 lines
Pali Rohár [email protected]
Quoted 15 lines · Pali Rohár
Quoted 7 lines · On Friday 05 June 2015 22:17:09 Felipe Balbi wrote:
Hi,
Quoted 4 lines · Pali Rohár
Quoted 3 lines · On Friday 29 May 2015 18:57:06 Felipe Balbi wrote:
All right, I tried merging it and it added build breaks to the tree. I'll wait for another version for v4.3 merge window.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
cheers
Hello, version below compiles fine on top of linus tree. Please apply:
no signed-off-by,
Quoted 8 lines
Signed-off-by Pali Rohár <[email protected]>Quoted 1 line
not commit log.
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...
sorry, but you gotta resend it, you're just a git commit && git send-email -1 away.
Signature · 1 line
balbi
PATCH 1/1 usb: gadget: nokia: Add mass storage driver to g_nokia
This patch adds removable mass storage support to g_nokia gadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...
--- drivers/usb/gadget/legacy/Kconfig | 1 + drivers/usb/gadget/legacy/nokia.c | 102 ++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 1 deletion(-)
drivers/usb/gadget/legacy/Kconfig +1 -0
@@ -346,6 +346,7 @@ config USB_G_NOKIA select USB_F_OBEX select USB_F_PHONET select USB_F_ECM + select USB_F_MASS_STORAGE help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver.
drivers/usb/gadget/legacy/nokia.c +101 -1
194 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>
now in my testing/next, thanks
Signature · 1 line
balbi
Quoted 9 lines · On Monday 08 June 2015 18:08:19 Felipe Balbi wrote:
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>now in my testing/next, thanks
Hello, what happened with this patch? Version 4.2-rc1 was released, but I do not see it included yet...
Signature · 2 lines
Pali Rohár [email protected]
Quoted 7 lines · Pali Rohár
Quoted 6 lines · On Monday 08 June 2015 18:08:19 Felipe Balbi wrote:
Quoted 5 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Pali Rohár <[email protected]>now in my testing/next, thanks
Hello, what happened with this patch? Version 4.2-rc1 was released, but I do not see it included yet...
By the time I merged this to testing/next, my tree was already closed to v4.2, it's queued for v4.3. And I also fixed the NULL pointer dereference your patch caused, btw.
Signature · 1 line
balbi
Quoted 10 lines · Felipe Balbi
Quoted 9 lines · Pali Rohár
Quoted 8 lines · On Monday 08 June 2015 18:08:19 Felipe Balbi wrote:
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
now in my testing/next, thanks
Hello, what happened with this patch? Version 4.2-rc1 was released, but I do not see it included yet...
By the time I merged this to testing/next, my tree was already closed to v4.2, it's queued for v4.3. And I also fixed the NULL pointer dereference your patch caused, btw.
sorry, it was a build error.
Signature · 1 line
balbi
Quoted 13 lines · On Monday 06 July 2015 19:44:21 Felipe Balbi wrote:
Quoted 12 lines · Felipe Balbi
Quoted 11 lines · Pali Rohár
Quoted 9 lines · On Monday 08 June 2015 18:08:19 Felipe Balbi wrote:
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>now in my testing/next, thanks
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Hello, what happened with this patch? Version 4.2-rc1 was released, but I do not see it included yet...
By the time I merged this to testing/next, my tree was already closed to v4.2, it's queued for v4.3. And I also fixed the NULL pointer dereference your patch caused, btw.
sorry, it was a build error.
When I sent this patch, it compiled without any error...
Signature · 2 lines
Pali Rohár [email protected]
Hi,
Quoted 17 lines · Pali Rohár
Quoted 16 lines · On Monday 06 July 2015 19:44:21 Felipe Balbi wrote:
Quoted 15 lines · Felipe Balbi
Quoted 13 lines · Pali Rohár
Quoted 9 lines · On Monday 08 June 2015 18:08:19 Felipe Balbi wrote:
Quoted 6 lines · Pali Rohár
This patch adds removable mass storage support to
g_nokiagadget (for N900). It means that at runtime block device can be exported or unexported. So it does not export anything by default and thus allows to use MyDocs partition as before...Signed-off-by Pali Rohár <[email protected]>now in my testing/next, thanks
Hello, what happened with this patch? Version 4.2-rc1 was released, but I do not see it included yet...
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
By the time I merged this to testing/next, my tree was already closed to v4.2, it's queued for v4.3. And I also fixed the NULL pointer dereference your patch caused, btw.
sorry, it was a build error.
When I sent this patch, it compiled without any error...
there was a build error due to undefined nlus (IIRC). In any case, it's fixed. No harm done.
Signature · 1 line
balbi