ieee1394 hotplug SCSI interaction 2.4.20-pre10
PATCH 1/1 ieee1394 hotplug SCSI interaction 2.4.20-pre10
As has been reported a few times on the linux1394-devel mailing list, hotplugging firewire drives only sortof works. A recent posting to the list rehashing the problems
http://sourceforge.net/mailarchive/forum.php?thread_id=1151203&forum_id=5389
reminded me of my old partial fix for this problem that was sitting unfinished. So last night I polished it up, fixed the bugs, and it is now working perfectly for me.
Without this patch, hotplugging firewire drives will register the drives with the 1394 layers, but will not register them with the SCSI subsystem. Unplugging firewire drives leaves the (now absent) drives still registered with the SCSI subsystem. As you can imagine, the current situation sucks, and makes hotplugging firewire drives mostly useless. To make things behave correctly, one needs to manually add/remove SBP-2 devices using a shell script
(http://www.garloff.de/kurt/linux/rescan-scsi-bus.sh) that pokes at /proc/scsi/scsi by scanning though all your SCSI hosts and then does things like
echo "scsi remove-single-device 0 0 0 0" > /proc/scsi/scsi
for each and every SCSI device on your system. I don't consider such things safe or desirable at all.
It seemed to me that since the kernel had all the information to do the Right Thing(tm), it made sense to connect the remove-single-device and add-single-device functionality of /proc/scsi/scsi together with the sbp2 driver so the Right Thing(tm) could happen automagically.
With my patch applied, one can now plug in firewire drives and they will all be automagically registered with the SCSI subsystem. When one unplugs SBP-2 devices, they will be automagically unregistered from the SCSI subsystem.
When I posted my earlier effort to the linux1394-devel list:
http://sourceforge.net/mailarchive/forum.php?thread_id=949390&forum_id=5389
it was decided that the change to the SCSI subsystem needed to expose scsi_add_single_device() and scsi_remove_single_device() was not desirable. I'll leave the decision on that to others.
For the moment, this patch is works nicely for me and makes using firewire drives a much nicer experience.
Have fun,
-Erik
--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--
drivers/ieee1394/sbp2.c renamed from drivers/ieee1394.orig/sbp2.c +27 -1
@@ -1681,6 +1681,18 @@SBP2_INFO ("Logged into SBP-2 device" ); +/* Try to hook ourselves into the SCSI subsystem */ + { +struct Scsi_Host *HBA_ptr; + HBA_ptr=hi->scsi_host; +if (HBA_ptr==NULL ) { +return 0 ; + } +if (scsi_add_single_device (HBA_ptr,0 , scsi_id->id,0 )!=0 ) { +SBP2_INFO ("Unable to connect SBP-2 device into the SCSI subsystem" ); + } + } +return (0 ); }
@@ -1739,8 +1751,22 @@SBP2_INFO ("Logged out of SBP-2 device" ); -return (0 ); +/* Now that we are logged out of the SBP-2 device, lets +* try to un-hook ourselves from the SCSI subsystem */ + { +Scsi_Device *scd; +struct Scsi_Host *HBA_ptr; + + HBA_ptr=hi->scsi_host; +if (HBA_ptr==NULL ) { +return 0 ; + } +if (scsi_remove_single_device (HBA_ptr,0 , scsi_id->id,0 )!=0 ) { +SBP2_INFO ("Unable to disconnect SBP-2 device from the SCSI subsystem" ); + } + } +return (0 ); }/*
drivers/scsi/hosts.h +7 -0
@@ -532,6 +532,13 @@int scsi_register_device (struct Scsi_Device_Template * sdpnt);void scsi_deregister_device (struct Scsi_Device_Template * tpnt); +/* Support for hot plugging and unplugging devices -- safe for +* ieee1394 or USB devices, but probably not for normal SCSI... */ +extern int scsi_add_single_device (struct Scsi_Host *shpnt, +int channel,int id,int lun); +extern int scsi_remove_single_device (struct Scsi_Host *shpnt, +int channel,int id,int lun); +/* These are used by loadable modules */ extern int scsi_register_module (int ,void *);extern int scsi_unregister_module (int ,void *);
drivers/scsi/scsi.c +95 -79
200 lines not on this page · raw message
drivers/scsi/scsi_syms.c +6 -0
@@ -103,3 +103,9 @@extern int scsi_delete_timer (Scsi_Cmnd *);EXPORT_SYMBOL (scsi_add_timer);EXPORT_SYMBOL (scsi_delete_timer); + +/* Support for hot plugging and unplugging devices -- safe for +* ieee1394 or USB devices, but probably not for normal SCSI... */ +EXPORT_SYMBOL (scsi_add_single_device); +EXPORT_SYMBOL (scsi_remove_single_device); +
Quoted 5 lines
When I posted my earlier effort to the linux1394-devel list:
http://sourceforge.net/mailarchive/forum.php?thread_id=949390&forum_id=5389it was decided that the change to the SCSI subsystem needed to expose
scsi_add_single_device()andscsi_remove_single_device()was not desirable. I'll leave the decision on that to others.
Never said it wasn't desirable per se, just that if Marcelo doesn't accept that patch, then we can't make use of it. If you feel so strongly about it, then send that portion of the patch to Marcelo for 2.4.20 or 2.4.21.
Signature · 4 lines
Debian - http://www.debian.org/ Linux 1394 - http://www.linux1394.org/ Subversion - http://subversion.tigris.org/ Deqo - http://www.deqo.com/