Skip to contentSkip to conversation

Small fixes and cleanup

PATCH Applied Finn Thain 5 participants 15 messages Aug 27, 2016 – Sep 14, 2016

Subsystems (3)
lore
Share & tools
lore

Finn Thain

author
#0 lore raw

cover Small fixes and cleanup

Miscellaneous small patches for an interrupt latency issue, a compiler warning and a documentation cleanup.

---
 Documentation/kernel-parameters.txt    |    2 --
 Documentation/scsi/scsi-parameters.txt |    2 --
 drivers/scsi/NCR5380.c                 |   13 +++----------
 drivers/scsi/NCR5380.h                 |    8 +++++++-
 4 files changed, 10 insertions(+), 15 deletions(-)
author
#1 lore raw

PATCH 1/3 documentation/scsi: Remove nodisconnect parameter

The driver that used the 'nodisconnect' parameter was removed in commit 565bae6a4a8f ("[SCSI] 53c7xx: kill driver"). Related documentation was cleaned up in commit f37a7238d379 ("[SCSI] 53c7xx: fix removal fallout"), except for the remaining two mentions that are removed here.

---
 Documentation/kernel-parameters.txt    |    2 --
 Documentation/scsi/scsi-parameters.txt |    2 --
 2 files changed, 4 deletions(-)
Documentation/kernel-parameters.txt +0 -2
Index: linux/Documentation/kernel-parameters.txt
===================================================================
@@ -2543,8 +2543,6 @@ bytes respectively. Such letter suffixes
 
 	nodelayacct	[KNL] Disable per-task delay accounting
 
-	nodisconnect	[HW,SCSI,M68K] Disables SCSI disconnects.
-
 	nodsp		[SH] Disable hardware DSP at boot time.
 
 	noefi		Disable EFI runtime services support.
Documentation/scsi/scsi-parameters.txt +0 -2
Index: linux/Documentation/scsi/scsi-parameters.txt
===================================================================
@@ -79,8 +79,6 @@ parameters may be changed at runtime by
 
 	ncr53c8xx=	[HW,SCSI]
 
-	nodisconnect	[HW,SCSI,M68K] Disables SCSI disconnects.
-
 	osst=		[HW,SCSI] SCSI Tape Driver
 			Format: <buffer_size>,<write_threshold>
 			See also Documentation/scsi/st.txt.
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] documentation/scsi: Remove nodisconnect parameter

Quoted 6 lines · Finn Thain

The driver that used the 'nodisconnect' parameter was removed in commit 565bae6a4a8f ("[SCSI] 53c7xx: kill driver"). Related documentation was cleaned up in commit f37a7238d379 ("[SCSI] 53c7xx: fix removal fallout"), except for the remaining two mentions that are removed here.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

maintainer Applied
#3 lore raw

Re: [PATCH 1/3] documentation/scsi: Remove nodisconnect parameter

In reply to Finn Thain
Quoted 4 lines · On Sat, 27 Aug 2016 12:29:59 +1000 Finn Thain <[email protected]>…

The driver that used the 'nodisconnect' parameter was removed in commit 565bae6a4a8f ("[SCSI] 53c7xx: kill driver"). Related documentation was cleaned up in commit f37a7238d379 ("[SCSI] 53c7xx: fix removal fallout"), except for the remaining two mentions that are removed here.

Applied to the docs tree, thanks.

jon

author
#4 lore raw

PATCH 2/3 scsi/ncr5380: Avoid a compiler warning

In reply to Finn Thain

With commit 3a0f64bfa907 ("mac_scsi: Fix pseudo DMA implementation") some versions of gcc now warn:

In file included from drivers/scsi/mac_scsi.c:335:
drivers/scsi/NCR5380.h:295: warning: NCR5380_poll_politely' declared inline after being called drivers/scsi/NCR5380.h:295: warning: previous declaration of NCR5380_poll_politely' was here

Avoid this by defining NCR5380_poll_politely() in NCR5380.h.

---
 drivers/scsi/NCR5380.c |    7 -------
 drivers/scsi/NCR5380.h |    8 +++++++-
 2 files changed, 7 insertions(+), 8 deletions(-)
drivers/scsi/NCR5380.c +0 -7
Index: linux/drivers/scsi/NCR5380.c
===================================================================
@@ -230,13 +230,6 @@ static int NCR5380_poll_politely2(struct
 	return -ETIMEDOUT;
 }
 
