Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1533834
| From | Finn Thain <fthain@telegraphics.com.au> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 06/10] via-cuda: Avoid TREQ race condition |
| Date | 2016-12-01 07:20 +0100 |
| Message-ID | <sJsSR-7F-3@gated-at.bofh.it> (permalink) |
| References | <sJsJc-8rI-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
When a read transaction completes, one of several things will happen:
either a new transfer is started by the driver, a new transfer request
is raised by the Cuda (i.e. TREQ asserted), or both happen at once.
When both happen at once, there is a race condition between the TREQ test
in the read_done state and the same test in cuda_start(). Moreover, the
former test uses a stale TREQ value.
Theoretically, this can result in the undesirable outcome that the
interrupt handler completes with the state machine 'idle' when it should
instead start the next transaction.
Avoid this race by calling cuda_start() first and then confirming that it
succeeded. If not, test the current TREQ value before entering the
'reading' state.
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
drivers/macintosh/via-cuda.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index e65c0b6..ff9062a 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -605,12 +605,11 @@ cuda_interrupt(int irq, void *arg)
memcpy(ibuf, cuda_rbuf, ibuf_len);
}
reply_ptr = cuda_rbuf;
- if (TREQ_asserted(status)) {
+ cuda_state = idle;
+ cuda_start();
+ if (cuda_state == idle && TREQ_asserted(in_8(&via[B]))) {
assert_TIP();
cuda_state = reading;
- } else {
- cuda_state = idle;
- cuda_start();
}
break;
--
2.7.3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/10] Replace via-maciisi with via-cuda driver Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:10 +0100 [PATCH 03/10] via-cuda: Add TREQ, TIP and TACK signal helpers Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:10 +0100 [PATCH 04/10] via-cuda: Prevent read buffer overflow Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:10 +0100 [PATCH 10/10] m68k/mac: Replace via-maciisi driver with via-cuda driver Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:10 +0100 [PATCH 06/10] via-cuda: Avoid TREQ race condition Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100 [PATCH 05/10] via-cuda: Fix re-initialization of reply_ptr and reading_reply Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100 [PATCH 09/10] via-cuda: Add support for Egret system controller Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100 [PATCH 01/10] via-cuda: Cleanup printk calls Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100 [PATCH 08/10] via-cuda: Initialize data_index early and increment consistently Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100 [PATCH 02/10] via-cuda: Remove redundant temporary variable Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100 [PATCH 07/10] via-cuda: Use spinlock_irq_save/restore instead of enable/disable_irq Finn Thain <fthain@telegraphics.com.au> - 2016-12-01 07:20 +0100
csiph-web