From 0e9f21dc24e4846a711fe56c898b6991f28f0f02 Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Wed, 25 May 2016 01:23:19 +0000 Subject: [PATCH] Set the TLB caching properties for portals at attach time. This was found while reworking the device tree nodes for dtsec to match the Linux device tree. Instead of waiting and expecting later code to call dpaa_portal_map_registers(), do the equivalent immediately upon mapping. Otherwise, it's possible to access the pages before that function is called, and hang the CPU. --- sys/dev/dpaa/portals_common.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sys/dev/dpaa/portals_common.c b/sys/dev/dpaa/portals_common.c index 7c7408d2e24d..207fcbdc6dbd 100644 --- a/sys/dev/dpaa/portals_common.c +++ b/sys/dev/dpaa/portals_common.c @@ -76,9 +76,12 @@ dpaa_portal_alloc_res(device_t dev, struct dpaa_portals_devinfo *di, int cpu) SYS_RES_MEMORY, &sc->sc_rrid[0], rle->start + sc->sc_dp_pa, rle->end + sc->sc_dp_pa, rle->count, RF_ACTIVE); if (sc->sc_rres[0] == NULL) { - device_printf(dev, "Could not allocate memory.\n"); + device_printf(dev, + "Could not allocate cache enabled memory.\n"); return (ENXIO); } + tlb1_set_entry(rman_get_bushandle(sc->sc_rres[0]), + rle->start + sc->sc_dp_pa, rle->count, _TLB_ENTRY_MEM); /* Cache inhibited area */ rle = resource_list_find(res, SYS_RES_MEMORY, 1); sc->sc_rrid[1] = 1; @@ -86,11 +89,15 @@ dpaa_portal_alloc_res(device_t dev, struct dpaa_portals_devinfo *di, int cpu) SYS_RES_MEMORY, &sc->sc_rrid[1], rle->start + sc->sc_dp_pa, rle->end + sc->sc_dp_pa, rle->count, RF_ACTIVE); if (sc->sc_rres[1] == NULL) { - device_printf(dev, "Could not allocate memory.\n"); + device_printf(dev, + "Could not allocate cache inhibited memory.\n"); bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_rrid[0], sc->sc_rres[0]); return (ENXIO); } + tlb1_set_entry(rman_get_bushandle(sc->sc_rres[1]), + rle->start + sc->sc_dp_pa, rle->count, _TLB_ENTRY_IO); + sc->sc_dp[cpu].dp_regs_mapped = 1; } /* Acquire portal's CE_PA and CI_PA */ rle = resource_list_find(res, SYS_RES_MEMORY, 0);