-static inline int NCR5380_poll_politely(struct Scsi_Host *instance,
-                                        int reg, int bit, int val, int wait)
-{
-	return NCR5380_poll_politely2(instance, reg, bit, val,
-	                                        reg, bit, val, wait);
-}
-
 #if NDEBUG
 static struct {
 	unsigned char mask;
drivers/scsi/NCR5380.h +7 -1
Index: linux/drivers/scsi/NCR5380.h
===================================================================
@@ -292,8 +292,14 @@ static void NCR5380_reselect(struct Scsi
 static struct scsi_cmnd *NCR5380_select(struct Scsi_Host *, struct scsi_cmnd *);
 static int NCR5380_transfer_dma(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data);
 static int NCR5380_transfer_pio(struct Scsi_Host *instance, unsigned char *phase, int *count, unsigned char **data);
-static int NCR5380_poll_politely(struct Scsi_Host *, int, int, int, int);
 static int NCR5380_poll_politely2(struct Scsi_Host *, int, int, int, int, int, int, int);
 
+static inline int NCR5380_poll_politely(struct Scsi_Host *instance,
+                                        int reg, int bit, int val, int wait)
+{
+	return NCR5380_poll_politely2(instance, reg, bit, val,
+	                                        reg, bit, val, wait);
+}
+
 #endif				/* __KERNEL__ */
 #endif				/* NCR5380_H */
Tested-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] scsi/ncr5380: Avoid a compiler warning

Quoted 11 lines · Finn Thain

With commit 3a0f64bfa907 ("mac_scsi: Fix pseudo DMA implementation") some versions of gcc now warn:

In file included from drivers/scsi/mac_scsi.c:335:
drivers/scsi/NCR5380.h:295: warning: NCR5380_poll_politely' declared inline after being called drivers/scsi/NCR5380.h:295: warning: previous declaration of NCR5380_poll_politely' was here

Avoid this by defining NCR5380_poll_politely() in NCR5380.h.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#6 lore raw

PATCH 3/3 scsi/ncr5380: Improve interrupt latency during PIO tranfers

In reply to Finn Thain

Large PIO transfers are broken up into chunks to try to avoid disabling local IRQs for long periods. But IRQs are still disabled for too long and this causes SCC FIFO overruns during serial port transfers. This patch fixes the problem by halving the PIO chunk size.

Testing with mac_scsi shows that the extra NCR5380_main() loop iterations have negligible performance impact on SCSI transfers (about 1% slower). On a faster system (using the dmx3191d module) transfers showed no measurable change.

---
 drivers/scsi/NCR5380.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/NCR5380.c +3 -3
Index: linux/drivers/scsi/NCR5380.c
===================================================================
@@ -1847,11 +1847,11 @@ static void NCR5380_information_transfer
 						/* XXX - need to source or sink data here, as appropriate */
 					}
 				} else {
-					/* Break up transfer into 3 ms chunks,
-					 * presuming 6 accesses per handshake.
+					/* Transfer a small chunk so that the
+					 * irq mode lock is not held too long.
 					 */
 					transfersize = min((unsigned long)cmd->SCp.this_residual,
-					                   hostdata->accesses_per_ms / 2);
+					                   hostdata->accesses_per_ms >> 2);
 					len = transfersize;
 					NCR5380_transfer_pio(instance, &phase, &len,
 					                     (unsigned char **)&cmd->SCp.ptr);
#7 lore raw

Re: [PATCH 3/3] scsi/ncr5380: Improve interrupt latency during PIO tranfers

Hi Finn,

Quoted 22 lines · Finn Thain

Large PIO transfers are broken up into chunks to try to avoid disabling local IRQs for long periods. But IRQs are still disabled for too long and this causes SCC FIFO overruns during serial port transfers. This patch fixes the problem by halving the PIO chunk size.

Testing with mac_scsi shows that the extra NCR5380_main() loop iterations have negligible performance impact on SCSI transfers (about 1% slower). On a faster system (using the dmx3191d module) transfers showed no measurable change.

---
 drivers/scsi/NCR5380.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================

drivers/scsi/NCR5380.c 2016-08-27 12:29:58.000000000 +1000 renamed from drivers/scsi/NCR5380.c 2016-08-27 12:29:57.000000000 +1000 +0 -0
@@ -1847,11 +1847,11 @@ static void NCR5380_information_transfer
                                                /* XXX - need to source or sink data here, as appropriate */

