From: Finn Thain <fthain@telegraphics.com.au>
To: "James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Michael Schmitz <schmitzmic@gmail.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Joshua Thompson <funaho@jurai.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
linux-m68k@lists.linux-m68k.org
Subject: [PATCH 6/7] scsi: mac_scsi: Enable PDMA on Mac IIfx
Date: Sun, 02 Jun 2019 11:24:12 +1000 [thread overview]
Message-ID: <a69c9e248f46f02a2cdef95e2ff3d3b08531c6fa.1559438652.git.fthain@telegraphics.com.au> (raw)
In-Reply-To: <cover.1559438652.git.fthain@telegraphics.com.au>
Add support for Apple's custom "SCSI DMA" chip. This patch doesn't make
use of its DMA capability. Just the PDMA capability is sufficient to
improve sequential read throughput by a factor of 5.
Cc: Michael Schmitz <schmitzmic@gmail.com>
Cc: Joshua Thompson <funaho@jurai.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
arch/m68k/mac/config.c | 10 +++++++--
drivers/scsi/mac_scsi.c | 47 ++++++++++++++++++++++++++++++++++-------
2 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 39835ca5a474..611f73bfc87c 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -911,6 +911,10 @@ static const struct resource mac_scsi_iifx_rsrc[] __initconst = {
.flags = IORESOURCE_MEM,
.start = 0x50008000,
.end = 0x50009FFF,
+ }, {
+ .flags = IORESOURCE_MEM,
+ .start = 0x50008000,
+ .end = 0x50009FFF,
},
};
@@ -1012,10 +1016,12 @@ int __init mac_platform_init(void)
case MAC_SCSI_IIFX:
/* Addresses from The Guide to Mac Family Hardware.
* $5000 8000 - $5000 9FFF: SCSI DMA
+ * $5000 A000 - $5000 BFFF: Alternate SCSI
* $5000 C000 - $5000 DFFF: Alternate SCSI (DMA)
* $5000 E000 - $5000 FFFF: Alternate SCSI (Hsk)
- * The SCSI DMA custom IC embeds the 53C80 core. mac_scsi does
- * not make use of its DMA or hardware handshaking logic.
+ * The A/UX header file sys/uconfig.h says $50F0 8000.
+ * The "SCSI DMA" custom IC embeds the 53C80 core and
+ * supports Programmed IO, DMA and PDMA (hardware handshake).
*/
platform_device_register_simple("mac_scsi", 0,
mac_scsi_iifx_rsrc, ARRAY_SIZE(mac_scsi_iifx_rsrc));
diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c
index e83b47a7e4b5..2e503f06ac99 100644
--- a/drivers/scsi/mac_scsi.c
+++ b/drivers/scsi/mac_scsi.c
@@ -22,6 +22,7 @@
#include <asm/hwtest.h>
#include <asm/io.h>
#include <asm/mac_pdma.h>
+#include <asm/macintosh.h>
#include <asm/macints.h>
#include <asm/setup.h>
@@ -90,11 +91,22 @@ static int __init mac_scsi_setup(char *str)
__setup("mac5380=", mac_scsi_setup);
#endif /* !MODULE */
+/* The "SCSI DMA" chip on the IIfx implements this register. */
+#define CTRL_REG 0x8
+#define CTRL_INTERRUPTS_ENABLE BIT(1)
+#define CTRL_HANDSHAKE_MODE BIT(3)
+
+static inline void write_ctrl_reg(struct NCR5380_hostdata *hostdata, u32 value)
+{
+ out_be32(hostdata->io + (CTRL_REG << 4), value);
+}
+
static inline int macscsi_pread(struct NCR5380_hostdata *hostdata,
unsigned char *dst, int len)
{
u8 __iomem *s = hostdata->pdma_io + (INPUT_DATA_REG << 4);
unsigned char *d = dst;
+ int result = 0;
hostdata->pdma_residual = len;
@@ -103,6 +115,10 @@ static inline int macscsi_pread(struct NCR5380_hostdata *hostdata,
BASR_DRQ | BASR_PHASE_MATCH, HZ / 64)) {
int bytes;
+ if (macintosh_config->ident == MAC_MODEL_IIFX)
+ write_ctrl_reg(hostdata, CTRL_HANDSHAKE_MODE |
+ CTRL_INTERRUPTS_ENABLE);
+
bytes = mac_pdma_recv(s, d, min(hostdata->pdma_residual, 512));
if (bytes > 0) {
@@ -111,7 +127,7 @@ static inline int macscsi_pread(struct NCR5380_hostdata *hostdata,
}
if (hostdata->pdma_residual == 0)
- return 0;
+ goto out;
if (NCR5380_poll_politely2(hostdata, STATUS_REG, SR_REQ, SR_REQ,
BUS_AND_STATUS_REG, BASR_ACK,
@@ -119,7 +135,7 @@ static inline int macscsi_pread(struct NCR5380_hostdata *hostdata,
scmd_printk(KERN_DEBUG, hostdata->connected,
"%s: !REQ and !ACK\n", __func__);
if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH))
- return 0;
+ goto out;
if (bytes == 0)
udelay(MAC_PDMA_DELAY);
@@ -130,13 +146,18 @@ static inline int macscsi_pread(struct NCR5380_hostdata *hostdata,
dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host,
"%s: bus error (%d/%d)\n", __func__, d - dst, len);
NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host);
- return -1;
+ result = -1;
+ goto out;
}
scmd_printk(KERN_ERR, hostdata->connected,
"%s: phase mismatch or !DRQ\n", __func__);
NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host);
- return -1;
+ result = -1;
+out:
+ if (macintosh_config->ident == MAC_MODEL_IIFX)
+ write_ctrl_reg(hostdata, CTRL_INTERRUPTS_ENABLE);
+ return result;
}
static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata,
@@ -144,6 +165,7 @@ static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata,
{
unsigned char *s = src;
u8 __iomem *d = hostdata->pdma_io + (OUTPUT_DATA_REG << 4);
+ int result = 0;
hostdata->pdma_residual = len;
@@ -152,6 +174,10 @@ static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata,
BASR_DRQ | BASR_PHASE_MATCH, HZ / 64)) {
int bytes;
+ if (macintosh_config->ident == MAC_MODEL_IIFX)
+ write_ctrl_reg(hostdata, CTRL_HANDSHAKE_MODE |
+ CTRL_INTERRUPTS_ENABLE);
+
bytes = mac_pdma_send(s, d, min(hostdata->pdma_residual, 512));
if (bytes > 0) {
@@ -165,7 +191,7 @@ static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata,
TCR_LAST_BYTE_SENT, HZ / 64) < 0)
scmd_printk(KERN_ERR, hostdata->connected,
"%s: Last Byte Sent timeout\n", __func__);
- return 0;
+ goto out;
}
if (NCR5380_poll_politely2(hostdata, STATUS_REG, SR_REQ, SR_REQ,
@@ -174,7 +200,7 @@ static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata,
scmd_printk(KERN_DEBUG, hostdata->connected,
"%s: !REQ and !ACK\n", __func__);
if (!(NCR5380_read(BUS_AND_STATUS_REG) & BASR_PHASE_MATCH))
- return 0;
+ goto out;
if (bytes == 0)
udelay(MAC_PDMA_DELAY);
@@ -185,13 +211,18 @@ static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata,
dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host,
"%s: bus error (%d/%d)\n", __func__, s - src, len);
NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host);
- return -1;
+ result = -1;
+ goto out;
}
scmd_printk(KERN_ERR, hostdata->connected,
"%s: phase mismatch or !DRQ\n", __func__);
NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host);
- return -1;
+ result = -1;
+out:
+ if (macintosh_config->ident == MAC_MODEL_IIFX)
+ write_ctrl_reg(hostdata, CTRL_INTERRUPTS_ENABLE);
+ return result;
}
static int macscsi_dma_xfer_len(struct NCR5380_hostdata *hostdata,
--
2.21.0
next prev parent reply other threads:[~2019-06-02 1:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-02 1:24 [PATCH 0/7] NCR5380 drivers: fixes and improvements Finn Thain
2019-06-02 1:24 ` [PATCH 2/7] scsi: NCR5380: Always re-enable reselection interrupt Finn Thain
2019-06-02 1:24 ` [PATCH 7/7] scsi: mac_scsi: Treat Last Byte Sent time-out as failure Finn Thain
2019-06-02 1:24 ` [PATCH 5/7] scsi: mac_scsi: Fix pseudo DMA implementation, take 2 Finn Thain
2019-06-02 9:07 ` Geert Uytterhoeven
2019-06-02 23:32 ` Finn Thain
2019-06-03 6:23 ` Geert Uytterhoeven
2019-06-03 7:40 ` Finn Thain
2019-06-03 7:53 ` Geert Uytterhoeven
2019-06-03 21:25 ` Michael Schmitz
2019-06-04 0:05 ` Finn Thain
2019-06-02 1:24 ` [PATCH 1/7] Revert "scsi: ncr5380: Increase register polling limit" Finn Thain
2019-06-02 1:24 ` [PATCH 3/7] scsi: NCR5380: Handle PDMA failure reliably Finn Thain
2019-06-02 1:24 ` [PATCH 4/7] scsi: mac_scsi: Increase PIO/PDMA transfer length threshold Finn Thain
2019-06-02 1:24 ` Finn Thain [this message]
2019-06-02 9:04 ` [PATCH 6/7] scsi: mac_scsi: Enable PDMA on Mac IIfx Geert Uytterhoeven
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=a69c9e248f46f02a2cdef95e2ff3d3b08531c6fa.1559438652.git.fthain@telegraphics.com.au \
--to=fthain@telegraphics.com.au \
--cc=funaho@jurai.org \
--cc=geert@linux-m68k.org \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-scsi@vger.kernel.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: 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