CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]    2024/12/20 15:18:27

Modified files:
        sys/dev/fdt    : virtio_mmio.c 
        sys/dev/pci    : virtio_pci.c 
        sys/dev/pv     : if_vio.c vioblk.c viocon.c viogpu.c viomb.c 
                         viornd.c vioscsi.c virtio.c virtiovar.h vmmci.c 

Log message:
virtio: Refactor attach logic

virtio 1.x requires that all queue setup, including the queue interrupt
vector, is done before setting the queue_enable register to 1. This
conflicts with how we do things right now:

* We implicitly make queue setup in virtio_alloc_vq(), which is called
from the child driver attach functions. This also sets queue_enable=1.

* Later, we allocate the interrupts and set the queue interrupt vectors
in the second half of the virtio transport attach functions.

This is a violation of a MUST from the standard and causes problems with
some hypervisors, in particular those that have no virtio 0.9 support,
which has no such ordering requirements.

To fix this:

* Move the interrupt allocation to a new virtio_attach_finish() function.
This does all queue setup, including the interrupt vectors.

* Don't call virtio_setup_queue() in virtio_alloc_vq() anymore.

* We can also move the setting of the DRIVER_OK flag into this function.
virtio_attach_finish() must be called before using any virtqueue or
writing any virtio config register.

While there,

* also streamline the attach error handling in all drivers.

* skip initially setting sc_config_change to NULL, the softc is
initialized to 0.

ok jan@
tested by bluhm@

Reply via email to