git: 4740d47238cf - main - virtio/mmio: Remove the unused virtio_mmio_if.m

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Thu, 21 Aug 2025 08:44:00 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=4740d47238cf2d707aae8f060fa37ac046bd06dc

commit 4740d47238cf2d707aae8f060fa37ac046bd06dc
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2025-08-19 03:53:52 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2025-08-21 08:37:53 +0000

    virtio/mmio: Remove the unused virtio_mmio_if.m
    
    The only driver I know that implemented this interface was removed 7
    months ago. Remove the interface and platform from the softc.
    
    Reviewed by:    imp
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D51992
---
 sys/conf/files                        |  1 -
 sys/dev/virtio/mmio/virtio_mmio.c     | 48 ++---------------
 sys/dev/virtio/mmio/virtio_mmio.h     |  1 -
 sys/dev/virtio/mmio/virtio_mmio_fdt.c | 47 -----------------
 sys/dev/virtio/mmio/virtio_mmio_if.m  | 99 -----------------------------------
 5 files changed, 3 insertions(+), 193 deletions(-)

diff --git a/sys/conf/files b/sys/conf/files
index 8bb14bd3d953..d89813c70355 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -3451,7 +3451,6 @@ dev/virtio/mmio/virtio_mmio.c		optional	virtio_mmio
 dev/virtio/mmio/virtio_mmio_acpi.c	optional	virtio_mmio acpi
 dev/virtio/mmio/virtio_mmio_cmdline.c	optional	virtio_mmio
 dev/virtio/mmio/virtio_mmio_fdt.c	optional	virtio_mmio fdt
-dev/virtio/mmio/virtio_mmio_if.m	optional	virtio_mmio
 dev/virtio/network/if_vtnet.c		optional	vtnet
 dev/virtio/balloon/virtio_balloon.c	optional	virtio_balloon
 dev/virtio/block/virtio_blk.c		optional	virtio_blk
diff --git a/sys/dev/virtio/mmio/virtio_mmio.c b/sys/dev/virtio/mmio/virtio_mmio.c
index 5a81c8a24779..fe531fced998 100644
--- a/sys/dev/virtio/mmio/virtio_mmio.c
+++ b/sys/dev/virtio/mmio/virtio_mmio.c
@@ -53,7 +53,6 @@
 #include <dev/virtio/virtqueue.h>
 #include <dev/virtio/mmio/virtio_mmio.h>
 
-#include "virtio_mmio_if.h"
 #include "virtio_bus_if.h"
 #include "virtio_if.h"
 
@@ -79,7 +78,6 @@ static int	vtmmio_alloc_virtqueues(device_t, int,
 		    struct vq_alloc_info *);
 static int	vtmmio_setup_intr(device_t, enum intr_type);
 static void	vtmmio_stop(device_t);
-static void	vtmmio_poll(device_t);
 static int	vtmmio_reinit(device_t, uint64_t);
 static void	vtmmio_reinit_complete(device_t);
 static void	vtmmio_notify_virtqueue(device_t, uint16_t, bus_size_t);
@@ -104,29 +102,11 @@ static void	vtmmio_vq_intr(void *);
  * I/O port read/write wrappers.
  */
 #define vtmmio_write_config_1(sc, o, v)				\
-do {								\
-	if (sc->platform != NULL)				\
-		VIRTIO_MMIO_PREWRITE(sc->platform, (o), (v));	\
-	bus_write_1((sc)->res[0], (o), (v)); 			\
-	if (sc->platform != NULL)				\
-		VIRTIO_MMIO_NOTE(sc->platform, (o), (v));	\
-} while (0)
+	bus_write_1((sc)->res[0], (o), (v))
 #define vtmmio_write_config_2(sc, o, v)				\
