macintosh/via-cuda: Don't rely on Cuda to end a transfer

This change “macintosh/via-cuda: Don’t rely on Cuda to end a transfer” in Linux kernel is authored by Finn Thain <fthain [at]> on Tue Jan 15 15:18:56 2019 +1100.

macintosh/via-cuda: Don't rely on Cuda to end a transfer

Certain Cuda transfers have to be ended by the driver. According
to Apple's open source Cuda driver, as found in mkLinux and XNU, this
applies to any "open ended request such as PRAM read". This fixes an
infinite polling loop in cuda_pram_read_byte().

Tested-by: Stan Johnson <>
Signed-off-by: Finn Thain <>
Signed-off-by: Greg Kroah-Hartman <>

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit 458c77f.

There are 8 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/macintosh/via-cuda.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index bbec6ac..3581abf 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -569,6 +569,7 @@ __init cuda_init_via(void)
     unsigned char ibuf[16];
     int ibuf_len = 0;
     int complete = 0;
+    bool full;
     spin_lock_irqsave(&cuda_lock, flags);
@@ -656,12 +657,13 @@ __init cuda_init_via(void)
     case reading:
-	if (reading_reply ? ARRAY_FULL(current_req->reply, reply_ptr)
-	                  : ARRAY_FULL(cuda_rbuf, reply_ptr))
+	full = reading_reply ? ARRAY_FULL(current_req->reply, reply_ptr)
+	                     : ARRAY_FULL(cuda_rbuf, reply_ptr);
+	if (full)
 	    *reply_ptr++ = in_8(&via[SR]);
-	if (!TREQ_asserted(status)) {
+	if (!TREQ_asserted(status) || full) {
 	    if (mcu_is_egret)
 	    /* that's all folks */

The commit for this change in Linux stable tree is 458c77f (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *