Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Redefining bus_space functions in drivers is a b...



details:   https://anonhg.NetBSD.org/src/rev/89e12fc1ba7b
branches:  trunk
changeset: 958901:89e12fc1ba7b
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sun Jan 24 15:34:07 2021 +0000

description:
Redefining bus_space functions in drivers is a bad idea, and we just
should't be in the habit of doing so.  Besides, the previous "solutions"
still did not compile correctly, and this does, so let's be done with
this nonsense, shall we?

diffstat:

 sys/dev/pci/virtio_pci.c |  30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diffs (76 lines):

diff -r 53b764d590be -r 89e12fc1ba7b sys/dev/pci/virtio_pci.c
--- a/sys/dev/pci/virtio_pci.c  Sun Jan 24 15:33:02 2021 +0000
+++ b/sys/dev/pci/virtio_pci.c  Sun Jan 24 15:34:07 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.23 2021/01/24 15:33:02 reinoud Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.24 2021/01/24 15:34:07 thorpej 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.23 2021/01/24 15:33:02 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.24 2021/01/24 15:34:07 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -738,19 +738,19 @@
 /*
  * By definition little endian only in v1.0 and 8 byters are allowed to be
  * written as two 4 byters
- */
-#ifndef __HAVE_BUS_SPACE_8
-/*
+ *
  * This is not a general purpose function that can be used in any
  * driver. Virtio specifically allows the 8 byte bus transaction
  * to be split into two 4 byte transactions. Do not copy/use it
  * in other device drivers unless you know that the device accepts it.
  */
 static __inline void
-bus_space_write_8(bus_space_tag_t iot, bus_space_handle_t ioh,
+virtio_pci_bus_space_write_8(bus_space_tag_t iot, bus_space_handle_t ioh,
      bus_size_t offset, uint64_t value)
 {
-#if _QUAD_HIGHWORD
+#if defined(__HAVE_BUS_SPACE_8)
+       bus_space_write_8(iot, ioh, offset, value);
+#elif _QUAD_HIGHWORD
        bus_space_write_4(iot, ioh, offset, BUS_ADDR_LO32(value));
        bus_space_write_4(iot, ioh, offset + 4, BUS_ADDR_HI32(value));
 #else
@@ -758,7 +758,6 @@
        bus_space_write_4(iot, ioh, offset + 4, BUS_ADDR_LO32(value));
 #endif
 }
-#endif
 
 static void
 virtio_pci_setup_queue_10(struct virtio_softc *sc, uint16_t idx, uint64_t addr)
@@ -772,15 +771,18 @@
        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);
+               virtio_pci_bus_space_write_8(iot, ioh,
+                   VIRTIO_CONFIG1_QUEUE_DESC,   0);
+               virtio_pci_bus_space_write_8(iot, ioh,
+                   VIRTIO_CONFIG1_QUEUE_AVAIL,  0);
+               virtio_pci_bus_space_write_8(iot, ioh,
+                   VIRTIO_CONFIG1_QUEUE_USED,   0);
        } else {
-               bus_space_write_8(iot, ioh,
+               virtio_pci_bus_space_write_8(iot, ioh,
                        VIRTIO_CONFIG1_QUEUE_DESC, addr);
-               bus_space_write_8(iot, ioh,
+               virtio_pci_bus_space_write_8(iot, ioh,
                        VIRTIO_CONFIG1_QUEUE_AVAIL, addr + vq->vq_availoffset);
-               bus_space_write_8(iot, ioh,
+               virtio_pci_bus_space_write_8(iot, ioh,
                        VIRTIO_CONFIG1_QUEUE_USED, addr + vq->vq_usedoffset);
                bus_space_write_2(iot, ioh,
                        VIRTIO_CONFIG1_QUEUE_ENABLE, 1);



Home | Main Index | Thread Index | Old Index