Module Name: src Committed By: reinoud Date: Thu Jan 21 20:48:33 UTC 2021
Modified Files: src/sys/dev/pci: virtio_pci.c Log Message: Remove dependency on bus_space_write_8() for i386 and instead implement it as two bus_space_write_4()'s as allowed in the spec. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/pci/virtio_pci.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/virtio_pci.c diff -u src/sys/dev/pci/virtio_pci.c:1.17 src/sys/dev/pci/virtio_pci.c:1.18 --- src/sys/dev/pci/virtio_pci.c:1.17 Thu Jan 21 08:17:13 2021 +++ src/sys/dev/pci/virtio_pci.c Thu Jan 21 20:48:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: virtio_pci.c,v 1.17 2021/01/21 08:17:13 martin Exp $ */ +/* $NetBSD: virtio_pci.c,v 1.18 2021/01/21 20:48:33 reinoud Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.17 2021/01/21 08:17:13 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.18 2021/01/21 20:48:33 reinoud Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -727,6 +727,14 @@ virtio_pci_read_queue_size_10(struct vir return bus_space_read_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_SIZE); } +/* + * By definition little endian only in v1.0 and 8 byters are allowed to be + * written as two 4 byters + */ +#define bus_space_write_le_8(iot, ioh, reg, val) \ + bus_space_write_4(iot, ioh, reg, ((uint64_t) (val)) & 0xffffffff); \ + bus_space_write_4(iot, ioh, reg + 4, ((uint64_t) (val)) >> 32); + static void virtio_pci_setup_queue_10(struct virtio_softc *sc, uint16_t idx, uint64_t addr) { @@ -739,15 +747,15 @@ virtio_pci_setup_queue_10(struct virtio_ bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_SELECT, vq->vq_index); if (addr == 0) { bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_ENABLE, 0); - bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC, 0); - bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL, 0); - bus_space_write_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED, 0); + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC, 0); + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL, 0); + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED, 0); } else { - bus_space_write_8(iot, ioh, + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_DESC, addr); - bus_space_write_8(iot, ioh, + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_AVAIL, addr + vq->vq_availoffset); - bus_space_write_8(iot, ioh, + bus_space_write_le_8(iot, ioh, VIRTIO_CONFIG1_QUEUE_USED, addr + vq->vq_usedoffset); bus_space_write_2(iot, ioh, VIRTIO_CONFIG1_QUEUE_ENABLE, 1); @@ -763,6 +771,7 @@ virtio_pci_setup_queue_10(struct virtio_ VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR, vec); } } +#undef bus_space_write_le_8 static void virtio_pci_set_status_10(struct virtio_softc *sc, int status)