Re: [PATCH v3 26/77] ncr5380: Fix NCR5380_transfer_pio() result

2015-12-21 Thread Hannes Reinecke

On 12/22/2015 02:18 AM, Finn Thain wrote:

According to the SCSI-2 draft revision 10L, atari_NCR5380.c is correct
when it says that the phase lines are valid up until ACK is negated
following the transmission of the last byte in MESSAGE IN phase. This is
true for all information transfer phases, from target to initiator.

Sample the phase bits in STATUS_REG so that NCR5380_transfer_pio() can
return the correct result. The return value is presently unused (perhaps
because of bugs like this) but this change at least fixes the caller's
phase variable, which is passed by reference.

Signed-off-by: Finn Thain 

---
  drivers/scsi/NCR5380.c   |   12 +---
  drivers/scsi/atari_NCR5380.c |   11 ++-
  2 files changed, 15 insertions(+), 8 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
--
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 26/77] ncr5380: Fix NCR5380_transfer_pio() result

2015-12-21 Thread Finn Thain
According to the SCSI-2 draft revision 10L, atari_NCR5380.c is correct
when it says that the phase lines are valid up until ACK is negated
following the transmission of the last byte in MESSAGE IN phase. This is
true for all information transfer phases, from target to initiator.

Sample the phase bits in STATUS_REG so that NCR5380_transfer_pio() can
return the correct result. The return value is presently unused (perhaps
because of bugs like this) but this change at least fixes the caller's
phase variable, which is passed by reference.

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.c   |   12 +---
 drivers/scsi/atari_NCR5380.c |   11 ++-
 2 files changed, 15 insertions(+), 8 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===
--- linux.orig/drivers/scsi/NCR5380.c   2015-12-22 12:16:10.0 +1100
+++ linux/drivers/scsi/NCR5380.c2015-12-22 12:16:12.0 +1100
@@ -1393,8 +1393,10 @@ static int NCR5380_transfer_pio(struct S
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
ICR_ASSERT_ACK);
}
 
-   /* FIXME - if this fails bus reset ?? */
-   NCR5380_poll_politely(instance, STATUS_REG, SR_REQ, 0, 5*HZ);
+   if (NCR5380_poll_politely(instance,
+ STATUS_REG, SR_REQ, 0, 5 * HZ) < 0)
+   break;
+
dprintk(NDEBUG_HANDSHAKE, "scsi%d : req false, handshake 
complete\n", instance->host_no);
 
 /*
@@ -1421,7 +1423,11 @@ static int NCR5380_transfer_pio(struct S
*count = c;
*data = d;
tmp = NCR5380_read(STATUS_REG);
-   if (tmp & SR_REQ)
+   /* The phase read from the bus is valid if either REQ is (already)
+* asserted or if ACK hasn't been released yet. The latter applies if
+* we're in MSG IN, DATA IN or STATUS and all bytes have been received.
+*/
+   if ((tmp & SR_REQ) || ((tmp & SR_IO) && c == 0))
*phase = tmp & PHASE_MASK;
else
*phase = PHASE_UNKNOWN;
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2015-12-22 12:16:10.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2015-12-22 12:16:12.0 +1100
@@ -1776,8 +1776,9 @@ static int NCR5380_transfer_pio(struct S
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
ICR_ASSERT_ACK);
}
 
-   while (NCR5380_read(STATUS_REG) & SR_REQ)
-   ;
+   if (NCR5380_poll_politely(instance,
+ STATUS_REG, SR_REQ, 0, 5 * HZ) < 0)
+   break;
 
dprintk(NDEBUG_HANDSHAKE, "scsi%d: req false, handshake 
complete\n", HOSTNO);
 
@@ -1806,10 +1807,10 @@ static int NCR5380_transfer_pio(struct S
*data = d;
tmp = NCR5380_read(STATUS_REG);
/* The phase read from the bus is valid if either REQ is (already)
-* asserted or if ACK hasn't been released yet. The latter is the case 
if
-* we're in MSGIN and all wanted bytes have been received.
+* asserted or if ACK hasn't been released yet. The latter applies if
+* we're in MSG IN, DATA IN or STATUS and all bytes have been received.
 */
-   if ((tmp & SR_REQ) || (p == PHASE_MSGIN && c == 0))
+   if ((tmp & SR_REQ) || ((tmp & SR_IO) && c == 0))
*phase = tmp & PHASE_MASK;
else
*phase = PHASE_UNKNOWN;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 26/77] ncr5380: Fix NCR5380_transfer_pio() result

2015-12-21 Thread Finn Thain
According to the SCSI-2 draft revision 10L, atari_NCR5380.c is correct
when it says that the phase lines are valid up until ACK is negated
following the transmission of the last byte in MESSAGE IN phase. This is
true for all information transfer phases, from target to initiator.

Sample the phase bits in STATUS_REG so that NCR5380_transfer_pio() can
return the correct result. The return value is presently unused (perhaps
because of bugs like this) but this change at least fixes the caller's
phase variable, which is passed by reference.

Signed-off-by: Finn Thain 

---
 drivers/scsi/NCR5380.c   |   12 +---
 drivers/scsi/atari_NCR5380.c |   11 ++-
 2 files changed, 15 insertions(+), 8 deletions(-)

Index: linux/drivers/scsi/NCR5380.c
===
--- linux.orig/drivers/scsi/NCR5380.c   2015-12-22 12:16:10.0 +1100
+++ linux/drivers/scsi/NCR5380.c2015-12-22 12:16:12.0 +1100
@@ -1393,8 +1393,10 @@ static int NCR5380_transfer_pio(struct S
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
ICR_ASSERT_ACK);
}
 
