ar9170usb: add mode-switching for AVM Fritz!WLAN USB N devices in cdrom mode
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 ar9170usb: add mode-switching for AVM Fritz!WLAN USB N devices in cdrom mode
Quoted 39 lines · Frank Schaefer
Quoted 27 lines · Matthew Dharm
Quoted 16 lines · Alan Stern
Quoted 12 lines · Oliver Neukum
Am Samstag, 17. Oktober 2009 15:14:28 schrieb Frank Schaefer:
Quoted 6 lines
I can think of multiple solutions for this, my first questions are:
Is there already a common solution for these devices in the kernel ? How widespread is this bad habit of device-design ? So far, the only devices I know areThis is usually handled by the modeswitch tool outside the kernel.
Quoted 8 lines
Alternatively, you may be able to force the device to switch modes by running the "eject" program on it.
There is mode-switching code in the kernel for a few devices. The current trend is to move this out of the kernel and let user programs be responsible for it.
Quoted 7 lines
If you go with the current trend, then you probably will want to write some UDEV rules to recognize these devices and issue the mode-changing command (either modeswitch or eject).
Matt
Thanks for your replies, I really didn't know that there are so many devices showing this behavior.
Quoted 8 lines
On Windows, AVM does the fast-eject for its devices with a small filter-driver avmeject.sys.
I will try to find out the "magic sequence" needed for the mode-switch with a USB-logger.Regards,
Frank
I finally found the "magic" sequence.
In the meantime I've been thinking a lot (too much ?) about HOW and WHERE to do the mode-switching.
The mailing-list-archieves were really inspiring, maybe you remember the discussion about Tejun Heos' patches in april 2008.
The conclusion was that there is no clearly preferable way to do this and that compromises are inevitable.
The attached patch adds the mode-switching-procedure to the WLAN-driver (ar9170usb) and disables the storage device in the usb-storage-driver.
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
Doing it in the driver means putting the code for these device together in a single place.
It also doesn't "pollute" the driver with much code (adds a single usb_bulk_msg()).
Another benfit is that it binds the mode-switching to the driver. If the driver is blacklisted/not used, there will be no mode-switching. If there would be a way to keep the usb-storage-driver enabled as "fallback-driver" it would be an almost perfect solution...
Regards,
Frank
From 372e9f3e6d61e195339d955a1d75b15a23dde624 Mon Sep 17 00:00:00 2001
From: Frank Schaefer <[email protected]>
Date: Sun, 1 Nov 2009 17:31:14 +0100
Subject: [PATCH] ar9170usb: add mode-switching for AVM Fritz!WLAN USB N devices in cdrom mode
The devices
057c:8401 AVM Fritz!WLAN USB N
057c:8402 AVM Fritz!WLAN USB N 2.4
have a built-in cdrom-mode:
When they are plugged in, they appear as read-only USB-mass-storage-device (SCSI-CDROM, iso9660) 057c:84ff containing Windows driver files. I takes about 2 minutes until the firmware times-out and disconnects these devices.
Then USB-product-id changes and they appear again as WLAN-device.
We don't need the Windows drivers and we just want a WLAN-device which is immediately available.
This patch adds the necessary mode-switching-/fast-eject-procedure to the driver.
Tested with device 057c:8401.
--- drivers/net/wireless/ath/ar9170/usb.c | 57 ++++++++++++++++++++++++++++++-- drivers/usb/storage/usual-tables.c | 4 ++ 2 files changed, 57 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ar9170/usb.c +53 -4
@@ -88,10 +88,12 @@ static struct usb_device_id ar9170_usb_ids[] = { { USB_DEVICE(0x2019, 0x5304) },/* IO-Data WNGDNUS2 */ { USB_DEVICE(0x04bb, 0x093f) }, +/* AVM FRITZ!WLAN USB Stick N (2.4) in cdrom mode */ + { USB_DEVICE(0x057c, 0x84ff) },/* AVM FRITZ!WLAN USB Stick N */ - { USB_DEVICE(0x057C, 0x8401) }, + { USB_DEVICE(0x057c, 0x8401) },/* AVM FRITZ!WLAN USB Stick N 2.4 */ - { USB_DEVICE(0x057C, 0x8402), .driver_info = AR9170_REQ_FW1_ONLY }, + { USB_DEVICE(0x057c, 0x8402), .driver_info = AR9170_REQ_FW1_ONLY }, /* terminate */ {}
@@ -762,6 +764,43 @@ static bool ar9170_requires_one_stage(const struct usb_device_id *id)return false; } +static void ar9170_usb_avm_cdrom_fast_eject (struct usb_interface *intf, +struct usb_device *udev) +{ +const unsigned char scsi_stop_unit[31 ] = { +0x55 ,0x53 ,0x42 ,0x43 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x06 ,0x1B ,0x00 ,0x00 ,0x00 ,0xFF ,0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 }; + +__u8 epAddr; +unsigned char *tmpbuf; +int actual_len; + +printk (KERN_INFO "ar9170usb: Found device AVM FRITZ!WLAN USB N in " +"cdrom mode. Doing fast eject.\n" ); + tmpbuf = (unsigned char *)kmalloc (sizeof (scsi_stop_unit),GFP_KERNEL ); +if (tmpbuf ==NULL ) + goto error; +memcpy (tmpbuf, scsi_stop_unit,sizeof (scsi_stop_unit)); + epAddr = intf->altsetting[0 ].endpoint[0 ].desc.bEndpointAddress; +if (usb_bulk_msg (udev, +usb_sndbulkpipe (udev, epAddr), + tmpbuf, +sizeof (scsi_stop_unit), + &actual_len, +5 *HZ ) <0 ) + goto error; +if (actual_len !=sizeof (scsi_stop_unit)) + goto error; +kfree (tmpbuf); +return ; +error: +if (tmpbuf) +kfree (tmpbuf); +printk (KERN_ERR "ar9170usb: Fast eject failed. Device should timeout " +"in ~2 min. and eject itself.\n" ); +} +static int ar9170_usb_probe (struct usb_interface *intf,const struct usb_device_id *id) {
@@ -770,14 +809,24 @@ static int ar9170_usb_probe(struct usb_interface *intf,struct usb_device *udev;int err; + udev =interface_to_usbdev (intf); +usb_get_dev (udev); + +/* Fast eject for AVM FRITZ!WLAN USB Stick N (2.4) in cdrom mode */ +if ((le16_to_cpu (udev->descriptor.idVendor) ==0x057C ) + && (le16_to_cpu (udev->descriptor.idProduct) ==0x84FF )) { +ar9170_usb_avm_cdrom_fast_eject (intf, udev); +usb_put_dev (udev); +return 0 ; + } +/* NOTE: device will vanish and reappear with PID 0x8401 or 0x8402 */ + aru =ar9170_alloc (sizeof (*aru));if (IS_ERR (aru)) { err =PTR_ERR (aru); goto out; } - udev =interface_to_usbdev (intf); -usb_get_dev (udev); aru->udev = udev; aru->intf = intf; ar = &aru->common;
drivers/usb/storage/usual-tables.c +4 -0
@@ -88,6 +88,10 @@ static struct ignore_entry ignore_ids[] = {# include "unusual_sddr09.h" # include "unusual_sddr55.h" # include "unusual_usbat.h" +UNUSUAL_DEV (0x057c ,0x84ff ,0x0000 ,0xffff , +"AVM" , +"Fritz!WLAN USB N (2.4) in cdrom mode" , + US_SC_DEVICE, US_PR_DEVICE, NULL, 0), { } /* Terminating entry */ };
Signature · 1 line
1.6.0.2
Quoted 2 lines · Frank Schaefer
The attached patch adds the mode-switching-procedure to the WLAN-driver (ar9170usb) and disables the storage device in the usb-storage-driver.
This patch looks weird. Have you looked at zd1211rw, which also does this? I think it just adds something to usb-storage for the device IDs?
johannes
Quoted 12 lines · Johannes Berg
Quoted 3 lines · Frank Schaefer
The attached patch adds the mode-switching-procedure to the WLAN-driver (ar9170usb) and disables the storage device in the usb-storage-driver.
This patch looks weird. Have you looked at zd1211rw, which also does this? I think it just adds something to usb-storage for the device IDs?
johannes
Well, AFAICS, the zd1211rw does exactly what I suggest with my patch ?! It calls a function eject_installer(...) for these devices in the modules' probe-function which sends a single usb_bulk_msg.
Frank
Quoted 2 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
Quoted 2 lines
It also doesn't "pollute" the driver with much code (adds a single
usb_bulk_msg()).
That may be true for a single device but there are around 30+ others which are switched outside the kernel, some inside usb-storage, and this would add even more places where mode switching happened.
Quoted 2 lines
Another benfit is that it binds the mode-switching to the driver. If the driver is blacklisted/not used, there will be no mode-switching.
But how would you access the storage part of the device then?
Josua
Signature · 2 lines
Man is the only creature on earth enabled to take a warm meal while flying! Loriot
Quoted 7 lines · Josua Dietze
Quoted 2 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
And I think it should be done in userspace for issues of maintainability and useability. It is much easier for users to upgrade their udev then their kernel.
Quoted 5 lines
Quoted 2 lines
Another benfit is that it binds the mode-switching to the driver. If the driver is blacklisted/not used, there will be no mode-switching.
But how would you access the storage part of the device then?
And doing the switch in userspace would solve this problem also.
Finally, if we do this in userspace, device vendors might actually get a clue and start providing a small linux app or script to do the mode switch on their virtual storage device, just like they do for windows.
Matt
Signature · 7 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver C: They kicked your ass, didn't they? S: They were cheating! -- The Chief and Stef User Friendly, 11/19/1997
Quoted 8 lines · Matthew Dharm
Quoted 6 lines · Josua Dietze
Quoted 3 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
Quoted 8 lines
Quoted 3 lines
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
And I think it should be done in userspace for issues of maintainability and useability. It is much easier for users to upgrade their udev then their kernel.
Maintainability for whom ? The kernel-devs or the distro-people and the users ? ;)
Please think about the users. They don't know that they have to create udev-rules or have to install additional packages like usb_modeswitch (which is nevertheless a great tool !).
And even if they know, they don't want to do that. So it's up to the distros to do this automatically, which will in reality never come true for all devices and distros.
Do you know the microdia-webcam-driver which recently got into the kernel as sn9c20x-gspcav-sub-driver ?
It's a great and functional driver which supports lots of webcams, but in fact its useless for most users (at least the ones who don't know LD_PRELOAD-hack)...
Please don't understand me wrong: I agree that we should keep the kernel slim and do as much as possible in userspace and I can see the benefits of the userspace-approach.
But we have to make compromises and I think a kernel-space-apporach would be the best compromise in this case. Just my two cents.
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Another benfit is that it binds the mode-switching to the driver. If the driver is blacklisted/not used, there will be no mode-switching.
But how would you access the storage part of the device then?
Quoted 8 lines
And doing the switch in userspace would solve this problem also.
Finally, if we do this in userspace, device vendors might actually get a clue and start providing a small linux app or script to do the mode switch on their virtual storage device, just like they do for windows.
Matt
As I said in reply to Josua, this depends on device-type. For windows-driver-storage-devices we don't need such a tool.
Frank
Quoted 20 lines · On Sunday 01 November 2009 21:24:28 Frank Schaefer wrote:
Quoted 8 lines · Matthew Dharm
Quoted 6 lines · Josua Dietze
Quoted 3 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
Quoted 8 lines
Quoted 3 lines
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
And I think it should be done in userspace for issues of maintainability and useability. It is much easier for users to upgrade their udev then their kernel.
Maintainability for whom ? The kernel-devs or the distro-people and the users ? ;)
Quoted 6 lines
Please think about the users. They don't know that they have to create udev-rules or have to install additional packages like
usb_modeswitch(which is nevertheless a great tool !).
And even if they know, they don't want to do that. So it's up to the distros to do this automatically, which will in reality never come true for all devices and distros.
yes, please think about the users!
All not-so-trival-changes have to go through wireless-testing / wireless-next, net-next, linux-next until it hits finally the mainline... And then only users which are able to update their kernels will benefit, *everyone else* has to wait until their distros to pick up the new kernel... this could be easily more than a year before the device will work right out of the box for *everyone else*.
Therefore udev should be the way to go... and as a bonus: a userspace/udev solution does work with older kernels right away!
Regards,
Chr
Quoted 28 lines · Christian Lamparter
Quoted 19 lines · On Sunday 01 November 2009 21:24:28 Frank Schaefer wrote:
Quoted 7 lines · Matthew Dharm
Quoted 5 lines · Josua Dietze
Quoted 3 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
Quoted 7 lines
Quoted 3 lines
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
And I think it should be done in userspace for issues of maintainability and useability. It is much easier for users to upgrade their udev then their kernel.
Maintainability for whom ? The kernel-devs or the distro-people and the users ? ;)
Quoted 7 lines
Please think about the users. They don't know that they have to create udev-rules or have to install additional packages like
usb_modeswitch(which is nevertheless a great tool !).
And even if they know, they don't want to do that. So it's up to the distros to do this automatically, which will in reality never come true for all devices and distros.
Quoted 8 lines
yes, please think about the users!
All not-so-trival-changes have to go through wireless-testing / wireless-next, net-next, linux-next until it hits finally the mainline... And then only users which are able to update their kernels will benefit, *everyone else* has to wait until their distros to pick up the new kernel... this could be easily more than a year before the device will work right out of the box for *everyone else*.
Which potential not-so-trivial-changes do you think of in this case ? And userspace-software + packages have a quality-assurance-procedure, too, right ? ;)
Quoted 1 line
Therefore udev should be the way to go...
Maybe it should be, but it's a solution which will never work satisfyingly. At least as long as the needed udev-rules are not shipped with the kernel...
Quoted 5 lines
and as a bonus: a userspace/udev solution
does work with older kernels right away!Regards,
Chr
Frank
Quoted 13 lines · Frank Schaefer
Quoted 12 lines · Matthew Dharm
Quoted 9 lines · Josua Dietze
Quoted 3 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
Quoted 6 lines
Quoted 4 lines
And I think it should be done in userspace for issues of maintainability and useability. It is much easier for users to upgrade their udev then their kernel.
Maintainability for whom ? The kernel-devs or the distro-people and the users ? ;)
Both.
Quoted 6 lines
Please think about the users. They don't know that they have to create udev-rules or have to install additional packages like
usb_modeswitch(which is nevertheless a great tool !).
And even if they know, they don't want to do that. So it's up to the distros to do this automatically, which will in reality never come true for all devices and distros.
I am thinking about the users. Do you really think someone who has difficulty installing a new udev rule (probably a line or two of text copied from a google search) or installing a new version of usb_modeswitch (probably one or two commands to the distro package manager) will have an easier time doing a custom kernel-compile and update?
Updates in userspace are universally easier; on users, on kernel deves, and on distro devs.
Matt
Signature · 7 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver Hey Chief. We've figured out how to save the technical department. We need to be committed. -- The Techs User Friendly, 1/22/1998
Quoted 30 lines · Matthew Dharm
Quoted 11 lines · Frank Schaefer
Quoted 9 lines · Matthew Dharm
Quoted 7 lines · Josua Dietze
Quoted 3 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
Quoted 7 lines
Quoted 4 lines
And I think it should be done in userspace for issues of maintainability and useability. It is much easier for users to upgrade their udev then their kernel.
Maintainability for whom ? The kernel-devs or the distro-people and the users ? ;)
Both.
Quoted 6 lines
Please think about the users. They don't know that they have to create udev-rules or have to install additional packages like
usb_modeswitch(which is nevertheless a great tool !).
And even if they know, they don't want to do that. So it's up to the distros to do this automatically, which will in reality never come true for all devices and distros.
Quoted 6 lines
I am thinking about the users. Do you really think someone who has difficulty installing a new udev rule (probably a line or two of text copied from a google search) or installing a new version of
usb_modeswitch(probably one or two commands to the distro package manager) will have an easier time doing a custom kernel-compile and update?
I think users should not need to do ANY of these things ! That's called usability.
Which users do you think know how to create udev-rules and how to compile a kernel ?
Of course you and me and likely all others on this mailing-list and maybe you think Linux should be for them, only.
I think we should do as much as possible to improve Linux-usability for "normal" and even "less experienced" users.
And in this case, it would be really easy.
Quoted 5 lines
Updates in userspace are universally easier; on users, on kernel deves, and on distro devs.
Matt
Why ? Of course, the benfit for kernel-developers is that the work is done by others...
But for the distros it makes life much more difficult in many respects. And users are in the somehow insane situation that they have to keep the driver (kernel) AND the "key to be able to use it" up-to-date. That's not only a problem because they both things from different sources/directions !
Frank
Quoted 9 lines · Frank Schaefer
Quoted 6 lines · Matthew Dharm
I am thinking about the users. Do you really think someone who has difficulty installing a new udev rule (probably a line or two of text copied from a google search) or installing a new version of
usb_modeswitch(probably one or two commands to the distro package manager) will have an easier time doing a custom kernel-compile and update?I think users should not need to do ANY of these things ! That's called usability.
So, new hardware should "magically" work? When you can write software to support hardware that doesn't exist yet, let me know.
Quoted 7 lines
Which users do you think know how to create udev-rules and how to compile a kernel ?
Of course you and me and likely all others on this mailing-list and maybe you think Linux should be for them, only.I think we should do as much as possible to improve Linux-usability for "normal" and even "less experienced" users.
Okay, let's talk about "less experienced" users. Suppose you are one of these users. You get a new device, and you want to use it. You do some web searching, and discover either:
(a) you need to download and recompile your kernel
(b) you need to cut-and-paste some text from a web page into a file
Which do you think is easier?
And, the situation above pre-supposes that the requisite changes (kernel or userspace) haven't already been picked up by a distro maintainer.
Quoted 7 lines
And in this case, it would be really easy.
Quoted 3 lines
Updates in userspace are universally easier; on users, on kernel deves, and on distro devs.
Why ? Of course, the benfit for kernel-developers is that the work is done by others...
But for the distros it makes life much more difficult in many respects.
I highly doubt this. Distros must very carefully test all the kernel changes they decide to pull in. Each and every change in a kernel-layer is a high-risk change for them. Changing userspace packages is much lower-risk, and thus consumes correspondingly fewer resources.
Quoted 4 lines
And users are in the somehow insane situation that they have to keep the driver (kernel) AND the "key to be able to use it" up-to-date. That's not only a problem because they both things from different sources/directions !
I think you may have missed part of an earlier discussion, wherein we discussed such devices which would NOT need ANY kernel changes. The idea was that udev could "eject" the fake-USB device, then add the device IDs to the serial/cdc_amc/whatever driver dynamically, at runtime. Thus, no need to make any kernel updates at all.
And, that system works *today* with the existing kernel code.
Matt
Signature · 6 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver Okay, this isn't funny anymore! Let me down! I'll tell Bill on you!! -- Microsoft Salesman User Friendly, 4/1/1998
Quoted 7 lines · Matthew Dharm
I think you may have missed part of an earlier discussion, wherein we discussed such devices which would NOT need ANY kernel changes. The idea was that udev could "eject" the fake-USB device, then add the device IDs to the serial/cdc_amc/whatever driver dynamically, at runtime. Thus, no need to make any kernel updates at all.
And, that system works *today* with the existing kernel code.
Search the archives for "Toshiba G450" if you want to find that discussion.
Matt
Signature · 7 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver Sir, for the hundreth time, we do NOT carry 600-round boxes of belt-fed suction darts! -- Salesperson to Greg User Friendly, 12/30/1997
Quoted 10 lines · Matthew Dharm
Quoted 8 lines · Frank Schaefer
Quoted 6 lines · Matthew Dharm
I am thinking about the users. Do you really think someone who has difficulty installing a new udev rule (probably a line or two of text copied from a google search) or installing a new version of
usb_modeswitch(probably one or two commands to the distro package manager) will have an easier time doing a custom kernel-compile and update?
Quoted 7 lines
Quoted 3 lines
I think users should not need to do ANY of these things ! That's called usability.
So, new hardware should "magically" work? When you can write software to support hardware that doesn't exist yet, let me know.
I can make nothing of that.
It really doesn't make sense to discuss about mode-switches for devices for which we not even have a driver.
Quoted 9 lines
Quoted 8 lines
Which users do you think know how to create udev-rules and how to compile a kernel ?
Of course you and me and likely all others on this mailing-list and maybe you think Linux should be for them, only.I think we should do as much as possible to improve Linux-usability for "normal" and even "less experienced" users.
Quoted 9 lines
Okay, let's talk about "less experienced" users. Suppose you are one of these users. You get a new device, and you want to use it. You do some web searching, and discover either:
(a) you need to download and recompile your kernel
(b) you need to cut-and-paste some text from a web page into a fileWhich do you think is easier?
It's easier to let the driver/kernel do the mode-switch automatically if it makes sense !
That's perfect Plug'N Play and (a) and (b) are dispensable.
Apart from that, I think that "just cut-and-paste some text from a web page into a file" is an illusion.
Starts with the right key-words you need for the search and continues with the quality of the documentation.
It's not that easy to create universal and especially complete manuals (we all love documentation-work right !? ;) ).
For example: what's udev ? Of course, WE know, but ...
Quoted 15 lines
And, the situation above pre-supposes that the requisite changes (kernel or userspace) haven't already been picked up by a distro maintainer.
Quoted 10 lines
And in this case, it would be really easy.
Quoted 4 lines
Updates in userspace are universally easier; on users, on kernel deves, and on distro devs.
Why ? Of course, the benfit for kernel-developers is that the work is done by others...
But for the distros it makes life much more difficult in many respects.
Quoted 6 lines
I highly doubt this. Distros must very carefully test all the kernel changes they decide to pull in. Each and every change in a kernel-layer is a high-risk change for them. Changing userspace packages is much lower-risk, and thus consumes correspondingly fewer resources.
And they don't have to test userspace-software carefully, too ??? Especially sysconfig-software ?
I can't see a significant difference here.
Quoted 12 lines
Quoted 5 lines
And users are in the somehow insane situation that they have to keep the driver (kernel) AND the "key to be able to use it" up-to-date. That's not only a problem because they both things from different sources/directions !
I think you may have missed part of an earlier discussion, wherein we discussed such devices which would NOT need ANY kernel changes. The idea was that udev could "eject" the fake-USB device, then add the device IDs to the serial/cdc_amc/whatever driver dynamically, at runtime. Thus, no need to make any kernel updates at all.
Quoted 4 lines
And, that system works *today* with the existing kernel code.
Matt
You didn't understand me right. No problem.
I was talking about inconsistencies we get when driver and the mode-switch-part come from different sources.
That's one of the main problems in Unix-world, maybe that's the price we have to pay for thinking more modular (packages) than in products like in M$-world.
But we shouldn't pay that price needlessly because of splitting things at the wrong position.
Frank
Quoted 7 lines · Josua Dietze
Quoted 2 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
It returns an error but the device is ejected.
But do you really want the users to open a terminal window and call "eject" each time they plug their device in ;) ?
Quoted 6 lines
Quoted 2 lines
It also doesn't "pollute" the driver with much code (adds a single
usb_bulk_msg()).That may be true for a single device but there are around 30+ others which are switched outside the kernel, some inside usb-storage, and this would add even more places where mode switching happened.
Of course I like the idea of having all mode-switches at the same place, but we learnt from discussions in the past that there will likely never be a unified solution for all devices.
Devices are to different. Some disconnect and change their IDs and others only change their interface-setup.
In addition to that it depends on the purpose/type of the two devices. In this case, the only purpose of the storage device is to provide windows-drivers for installation. When the driver is installed, the storage-device should not appear any more.
Quoted 6 lines
Quoted 2 lines
Another benfit is that it binds the mode-switching to the driver. If the driver is blacklisted/not used, there will be no mode-switching.
But how would you access the storage part of the device then?
Josua
Never, that's the compromise we have to make. But we can really make it, simply because we will never need it.
Please let me know if there is a possibility to "keep" the usb-mass-storage-driver as "fallback-driver".
Frank
Quoted 11 lines · Frank Schaefer
Quoted 7 lines · Josua Dietze
Quoted 2 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
It returns an error but the device is ejected.
But do you really want the users to open a terminal window and call "eject" each time they plug their device in ;) ?
If 'eject' worked, then why not use a simple udev entry? That way nobody has to call anything by hand...
Matt
Signature · 6 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver Why am I talking to a toilet brush? -- CEO User Friendly, 4/30/1998
Quoted 17 lines · Matthew Dharm
Quoted 7 lines · Frank Schaefer
Quoted 5 lines · Josua Dietze
Quoted 3 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
Quoted 7 lines
Quoted 3 lines
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
It returns an error but the device is ejected.
But do you really want the users to open a terminal window and call "eject" each time they plug their device in ;) ?
Quoted 5 lines
If 'eject' worked, then why not use a simple udev entry? That way nobody has to call anything by hand...
Matt
And who will create this udev-entry ;) ? How can you make sure that this is done on all systems ?
Frank
Quoted 18 lines · Frank Schaefer
Quoted 17 lines · Matthew Dharm
Quoted 14 lines · Frank Schaefer
Quoted 8 lines · Josua Dietze
Quoted 3 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
It returns an error but the device is ejected.
But do you really want the users to open a terminal window and call "eject" each time they plug their device in ;) ?
Quoted 7 lines
Quoted 5 lines
If 'eject' worked, then why not use a simple udev entry? That way nobody has to call anything by hand...
Matt
And who will create this udev-entry ;) ? How can you make sure that this is done on all systems ?
You can't. The distros have to make sure it works. Personally, I think these should all be in the kernel, but the kernel doesn't contain policy. And unfortunately, for some devices (3G modems specifically) ejecting the driver CD thing *is* policy. Option for example protested mightily when I sent a patch to auto-eject their driver CD, because they apparently do use the driver CD thing to send Linux drivers and software to a few clients. But by and large, the driver CD is completely useless.
Devices with fake driver CDs and how they are handled currently:
Zydas WLAN - kernel Huawei 3G - kernel (unusual_devs entry) Sierra 3G - kernel (drivers/usb/serial/sierra.c) Option 3G - udev rules, 'rezero', or usb_modeswitch ZTE 3G - udev rules, simple 'eject'
Dan
Quoted 3 lines
apparently do use the driver CD thing to send Linux drivers and software to a few clients. But by and large, the driver CD is completely useless.
And then every so often you need to rummage around the driver CD image to extract the APN or other data you need to make your modem work. At which point you end up having to recompile the kernel to get it. Very annoying given it could be trivially done properly in user space.
HAL probably needs the database of these devices *not* the kernel.
Quoted 10 lines · Alan Cox
Quoted 3 lines
apparently do use the driver CD thing to send Linux drivers and software to a few clients. But by and large, the driver CD is completely useless.
And then every so often you need to rummage around the driver CD image to extract the APN or other data you need to make your modem work. At which point you end up having to recompile the kernel to get it. Very annoying given it could be trivially done properly in user space.
HAL probably needs the database of these devices *not* the kernel.
It's udev these days; HAL is going away since it and udev pretty much can do the same thing anyway. The tool you're looking for is called usb_modeswitch, but it needs a bit of work to Just Work in a stock distro install with the user having to edit a config file.
Dan
Quoted 8 lines · Alan Cox
Quoted 3 lines
apparently do use the driver CD thing to send Linux drivers and software to a few clients. But by and large, the driver CD is completely useless.
And then every so often you need to rummage around the driver CD image to extract the APN or other data you need to make your modem work. At which point you end up having to recompile the kernel to get it. Very annoying given it could be trivially done properly in user space.
Maybe there's a better way as I said a bit lower in the thread; could we put the logic for ejection into the driver (and not usb_modeswitch or whatever) but put the decision into userspace in udev?
Right now the kernel drivers know what hardware they support, and that's a great place to also put how to eject the fake driver CD. So the mechanism could live in the kernel still (instead of in usb_modeswitch in userspace) while the actual decision still gets made in userspace with udev rules. The rules would say something like "if this USB storage device has an 'fakecd' attribute, then touch the 'ejectmeharder' attribute" instead of complex rules to run usb_modeswitch that duplicate all the device IDs in userspace. If you need to rummage around on the driver CD for whatever reason, you disable the udev rule. Maybe?
I simply hate the duplication of all the device IDs with one set in the kernel and one set in userspace because it's pretty pointless and makes twice the work when new hardware comes out.
Dan
Quoted 24 lines · On Monday 02 November 2009 22:45:59 Dan Williams wrote:
Quoted 8 lines · Alan Cox
Quoted 3 lines
apparently do use the driver CD thing to send Linux drivers and software to a few clients. But by and large, the driver CD is completely useless.
And then every so often you need to rummage around the driver CD image to extract the APN or other data you need to make your modem work. At which point you end up having to recompile the kernel to get it. Very annoying given it could be trivially done properly in user space.
Maybe there's a better way as I said a bit lower in the thread; could we put the logic for ejection into the driver (and not
usb_modeswitchor whatever) but put the decision into userspace in udev?Right now the kernel drivers know what hardware they support, and that's a great place to also put how to eject the fake driver CD. So the mechanism could live in the kernel still (instead of in
usb_modeswitchin userspace) while the actual decision still gets made in userspace with udev rules. The rules would say something like "if this USB storage device has an 'fakecd' attribute, then touch the 'ejectmeharder' attribute" instead of complex rules to runusb_modeswitchthat duplicate all the device IDs in userspace. If you need to rummage around on the driver CD for whatever reason, you disable the udev rule. Maybe?
Quoted 4 lines
I simply hate the duplication of all the device IDs with one set in the kernel and one set in userspace because it's pretty pointless and makes twice the work when new hardware comes out.
well, there's more to Alan's theory here.
AVM provides a beta firmware [1] which allows the user to but the stick into the mass storage mode again and stream the data over WLAN connection. (of course, you'll need a special AP which supports this)
[1]: (german only, they haven't bothered to do a translation)
http://www.avm.de/de/Service/Service-Portale/Service-Portal/Labor/7270_streaming_stick/labor_start_streaming_stick.php
Of course, I haven't tested, or even seen such setup yet. But it appears to be working (based on google).
Therefore, it might be a good idea to start a new user app, which does this 3-way usb-mode switching for these devices.
Regards,
Chr
Quoted 5 lines · Dan Williams
...
Maybe there's a better way as I said a bit lower in the thread; could we put the logic for ejection into the driver (and notusb_modeswitchor whatever) but put the decision into userspace in udev?
Quoted 10 lines
Right now the kernel drivers know what hardware they support, and that's a great place to also put how to eject the fake driver CD. So the mechanism could live in the kernel still (instead of in
usb_modeswitchin userspace) while the actual decision still gets made in userspace with udev rules. The rules would say something like "if this USB storage device has an 'fakecd' attribute, then touch the 'ejectmeharder' attribute" instead of complex rules to runusb_modeswitchthat duplicate all the device IDs in userspace. If you need to rummage around on the driver CD for whatever reason, you disable the udev rule. Maybe?
...
That would make system-configuration much easier and would also reduce the work for the distros.
Mode-switch-tools would be much easier to maintain, too.
How do you want to implement this policy-hint ?
Frank
Quoted 7 lines · Dan Williams
Devices with fake driver CDs and how they are handled currently:
Zydas WLAN - kernel Huawei 3G - kernel (unusual_devs entry) Sierra 3G - kernel (drivers/usb/serial/sierra.c) Option 3G - udev rules, 'rezero', or usb_modeswitch ZTE 3G - udev rules, simple 'eject'
It's worth noting that for some of these which are handled in-kernel, it had to be done that way because their storage-emulation was so poor that the normal 'eject' WOULD NOT work properly.
Any device which can be handled in userspace SHOULD be handled there.
Matt
Signature · 7 lines
Matthew Dharm Home: [email protected] Maintainer, Linux USB Mass Storage Driver But where are the THEMES?! How do you expect me to use an OS without themes?! -- Stef User Friendly, 10/9/1998
Quoted 9 lines · Matthew Dharm
Quoted 7 lines · Dan Williams
Devices with fake driver CDs and how they are handled currently:
Zydas WLAN - kernel Huawei 3G - kernel (unusual_devs entry) Sierra 3G - kernel (drivers/usb/serial/sierra.c) Option 3G - udev rules, 'rezero', or usb_modeswitch ZTE 3G - udev rules, simple 'eject'
Quoted 3 lines
It's worth noting that for some of these which are handled in-kernel, it had to be done that way because their storage-emulation was so poor that the normal 'eject' WOULD NOT work properly.
Half of them don't use eject at all, because of course on Windows the vendor driver owns the device and can do whatever it wants. Huawei uses a custom sequence, Option uses a custom sequence, and so does Sierra. ZTE is the only one that I've seen that you can actually just "eject" and make it work.
In userspace, usb_modeswitch is the place to put all this logic. Then you tie it together with udev rules using some bubble-gum and duct-tape, and maybe it works. Of course, there's massive duplication of data between usb_modeswitch and the kernel drivers, because the there's simply no communication between the two.
The kernel drivers know which devices are supported and how to drive them. But because the eject code isn't in kernelspace, all that device selection logic has to be duplicated in userspace with usb_modeswitch. Pretty dumb.
Maybe we can get the kernel drivers to expose the information we need (maybe even an 'eject' attribute in sysfs or something) and then we just have to write udev rules instead of having a whole bunch of libusb junk in userspace? Would that preserve the policy-always-in-userspace requirement yet keep the code to drive the hardware in kernel space where it really belongs?
Dan
Quoted 6 lines
Maybe we can get the kernel drivers to expose the information we need (maybe even an 'eject' attribute in sysfs or something) and then we just have to write udev rules instead of having a whole bunch of libusb junk in userspace? Would that preserve the policy-always-in-userspace requirement yet keep the code to drive the hardware in kernel space where it really belongs?
Or put the magic strings in the kernel with a translation hook for the eject request ? That would keep policy and method in the right places. You ask the kernel to eject, it hides the magic weirdness.
Quoted 10 lines · Alan Cox
Quoted 6 lines
Maybe we can get the kernel drivers to expose the information we need (maybe even an 'eject' attribute in sysfs or something) and then we just have to write udev rules instead of having a whole bunch of libusb junk in userspace? Would that preserve the policy-always-in-userspace requirement yet keep the code to drive the hardware in kernel space where it really belongs?
Or put the magic strings in the kernel with a translation hook for the eject request ? That would keep policy and method in the right places. You ask the kernel to eject, it hides the magic weirdness.
Yes, that would be awesome.
Dan
Am Montag, 2. November 2009 22:42:04 schrieb Dan Williams:
Quoted 4 lines
The kernel drivers know which devices are supported and how to drive them. But because the eject code isn't in kernelspace, all that device selection logic has to be duplicated in userspace with
usb_modeswitch. Pretty dumb.
No, the kernel doesn't have to know which devices need a mode switch. Nor does user space need to know which driver a device needs to switch its mode.
Regards
Oliver
Alan Stern
maintainerQuoted 5 lines · Dan Williams
In userspace,
usb_modeswitchis the place to put all this logic. Then you tie it together with udev rules using some bubble-gum and duct-tape, and maybe it works. Of course, there's massive duplication of data betweenusb_modeswitchand the kernel drivers, because the there's simply no communication between the two.
The only reason for this "massive" duplication is that nobody has bothered to remove from the kernel the parts that usb_modeswitch can handle. Adding yet more switching code into the kernel, thereby _increasing_ the amount of duplication, seems like a bad idea.
Quoted 2 lines
The kernel drivers know which devices are supported and how to drive them.
No. The kernel drivers (usb-storage is where most if not all of the kernel-side mode-switching code has ended up) only know about the particular devices _they_ support. They don't know about the other devices supported by usb_modeswitch.
Quoted 3 lines
But because the eject code isn't in kernelspace, all that device
selection logic has to be duplicated in userspace withusb_modeswitch. Pretty dumb.
What are you talking about? Of course usb-storage contains mode-switching code for the devices it switches. And for the devices it doesn't switch, it does not contain device-selection logic.
Quoted 6 lines
Maybe we can get the kernel drivers to expose the information we need (maybe even an 'eject' attribute in sysfs or something) and then we just have to write udev rules instead of having a whole bunch of libusb junk in userspace? Would that preserve the policy-always-in-userspace requirement yet keep the code to drive the hardware in kernel space where it really belongs?
This sounds as if you are trying very hard to get the _worst_ of both worlds! You would force users to upgrade their kernels before they can use new devices (because the kernel is where the mode-switch code will be), and you also would force them to upgrade their userspace settings (so that the new mode-switch code will be called).
I'm with Matt Dharm and Josua Dietze on this. Jobs that can be handled in userspace _should_ be handled there.
Alan Stern
Am Dienstag, 3. November 2009 16:16:12 schrieb Alan Stern:
Quoted 5 lines
This sounds as if you are trying very hard to get the _worst_ of both worlds! You would force users to upgrade their kernels before they can use new devices (because the kernel is where the mode-switch code will be), and you also would force them to upgrade their userspace settings (so that the new mode-switch code will be called).
Yes.
Quoted 2 lines
I'm with Matt Dharm and Josua Dietze on this. Jobs that can be handled in userspace _should_ be handled there.
There is the inconvenient problem of hibernation. And, if more systems start cutting power to USB in STR, the problem of STR. I am inclined to declare that hibernation is a problem of those pesky misdesigns. But dare we say that also about STR?
Regards
Oliver
Alan Stern
maintainerQuoted 7 lines · Oliver Neukum
Quoted 2 lines
I'm with Matt Dharm and Josua Dietze on this. Jobs that can be handled in userspace _should_ be handled there.
There is the inconvenient problem of hibernation. And, if more systems start cutting power to USB in STR, the problem of STR. I am inclined to declare that hibernation is a problem of those pesky misdesigns. But dare we say that also about STR?
If power is turned off, there's nothing we can do about it. Once that happens, it doesn't make much difference whether the mode switch occurs in usb-storage or from a userspace program. The old device instance will go away and a new one will appear.
Alan Stern
Am Dienstag, 3. November 2009 23:47:55 schrieb Alan Stern:
Quoted 9 lines · Oliver Neukum
Quoted 7 lines
Quoted 2 lines
I'm with Matt Dharm and Josua Dietze on this. Jobs that can be handled in userspace _should_ be handled there.
There is the inconvenient problem of hibernation. And, if more systems start cutting power to USB in STR, the problem of STR. I am inclined to declare that hibernation is a problem of those pesky misdesigns. But dare we say that also about STR?
Quoted 4 lines
If power is turned off, there's nothing we can do about it. Once that happens, it doesn't make much difference whether the mode switch occurs in usb-storage or from a userspace program. The old device instance will go away and a new one will appear.
That is what happens and what must happen if we switch mode in user space. In kernel space, the kernel could repeat the mode switch.
Regards
Oliver
Alan Stern
maintainerQuoted 7 lines · Oliver Neukum
Quoted 4 lines
If power is turned off, there's nothing we can do about it. Once that happens, it doesn't make much difference whether the mode switch occurs in usb-storage or from a userspace program. The old device instance will go away and a new one will appear.
That is what happens and what must happen if we switch mode in user space. In kernel space, the kernel could repeat the mode switch.
How? Doesn't the mode switch cause a change in the configuration, interface, or endpoint descriptors? The end result would be the same -- the old device instance would go away and a new one would appear.
Alan Stern
Am Mittwoch, 4. November 2009 04:57:59 schrieb Alan Stern:
Quoted 6 lines · Oliver Neukum
Quoted 5 lines
Quoted 4 lines
If power is turned off, there's nothing we can do about it. Once that happens, it doesn't make much difference whether the mode switch occurs in usb-storage or from a userspace program. The old device instance will go away and a new one will appear.
Quoted 6 lines
Quoted 2 lines
That is what happens and what must happen if we switch mode in user space. In kernel space, the kernel could repeat the mode switch.
How? Doesn't the mode switch cause a change in the configuration, interface, or endpoint descriptors? The end result would be the same -- the old device instance would go away and a new one would appear.
But it switches to a known state which we could use to trigger a switch and recompare after the switch.
Regards
Oliver
Quoted 7 lines · Alan Stern
On Mon, 2 Nov 2009, Dan Williams wrote
Quoted 6 lines
In userspace,
usb_modeswitchis the place to put all this logic. Then you tie it together with udev rules using some bubble-gum and duct-tape, and maybe it works. Of course, there's massive duplication of data betweenusb_modeswitchand the kernel drivers, because the there's simply no communication between the two.
Quoted 5 lines
The only reason for this "massive" duplication is that nobody has bothered to remove from the kernel the parts that
usb_modeswitchcan handle. Adding yet more switching code into the kernel, thereby _increasing_ the amount of duplication, seems like a bad idea.
Or the other way around ;) .
Of course, we all don't want any duplicate code. We need a kernelspace OR a userspace-solution.
But we should make pragmatic and device-(group-)specific decisions. The hardware itself and the context in which it is used (=> switch-policy) are too different.
...
Quoted 5 lines
... Jobs that can be handled
in userspace _should_ be handled there.Alan Stern
Basically, I have no problem to agree here.
But what's the price we pay for this solution(s) in this case (and most other devices with windows-driver-disc-mode) ?
You should not ignore the problems coming-up with the discussed userspace-solutions.
This is not ONLY about technical aspects. We already discussed usability and maintanance. Think about the whole product, not only the kernel-part. Then, please, make a list of ALL pros and cons a make a pragmatic decision.
Frank
Alan Stern
maintainerQuoted 8 lines · Frank Schaefer
Basically, I have no problem to agree here.
But what's the price we pay for this solution(s) in this case (and most other devices with windows-driver-disc-mode) ?
You should not ignore the problems coming-up with the discussed userspace-solutions.
This is not ONLY about technical aspects. We already discussed usability and maintanance. Think about the whole product, not only the kernel-part. Then, please, make a list of ALL pros and cons a make a pragmatic decision.
Here's my first attempt at considering all the pros and cons. Has anything important been left out?
First, let's consider the case where the relevant drivers/programs are already present when a switchable device is plugged in. Then presumably it all works correctly and there's no problem. :-)
So second, let's consider the case where the drivers/programs are not already present. The device does not get switched automatically. In order to do anything with it, the user must upgrade his system.
1. If the mode-switch code is in the kernel: The user must install a new kernel. This might mean downloading a new version from the distro or it might mean installing a patch and rebuilding manually.
2. If the mode-switch code is in userspace: The user must update the mode-switch program. This might mean adding a line to a udev script file, installing a new binary package, or downloading new source code to usb_modeswitch and rebuilding manually.
3. If the policy is handled by a userspace program while the mechanism is handled by the kernel: The user will have to carry out 1 or 2 or possibly both. Hence this case reduces to the earlier cases (plus the fact that the user somehow has to determine which steps are necessary).
Either way, once the upgrade has been done the device will work. So the only question is which is easier for everybody, 1 or 2?
Clearly 1 puts more of a burden on the kernel/distro developers while 2 puts more of a burden on the userspace support teams. But they comprise a relatively small number of people compared to the total user population. For users, then, which is easier?
Downloading a new kernel package is roughly equivalent to downloading a new usb_modeswitch binary package. It takes longer and there might be administrative issues (updating the kernel has more repercussions than updating a single program), but overall they are similar.
Clearly editing a udev script is very easy. Downloading patches or source code and rebuilding by hand requires a certain amount of skill, and it is not something most people would care to do -- although if they had to, building a program is much easier than building a kernel.
Thus, in terms of the amount of work required of the user, I'd say that 1 is worse than 2. But there's more to consider. How long does it take for new-device support to get disseminated?
User programs like usb_modeswitch can be updated very rapidly. It's merely a question of writing the new code and making it publicly available in the appropriate repository. Typically this might involve a delay of a few days. By contrast, new kernels appear roughly every three months. It's possible that new mode-switch code would be allowed in a stable release (although this is far from certain). If so, then the delay could drop as low as a few weeks.
Thus, in terms of the delay time for new support, I'd say again that 1 is worse than 2. Finally, let's consider adding support for a new device to an old system.
An old system is not readily upgradable. But _some_ sort of upgrade is needed to support new devices.
If all that is needed is a modification to a udev script, there is no problem.
Installing a new version of a program might be difficult because of library dependencies that aren't up to date.
Installing a new version of the kernel might be difficult because of incompatibilities with old userspace components.
Comparing the last two directly is hard; either could be a show-stopper. The ideal solution would be to provide a way to upgrade a mode-switching program by modifying a text configuration or script file rather than by changing the code. For example, if usb_modeswitch could parse a text file containing device IDs to match and packet contents to send, then upgrades would be very easy.
In short, for users I don't see any advantage to putting the mode-switching stuff in the kernel, whereas there may be considerable advantages to putting it in userspace.
The only exception would be the case that Oliver is worried about, where a device loses its mode setting during a reset or system sleep. In principle the kernel could put it back in the correct mode while keeping the device's identity intact (although the code to do this would be extremely ugly, and convincing people to allow it would be hard). Even then, I don't see how existing serial/phone connections could be maintained across a reset, so there might not be any point.
Alan Stern
Quoted 2 lines · Alan Stern
Here's my first attempt at considering all the pros and cons. Has anything important been left out?
[snip]
I think you forgot to consider the case where both the driver and the mode switch code need an update to handle a new device. This is relevant in the case where a new device shows up that needs mode-switching, but even after switching has an ID that the current driver doesn't know about.
It's not clear to me which case typically happens though. I suppose that often enough it'd be possible to have a device that shows up with a special driver USB ID, and then after you eject it comes up again with a regular USB ID that other devices use too.
Input from people who have such switching devices could be helpful.
johannes
Alan Stern
maintainerQuoted 5 lines · Johannes Berg
Quoted 2 lines · Alan Stern
Here's my first attempt at considering all the pros and cons. Has anything important been left out?
Quoted 7 lines
[snip]
I think you forgot to consider the case where both the driver and the mode switch code need an update to handle a new device. This is relevant in the case where a new device shows up that needs mode-switching, but even after switching has an ID that the current driver doesn't know about.
This could be handled by programs like usb_modeswitch. The USB serial drivers allow IDs to be added dynamically.
Of course, if something more than that is required then the situation would be different. However I think this is pretty rare.
Alan Stern
Quoted 11 lines · Alan Stern
Quoted 5 lines · Johannes Berg
I think you forgot to consider the case where both the driver and the mode switch code need an update to handle a new device. This is relevant in the case where a new device shows up that needs mode-switching, but even after switching has an ID that the current driver doesn't know about.
This could be handled by programs like
usb_modeswitch. The USB serial drivers allow IDs to be added dynamically.Of course, if something more than that is required then the situation would be different. However I think this is pretty rare.
So far, mostly cdc_acm and high speed serial devices are known. There is the special case of the HSO interface for "Option" modems which resembles a network device IIRC. But switching them is pretty straightforward and driver support by the manufacturer seems to be OK. I don't know of any "switching" devices which are completely unsupported by the recent kernels.
usb_modeswitch now has a wrapper which loads the "option" module by default if the "new" device will not be claimed by "cdc_acm", "hso" or "option". Using the "new_id" feature *any* ID can be used with it right away.
Josua Dietze
Signature · 2 lines
Man is the only creature on earth enabled to take a warm meal while flying! Loriot
Am Mittwoch, 4. November 2009 17:16:18 schrieb Alan Stern:
Quoted 5 lines
The only exception would be the case that Oliver is worried about, where a device loses its mode setting during a reset or system sleep. In principle the kernel could put it back in the correct mode while keeping the device's identity intact (although the code to do this would be extremely ugly, and convincing people to allow it would be
Oh yes.
Quoted 2 lines
hard). Even then, I don't see how existing serial/phone connections could be maintained across a reset, so there might not be any point.
I am afraid this will spread beyond modems.
For now I'd like those devices which are affected by resets to get a quirk that marks them as not resettable for purposes of error handling. But I fear we may have to face this system in the future on a regular basis.
Regards
Oliver
Quoted 5 lines · Oliver Neukum
I am afraid this will spread beyond modems. For now I'd like those devices which are affected by resets to get a quirk that marks them as not resettable for purposes of error handling. But I fear we may have to face this system in the future on a regular basis.
I had similar thoughts when I first encountered a device with drivers "on board". But so far (around three years now) only wireless communication devices have shown up.
My guess is that these things are basically working with cell phone chipsets most of which have the "dual device" built in; many cellphones can USB-connect as "modem" or "storage".
So it's just a case of using what's there already and would probably lie around unnoticed otherwise.
Josua Dietze
Signature · 2 lines
Man is the only creature on earth enabled to take a warm meal while flying! Loriot
Am Montag, 2. November 2009 22:11:23 schrieb Matthew Dharm:
Quoted 5 lines
It's worth noting that for some of these which are handled in-kernel, it had to be done that way because their storage-emulation was so poor that the normal 'eject' WOULD NOT work properly.
Any device which can be handled in userspace SHOULD be handled there.
Do these devices survive a reset and stay in the correct mode? Has that been tested?
Regards
Oliver
Quoted 9 lines · On Tuesday 03 November 2009 11:57:22 Oliver Neukum wrote:
Am Montag, 2. November 2009 22:11:23 schrieb Matthew Dharm:
Quoted 5 lines
It's worth noting that for some of these which are handled in-kernel, it had to be done that way because their storage-emulation was so poor that the normal 'eject' WOULD NOT work properly.
Any device which can be handled in userspace SHOULD be handled there.
Do these devices survive a reset and stay in the correct mode? Has that been tested?
ar9170usb does an usb reset right before it uploads the WLAN firmware. The device stays in the correct mode, else it wouldn't be possible to continue because usb-storage mode has a different PID.
Regards,
Chr
Quoted 24 lines · Dan Williams
Quoted 22 lines · Frank Schaefer
Quoted 20 lines · Matthew Dharm
Quoted 8 lines · Frank Schaefer
Quoted 6 lines · Josua Dietze
Quoted 3 lines · Frank Schaefer
I really think the mode-switching should be done in the kernel and not in user-space for reasons of usability.
Quoted 7 lines
Quoted 3 lines
What is wrong with an udev rule entry? By the way, did the "eject" command line tool work as well?
It returns an error but the device is ejected.
But do you really want the users to open a terminal window and call "eject" each time they plug their device in ;) ?If 'eject' worked, then why not use a simple udev entry? That way nobody has to call anything by hand...
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Matt
And who will create this udev-entry ;) ? How can you make sure that this is done on all systems ?
You can't. The distros have to make sure it works.
Right, and here the trouble begins.
The driver and the mode-switch needed to use it must come from the same source.
Otherwise we will always have inconsistencies.
Quoted 4 lines
Personally, I think
these should all be in the kernel, but the kernel doesn't contain policy. And unfortunately, for some devices (3G modems specifically) ejecting the driver CD thing *is* policy.
Hmm, policy...
Talking about the large group of devices with a driver-disk-mode only:
Isn't an installed driver for the device the policy itself, because it makes the driver-disk obsolete !?
Quoted 8 lines
Option for example protested
mightily when I sent a patch to auto-eject their driver CD, because they apparently do use the driver CD thing to send Linux drivers and software to a few clients. But by and large, the driver CD is completely useless.Devices with fake driver CDs and how they are handled currently:
Quoted 8 lines
Zydas WLAN - kernel Huawei 3G - kernel (unusual_devs entry) Sierra 3G - kernel (drivers/usb/serial/sierra.c) Option 3G - udev rules, 'rezero', or usb_modeswitch ZTE 3G - udev rules, simple 'eject'Dan
I can't see any real problems having device-(group-)specific policies and switching-solutions.
Of course, it would be nice to have a common solution for all, but the devices are too different.
Therefore the compromises we have to make should be individual (to a certain degree).
Frank