summary refs log tree commit diff stats
path: root/hw/misc/macio/cuda.c
diff options
context:
space:
mode:
authorMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2020-06-23 21:49:30 +0100
committerMark Cave-Ayland <mark.cave-ayland@ilande.co.uk>2020-06-26 10:13:52 +0100
commit45c9d721ef9ea4e50dbede53bc97922767db70b8 (patch)
treea7a2631b95ed15609be9df6e77a3bacf2d8cbeb8 /hw/misc/macio/cuda.c
parent4e5df0369fb5a49ed26518dccffeb03a252352db (diff)
downloadfocaccia-qemu-45c9d721ef9ea4e50dbede53bc97922767db70b8.tar.gz
focaccia-qemu-45c9d721ef9ea4e50dbede53bc97922767db70b8.zip
cuda: add adb_autopoll_block() and adb_autopoll_unblock() functions
Ensure that the CUDA buffer is protected from autopoll requests overwriting
its contents whilst existing CUDA requests are in progress.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Tested-by: Finn Thain <fthain@telegraphics.com.au>
Acked-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200623204936.24064-17-mark.cave-ayland@ilande.co.uk>
Diffstat (limited to 'hw/misc/macio/cuda.c')
-rw-r--r--hw/misc/macio/cuda.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index b7071e89d5..5bbc7770fa 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -116,6 +116,7 @@ static void cuda_update(CUDAState *s)
 {
     MOS6522CUDAState *mcs = &s->mos6522_cuda;
     MOS6522State *ms = MOS6522(mcs);
+    ADBBusState *adb_bus = &s->adb_bus;
     int packet_received, len;
 
     packet_received = 0;
@@ -126,6 +127,9 @@ static void cuda_update(CUDAState *s)
             /* data output */
             if ((ms->b & (TACK | TIP)) != (s->last_b & (TACK | TIP))) {
                 if (s->data_out_index < sizeof(s->data_out)) {
+                    if (s->data_out_index == 0) {
+                        adb_autopoll_block(adb_bus);
+                    }
                     trace_cuda_data_send(ms->sr);
                     s->data_out[s->data_out_index++] = ms->sr;
                     cuda_delay_set_sr_int(s);
@@ -140,6 +144,7 @@ static void cuda_update(CUDAState *s)
                     /* indicate end of transfer */
                     if (s->data_in_index >= s->data_in_size) {
                         ms->b = (ms->b | TREQ);
+                        adb_autopoll_unblock(adb_bus);
                     }
                     cuda_delay_set_sr_int(s);
                 }