Request for testing bus_get_bus_tag() nexus method

Marcin Mazurek mma at semihalf.com
Fri Feb 5 16:11:20 UTC 2016


Hello,

I am looking for testers for a patch to add BUS_GET_BUS_TAG method to some
platforms nexus that return per platform specific default tag.

It works fine on arm, but I do not have any powerpc or mips hardware to
test it on,
so I would like it if this could be tested on these platforms using this
code to check
if it does not break them.

Any comments and feedback are welcome.

Thanks,
Marcin
-------------- next part --------------
diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c
index 8dce36c..e1e983f 100644
--- a/sys/arm/arm/nexus.c
+++ b/sys/arm/arm/nexus.c
@@ -85,6 +85,7 @@ static	struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
     u_long, u_long, u_long, u_int);
 static	int nexus_activate_resource(device_t, device_t, int, int,
     struct resource *);
+static bus_space_tag_t nexus_get_bus_tag(device_t, device_t);
 #ifdef ARM_INTRNG
 #ifdef SMP
 static	int nexus_bind_intr(device_t, device_t, struct resource *, int);
@@ -124,6 +125,7 @@ static device_method_t nexus_methods[] = {
 	DEVMETHOD(bus_release_resource,	nexus_release_resource),
 	DEVMETHOD(bus_setup_intr,	nexus_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	nexus_teardown_intr),
+	DEVMETHOD(bus_get_bus_tag,	nexus_get_bus_tag),
 #ifdef ARM_INTRNG
 	DEVMETHOD(bus_describe_intr,	nexus_describe_intr),
 #ifdef SMP
@@ -260,6 +262,17 @@ nexus_release_resource(device_t bus, device_t child, int type, int rid,
 	return (rman_release_resource(res));
 }
 
+static bus_space_tag_t
+nexus_get_bus_tag(device_t bus __unused, device_t child __unused)
+{
+
+#ifdef FDT
+		return(fdtbus_bs_tag);
+#else
+		return((void *)1);
+#endif
+}
+
 static int
 nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
     enum intr_polarity pol)
diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c
index 807993b..3473649 100644
--- a/sys/arm64/arm64/nexus.c
+++ b/sys/arm64/arm64/nexus.c
@@ -112,6 +112,7 @@ static	int nexus_deactivate_resource(device_t, device_t, int, int,
 static int nexus_setup_intr(device_t dev, device_t child, struct resource *res,
     int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep);
 static int nexus_teardown_intr(device_t, device_t, struct resource *, void *);
+static bus_space_tag_t nexus_get_bus_tag(device_t, device_t);
 
 #ifdef FDT
 static int nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent,
@@ -130,6 +131,7 @@ static device_method_t nexus_methods[] = {
 	DEVMETHOD(bus_deactivate_resource,	nexus_deactivate_resource),
 	DEVMETHOD(bus_setup_intr,	nexus_setup_intr),
 	DEVMETHOD(bus_teardown_intr,	nexus_teardown_intr),
+	DEVMETHOD(bus_get_bus_tag,	nexus_get_bus_tag),
 
 	{ 0, 0 }
 };
@@ -292,6 +294,13 @@ nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
 	return (arm_teardown_intr(ih));
 }
 
+static bus_space_tag_t
+nexus_get_bus_tag(device_t bus __unused, device_t child __unused)
+{
+
+		return(&memmap_bus);
+}
+
 static int
 nexus_activate_resource(device_t bus, device_t child, int type, int rid,
     struct resource *r)
diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m
index bafa448..d29bfb9 100644
--- a/sys/kern/bus_if.m
+++ b/sys/kern/bus_if.m
@@ -637,6 +637,17 @@ METHOD bus_dma_tag_t get_dma_tag {
 } DEFAULT bus_generic_get_dma_tag;
 
 /**
+ * @brief Returns bus_space_tag_t for use w/ devices on the bus.
+ *
+ * @param _dev		the parent device of @p _child
+ * @param _child	the device to which the tag will belong
+ */
+METHOD bus_space_tag_t get_bus_tag {
+	device_t	_dev;
+	device_t	_child;
+} DEFAULT bus_generic_get_bus_tag;
+
+/**
  * @brief Allow the bus to determine the unit number of a device.
  *
  * @param _dev		the parent device of @p _child
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index b1159b6..f8798d5 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -4095,6 +4095,22 @@ bus_generic_get_dma_tag(device_t dev, device_t child)
 }
 
 /**
+ * @brief Helper function for implementing BUS_GET_BUS_TAG().
+ *
+ * This simple implementation of BUS_GET_BUS_TAG() simply calls the
+ * BUS_GET_BUS_TAG() method of the parent of @p dev.
+ */
+bus_space_tag_t
+bus_generic_get_bus_tag(device_t dev, device_t child)
+{
+
+	/* Propagate up the bus hierarchy until someone handles it. */
+	if (dev->parent != NULL)
+		return (BUS_GET_BUS_TAG(dev->parent, child));
+	return (NULL);
+}
+
+/**
  * @brief Helper function for implementing BUS_GET_RESOURCE().
  *
  * This implementation of BUS_GET_RESOURCE() uses the
@@ -4574,6 +4590,23 @@ bus_get_dma_tag(device_t dev)
 }
 
 /**
+ * @brief Wrapper function for BUS_GET_BUS_TAG().
+ *
+ * This function simply calls the BUS_GET_BUS_TAG() method of the
+ * parent of @p dev.
+ */
+bus_space_tag_t
+bus_get_bus_tag(device_t dev)
+{
+	device_t parent;
+
+	parent = device_get_parent(dev);
+	if (parent == NULL)
+		return (NULL);
+	return (BUS_GET_BUS_TAG(parent, dev));
+}
+
+/**
  * @brief Wrapper function for BUS_GET_DOMAIN().
  *
  * This function simply calls the BUS_GET_DOMAIN() method of the
diff --git a/sys/powerpc/powerpc/nexus.c b/sys/powerpc/powerpc/nexus.c
index 8a4d815..560a46a 100644
--- a/sys/powerpc/powerpc/nexus.c
+++ b/sys/powerpc/powerpc/nexus.c
@@ -66,6 +66,7 @@ static bus_setup_intr_t nexus_setup_intr;
 static bus_teardown_intr_t nexus_teardown_intr;
 static bus_activate_resource_t nexus_activate_resource;
 static bus_deactivate_resource_t nexus_deactivate_resource;
+static bus_space_tag_t nexus_get_bus_tag(device_t, device_t);
 #ifdef SMP
 static bus_bind_intr_t nexus_bind_intr;
 #endif
@@ -87,6 +88,7 @@ static device_method_t nexus_methods[] = {
 	DEVMETHOD(bus_bind_intr,	nexus_bind_intr),
 #endif
 	DEVMETHOD(bus_config_intr,	nexus_config_intr),
+	DEVMETHOD(bus_get_bus_tag,	nexus_get_bus_tag),
 
 	/* ofw_bus interface */
 	DEVMETHOD(ofw_bus_map_intr,	nexus_ofw_map_intr),
