Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Apr 2006 21:38:22 GMT
From:      John-Mark Gurney <jmg@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 94777 for review
Message-ID:  <200604072138.k37LcM93012762@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=94777

Change 94777 by jmg@jmg_carbon-60 on 2006/04/07 21:37:31

	first cut at hviommu support, this doesn't really build the iotte
	as I need to confirm w/ kmacy on what it really looks like...
	
	This also implements the long awaited, get the bus_dma_tag_t for
	the parent from your parent bus instead of using NULL...

Affected files ...

.. //depot/projects/kmacy_sun4v/src/sys/conf/files.sun4v#12 edit
.. //depot/projects/kmacy_sun4v/src/sys/kern/bus_if.m#3 edit
.. //depot/projects/kmacy_sun4v/src/sys/kern/subr_bus.c#3 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hv_pcivar.h#6 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hviommu.h#1 add
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hypervisor_api.h#11 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hv_pci.c#26 edit
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hviommu.c#1 add
.. //depot/projects/kmacy_sun4v/src/sys/sys/bus.h#3 edit

Differences ...

==== //depot/projects/kmacy_sun4v/src/sys/conf/files.sun4v#12 (text+ko) ====

@@ -56,6 +56,7 @@
 # XXX hvcons should be optional
 sun4v/sun4v/hvcons.c	standard	
 sun4v/sun4v/hcall.S	standard
+sun4v/sun4v/hviommu.c	standard
 sun4v/sun4v/identcpu.c	standard
 sun4v/sun4v/in_cksum.c	optional	inet
 sun4v/sun4v/interrupt.S	standard	no-obj

==== //depot/projects/kmacy_sun4v/src/sys/kern/bus_if.m#3 (text+ko) ====

@@ -507,3 +507,14 @@
 	enum intr_trigger _trig;
 	enum intr_polarity _pol;
 } DEFAULT bus_generic_config_intr;
+
+/**
+ * @brief Returns bus_dma_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_dma_tag_t get_dma_tag {
+	device_t	_dev;
+	device_t	_child;
+} DEFAULT bus_generic_get_dma_tag;

==== //depot/projects/kmacy_sun4v/src/sys/kern/subr_bus.c#3 (text+ko) ====

@@ -3199,6 +3199,22 @@
 }
 
 /**
+ * @brief Helper function for implementing BUS_GET_DMA_TAG().
+ *
+ * This simple implementation of BUS_GET_DMA_TAG() simply calls the
+ * BUS_GET_DMA_TAG() method of the parent of @p dev.
+ */
+bus_dma_tag_t
+bus_generic_get_dma_tag(device_t dev)
+{
+
+	/* Propagate up the bus hierarchy until someone handles it. */
+	if (dev->parent != NULL)
+		return (BUS_GET_DMA_TAG(dev->parent, dev));
+	return (NULL);
+}
+
+/**
  * @brief Helper function for implementing BUS_GET_RESOURCE().
  *
  * This implementation of BUS_GET_RESOURCE() uses the
@@ -3597,6 +3613,21 @@
 	return (BUS_CHILD_LOCATION_STR(parent, child, buf, buflen));
 }
 
+/**
+ * @brief Wrapper function for BUS_GET_DMA_TAG().
+ *
+ * This function simply calls the BUS_GET_DMA_TAG() method of the
+ * parent of @p dev.
+ */
+bus_dma_tag_t
+bus_get_dma_tag(device_t dev)
+{
+
+	if (dev->parent == NULL)
+		return (NULL);
+	return (BUS_GET_DMA_TAG(dev->parent, dev));
+}
+
 /* Resume all devices and then notify userland that we're up again. */
 static int
 root_resume(device_t dev)

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hv_pcivar.h#6 (text+ko) ====

@@ -34,6 +34,8 @@
 	devhandle_t	hs_devhandle;
 	uint8_t		hs_busnum;
 
+	struct bus_dma_tag	hs_dmatag;
+
 	struct resource	*hs_intr;
 	void		*hs_intrcookie;
 

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/hypervisor_api.h#11 (text+ko) ====

