svn commit: r259420 - in projects/altix2/sys/sparc64: pci sbus sparc64
Marcel Moolenaar
marcel at FreeBSD.org
Sun Dec 15 18:05:06 UTC 2013
Author: marcel
Date: Sun Dec 15 18:05:04 2013
New Revision: 259420
URL: http://svnweb.freebsd.org/changeset/base/259420
Log:
Add support for switching sparc64 to busdma/mi. The legacy bus_dma
bits are conditionally compiled based on LEGACY_BUS_DMA option.
Modified:
projects/altix2/sys/sparc64/pci/fire.c
projects/altix2/sys/sparc64/pci/firevar.h
projects/altix2/sys/sparc64/pci/psycho.c
projects/altix2/sys/sparc64/pci/psychovar.h
projects/altix2/sys/sparc64/pci/schizo.c
projects/altix2/sys/sparc64/pci/schizovar.h
projects/altix2/sys/sparc64/sbus/sbus.c
projects/altix2/sys/sparc64/sparc64/bus_machdep.c
projects/altix2/sys/sparc64/sparc64/iommu.c
projects/altix2/sys/sparc64/sparc64/nexus.c
Modified: projects/altix2/sys/sparc64/pci/fire.c
==============================================================================
--- projects/altix2/sys/sparc64/pci/fire.c Sun Dec 15 18:01:18 2013 (r259419)
+++ projects/altix2/sys/sparc64/pci/fire.c Sun Dec 15 18:05:04 2013 (r259420)
@@ -88,8 +88,10 @@ __FBSDID("$FreeBSD$");
struct fire_msiqarg;
static const struct fire_desc *fire_get_desc(device_t dev);
+#ifdef LEGACY_BUS_DMA
static void fire_dmamap_sync(bus_dma_tag_t dt __unused, bus_dmamap_t map,
bus_dmasync_op_t op);
+#endif
static int fire_get_intrmap(struct fire_softc *sc, u_int ino,
bus_addr_t *intrmapptr, bus_addr_t *intrclrptr);
static void fire_intr_assign(void *arg);
@@ -707,15 +709,19 @@ fire_attach(device_t dev)
* Set up the IOMMU. Both Fire and Oberon have one per PBM, but
* neither has a streaming buffer.
*/
+#ifdef LEGACY_BUS_DMA
memcpy(&sc->sc_dma_methods, &iommu_dma_methods,
sizeof(sc->sc_dma_methods));
+#endif
sc->sc_is_ptr = &sc->sc_is; /* For busdma/mi */
sc->sc_is.is_flags = IOMMU_FIRE | IOMMU_PRESERVE_PROM;
if (sc->sc_mode == FIRE_MODE_OBERON) {
sc->sc_is.is_flags |= IOMMU_FLUSH_CACHE;
sc->sc_is.is_pmaxaddr = IOMMU_MAXADDR(OBERON_IOMMU_BITS);
} else {
+#ifdef LEGACY_BUS_DMA
sc->sc_dma_methods.dm_dmamap_sync = fire_dmamap_sync;
+#endif
sc->sc_is.is_pmaxaddr = IOMMU_MAXADDR(FIRE_IOMMU_BITS);
}
sc->sc_is.is_sb[0] = sc->sc_is.is_sb[1] = 0;
@@ -776,10 +782,11 @@ fire_attach(device_t dev)
sc->sc_is.is_pmaxaddr, ~0, NULL, NULL, sc->sc_is.is_pmaxaddr,
0xff, 0xffffffff, 0, NULL, NULL, &sc->sc_pci_dmat) != 0)
panic("%s: could not create PCI DMA tag", __func__);
+#ifdef LEGACY_BUS_DMA
/* Customize the tag. */
sc->sc_pci_dmat->dt_cookie = &sc->sc_is;
sc->sc_pci_dmat->dt_mt = &sc->sc_dma_methods;
-
+#endif
/*
* Get the bus range from the firmware.
* NB: Neither Fire nor Oberon support PCI bus reenumeration.
@@ -1510,6 +1517,7 @@ fire_read_ivar(device_t dev, device_t ch
return (ENOENT);
}
+#ifdef LEGACY_BUS_DMA
static void
fire_dmamap_sync(bus_dma_tag_t dt __unused, bus_dmamap_t map,
bus_dmasync_op_t op)
@@ -1532,6 +1540,7 @@ fire_dmamap_sync(bus_dma_tag_t dt __unus
} else if ((op & BUS_DMASYNC_PREWRITE) != 0)
membar(Sync);
}
+#endif /* LEGACY_BUS_DMA */
static void
fire_intr_enable(void *arg)
Modified: projects/altix2/sys/sparc64/pci/firevar.h
==============================================================================
--- projects/altix2/sys/sparc64/pci/firevar.h Sun Dec 15 18:01:18 2013 (r259419)
+++ projects/altix2/sys/sparc64/pci/firevar.h Sun Dec 15 18:05:04 2013 (r259420)
@@ -39,8 +39,9 @@ struct fire_softc {
*/
struct iommu_state *sc_is_ptr;
struct iommu_state sc_is;
+#ifdef LEGACY_BUS_DMA
struct bus_dma_methods sc_dma_methods;
-
+#endif
struct mtx sc_msi_mtx;
struct mtx sc_pcib_mtx;
Modified: projects/altix2/sys/sparc64/pci/psycho.c
==============================================================================
--- projects/altix2/sys/sparc64/pci/psycho.c Sun Dec 15 18:01:18 2013 (r259419)
+++ projects/altix2/sys/sparc64/pci/psycho.c Sun Dec 15 18:05:04 2013 (r259420)
@@ -86,8 +86,10 @@ static void psycho_set_intr(struct psych
driver_filter_t, driver_intr_t);
static int psycho_find_intrmap(struct psycho_softc *, u_int, bus_addr_t *,
bus_addr_t *, u_long *);
+#ifdef LEGACY_BUS_DMA
static void sabre_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map,
bus_dmasync_op_t op);
+#endif
static void psycho_intr_enable(void *);
static void psycho_intr_disable(void *);
static void psycho_intr_assign(void *);
@@ -549,6 +551,7 @@ psycho_attach(device_t dev)
panic("%s: could not malloc IOMMU state", __func__);
sc->sc_is->is_flags = IOMMU_PRESERVE_PROM;
if (sc->sc_mode == PSYCHO_MODE_SABRE) {
+#ifdef LEGACY_BUS_DMA
sc->sc_dma_methods =
malloc(sizeof(*sc->sc_dma_methods), M_DEVBUF,
M_NOWAIT);
@@ -559,10 +562,13 @@ psycho_attach(device_t dev)
sizeof(*sc->sc_dma_methods));
sc->sc_dma_methods->dm_dmamap_sync =
sabre_dmamap_sync;
+#endif
sc->sc_is->is_pmaxaddr =
IOMMU_MAXADDR(SABRE_IOMMU_BITS);
} else {
+#ifdef LEGACY_BUS_DMA
sc->sc_dma_methods = &iommu_dma_methods;
+#endif
sc->sc_is->is_pmaxaddr =
IOMMU_MAXADDR(PSYCHO_IOMMU_BITS);
}
@@ -572,8 +578,10 @@ psycho_attach(device_t dev)
sc->sc_is->is_flags |= (rerun != 1) ? IOMMU_RERUN_DISABLE : 0;
psycho_iommu_init(sc, 3, dvmabase);
} else {
+#ifdef LEGACY_BUS_DMA
/* Just copy IOMMU state, config tag and address. */
sc->sc_dma_methods = &iommu_dma_methods;
+#endif
sc->sc_is = osc->sc_is;
if (OF_getproplen(node, "no-streaming-cache") < 0)
sc->sc_is->is_sb[1] = sc->sc_pcictl + PCR_STRBUF;
@@ -592,10 +600,11 @@ psycho_attach(device_t dev)
sc->sc_is->is_pmaxaddr, ~0, NULL, NULL, sc->sc_is->is_pmaxaddr,
0xff, 0xffffffff, 0, NULL, NULL, &sc->sc_pci_dmat) != 0)
panic("%s: could not create PCI DMA tag", __func__);
+#ifdef LEGACY_BUS_DMA
/* Customize the tag. */
sc->sc_pci_dmat->dt_cookie = sc->sc_is;
sc->sc_pci_dmat->dt_mt = sc->sc_dma_methods;
-
+#endif
i = OF_getprop(node, "bus-range", (void *)prop_array,
sizeof(prop_array));
if (i == -1)
@@ -1105,6 +1114,7 @@ psycho_read_ivar(device_t dev, device_t
return (ENOENT);
}
+#ifdef LEGACY_BUS_DMA
static void
sabre_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map, bus_dmasync_op_t op)
{
@@ -1120,6 +1130,7 @@ sabre_dmamap_sync(bus_dma_tag_t dt, bus_
if ((op & BUS_DMASYNC_PREWRITE) != 0)
membar(Sync);
}
+#endif /* LEGACY_BUS_DMA */
static void
psycho_intr_enable(void *arg)
Modified: projects/altix2/sys/sparc64/pci/psychovar.h
==============================================================================
--- projects/altix2/sys/sparc64/pci/psychovar.h Sun Dec 15 18:01:18 2013 (r259419)
+++ projects/altix2/sys/sparc64/pci/psychovar.h Sun Dec 15 18:05:04 2013 (r259420)
@@ -42,8 +42,9 @@ struct psycho_softc {
* it from within the busdma I/F methods.
*/
struct iommu_state *sc_is;
+#ifdef LEGACY_BUS_DMA
struct bus_dma_methods *sc_dma_methods;
-
+#endif
device_t sc_dev;
struct mtx *sc_mtx;
Modified: projects/altix2/sys/sparc64/pci/schizo.c
==============================================================================
--- projects/altix2/sys/sparc64/pci/schizo.c Sun Dec 15 18:01:18 2013 (r259419)
+++ projects/altix2/sys/sparc64/pci/schizo.c Sun Dec 15 18:05:04 2013 (r259420)
@@ -82,10 +82,12 @@ __FBSDID("$FreeBSD$");
static const struct schizo_desc *schizo_get_desc(device_t);
static void schizo_set_intr(struct schizo_softc *, u_int, u_int,
driver_filter_t);
+#ifdef LEGACY_BUS_DMA
static void schizo_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map,
bus_dmasync_op_t op);
static void ichip_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map,
bus_dmasync_op_t op);
+#endif
static void schizo_intr_enable(void *);
static void schizo_intr_disable(void *);
static void schizo_intr_assign(void *);
@@ -512,8 +514,10 @@ schizo_attach(device_t dev)
* affected by several errata though. However, except for context
* flushes, taking advantage of it should be okay even with those.
*/
+#ifdef LEGACY_BUS_DMA
memcpy(&sc->sc_dma_methods, &iommu_dma_methods,
sizeof(sc->sc_dma_methods));
+#endif
sc->sc_is_ptr = &sc->sc_is.sis_is; /* For busdma/mi */
sc->sc_is.sis_sc = sc;
sc->sc_is.sis_is.is_flags = IOMMU_PRESERVE_PROM;
@@ -601,10 +605,11 @@ schizo_attach(device_t dev)
sc->sc_is.sis_is.is_pmaxaddr, 0xff, 0xffffffff, 0, NULL, NULL,
&sc->sc_pci_dmat) != 0)
panic("%s: could not create PCI DMA tag", __func__);
+#ifdef LEGACY_BUS_DMA
/* Customize the tag. */
sc->sc_pci_dmat->dt_cookie = &sc->sc_is;
sc->sc_pci_dmat->dt_mt = &sc->sc_dma_methods;
-
+#endif
/*
* Get the bus range from the firmware.
* NB: Tomatillos don't support PCI bus reenumeration.
@@ -704,8 +709,10 @@ schizo_attach(device_t dev)
sc->sc_mode == SCHIZO_MODE_TOM ||
sc->sc_mode == SCHIZO_MODE_XMS) {
if (sc->sc_mode == SCHIZO_MODE_SCZ) {
+#ifdef LEGACY_BUS_DMA
sc->sc_dma_methods.dm_dmamap_sync =
schizo_dmamap_sync;
+#endif
sc->sc_cdma_state = SCHIZO_CDMA_STATE_IDLE;
/*
* Some firmware versions include the CDMA interrupt
@@ -741,8 +748,10 @@ schizo_attach(device_t dev)
NULL, MTX_SPIN);
sc->sc_sync_val = 1ULL << (STX_PCIERR_A_INO +
sc->sc_half);
+#ifdef LEGACY_BUS_DMA
sc->sc_dma_methods.dm_dmamap_sync =
ichip_dmamap_sync;
+#endif
}
if (sc->sc_mode == SCHIZO_MODE_TOM && sc->sc_ver <= 4)
sc->sc_flags |= SCHIZO_FLAGS_BSWAR;
@@ -1159,6 +1168,7 @@ schizo_read_ivar(device_t dev, device_t
return (ENOENT);
}
+#ifdef LEGACY_BUS_DMA
static void
schizo_dmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map, bus_dmasync_op_t op)
{
@@ -1271,6 +1281,7 @@ ichip_dmamap_sync(bus_dma_tag_t dt, bus_
if ((op & BUS_DMASYNC_PREWRITE) != 0)
membar(Sync);
}
+#endif /* LEGACY_BUS_DMA */
static void
schizo_intr_enable(void *arg)
Modified: projects/altix2/sys/sparc64/pci/schizovar.h
==============================================================================
--- projects/altix2/sys/sparc64/pci/schizovar.h Sun Dec 15 18:01:18 2013 (r259419)
+++ projects/altix2/sys/sparc64/pci/schizovar.h Sun Dec 15 18:05:04 2013 (r259420)
@@ -45,8 +45,9 @@ struct schizo_softc {
* it from within the busdma I/F methods.
*/
struct iommu_state *sc_is_ptr;
+#ifdef LEGACY_BUS_DMA
struct bus_dma_methods sc_dma_methods;
-
+#endif
device_t sc_dev;
struct mtx sc_sync_mtx;
Modified: projects/altix2/sys/sparc64/sbus/sbus.c
==============================================================================
--- projects/altix2/sys/sparc64/sbus/sbus.c Sun Dec 15 18:01:18 2013 (r259419)
+++ projects/altix2/sys/sparc64/sbus/sbus.c Sun Dec 15 18:05:04 2013 (r259420)
@@ -385,10 +385,11 @@ sbus_attach(device_t dev)
sc->sc_is.is_pmaxaddr, ~0, NULL, NULL, sc->sc_is.is_pmaxaddr,
0xff, 0xffffffff, 0, NULL, NULL, &sc->sc_cdmatag) != 0)
panic("%s: bus_dma_tag_create failed", __func__);
+#ifdef LEGACY_BUS_DMA
/* Customize the tag. */
sc->sc_cdmatag->dt_cookie = &sc->sc_is;
sc->sc_cdmatag->dt_mt = &iommu_dma_methods;
-
+#endif
/*
* Hunt through all the interrupt mapping regs and register our
* interrupt controller for the corresponding interrupt vectors.
Modified: projects/altix2/sys/sparc64/sparc64/bus_machdep.c
==============================================================================
--- projects/altix2/sys/sparc64/sparc64/bus_machdep.c Sun Dec 15 18:01:18 2013 (r259419)
+++ projects/altix2/sys/sparc64/sparc64/bus_machdep.c Sun Dec 15 18:05:04 2013 (r259420)
@@ -138,6 +138,7 @@ const int bus_stream_asi[] = {
0
};
+#ifdef LEGACY_BUS_DMA
/*
* Convenience function for manipulating driver locks from busdma (during
* busdma_swi, for example). Drivers that don't provide their own locks
@@ -593,6 +594,7 @@ struct bus_dma_tag nexus_dmatag = {
NULL,
&nexus_dma_methods,
};
+#endif /* LEGACY_BUS_DMA */
/*
* Helpers to map/unmap bus memory
Modified: projects/altix2/sys/sparc64/sparc64/iommu.c
==============================================================================
--- projects/altix2/sys/sparc64/sparc64/iommu.c Sun Dec 15 18:01:18 2013 (r259419)
+++ projects/altix2/sys/sparc64/sparc64/iommu.c Sun Dec 15 18:05:04 2013 (r259420)
@@ -219,6 +219,7 @@ iommu_strbuf_sync(struct iommu_state *is
iommu_strbuf_flush_sync(is);
}
+#ifdef LEGACY_BUS_DMA
/* LRU queue handling for lazy resource allocation. */
static __inline void
iommu_map_insq(struct iommu_state *is, bus_dmamap_t map)
@@ -242,6 +243,7 @@ iommu_map_remq(struct iommu_state *is, b
TAILQ_REMOVE(&is->is_maplruq, map, dm_maplruq);
map->dm_onq = 0;
}
+#endif /* LEGACY_BUS_DMA */
/*
* initialise the UltraSPARC IOMMU (PCI or SBus):
@@ -561,6 +563,7 @@ iommu_strbuf_flush_sync(struct iommu_sta
return (1);
}
+#ifdef LEGACY_BUS_DMA
/* Determine whether we may enable streaming on a mapping. */
static __inline int
iommu_use_streaming(struct iommu_state *is, bus_dmamap_t map, bus_size_t size)
@@ -1166,6 +1169,7 @@ iommu_dvmamap_sync(bus_dma_tag_t dt, bus
if ((op & BUS_DMASYNC_PREWRITE) != 0)
membar(Sync);
}
+#endif /* LEGACY_BUS_DMA */
@@ -1202,8 +1206,10 @@ iommu_map(device_t bus, device_t dev __u
size = busdma_md_get_size(md, idx) + (ba & IO_PAGE_MASK);
size = round_io_page(size) >> IO_PAGE_SHIFT;
+ IS_LOCK(is);
r = rman_reserve_resource_bound(&is->is_dvma_rman, 0L, maxaddr, size,
bndry, RF_ACTIVE | rman_make_alignment_flags(align), NULL);
+ IS_UNLOCK(is);
if (r == NULL)
return (ENOMEM);
@@ -1341,6 +1347,7 @@ iommu_diag(struct iommu_state *is, vm_of
#endif /* IOMMU_DIAG */
+#ifdef LEGACY_BUS_DMA
struct bus_dma_methods iommu_dma_methods = {
iommu_dvmamap_create,
iommu_dvmamap_destroy,
@@ -1353,3 +1360,4 @@ struct bus_dma_methods iommu_dma_methods
iommu_dvmamem_alloc,
iommu_dvmamem_free,
};
+#endif /* LEGACY_BUS_DMA */
Modified: projects/altix2/sys/sparc64/sparc64/nexus.c
==============================================================================
--- projects/altix2/sys/sparc64/sparc64/nexus.c Sun Dec 15 18:01:18 2013 (r259419)
+++ projects/altix2/sys/sparc64/sparc64/nexus.c Sun Dec 15 18:05:04 2013 (r259420)
@@ -97,7 +97,9 @@ static bus_get_resource_list_t nexus_get
static bus_bind_intr_t nexus_bind_intr;
#endif
static bus_describe_intr_t nexus_describe_intr;
+#ifdef LEGACY_BUS_DMA
static bus_get_dma_tag_t nexus_get_dma_tag;
+#endif
static ofw_bus_get_devinfo_t nexus_get_devinfo;
static int nexus_inlist(const char *, const char *const *);
@@ -134,8 +136,9 @@ static device_method_t nexus_methods[] =
DEVMETHOD(bus_bind_intr, nexus_bind_intr),
#endif
DEVMETHOD(bus_describe_intr, nexus_describe_intr),
+#ifdef LEGACY_BUS_DMA
DEVMETHOD(bus_get_dma_tag, nexus_get_dma_tag),
-
+#endif
/* ofw_bus interface */
DEVMETHOD(ofw_bus_get_devinfo, nexus_get_devinfo),
DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat),
@@ -181,7 +184,9 @@ static const char *const nexus_excl_type
};
extern struct bus_space_tag nexus_bustag;
+#ifdef LEGACY_BUS_DMA
extern struct bus_dma_tag nexus_dmatag;
+#endif
static int
nexus_inlist(const char *name, const char *const *list)
@@ -495,12 +500,14 @@ nexus_get_resource_list(device_t bus __u
return (&ndi->ndi_rl);
}
+#ifdef LEGACY_BUS_DMA
static bus_dma_tag_t
nexus_get_dma_tag(device_t bus __unused, device_t child __unused)
{
return (&nexus_dmatag);
}
+#endif
static const struct ofw_bus_devinfo *
nexus_get_devinfo(device_t bus __unused, device_t child)
More information about the svn-src-projects
mailing list