aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kurz <groug@kaod.org>2020-03-09 23:43:12 +0100
committerAlexey Kardashevskiy <aik@ozlabs.ru>2020-03-11 15:43:22 +1100
commitcf28264196e596c11d0d47f6150dfef5c0e4239f (patch)
treebfd0b8f9a126e98ae9e43ca1bec2faa37516bd38
parent1641d2d5ebdf67d515d7679f96d0623b5886b630 (diff)
downloadSLOF-cf28264196e596c11d0d47f6150dfef5c0e4239f.zip
SLOF-cf28264196e596c11d0d47f6150dfef5c0e4239f.tar.gz
SLOF-cf28264196e596c11d0d47f6150dfef5c0e4239f.tar.bz2
virtio-serial: Rework shutdown sequence
The "io" word of term-io.fs opens two separate instances of the device for stdin and stdout. The prom_init() function in Linux closes stdin at some point, which internally calls quiesce and shuts the device down through a quiesce hook. When the "open-count" variable in virtio-serial.fs reaches 0, ie. when closing the last instance, we call "close" two times, which is clearly wrong. This never hits however because the stdout instance is never closed which prevents "open-count" to reach 0. It would make more sense to shutdown the device when closing the last instance, for symmetry with the first open that initializes the device. Change the shutdown sequence to do that rather than relying on a quiesce hook. Have quiesce to explicitly close stdout, which is supposedly the last instance, and shutdown the device. Signed-off-by: Greg Kurz <groug@kaod.org> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
-rw-r--r--board-qemu/slof/virtio-serial.fs12
-rw-r--r--slof/fs/client.fs5
2 files changed, 8 insertions, 9 deletions
diff --git a/board-qemu/slof/virtio-serial.fs b/board-qemu/slof/virtio-serial.fs
index a99293f..e307231 100644
--- a/board-qemu/slof/virtio-serial.fs
+++ b/board-qemu/slof/virtio-serial.fs
@@ -19,13 +19,8 @@ virtio-setup-vd VALUE virtiodev
\ Quiescence the virtqueue of this device so that no more background
\ transactions can be pending.
: shutdown ( -- )
- initialized? IF
- my-phandle node>path open-dev ?dup IF
- virtiodev virtio-serial-shutdown
- close-dev
- THEN
- FALSE to initialized?
- THEN
+ virtiodev virtio-serial-shutdown
+ FALSE to initialized?
;
: virtio-serial-term-emit
@@ -39,7 +34,6 @@ virtio-setup-vd VALUE virtiodev
: init ( -- )
virtiodev virtio-serial-init drop
TRUE to initialized?
- ['] shutdown add-quiesce-xt
;
0 VALUE open-count
@@ -58,7 +52,7 @@ virtiodev virtio-serial-init drop
: close
open-count 0> IF
open-count 1 - dup to open-count
- 0= IF close THEN
+ 0= IF shutdown THEN
THEN
close
;
diff --git a/slof/fs/client.fs b/slof/fs/client.fs
index db7a192..76231f9 100644
--- a/slof/fs/client.fs
+++ b/slof/fs/client.fs
@@ -203,6 +203,11 @@ ALSO client-voc DEFINITIONS
\ End of life of SLOF now, call platform quiesce as quiesce
\ is an undocumented extension and not everybody supports it
close-dev
+ \ Some device, eg. virtio-serial, need all instances to be
+ \ closed in order to be reset properly
+ s" stdout" get-chosen IF
+ decode-int nip nip close-dev
+ THEN
quiesce
ELSE
close-dev