@@ -108,8 +108,20 @@
 extern uint64_t hvio_config_get(devhandle_t dev_hdl, pci_device_t pci_device, 
 				pci_config_offset_t off, pci_config_size_t size, pci_cfg_data_t *data);
 extern uint64_t hvio_config_put(devhandle_t dev_hdl, pci_device_t pci_device, 
-				pci_config_offset_t off, pci_config_size_t size, 
+				pci_config_offset_t off, pci_config_size_t size,
 				pci_cfg_data_t data);
+extern uint64_t hvio_iommu_map(devhandle_t dev_hdl, tsbid_t tsbid,
+				pages_t pages, io_attributes_t io_attributes,
+				io_page_list_t *io_page_list_p,
+				pages_t *pages_mapped);
+extern uint64_t hvio_iommu_demap(devhandle_t dev_hdl, tsbid_t tsbid,
+				pages_t pages, pages_t *pages_demapped);
+extern uint64_t hvio_iommu_getmap(devhandle_t dev_hdl, tsbid_t tsbid,
+				io_attributes_t *attributes_p,
+				r_addr_t *r_addr_p);
+extern uint64_t hvio_iommu_getbypass(devhandle_t dev_hdl, r_addr_t ra,
+				io_attributes_t io_attributes,
+				io_addr_t *io_addr_p);
 
 extern void hv_magic_trap_on(void);
 extern void hv_magic_trap_off(void);

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/hv_pci.c#26 (text+ko) ====

@@ -52,6 +52,7 @@
 #include <sparc64/pci/ofw_pci.h>
 
 #include <machine/hv_pcivar.h>
+#include <machine/hviommu.h>
 #include <machine/vmparam.h>
 #include <machine/tlb.h>
 
@@ -76,6 +77,7 @@
 static bus_activate_resource_t hvpci_activate_resource;
 static bus_deactivate_resource_t hvpci_deactivate_resource;
 static bus_release_resource_t hvpci_release_resource;
+static bus_get_dma_tag_t hvpci_get_dma_tag;
 static pcib_maxslots_t hvpci_maxslots;
 static pcib_read_config_t hvpci_read_config;
 static pcib_write_config_t hvpci_write_config;
@@ -101,6 +103,7 @@
 	DEVMETHOD(bus_activate_resource,	hvpci_activate_resource),
 	DEVMETHOD(bus_deactivate_resource,	hvpci_deactivate_resource),
 	DEVMETHOD(bus_release_resource,	hvpci_release_resource),
+	DEVMETHOD(bus_get_dma_tag,	hvpci_get_dma_tag),
 
 	/* pcib interface */
 	DEVMETHOD(pcib_maxslots,	hvpci_maxslots),
@@ -150,6 +153,7 @@
 	struct ofw_pci_ranges *range;
 	struct rman *rmanp;
 	struct hvpci_softc *sc;
+	struct hviommu *himp;
 	bus_space_tag_t *btp;
 	phandle_t node;
 #if 0
@@ -255,6 +259,11 @@
 		(*btp)->bst_type = type;
 	}
 
+	/* Setup bus_dma_tag */
+	himp = hviommu_init(sc->hs_devhandle);
+	sc->hs_dt_cookie = himp;
+	sc->hs_dt_mt = &hviommu_dma_methods;
+
 	device_add_child(dev, "pci", -1);
 
 	return (bus_generic_attach(dev));
@@ -499,3 +508,13 @@
 
 	return (0);
 }
+
+static bus_dma_tag_t
+hvpci_get_dma_tag(device_t bus, device_t child)
+{
+	struct hvpci_softc *sc;
+
+	sc = device_get_softc(bus);
+
+	return &sc->hs_dmatag;
+}

==== //depot/projects/kmacy_sun4v/src/sys/sys/bus.h#3 (text+ko) ====

@@ -252,6 +252,8 @@
 					int rid, struct resource *r);
 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);
 struct resource_list *
 	bus_generic_get_resource_list (device_t, device_t);
 int	bus_print_child_header(device_t dev, device_t child);
@@ -306,6 +308,7 @@
 			      struct resource *r);
 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);
 int	bus_release_resource(device_t dev, int type, int rid,
 			     struct resource *r);
 int	bus_free_resource(device_t dev, int type, struct resource *r);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604072138.k37LcM93012762>