From b9931c0786d717ff5665ec22cce026375c2d759e Mon Sep 17 00:00:00 2001 From: Brandon Bergren Date: Tue, 25 Feb 2020 03:35:52 +0000 Subject: [PATCH] [PowerPC] [Book-E] Fix dpaa interrupt binding. After the network epoch was added, we lost the ability to migrate the ithread in the middle of dispatch, as being in the network epoch will pin the current thread (for safety reasons.) Luckily, we don't actually have to do this workaround in the first place, as we can just bind it to the correct cpu when we preallocate it. Pass dev through to XX_PreallocAndBindIntr() and actually bind it to the cpu like it was supposed to in the first place, instad of leaving it floating and moving it to the correct cpu the first time it fires. This fixes panics while bringing up dtsec on my X5000. Reviewed by: jhibbits Sponsored by: Tag1 Consulting, Inc. Differential Revision: https://reviews.freebsd.org/D23826 --- sys/contrib/ncsw/inc/xx_ext.h | 2 +- sys/contrib/ncsw/user/env/xx.c | 19 ++++++------------- sys/dev/dpaa/portals_common.c | 3 +-- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/sys/contrib/ncsw/inc/xx_ext.h b/sys/contrib/ncsw/inc/xx_ext.h index 32e0c39d3634..14e9426a18d2 100644 --- a/sys/contrib/ncsw/inc/xx_ext.h +++ b/sys/contrib/ncsw/inc/xx_ext.h @@ -205,7 +205,7 @@ uint32_t XX_DisableAllIntr(void); void XX_RestoreAllIntr(uint32_t flags); -t_Error XX_PreallocAndBindIntr(uintptr_t irq, unsigned int cpu); +t_Error XX_PreallocAndBindIntr(device_t dev, uintptr_t irq, unsigned int cpu); t_Error XX_DeallocIntr(uintptr_t irq); /**************************************************************************//** diff --git a/sys/contrib/ncsw/user/env/xx.c b/sys/contrib/ncsw/user/env/xx.c index 4cf78d52f9eb..afaeb562b8e4 100644 --- a/sys/contrib/ncsw/user/env/xx.c +++ b/sys/contrib/ncsw/user/env/xx.c @@ -95,8 +95,7 @@ MTX_SYSINIT(XX_MallocTrackLockInit, &XX_MallocTrackLock, /* Interrupt info */ #define XX_INTR_FLAG_PREALLOCATED (1 << 0) -#define XX_INTR_FLAG_BOUND (1 << 1) -#define XX_INTR_FLAG_FMAN_FIX (1 << 2) +#define XX_INTR_FLAG_FMAN_FIX (1 << 1) struct XX_IntrInfo { driver_intr_t *handler; @@ -320,16 +319,6 @@ XX_Dispatch(void *arg) info = arg; - /* Bind this thread to proper CPU when SMP has been already started. */ - if ((info->flags & XX_INTR_FLAG_BOUND) == 0 && smp_started && - info->cpu >= 0) { - thread_lock(curthread); - sched_bind(curthread, info->cpu); - thread_unlock(curthread); - - info->flags |= XX_INTR_FLAG_BOUND; - } - if (info->handler == NULL) { printf("%s(): IRQ handler is NULL!\n", __func__); return; @@ -339,7 +328,7 @@ XX_Dispatch(void *arg) } t_Error -XX_PreallocAndBindIntr(uintptr_t irq, unsigned int cpu) +XX_PreallocAndBindIntr(device_t dev, uintptr_t irq, unsigned int cpu) { struct resource *r; unsigned int inum; @@ -352,6 +341,10 @@ XX_PreallocAndBindIntr(uintptr_t irq, unsigned int cpu) if (error != 0) return (error); + error = bus_bind_intr(dev, r, cpu); + if (error != 0) + return (error); + XX_IntrInfo[inum].flags = XX_INTR_FLAG_PREALLOCATED; XX_IntrInfo[inum].cpu = cpu; diff --git a/sys/dev/dpaa/portals_common.c b/sys/dev/dpaa/portals_common.c index 02729f2fcb7d..971dd5793972 100644 --- a/sys/dev/dpaa/portals_common.c +++ b/sys/dev/dpaa/portals_common.c @@ -120,8 +120,7 @@ dpaa_portal_alloc_res(device_t dev, struct dpaa_portals_devinfo *di, int cpu) device_printf(dev, "Could not allocate irq.\n"); return (ENXIO); } - - err = XX_PreallocAndBindIntr((uintptr_t)sc->sc_dp[cpu].dp_ires, cpu); + err = XX_PreallocAndBindIntr(dev, (uintptr_t)sc->sc_dp[cpu].dp_ires, cpu); if (err != E_OK) { device_printf(dev, "Could not prealloc and bind interrupt\n");