drivers/scsi/NCR5380.c 2016-08-27 12:29:58.000000000 +1000 static void NCR5380_information_transfer · line 1854

Quoted 10 lines
drivers/scsi/NCR5380.c 2016-08-27 12:29:58.000000000 +1000 renamed from drivers/scsi/NCR5380.c 2016-08-27 12:29:57.000000000 +1000 +3 -3
                                        }
                                } else {
-                                       /* Break up transfer into 3 ms chunks,
-                                        * presuming 6 accesses per handshake.
+                                       /* Transfer a small chunk so that the
+                                        * irq mode lock is not held too long.
                                         */
                                        transfersize = min((unsigned long)cmd->SCp.this_residual,
-                                                          hostdata->accesses_per_ms / 2);
+                                                          hostdata->accesses_per_ms >> 2);

I think it's easier to read if you use "/ 4".

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author
#8 lore raw

Re: [PATCH 3/3] scsi/ncr5380: Improve interrupt latency during PIO tranfers

Quoted 30 lines · Geert Uytterhoeven

Hi Finn,

Quoted 26 lines · Finn Thain

Large PIO transfers are broken up into chunks to try to avoid disabling local IRQs for long periods. But IRQs are still disabled for too long and this causes SCC FIFO overruns during serial port transfers. This patch fixes the problem by halving the PIO chunk size.

Testing with mac_scsi shows that the extra NCR5380_main() loop iterations have negligible performance impact on SCSI transfers (about 1% slower). On a faster system (using the dmx3191d module) transfers showed no measurable change.

---
 drivers/scsi/NCR5380.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================

drivers/scsi/NCR5380.c 2016-08-27 12:29:58.000000000 +1000 renamed from drivers/scsi/NCR5380.c 2016-08-27 12:29:57.000000000 +1000 +0 -2
@@ -1847,11 +1847,11 @@ static void NCR5380_information_transfer
                                                /* XXX - need to source or sink data here, as appropriate */
                                        }
                                } else {
-                                       /* Break up transfer into 3 ms chunks,
-                                        * presuming 6 accesses per handshake.
Quoted 8 lines

drivers/scsi/NCR5380.c 2016-08-27 12:29:58.000000000 +1000 static void NCR5380_information_transfer · line 1854

Quoted 6 lines
drivers/scsi/NCR5380.c 2016-08-27 12:29:58.000000000 +1000 renamed from drivers/scsi/NCR5380.c 2016-08-27 12:29:57.000000000 +1000 +3 -1
+                                       /* Transfer a small chunk so that the
+                                        * irq mode lock is not held too long.
                                         */
                                        transfersize = min((unsigned long)cmd->SCp.this_residual,
-                                                          hostdata->accesses_per_ms / 2);
+                                                          hostdata->accesses_per_ms >> 2);

I think it's easier to read if you use "/ 4".

I think the factor, "1/4 byte milliseconds per access" is not very meaningful. The PIO transfersize can be understood as,

pio_bytes_until_scc_fifo_overflow = accesses_per_ms /
(accesses_per_pio_byte / ms_until_fifo_overflow)

