From: Boaz Harrosh <bharrosh@panasas.com>
To: Randy Dunlap <rdunlap@xenotime.net>
Cc: "James Bottomley" <James.Bottomley@SteelEye.com>,
"\"Jürgen E. Fischer\"" <fischer@norbit.de>,
"FUJITA Tomonori" <fujita.tomonori@lab.ntt.co.jp>,
linux-scsi <linux-scsi@vger.kernel.org>,
"David A. Hinds" <dahinds@users.sourceforge.net>
Subject: Re: [PATCH 5/6] aha152x.c - Fix check_condition code-path
Date: Thu, 02 Aug 2007 14:26:47 +0300 [thread overview]
Message-ID: <46B1BF77.6060804@panasas.com> (raw)
In-Reply-To: <20070801093422.f986597d.rdunlap@xenotime.net>
Randy Dunlap wrote:
> On Wed, 01 Aug 2007 08:51:14 -0500 James Bottomley wrote:
>
>> On Tue, 2007-07-31 at 11:40 -0700, Randy Dunlap wrote:
>>> On Tue, 31 Jul 2007 10:59:51 +0300 Boaz Harrosh wrote:
>>>
>>>> Randy Dunlap wrote:
>>>>> Since you grok all of that (above), maybe you can help here:
>>>>>
>>>>> With these 6 patches applied, I do the following:
>>>>>
>>>>> 1. insert PCMCIA aha152x card with SCSI drive attached (/dev/sdb4)
>>>>> 2. mount -t vfat /dev/sdb4 /mnt/disk
>>>>> 3. play with /mnt/disk
>>>>> 4. umount /mnt/disk
>>>>>
>>>>> Now I would like to rmmod the aha152x_cs module, but its use count
>>>>> is 2. Even if I eject the card, its use count stays at 2.
>>>>> Maybe the reset or check_condition patch doesn't clean up correctly,
>>>>> or one of them isn't releasing a used resource ?
>>>>>
>>>>> (this is 2.6.23-rc1 + your 6 patches + 1 acpi seq-file throttling fix.)
>>>>>
>>>> I had an hard look and a very careful line-by-line compare
>>>> and I can't find anything obvious. Could you do a bisect.
>>>> maybe it will give me a clue as to where to look. Also please
>>>> Enable debug prints. Maybe the driver is stuck at some state
>>>> and does not exit.
>>> The good news is that this problem has nothing to do with this
>>> patch series. The bad news is that this problem is there anyway.
I was afraid of that. I will try and see what other PCMCIA drivers
are doing in this situation. It looks like the driver should bailout
much earlier in the event that the card is not present. But it lets
the request in anyway. The original driver was not written for hotplug
PCMCIA maybe that's why.
Please correct me if I'm wrong
1. pccard senses an eject coming and is doing device_unregister()
2. sd.c in sd_shutdown() is doing a Synchronize Cache.
3. The command is queued but since card is not there anymore an interrupt never
comes and the command is just stuck.
4. After one second an abort comes in an is returned with success (line 1113)
[ 88.869051] (scsi-1:-1:-1) (aha152x_internal_queue:1055) unlocked
[ 89.884469] (scsi-1:-1:-1) (aha152x_abort:1113) locking
5. Now a Test Unit Ready comes in. Already a good second and more after
the eject. The card is clearly not powered by now.
aha152x_internal_queue should check it's own presence. and return
appropriate value.
Two questions:
a. What should be the return value from a queuecommand handler
when the card is no longer present?
b. What should we check to know we no longer have a card?
6. One more second passes and 2nd abort comes in.
7. Than a reset comes in. Here too Should driver check for hardware
presence.
since ds.c is doing: p_dev->_removed=1;
before the shutdown. Maybe a solution is to have aha152x_stub.c,
which is the only one that knows of PCMCIA, Override queuecommand
and just check for p_dev->_removed==1. Something like:
-------------------------------------------------------------------------------------------------------------
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index d30a307..5fe55d0 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1062,7 +1063,7 @@ static int aha152x_internal_queue(Scsi_Cmnd *SCpnt, struct completion *complete,
* queue a command
*
*/
-static int aha152x_queue(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
+int aha152x_queue(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
{
#if 0
if(*SCpnt->cmnd == REQUEST_SENSE) {
diff --git a/drivers/scsi/aha152x.h b/drivers/scsi/aha152x.h
index ac4bfa4..065612f 100644
--- a/drivers/scsi/aha152x.h
+++ b/drivers/scsi/aha152x.h
@@ -333,5 +333,6 @@ struct aha152x_setup {
struct Scsi_Host *aha152x_probe_one(struct aha152x_setup *);
void aha152x_release(struct Scsi_Host *);
int aha152x_host_reset_host(struct Scsi_Host *);
+int aha152x_queue(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *));
#endif /* _AHA152X_H */
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 370802d..e2f5ea5 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -137,6 +137,19 @@ static void aha152x_detach(struct pcmcia_device *link)
} /* aha152x_detach */
/*====================================================================*/
+static int aha152x_queue_cs(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *))
+{
+struct pcmcia_device *p_dev;
+struct device *dev = &SCpnt->device->sdev_gendev;
+
+ p_dev = to_pcmcia_dev(dev);
+ if (p_dev->_removed==1)
+ return ENODEV;
+
+ return aha152x_queue(SCpnt, done);
+}
+
+/*====================================================================*/
#define CS_CHECK(fn, ret) \
do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
@@ -201,6 +214,7 @@ static int aha152x_config_cs(struct pcmcia_device *link)
goto cs_failed;
}
+ host->hostt->queuecommand = aha152x_queue_cs;
sprintf(info->node.dev_name, "scsi%d", host->host_no);
link->dev_node = &info->node;
info->host = host;
-------------------------------------------------------------------------------------------------------------
But you will have to totally check me out on that: to_pcmcia_dev()
thing above.
And maybe it is plain lobotomy. I wish sd.c could Just signal the
SCSI device that it is on the shutdown path.
Or maybe my original Question. How can a card identify it's un-presence?
>> So on a functionality basis you're prepared to ack this patch set on the
>> basis of empirical testing on the grounds that the bug predates them?
>
> Yes. Acked-and-tested-by: Randy Dunlap <randy.dunlap@oracle.com>
>
> Thanks.
Thank you Randy.
Boaz
> ---
> ~Randy
> *** Remember to use Documentation/SubmitChecklist when testing your code ***
next prev parent reply other threads:[~2007-08-02 11:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-29 19:10 [patch 0/6] aha152x.c - Cleanup, bugfixes, convert to accessors Boaz Harrosh
2007-07-29 19:16 ` [PATCH 1/6] aha152x.c - In debug mode Boaz Harrosh
2007-07-29 19:18 ` [PATCH 2/6] aha152x.c - use bounce buffer Boaz Harrosh
2007-07-29 19:22 ` [PATCH 3/6] aha152x.c - Preliminary fixes and some comments Boaz Harrosh
2007-07-29 19:24 ` [PATCH 4/6] aha152x.c - Clean Reset path Boaz Harrosh
2007-07-29 19:27 ` [PATCH 5/6] aha152x.c - Fix check_condition code-path Boaz Harrosh
2007-07-31 0:13 ` Randy Dunlap
2007-07-31 7:59 ` Boaz Harrosh
2007-07-31 17:08 ` Randy Dunlap
2007-07-31 18:40 ` Randy Dunlap
2007-08-01 13:51 ` James Bottomley
2007-08-01 16:34 ` Randy Dunlap
2007-08-02 11:26 ` Boaz Harrosh [this message]
2007-08-02 19:09 ` Randy Dunlap
2007-08-02 19:08 ` James Bottomley
2007-08-02 20:22 ` Jürgen E. Fischer
2007-08-02 22:47 ` Randy Dunlap
2007-07-29 19:29 ` [PATCH 6/6] aha152x.c - use data accessors and !use_sg cleanup Boaz Harrosh
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=46B1BF77.6060804@panasas.com \
--to=bharrosh@panasas.com \
--cc=James.Bottomley@SteelEye.com \
--cc=dahinds@users.sourceforge.net \
--cc=fischer@norbit.de \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=linux-scsi@vger.kernel.org \
--cc=rdunlap@xenotime.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).