summaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorFinn Thain <fthain@telegraphics.com.au>2016-10-10 00:46:52 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2016-11-08 17:29:47 -0500
commitd4408dd7ecff6ed3561f155923738474c585f31d (patch)
treed5b2e08ec4d80487519d6016ad329ae551b52dd5 /drivers/scsi
parentabd12b09292cc87a75f7c3e3c3f2b12589560bb1 (diff)
scsi: ncr5380: Simplify register polling limit
When polling a device register under irq lock the polling loop terminates after a given number of jiffies. Make this timeout independent of the HZ setting. All 5380 drivers benefit from this patch, which optimizes the PIO fast path, because they all use PIO transfers (for phases other than DATA IN and DATA OUT). Some cards support only PIO transfers (even for DATA phases). CPU cycles are scarce on some of these systems, so a small improvement here makes a big difference. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ondrej Zary <linux@rainbow-software.org> Tested-by: Michael Schmitz <schmitzmic@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/NCR5380.c10
-rw-r--r--drivers/scsi/NCR5380.h5
2 files changed, 8 insertions, 7 deletions
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index 790babc5ef66..c5c15573e23f 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -200,13 +200,9 @@ static int NCR5380_poll_politely2(struct Scsi_Host *instance,
200 int reg2, int bit2, int val2, int wait) 200 int reg2, int bit2, int val2, int wait)
201{ 201{
202 struct NCR5380_hostdata *hostdata = shost_priv(instance); 202 struct NCR5380_hostdata *hostdata = shost_priv(instance);
203 unsigned long n = hostdata->poll_loops;
203 unsigned long deadline = jiffies + wait; 204 unsigned long deadline = jiffies + wait;
204 unsigned long n;
205 205
206 /* Busy-wait for up to 10 ms */
207 n = min(10000U, jiffies_to_usecs(wait));
208 n *= hostdata->accesses_per_ms;
209 n /= 2000;
210 do { 206 do {
211 if ((NCR5380_read(reg1) & bit1) == val1) 207 if ((NCR5380_read(reg1) & bit1) == val1)
212 return 0; 208 return 0;
@@ -482,6 +478,7 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags)
482 struct NCR5380_hostdata *hostdata = shost_priv(instance); 478 struct NCR5380_hostdata *hostdata = shost_priv(instance);
483 int i; 479 int i;
484 unsigned long deadline; 480 unsigned long deadline;
481 unsigned long accesses_per_ms;
485 482
486 instance->max_lun = 7; 483 instance->max_lun = 7;
487 484
@@ -530,7 +527,8 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags)
530 ++i; 527 ++i;
531 cpu_relax(); 528 cpu_relax();
532 } while (time_is_after_jiffies(deadline)); 529 } while (time_is_after_jiffies(deadline));
533 hostdata->accesses_per_ms = i / 256; 530 accesses_per_ms = i / 256;
531 hostdata->poll_loops = NCR5380_REG_POLL_TIME * accesses_per_ms / 2;
534 532
535 return 0; 533 return 0;
536} 534}
diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h
index 965d92339455..cbb29d604fe0 100644
--- a/drivers/scsi/NCR5380.h
+++ b/drivers/scsi/NCR5380.h
@@ -239,7 +239,7 @@ struct NCR5380_hostdata {
239 * transfer to handle chip overruns */ 239 * transfer to handle chip overruns */
240 struct work_struct main_task; 240 struct work_struct main_task;
241 struct workqueue_struct *work_q; 241 struct workqueue_struct *work_q;
242 unsigned long accesses_per_ms; /* chip register accesses per ms */ 242 unsigned long poll_loops; /* register polling limit */
243}; 243};
244 244
245#ifdef __KERNEL__ 245#ifdef __KERNEL__
@@ -252,6 +252,9 @@ struct NCR5380_cmd {
252 252
253#define NCR5380_PIO_CHUNK_SIZE 256 253#define NCR5380_PIO_CHUNK_SIZE 256
254 254
255/* Time limit (ms) to poll registers when IRQs are disabled, e.g. during PDMA */
256#define NCR5380_REG_POLL_TIME 10
257
255static inline struct scsi_cmnd *NCR5380_to_scmd(struct NCR5380_cmd *ncmd_ptr) 258static inline struct scsi_cmnd *NCR5380_to_scmd(struct NCR5380_cmd *ncmd_ptr)
256{ 259{
257 return ((struct scsi_cmnd *)ncmd_ptr) - 1; 260 return ((struct scsi_cmnd *)ncmd_ptr) - 1;