-do {								\
-	if (sc->platform != NULL)				\
-		VIRTIO_MMIO_PREWRITE(sc->platform, (o), (v));	\
-	bus_write_2((sc)->res[0], (o), (v));			\
-	if (sc->platform != NULL)				\
-		VIRTIO_MMIO_NOTE(sc->platform, (o), (v));	\
-} while (0)
+	bus_write_2((sc)->res[0], (o), (v))
 #define vtmmio_write_config_4(sc, o, v)				\
-do {								\
-	if (sc->platform != NULL)				\
-		VIRTIO_MMIO_PREWRITE(sc->platform, (o), (v));	\
-	bus_write_4((sc)->res[0], (o), (v));			\
-	if (sc->platform != NULL)				\
-		VIRTIO_MMIO_NOTE(sc->platform, (o), (v));	\
-} while (0)
+	bus_write_4((sc)->res[0], (o), (v))
 
 #define vtmmio_read_config_1(sc, o) \
 	bus_read_1((sc)->res[0], (o))
@@ -157,7 +137,6 @@ static device_method_t vtmmio_methods[] = {
 	DEVMETHOD(virtio_bus_alloc_virtqueues,	  vtmmio_alloc_virtqueues),
 	DEVMETHOD(virtio_bus_setup_intr,	  vtmmio_setup_intr),
 	DEVMETHOD(virtio_bus_stop,		  vtmmio_stop),
-	DEVMETHOD(virtio_bus_poll,		  vtmmio_poll),
 	DEVMETHOD(virtio_bus_reinit,		  vtmmio_reinit),
 	DEVMETHOD(virtio_bus_reinit_complete,	  vtmmio_reinit_complete),
 	DEVMETHOD(virtio_bus_notify_vq,		  vtmmio_notify_virtqueue),
@@ -220,19 +199,9 @@ vtmmio_setup_intr(device_t dev, enum intr_type type)
 {
 	struct vtmmio_softc *sc;
 	int rid;
-	int err;
 
 	sc = device_get_softc(dev);
 
-	if (sc->platform != NULL) {
-		err = VIRTIO_MMIO_SETUP_INTR(sc->platform, sc->dev,
-					vtmmio_vq_intr, sc);
-		if (err == 0) {
-			/* Okay we have backend-specific interrupts */
-			return (0);
-		}
-	}
-
 	rid = 0;
 	sc->res[1] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
 		RF_ACTIVE);
@@ -597,17 +566,6 @@ vtmmio_stop(device_t dev)
 	vtmmio_reset(device_get_softc(dev));
 }
 
