From: Denys Vlasenko <dvlasenk@redhat.com>
To: James Bottomley <JBottomley@Parallels.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>,
Hannes Reinicke <hare@suse.de>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] scsi: aic7xxx: fix ahc_delay and ahd_delay
Date: Fri, 14 Oct 2016 16:20:00 +0200 [thread overview]
Message-ID: <20161014142000.18833-1-dvlasenk@redhat.com> (raw)
They are buggy:
while (usec > 0)
udelay(usec % 1024);
usec -= 1024;
For example, for usec = 100*1024 + 1, old code will udelay(1) 101 times,
i.e. it will be approximately equivalent to udelay(101),
not the expected udelay(102400).
This did not bite because all callers use values far from "pathological" ones,
such as 500 and 1000 - these work fine with buggy code.
This was reported in 2006 but was missed.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
CC: James Bottomley <JBottomley@Parallels.com>
CC: Hannes Reinicke <hare@suse.de>
CC: linux-scsi@vger.kernel.org
CC: linux-kernel@vger.kernel.org
---
drivers/scsi/aic7xxx/aic79xx_osm.c | 7 ++++---
drivers/scsi/aic7xxx/aic7xxx_osm.c | 7 ++++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 2588b8f..e7a7838 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -380,9 +380,10 @@ ahd_delay(long usec)
* multi-millisecond waits. Wait at most
* 1024us per call.
*/
- while (usec > 0) {
- udelay(usec % 1024);
- usec -= 1024;
+ udelay(usec & 1023);
+ usec >>= 10;
+ while (--usec >= 0) {
+ udelay(1024);
}
}
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index fc6a831..c81798e 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -388,9 +388,10 @@ ahc_delay(long usec)
* multi-millisecond waits. Wait at most
* 1024us per call.
*/
- while (usec > 0) {
- udelay(usec % 1024);
- usec -= 1024;
+ udelay(usec & 1023);
+ usec >>= 10;
+ while (--usec >= 0) {
+ udelay(1024);
}
}
--
2.9.2
reply other threads:[~2016-10-14 14:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20161014142000.18833-1-dvlasenk@redhat.com \
--to=dvlasenk@redhat.com \
--cc=JBottomley@Parallels.com \
--cc=hare@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/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
all inboxes | Powered by JetHome®