Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions supervisor/virtio-gpu.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand All @@ -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
Expand Down Expand Up @@ -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")))
Expand Down
13 changes: 13 additions & 0 deletions supervisor/virtio-pci.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions supervisor/virtio.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down