From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Pete Zaitcev <zaitcev@redhat.com>
Cc: Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] ub.c badness in current bk
Date: Sat, 18 Sep 2004 11:04:23 +1000 [thread overview]
Message-ID: <1095469463.3574.2.camel@gaston> (raw)
In-Reply-To: <20040917090448.32ff763c@lembas.zaitcev.lan>
Ok, here's a patch that works for me and makes more sense ;)
What happens is that ub_sync_tur() fails a few times when the device
is inserted. So we end up returning changed = 1 from within the call
to check_disk_change() done by do_open() from the partition code itself,
causing a re-entrance in there...
I think add_disk() is very fragile here, but I'll let others like viro
(or you :) to fix that.
Anyway, the fix is to better mimmic sd_spinup_disk() within our own
revalidate. I think we _should_ actually request sense & analyze it
properly, eventually sending spinup commands etc... but in the meantime,
a simple retry works well enough for me. Here's the patch:
===== drivers/block/ub.c 1.5 vs edited =====
--- 1.5/drivers/block/ub.c 2004-08-24 10:02:30 +10:00
+++ edited/drivers/block/ub.c 2004-09-18 10:55:49 +10:00
@@ -1217,9 +1217,16 @@
goto error;
}
+ /*
+ * ``If the allocation length is eighteen or greater, and a device
+ * server returns less than eithteen bytes of data, the application
+ * client should assume that the bytes not transferred would have been
+ * zeroes had the device server returned those bytes.''
+ */
memset(&sc->top_sense, 0, UB_SENSE_SIZE);
scmd = &sc->top_rqs_cmd;
scmd->cdb[0] = REQUEST_SENSE;
+ scmd->cdb[4] = UB_SENSE_SIZE;
scmd->cdb_len = 6;
scmd->dir = UB_DIR_READ;
scmd->state = UB_CMDST_INIT;
@@ -1352,6 +1359,7 @@
*/
static void ub_revalidate(struct ub_dev *sc)
{
+ int retries;
sc->readonly = 0; /* XXX Query this from the device */
@@ -1364,8 +1372,21 @@
sc->capacity.bsize = 512;
sc->capacity.bshift = 0;
- if (ub_sync_tur(sc) != 0)
- return; /* Not ready */
+ /*
+ * Here's our equivalent of spinup. We probably need to better check
+ * the sense codes from TUR ? Anyway, some flash devices tend to want
+ * us to wait a little bit before beeing ready. We may want to do something
+ * closer to what sd.c does here. --BenH
+ */
+ retries = 0;
+ for (;;) {
+ if (ub_sync_tur(sc) == 0)
+ break;
+ if (++retries > 3)
+ return;
+ msleep(10); /* ahem ... */
+ }
+
sc->changed = 0;
if (ub_sync_read_cap(sc, &sc->capacity) != 0) {
@@ -1531,6 +1552,7 @@
/* The sd.c clears this before returning (one-shot flag). Why? */
/* P3 */ printk("%s: %s changed\n", sc->name,
sc->changed? "is": "was not");
+ sc->changed = 0;
return sc->changed;
}
next prev parent reply other threads:[~2004-09-18 1:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.1095300780.10032.linux-kernel2news@redhat.com>
2004-09-16 6:17 ` [BUG] ub.c badness in current bk Pete Zaitcev
2004-09-17 7:29 ` Pete Zaitcev
2004-09-17 9:46 ` Benjamin Herrenschmidt
2004-09-17 16:04 ` Pete Zaitcev
2004-09-18 0:08 ` Benjamin Herrenschmidt
2004-09-18 0:12 ` Benjamin Herrenschmidt
2004-09-18 1:04 ` Benjamin Herrenschmidt [this message]
2004-09-18 2:08 ` Benjamin Herrenschmidt
2004-09-20 3:21 ` Pete Zaitcev
2004-09-20 3:37 ` Benjamin Herrenschmidt
2004-09-22 1:44 ` Pete Zaitcev
2004-09-16 2:06 Benjamin Herrenschmidt
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=1095469463.3574.2.camel@gaston \
--to=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zaitcev@redhat.com \
/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