-static void
-vtmmio_poll(device_t dev)
-{
-	struct vtmmio_softc *sc;
-
-	sc = device_get_softc(dev);
-
-	if (sc->platform != NULL)
-		VIRTIO_MMIO_POLL(sc->platform);
-}
-
 static int
 vtmmio_reinit(device_t dev, uint64_t features)
 {
diff --git a/sys/dev/virtio/mmio/virtio_mmio.h b/sys/dev/virtio/mmio/virtio_mmio.h
index ac6a96c1c7fe..edcbf0519acc 100644
--- a/sys/dev/virtio/mmio/virtio_mmio.h
+++ b/sys/dev/virtio/mmio/virtio_mmio.h
@@ -37,7 +37,6 @@ struct vtmmio_virtqueue;
 
 struct vtmmio_softc {
 	device_t			dev;
-	device_t			platform;
 	struct resource			*res[2];
 
 	uint64_t			vtmmio_features;
diff --git a/sys/dev/virtio/mmio/virtio_mmio_fdt.c b/sys/dev/virtio/mmio/virtio_mmio_fdt.c
index 7fba8aad8db8..bb9ea8efbaeb 100644
--- a/sys/dev/virtio/mmio/virtio_mmio_fdt.c
+++ b/sys/dev/virtio/mmio/virtio_mmio_fdt.c
@@ -63,12 +63,10 @@
 #include <dev/virtio/mmio/virtio_mmio.h>
 
 static int	vtmmio_fdt_probe(device_t);
-static int	vtmmio_fdt_attach(device_t);
 
 static device_method_t vtmmio_fdt_methods[] = {
 	/* Device interface. */
 	DEVMETHOD(device_probe,		vtmmio_fdt_probe),
-	DEVMETHOD(device_attach,	vtmmio_fdt_attach),
 
 	DEVMETHOD_END
 };
@@ -93,48 +91,3 @@ vtmmio_fdt_probe(device_t dev)
 
 	return (vtmmio_probe(dev));
 }
-
-static int
-vtmmio_setup_platform(device_t dev, struct vtmmio_softc *sc)
-{
-	phandle_t platform_node;
-	struct fdt_ic *ic;
-	phandle_t xref;
-	phandle_t node;
-
-	sc->platform = NULL;
-
-	if ((node = ofw_bus_get_node(dev)) == -1)
-		return (ENXIO);
-
-	if (OF_searchencprop(node, "platform", &xref,
-		sizeof(xref)) == -1) {
-		return (ENXIO);
-	}
-
-	platform_node = OF_node_from_xref(xref);
-
-	SLIST_FOREACH(ic, &fdt_ic_list_head, fdt_ics) {
-		if (ic->iph == platform_node) {
-			sc->platform = ic->dev;
-			break;
-		}
-	}
-
-	if (sc->platform == NULL) {
-		/* No platform-specific device. Ignore it. */
-	}
-
-	return (0);
-}
-
-static int
-vtmmio_fdt_attach(device_t dev)
-{
-	struct vtmmio_softc *sc;
-
-	sc = device_get_softc(dev);
-	vtmmio_setup_platform(dev, sc);
-
-	return (vtmmio_attach(dev));
-}
diff --git a/sys/dev/virtio/mmio/virtio_mmio_if.m b/sys/dev/virtio/mmio/virtio_mmio_if.m
deleted file mode 100644
index baebbd9a0b1c..000000000000
--- a/sys/dev/virtio/mmio/virtio_mmio_if.m
+++ /dev/null
@@ -1,99 +0,0 @@
-#-
-# Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com>
-# All rights reserved.
-#
-# This software was developed by SRI International and the University of
-# Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237)
-# ("CTSRD"), as part of the DARPA CRASH research programme.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-#    notice, this list of conditions and the following disclaimer in the
-#    documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-# SUCH DAMAGE.
-#
-#
-
-#include <sys/types.h>
-
-#
-# This is optional interface to virtio mmio backend.
-# Useful when backend is implemented not by the hardware but software, e.g.
-# by using another cpu core.
-#
-
-INTERFACE virtio_mmio;
-
-CODE {
-	static int
-	virtio_mmio_prewrite(device_t dev, size_t offset, int val)
-	{
-
-		return (1);
-	}
-
-	static int
-	virtio_mmio_note(device_t dev, size_t offset, int val)
-	{
-
-		return (1);
-	}
-
-	static int
-	virtio_mmio_setup_intr(device_t dev, device_t mmio_dev,
-					void *handler, void *ih_user)
-	{
-
-		return (1);
-	}
-};
-
-#
-# Inform backend we are going to write data at offset.
-#
-METHOD int prewrite {
-	device_t	dev;
-	size_t		offset;
-	int		val;
-} DEFAULT virtio_mmio_prewrite;
-
-#
-# Inform backend we have data wrotten to offset.
-#
-METHOD int note {
-	device_t	dev;
-	size_t		offset;
-	int		val;
-} DEFAULT virtio_mmio_note;
-
-#
-# Inform backend we are going to poll virtqueue.
-#
-METHOD int poll {
-	device_t	dev;
-};
-
-#
-# Setup backend-specific interrupts.
-#
-METHOD int setup_intr {
-	device_t	dev;
-	device_t	mmio_dev;
-	void		*handler;
-	void		*ih_user;
-} DEFAULT virtio_mmio_setup_intr;