diff --git a/supervisor/virtio-gpu.lisp b/supervisor/virtio-gpu.lisp index 2aec83e2d..f6f79cfac 100644 --- a/supervisor/virtio-gpu.lisp +++ b/supervisor/virtio-gpu.lisp @@ -241,6 +241,12 @@ must not be allocated by virgl.") (sys.int::memref-unsigned-byte-64 (+ addr +virtio-gpu-ctrl-hdr-fence-id+) 0) fence-id (sys.int::memref-unsigned-byte-32 (+ addr +virtio-gpu-ctrl-hdr-ctx-id+) 0) ctx-id))) +(defun virtio-gpu-irq-handler (gpu) + (let* ((device (virtio-gpu-virtio-device gpu)) + (events (virtio:virtio-device-specific-header/32 device +virtio-gpu-config-events-read+))) + (when (not (zerop events)) + (setf (virtio:virtio-device-specific-header/32 device +virtio-gpu-config-events-clear+) events)))) + (defun virtio-gpu-issue-command (gpu command-length response-length) (let* ((req-phys (virtio-gpu-request-phys gpu)) (dev (virtio-gpu-virtio-device gpu)) @@ -306,7 +312,9 @@ must not be allocated by virgl.") (base (virtio-gpu-response-address gpu)) (pmode nil) (pmode-width nil) - (pmode-height nil)) + (pmode-height nil) + (min-width 1024) + (min-height 768)) (when (not (eql resp-type +virtio-gpu-resp-ok-display-info+)) (sup:debug-print-line "virtio-gpu: Invalid response during get-display-info: " resp-type) (return-from virtio-gpu-get-display-info nil)) @@ -319,14 +327,11 @@ must not be allocated by virgl.") (enabled (sys.int::memref-unsigned-byte-32 (+ base offset +virtio-gpu-display-enabled+) 0)) (flags (sys.int::memref-unsigned-byte-32 (+ base offset +virtio-gpu-display-flags+) 0))) (sup:debug-print-line "Display " i ": x:" x " y:" y " w: " width " h:" height " en:" enabled " flg:" flags) - (when (not pmode) - #++ - (setf pmode i - pmode-width width - pmode-height height) + (when (and (not pmode) + (not (zerop enabled))) (setf pmode i - pmode-width 1024 - pmode-height 768)))) + pmode-width (max width min-width) + pmode-height (max height min-height))))) (values pmode pmode-width pmode-height)))) (define-virtio-gpu-command virtio-gpu-resource-create-2d @@ -543,6 +548,10 @@ must not be allocated by virgl.") (let ((gpu (make-virtio-gpu :virtio-device device))) (setf (virtio-gpu-command-lock gpu) (sup:make-mutex gpu)) + (virtio:virtio-attach-irq device + (lambda (interrupt-frame irq) + (declare (ignore interrupt-frame irq)) + (virtio-gpu-irq-handler gpu))) ;; Allocate some memory for the request header & footer. (let* ((frame (or (sup::allocate-physical-pages 1) (panic "Unable to allocate memory for virtio gpu request"))) diff --git a/supervisor/virtio-pci.lisp b/supervisor/virtio-pci.lisp index d27d5c256..a78ca7978 100644 --- a/supervisor/virtio-pci.lisp +++ b/supervisor/virtio-pci.lisp @@ -158,6 +158,19 @@ (if value 1 0)) value)) +(defun virtio-pci-transport-isr-status (device) + (multiple-value-bind (loc real-offset) + (virtio-pci-access (virtio-pci-device-isr-cfg device) 0) + (pci:pci-io-region/8 loc real-offset))) + +(defun virtio-pci-transport-device-irq (device) + (pci:pci-intr-line (virtio-pci-device-pci-device device))) + +(defun virtio-pci-transport-ack-irq (device status) + ;; Reading ISR status acknowledges the interrupt for modern virtio-pci. + (declare (ignore device status)) + nil) + (defun virtio-pci-transport-kick (device vq-id) "Notify the device that new buffers have been added to VQ-ID." (setf (virtio-pci-common-cfg-queue-select device) vq-id) diff --git a/supervisor/virtio.lisp b/supervisor/virtio.lisp index 9e4989ae4..7d368c6d5 100644 --- a/supervisor/virtio.lisp +++ b/supervisor/virtio.lisp @@ -513,10 +513,12 @@ (sup:irq-attach (sup:platform-irq (virtio-device-irq device)) (lambda (interrupt-frame irq) (let ((status (virtio-isr-status device))) - (when (logbitp 0 status) - (funcall handler interrupt-frame irq)) - (virtio-ack-irq device status)) - :completed) + (cond ((zerop status) + :rejected) + (t + (funcall handler interrupt-frame irq) + (virtio-ack-irq device status) + :completed)))) device)) ;; FIXME: Access to this needs to be protected.