All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Woestenberg <leonw@mailcan.com>
To: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: linux-scsi@vger.kernel.org, Mark Haverkamp <markh@osdl.org>,
	Eric Moore <Eric.Moore@lsil.com>
Subject: Re: how to use scsi_remove_device
Date: Sat, 18 Mar 2006 00:25:26 +0100	[thread overview]
Message-ID: <441B4566.8000803@mailcan.com> (raw)
In-Reply-To: <441B1C7F.2090605@s5r6.in-berlin.de>

Hello all,

Stefan Richter wrote:
> Hi all,
>
> the following drivers use [__]scsi_add_device/ scsi_remove_device:
>
> drivers/ieee1394/sbp2.c
> drivers/message/i2o/i2o_scsi.c
> drivers/message/fusion/mptsas.c
> drivers/scsi/aacraid/commsup.c
> drivers/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.)
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);
+	}
+}


      parent reply	other threads:[~2006-03-17 23:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1142598225.25906.256865850@webmail.messagingengine.com>
     [not found] ` <441B1388.20704@s5r6.in-berlin.de>
2006-03-17 20:30   ` how to use scsi_remove_device Stefan Richter
2006-03-17 21:11     ` Mark Haverkamp
2006-03-19 19:37       ` Stefan Richter
2006-03-17 21:39     ` James Bottomley
2006-03-17 23:25     ` Leon Woestenberg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=441B4566.8000803@mailcan.com \
    --to=leonw@mailcan.com \
    --cc=Eric.Moore@lsil.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=markh@osdl.org \
    --cc=stefanr@s5r6.in-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.