how to use scsi_remove_device
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]
Hi all,
the following drivers use [__]scsi_add_device/ scsi_remove_device:
drivers/ieee1394/sbp2.cdrivers/message/i2o/i2o_scsi.cdrivers/message/fusion/mptsas.cdrivers/scsi/aacraid/commsup.cdrivers/scsi/ipr.c
Sbp2 calls scsi_add_device + scsi_remove_device.I2o_scsi calls __scsi_add_device + scsi_remove_device + scsi_device_put. Ipr calls scsi_add_device + scsi_device_get + scsi_remove_device + scsi_device_put.
But aacraid and mptsas call scsi_add_device + scsi_remove_device + scsi_device_put. AFAICS this is either one scsi_device_put too many or one scsi_device_get too few.
(I am looking at Linus' tree.)
Signature · 3 lines
Stefan Richter -=====-=-==- --== =---= http://arcgraph.de/sr/
Quoted 10 lines · Stefan Richter
Hi all,
the following drivers use [__]scsi_add_device/
scsi_remove_device:
drivers/ieee1394/sbp2.cdrivers/message/i2o/i2o_scsi.cdrivers/message/fusion/mptsas.cdrivers/scsi/aacraid/commsup.cdrivers/scsi/ipr.c
Quoted 8 lines
Sbp2 calls
scsi_add_device+scsi_remove_device.I2o_scsicalls__scsi_add_device+scsi_remove_device+scsi_device_put. Ipr callsscsi_add_device+scsi_device_get+scsi_remove_device+scsi_device_put.But aacraid and mptsas call
scsi_add_device+scsi_remove_device+scsi_device_put. AFAICS this is either onescsi_device_puttoo many or onescsi_device_gettoo few.
I copied Mark Salyzyn since he is the aacraid driver writer.
Looking at commsup.c, though, I think that the scsi_device_put is done after the scsi_device_lookup only if the scsi_device_remove is not done.
Mark.
Quoted 2 lines
(I am looking at Linus' tree.)
Signature · 1 line
Mark Haverkamp <[email protected]>
Quoted 2 lines · Mark Haverkamp
Quoted 1 line · Stefan Richter
But aacraid and mptsas call
scsi_add_device+scsi_remove_device+scsi_device_put. AFAICS this is either onescsi_device_puttoo many or onescsi_device_gettoo few.
...
Quoted 2 lines
Looking at
commsup.c, though, I think that thescsi_device_putis done after thescsi_device_lookup
...
Yes, the scsi_device_put is correct since scsi_device_lookup took a reference.
Signature · 3 lines
Stefan Richter -=====-=-==- --== =--== http://arcgraph.de/sr/
Quoted 1 line · Stefan Richter
the following drivers use [__]scsi_add_device/
scsi_remove_device:
The rule is that scsi_add_device() doesn't leave you with a reference, but __scsi_add_device() does.
scsi_remove_device() does just that, but it doesn't put any references you might have taken separately.
Quoted 3 lines
But aacraid and mptsas call
scsi_add_device+scsi_remove_device+scsi_device_put. AFAICS this is either onescsi_device_puttoo many or onescsi_device_gettoo few.
These all look correct. The scsi_device_puts are paired with scsi_device_lookup() which does indeed get a reference which needs putting.
James
Hello all,
Quoted 10 lines · Stefan Richter
Hi all,
the following drivers use [__]scsi_add_device/
scsi_remove_device:
drivers/ieee1394/sbp2.cdrivers/message/i2o/i2o_scsi.cdrivers/message/fusion/mptsas.cdrivers/scsi/aacraid/commsup.cdrivers/scsi/ipr.c
Quoted 7 lines
Sbp2 calls
scsi_add_device+scsi_remove_device.I2o_scsicalls__scsi_add_device+scsi_remove_device+scsi_device_put. Ipr callsscsi_add_device+scsi_device_get+scsi_remove_device+scsi_device_put.But aacraid and mptsas call
scsi_add_device+scsi_remove_device+scsi_device_put. AFAICS this is either onescsi_device_puttoo many or onescsi_device_gettoo few.(I am looking at Linus' tree.)
I was just searching the linux-scsi mailing list and noticed this in-progress hotplug patch for the libata SATA framework, which in turn uses the SCSI layers.
In particular notice the lookup of the scsi_device before it scsi_remove_device(), then scsi_device_put().
In my particular case (Marvell's GPL'd SATA driver, not the libata one) *it seems* the device lookup is missing, although I have to do more work to verify this statement.
Regards,
Leon.
+void ata_scsi_hot_plug(struct ata_port *ap, unsigned int device) +{
+ /* libata uses the 'id' or 'target' value */
+ scsi_add_device(ap->host, 0, device, 0);
+}
+
+void ata_scsi_hot_unplug(struct ata_port *ap, unsigned int device) +{
+ /* libata uses the 'id' or 'target' value */
+ struct scsi_device *scd = scsi_device_lookup(ap->host, 0, device, 0);
+
+ /* Make sure that we set this here, in case we aren't called as a
+ * result of sata_hot_unplug */
+ ap->device[device].class = ATA_DEV_NONE;
+
+ if (scd) /* Set to cancel state to block further I/O */
+ scsi_device_set_state(scd, SDEV_CANCEL);
+
+ /* We might have a pending qc on I/O to a removed device. */
+ ata_check_kill_qc(ap, device);
+
+ if (scd) {
+ scsi_remove_device(scd);
+ scsi_device_put(scd);
+ }
+}