This loop seemed like a good place to avoid a DIV instruction (though I didn't try to confirm that) and so I used a bit shift to indicate that intention.

The shift amount was an empirical result that happened to work for the hardware I tested it on, at the baud rate I was using. Admittedly, if we want to avoid further tweaks to this then I'll have to do more testing and find a better approximation.

Quoted 5 lines

Gr{oetje,eeting}s,

Geert

author
#9 lore raw

PATCH v2 3/3 scsi/ncr5380: Improve interrupt latency during PIO tranfers

In reply to Finn Thain

Large PIO transfers are broken up into chunks to try to avoid disabling local IRQs for long periods. But IRQs are still disabled for too long and this causes SCC FIFO overruns during serial port transfers.

This patch reduces the PIO chunk size to reduce interrupt latency to something on the order of milliseconds, at the expense of additional CPU overhead from extra iterations of the NCR5380_main() loop.

That CPU overhead is a problem for slow machines (e.g. mac_scsi on 25 MHz 68030) but these machines generally use PDMA not PIO. This patch doesn't make the overhead any worse on my Mac LC III (because it only gets about 510 accesses per ms).

This patch decreases disk performance by a fraction of one percent for dmx3191d on my 333 MHz PowerPC 750. Other affected hardware (such as g_NCR5380 on x86) was not tested but 5380 ISA cards generally use PDMA and not PIO.

---
Changed since v1:
- PIO transfer chunk size is now hard-coded for simplicity.

---
 drivers/scsi/NCR5380.c |    8 ++++----
 drivers/scsi/NCR5380.h |    2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/NCR5380.c +4 -4
Index: linux/drivers/scsi/NCR5380.c
===================================================================
@@ -1849,11 +1849,11 @@ static void NCR5380_information_transfer
 						/* XXX - need to source or sink data here, as appropriate */
 					}
 				} else {
-					/* Break up transfer into 3 ms chunks,
-					 * presuming 6 accesses per handshake.
+					/* Transfer a small chunk so that the
+					 * irq mode lock is not held too long.
 					 */
-					transfersize = min((unsigned long)cmd->SCp.this_residual,
-					                   hostdata->accesses_per_ms / 2);
+					transfersize = min(cmd->SCp.this_residual,
+					                   NCR5380_PIO_CHUNK_SIZE);
 					len = transfersize;
 					NCR5380_transfer_pio(instance, &phase, &len,
 					                     (unsigned char **)&cmd->SCp.ptr);
drivers/scsi/NCR5380.h +2 -0
Index: linux/drivers/scsi/NCR5380.h
===================================================================
@@ -250,6 +250,8 @@ struct NCR5380_cmd {
 
 #define NCR5380_CMD_SIZE		(sizeof(struct NCR5380_cmd))
 
+#define NCR5380_PIO_CHUNK_SIZE		256
+
 static inline struct scsi_cmnd *NCR5380_to_scmd(struct NCR5380_cmd *ncmd_ptr)
 {
 	return ((struct scsi_cmnd *)ncmd_ptr) - 1;
#10 lore raw

Re: [PATCH v2 3/3] scsi/ncr5380: Improve interrupt latency during PIO tranfers

----- Original Message -----

Quoted 72 lines

From: "Finn Thain" <[email protected]>
To: "James E.J. Bottomley" <[email protected]>, "Martin K. Petersen" <[email protected]>, "Geert Uytterhoeven" <[email protected]>, [email protected], [email protected], [email protected], "Michael Schmitz" <[email protected]>
Sent: Wednesday, August 31, 2016 12:44:56 AM
Subject: [PATCH v2 3/3] scsi/ncr5380: Improve interrupt latency during PIO tranfers

Large PIO transfers are broken up into chunks to try to avoid disabling local IRQs for long periods. But IRQs are still disabled for too long and this causes SCC FIFO overruns during serial port transfers.

This patch reduces the PIO chunk size to reduce interrupt latency to something on the order of milliseconds, at the expense of additional CPU overhead from extra iterations of the NCR5380_main() loop.

That CPU overhead is a problem for slow machines (e.g. mac_scsi on 25 MHz 68030) but these machines generally use PDMA not PIO. This patch doesn't make the overhead any worse on my Mac LC III (because it only gets about 510 accesses per ms).

This patch decreases disk performance by a fraction of one percent for dmx3191d on my 333 MHz PowerPC 750. Other affected hardware (such as g_NCR5380 on x86) was not tested but 5380 ISA cards generally use PDMA and not PIO.

---
Changed since v1:
- PIO transfer chunk size is now hard-coded for simplicity.

---
 drivers/scsi/NCR5380.c |    8 ++++----
 drivers/scsi/NCR5380.h |    2 ++
 2 files changed, 6 insertions(+), 4 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===================================================================

drivers/scsi/NCR5380.c +4 -4
@@ -1849,11 +1849,11 @@ static void NCR5380_information_transfer
 						/* XXX - need to source or sink data here, as appropriate */
 					}
 				} else {
-					/* Break up transfer into 3 ms chunks,
-					 * presuming 6 accesses per handshake.
+					/* Transfer a small chunk so that the
+					 * irq mode lock is not held too long.
 					 */
-					transfersize = min((unsigned long)cmd->SCp.this_residual,
-					                   hostdata->accesses_per_ms / 2);
+					transfersize = min(cmd->SCp.this_residual,
+					                   NCR5380_PIO_CHUNK_SIZE);
 					len = transfersize;
 					NCR5380_transfer_pio(instance, &phase, &len,
 					                     (unsigned char **)&cmd->SCp.ptr);

Index: linux/drivers/scsi/NCR5380.h
===================================================================

drivers/scsi/NCR5380.h +2 -0
@@ -250,6 +250,8 @@ struct NCR5380_cmd {
 
 #define NCR5380_CMD_SIZE		(sizeof(struct NCR5380_cmd))
 
+#define NCR5380_PIO_CHUNK_SIZE		256
+
 static inline struct scsi_cmnd *NCR5380_to_scmd(struct NCR5380_cmd
 *ncmd_ptr)
 {

return ((struct scsi_cmnd *)ncmd_ptr) - 1;

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Patch makes sense, look good to me.

#11 lore raw

Re: [PATCH v2 3/3] scsi/ncr5380: Improve interrupt latency during PIO tranfers

In reply to Finn Thain
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Finn" == Finn Thain <[email protected]> writes:

Finn> Large PIO transfers are broken up into chunks to try to avoid Finn> disabling local IRQs for long periods. But IRQs are still disabled Finn> for too long and this causes SCC FIFO overruns during serial port Finn> transfers.

Finn> This patch reduces the PIO chunk size to reduce interrupt latency Finn> to something on the order of milliseconds, at the expense of Finn> additional CPU overhead from extra iterations of the Finn> NCR5380_main() loop.

Finn> That CPU overhead is a problem for slow machines (e.g. mac_scsi on Finn> 25 MHz
Finn> 68030) but these machines generally use PDMA not PIO. This patch
Finn> doesn't
Finn> make the overhead any worse on my Mac LC III (because it only gets Finn> about 510 accesses per ms).

Finn> This patch decreases disk performance by a fraction of one percent Finn> for dmx3191d on my 333 MHz PowerPC 750. Other affected hardware Finn> (such as g_NCR5380 on x86) was not tested but 5380 ISA cards Finn> generally use PDMA and not PIO.

Geert?

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#12 lore raw

Re: [PATCH v2 3/3] scsi/ncr5380: Improve interrupt latency during PIO tranfers

Quoted 19 lines · Martin K. Petersen
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Finn" == Finn Thain <[email protected]> writes:

Finn> Large PIO transfers are broken up into chunks to try to avoid Finn> disabling local IRQs for long periods. But IRQs are still disabled Finn> for too long and this causes SCC FIFO overruns during serial port Finn> transfers.

Finn> This patch reduces the PIO chunk size to reduce interrupt latency Finn> to something on the order of milliseconds, at the expense of Finn> additional CPU overhead from extra iterations of the Finn> NCR5380_main() loop.

Finn> That CPU overhead is a problem for slow machines (e.g. mac_scsi on Finn> 25 MHz
Finn> 68030) but these machines generally use PDMA not PIO. This patch
Finn> doesn't
Finn> make the overhead any worse on my Mac LC III (because it only gets Finn> about 510 accesses per ms).

Quoted 6 lines

Finn> This patch decreases disk performance by a fraction of one percent Finn> for dmx3191d on my 333 MHz PowerPC 750. Other affected hardware Finn> (such as g_NCR5380 on x86) was not tested but 5380 ISA cards Finn> generally use PDMA and not PIO.

Geert?

No comments from my side.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#13 lore raw

Re: [PATCH v2 3/3] scsi/ncr5380: Improve interrupt latency during PIO tranfers

In reply to Finn Thain
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Finn" == Finn Thain <[email protected]> writes:

Finn> Large PIO transfers are broken up into chunks to try to avoid Finn> disabling local IRQs for long periods. But IRQs are still disabled Finn> for too long and this causes SCC FIFO overruns during serial port Finn> transfers.

Finn> This patch reduces the PIO chunk size to reduce interrupt latency Finn> to something on the order of milliseconds, at the expense of Finn> additional CPU overhead from extra iterations of the Finn> NCR5380_main() loop.

Applied to 4.9/scsi-queue.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#14 lore raw
In reply to Finn Thain
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Finn" == Finn Thain <[email protected]> writes:

Finn> Miscellaneous small patches for an interrupt latency issue, a Finn> compiler warning and a documentation cleanup.

Applied patches 1 and 2 to 4.9/scsi-queue.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering