From: Finn Thain <fthain@telegraphics.com.au> To: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com> Cc: Michael Schmitz <schmitzmic@gmail.com>, Ondrej Zary <linux@rainbow-software.org>, <linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH v2 04/12] scsi/ncr5380: Simplify register polling limit Date: Thu, 6 Oct 2016 19:41:07 -0400 (EDT) [thread overview] Message-ID: <1210ba307641e20510dea6f221b8c6b8acae5546.1475791899.git.fthain@telegraphics.com.au> (raw) In-Reply-To: <cover.1475791899.git.fthain@telegraphics.com.au> 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> --- This patch eliminates a call to jiffies_to_usecs from the fast path. For g_NCR5380 it also eliminates a mul instruction and an imul instruction. For ARM drivers like oak, this change eliminates an __aeabi_uidiv call. --- drivers/scsi/NCR5380.c | 10 ++++------ drivers/scsi/NCR5380.h | 5 ++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index db27390..25ee5be 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -200,13 +200,9 @@ static int NCR5380_poll_politely2(struct Scsi_Host *instance, int reg2, int bit2, int val2, int wait) { struct NCR5380_hostdata *hostdata = shost_priv(instance); + unsigned long n = hostdata->poll_loops; unsigned long deadline = jiffies + wait; - unsigned long n; - /* Busy-wait for up to 10 ms */ - n = min(10000U, jiffies_to_usecs(wait)); - n *= hostdata->accesses_per_ms; - n /= 2000; do { if ((NCR5380_read(reg1) & bit1) == val1) return 0; @@ -482,6 +478,7 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags) struct NCR5380_hostdata *hostdata = shost_priv(instance); int i; unsigned long deadline; + unsigned long accesses_per_ms; instance->max_lun = 7; @@ -530,7 +527,8 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags) ++i; cpu_relax(); } while (time_is_after_jiffies(deadline)); - hostdata->accesses_per_ms = i / 256; + accesses_per_ms = i / 256; + hostdata->poll_loops = NCR5380_REG_POLL_TIME * accesses_per_ms / 2; return 0; } diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index 965d923..cbb29d6 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -239,7 +239,7 @@ struct NCR5380_hostdata { * transfer to handle chip overruns */ struct work_struct main_task; struct workqueue_struct *work_q; - unsigned long accesses_per_ms; /* chip register accesses per ms */ + unsigned long poll_loops; /* register polling limit */ }; #ifdef __KERNEL__ @@ -252,6 +252,9 @@ struct NCR5380_cmd { #define NCR5380_PIO_CHUNK_SIZE 256 +/* Time limit (ms) to poll registers when IRQs are disabled, e.g. during PDMA */ +#define NCR5380_REG_POLL_TIME 10 + static inline struct scsi_cmnd *NCR5380_to_scmd(struct NCR5380_cmd *ncmd_ptr) { return ((struct scsi_cmnd *)ncmd_ptr) - 1; -- 2.7.3
WARNING: multiple messages have this Message-ID (diff)
From: Finn Thain <fthain@telegraphics.com.au> To: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com> Cc: Michael Schmitz <schmitzmic@gmail.com>, Ondrej Zary <linux@rainbow-software.org>, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 04/12] scsi/ncr5380: Simplify register polling limit Date: Thu, 6 Oct 2016 19:41:07 -0400 (EDT) [thread overview] Message-ID: <1210ba307641e20510dea6f221b8c6b8acae5546.1475791899.git.fthain@telegraphics.com.au> (raw) In-Reply-To: <cover.1475791899.git.fthain@telegraphics.com.au> 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> --- This patch eliminates a call to jiffies_to_usecs from the fast path. For g_NCR5380 it also eliminates a mul instruction and an imul instruction. For ARM drivers like oak, this change eliminates an __aeabi_uidiv call. --- drivers/scsi/NCR5380.c | 10 ++++------ drivers/scsi/NCR5380.h | 5 ++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c index db27390..25ee5be 100644 --- a/drivers/scsi/NCR5380.c +++ b/drivers/scsi/NCR5380.c @@ -200,13 +200,9 @@ static int NCR5380_poll_politely2(struct Scsi_Host *instance, int reg2, int bit2, int val2, int wait) { struct NCR5380_hostdata *hostdata = shost_priv(instance); + unsigned long n = hostdata->poll_loops; unsigned long deadline = jiffies + wait; - unsigned long n; - /* Busy-wait for up to 10 ms */ - n = min(10000U, jiffies_to_usecs(wait)); - n *= hostdata->accesses_per_ms; - n /= 2000; do { if ((NCR5380_read(reg1) & bit1) == val1) return 0; @@ -482,6 +478,7 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags) struct NCR5380_hostdata *hostdata = shost_priv(instance); int i; unsigned long deadline; + unsigned long accesses_per_ms; instance->max_lun = 7; @@ -530,7 +527,8 @@ static int NCR5380_init(struct Scsi_Host *instance, int flags) ++i; cpu_relax(); } while (time_is_after_jiffies(deadline)); - hostdata->accesses_per_ms = i / 256; + accesses_per_ms = i / 256; + hostdata->poll_loops = NCR5380_REG_POLL_TIME * accesses_per_ms / 2; return 0; } diff --git a/drivers/scsi/NCR5380.h b/drivers/scsi/NCR5380.h index 965d923..cbb29d6 100644 --- a/drivers/scsi/NCR5380.h +++ b/drivers/scsi/NCR5380.h @@ -239,7 +239,7 @@ struct NCR5380_hostdata { * transfer to handle chip overruns */ struct work_struct main_task; struct workqueue_struct *work_q; - unsigned long accesses_per_ms; /* chip register accesses per ms */ + unsigned long poll_loops; /* register polling limit */ }; #ifdef __KERNEL__ @@ -252,6 +252,9 @@ struct NCR5380_cmd { #define NCR5380_PIO_CHUNK_SIZE 256 +/* Time limit (ms) to poll registers when IRQs are disabled, e.g. during PDMA */ +#define NCR5380_REG_POLL_TIME 10 + static inline struct scsi_cmnd *NCR5380_to_scmd(struct NCR5380_cmd *ncmd_ptr) { return ((struct scsi_cmnd *)ncmd_ptr) - 1; -- 2.7.3
next prev parent reply other threads:[~2016-10-06 23:41 UTC|newest] Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-10-06 23:41 [PATCH v2 00/12] Fixes, cleanup and g_NCR5380_mmio/g_NCR5380 merger Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` [PATCH v2 03/12] scsi/atari_scsi: Make device register accessors re-enterant Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` [PATCH v2 11/12] scsi/ncr5380: Use correct types for DMA routines Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` [PATCH v2 06/12] scsi/ncr5380: Improve hostdata struct member alignment and cache-ability Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` [PATCH v2 05/12] scsi/ncr5380: Increase register polling limit Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` [PATCH v2 07/12] scsi/ncr5380: Store IO ports and addresses in host private data Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` [PATCH v2 09/12] scsi/ncr5380: Pass hostdata pointer to register polling routines Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` Finn Thain [this message] 2016-10-06 23:41 ` [PATCH v2 04/12] scsi/ncr5380: Simplify register polling limit Finn Thain 2016-10-06 23:41 ` [PATCH v2 01/12] scsi/g_NCR5380: Merge g_NCR5380 and g_NCR5380_mmio drivers Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` [PATCH v2 02/12] scsi/cumana_1: Remove unused cumanascsi_setup() function Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` [PATCH v2 12/12] scsi/ncr5380: Suppress unhelpful "interrupt without IRQ bit" message Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` [PATCH v2 10/12] scsi/ncr5380: Expedite register polling Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` [PATCH v2 08/12] scsi/ncr5380: Use correct types for device register accessors Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-06 23:41 ` Finn Thain 2016-10-07 17:59 ` [PATCH v2 00/12] Fixes, cleanup and g_NCR5380_mmio/g_NCR5380 merger Ondrej Zary 2016-10-09 7:22 ` Michael Schmitz
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=1210ba307641e20510dea6f221b8c6b8acae5546.1475791899.git.fthain@telegraphics.com.au \ --to=fthain@telegraphics.com.au \ --cc=jejb@linux.vnet.ibm.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-scsi@vger.kernel.org \ --cc=linux@rainbow-software.org \ --cc=martin.petersen@oracle.com \ --cc=schmitzmic@gmail.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: linkBe 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.