@@ -155,6 +157,13 @@ nexus_teardown_intr(device_t bus __unused, device_t child __unused,
 	return (powerpc_teardown_intr(ih));
 }
 
+static bus_space_tag_t
+nexus_get_bus_tag(device_t bus __unused, device_t child __unused)
+{
+
+	return(&bs_be_tag);
+}
+
 #ifdef SMP
 static int
 nexus_bind_intr(device_t bus __unused, device_t child __unused,
@@ -224,4 +233,3 @@ nexus_deactivate_resource(device_t bus __unused, device_t child __unused,
 
 	return (rman_deactivate_resource(r));
 }
-
diff --git a/sys/sparc64/sparc64/nexus.c b/sys/sparc64/sparc64/nexus.c
index 30374e5..f5ce472 100644
--- a/sys/sparc64/sparc64/nexus.c
+++ b/sys/sparc64/sparc64/nexus.c
@@ -98,6 +98,7 @@ static bus_bind_intr_t nexus_bind_intr;
 #endif
 static bus_describe_intr_t nexus_describe_intr;
 static bus_get_dma_tag_t nexus_get_dma_tag;
+static bus_get_bus_tag_t nexus_get_bus_tag;
 static ofw_bus_get_devinfo_t nexus_get_devinfo;
 
 static int nexus_inlist(const char *, const char *const *);
@@ -135,6 +136,7 @@ static device_method_t nexus_methods[] = {
 #endif
 	DEVMETHOD(bus_describe_intr,	nexus_describe_intr),
 	DEVMETHOD(bus_get_dma_tag,	nexus_get_dma_tag),
+	DEVMETHOD(bus_get_bus_tag,	nexus_get_bus_tag),
 
 	/* ofw_bus interface */
 	DEVMETHOD(ofw_bus_get_devinfo,	nexus_get_devinfo),
@@ -502,6 +504,13 @@ nexus_get_dma_tag(device_t bus __unused, device_t child __unused)
 	return (&nexus_dmatag);
 }
 
+static bus_space_tag_t
+nexus_get_bus_tag(device_t bus __unused, device_t child __unused)
+{
+
+	return (&nexus_bustag);
+}
+
 static const struct ofw_bus_devinfo *
 nexus_get_devinfo(device_t bus __unused, device_t child)
 {
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
index 42d3a3f..9cd2174 100644
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -30,6 +30,7 @@
 #define _SYS_BUS_H_
 
 #include <machine/_limits.h>
+#include <machine/_bus.h>
 #include <sys/_bus_dma.h>
 #include <sys/ioccom.h>
 
@@ -383,6 +384,8 @@ int	bus_generic_detach(device_t dev);
 void	bus_generic_driver_added(device_t dev, driver_t *driver);
 bus_dma_tag_t
 	bus_generic_get_dma_tag(device_t dev, device_t child);
+bus_space_tag_t
+	bus_generic_get_bus_tag(device_t dev, device_t child);
 int	bus_generic_get_domain(device_t dev, device_t child, int *domain);
 struct resource_list *
 	bus_generic_get_resource_list (device_t, device_t);
@@ -448,6 +451,7 @@ int	bus_activate_resource(device_t dev, int type, int rid,
 int	bus_deactivate_resource(device_t dev, int type, int rid,
 				struct resource *r);
 bus_dma_tag_t bus_get_dma_tag(device_t dev);
+bus_space_tag_t bus_get_bus_tag(device_t dev);
 int	bus_get_domain(device_t dev, int *domain);
 int	bus_release_resource(device_t dev, int type, int rid,
 			     struct resource *r);


More information about the freebsd-ppc mailing list