-   /* FIXME - if this fails bus reset ?? */
-   NCR5380_poll_politely(instance, STATUS_REG, SR_REQ, 0, 5*HZ);
+   if (NCR5380_poll_politely(instance,
+ STATUS_REG, SR_REQ, 0, 5 * HZ) < 0)
+   break;
+
dprintk(NDEBUG_HANDSHAKE, "scsi%d : req false, handshake 
complete\n", instance->host_no);
 
 /*
@@ -1421,7 +1423,11 @@ static int NCR5380_transfer_pio(struct S
*count = c;
*data = d;
tmp = NCR5380_read(STATUS_REG);
-   if (tmp & SR_REQ)
+   /* The phase read from the bus is valid if either REQ is (already)
+* asserted or if ACK hasn't been released yet. The latter applies if
+* we're in MSG IN, DATA IN or STATUS and all bytes have been received.
+*/
+   if ((tmp & SR_REQ) || ((tmp & SR_IO) && c == 0))
*phase = tmp & PHASE_MASK;
else
*phase = PHASE_UNKNOWN;
Index: linux/drivers/scsi/atari_NCR5380.c
===
--- linux.orig/drivers/scsi/atari_NCR5380.c 2015-12-22 12:16:10.0 
+1100
+++ linux/drivers/scsi/atari_NCR5380.c  2015-12-22 12:16:12.0 +1100
@@ -1776,8 +1776,9 @@ static int NCR5380_transfer_pio(struct S
NCR5380_write(INITIATOR_COMMAND_REG, ICR_BASE | 
ICR_ASSERT_ACK);
}
 
-   while (NCR5380_read(STATUS_REG) & SR_REQ)
-   ;
+   if (NCR5380_poll_politely(instance,
+ STATUS_REG, SR_REQ, 0, 5 * HZ) < 0)
+   break;
 
dprintk(NDEBUG_HANDSHAKE, "scsi%d: req false, handshake 
complete\n", HOSTNO);
 
@@ -1806,10 +1807,10 @@ static int NCR5380_transfer_pio(struct S
*data = d;
tmp = NCR5380_read(STATUS_REG);
/* The phase read from the bus is valid if either REQ is (already)
-* asserted or if ACK hasn't been released yet. The latter is the case 
if
-* we're in MSGIN and all wanted bytes have been received.
+* asserted or if ACK hasn't been released yet. The latter applies if
+* we're in MSG IN, DATA IN or STATUS and all bytes have been received.
 */
-   if ((tmp & SR_REQ) || (p == PHASE_MSGIN && c == 0))
+   if ((tmp & SR_REQ) || ((tmp & SR_IO) && c == 0))
*phase = tmp & PHASE_MASK;
else
*phase = PHASE_UNKNOWN;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 26/77] ncr5380: Fix NCR5380_transfer_pio() result

2015-12-21 Thread Hannes Reinecke

On 12/22/2015 02:18 AM, Finn Thain wrote:

According to the SCSI-2 draft revision 10L, atari_NCR5380.c is correct
when it says that the phase lines are valid up until ACK is negated
following the transmission of the last byte in MESSAGE IN phase. This is
true for all information transfer phases, from target to initiator.

Sample the phase bits in STATUS_REG so that NCR5380_transfer_pio() can
return the correct result. The return value is presently unused (perhaps
because of bugs like this) but this change at least fixes the caller's
phase variable, which is passed by reference.

Signed-off-by: Finn Thain 

---
  drivers/scsi/NCR5380.c   |   12 +---
  drivers/scsi/atari_NCR5380.c |   11 ++-
  2 files changed, 15 insertions(+), 8 deletions(-)


Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
--
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/