From owner-svn-src-all@FreeBSD.ORG Mon May 26 01:37:44 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 75C5DDFA; Mon, 26 May 2014 01:37:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6171F25F6; Mon, 26 May 2014 01:37:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4Q1biYE087755; Mon, 26 May 2014 01:37:44 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4Q1bh0Q087752; Mon, 26 May 2014 01:37:43 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201405260137.s4Q1bh0Q087752@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 26 May 2014 01:37:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r266676 - in stable/10/sys/powerpc: powerpc ps3 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 May 2014 01:37:44 -0000 Author: nwhitehorn Date: Mon May 26 01:37:43 2014 New Revision: 266676 URL: http://svnweb.freebsd.org/changeset/base/266676 Log: MFC r265900: Repair some races in IPI handling: 1. Make sure IPI mask is set before sending the IPI 2. Operate atomically on PS3 PIC outstanding interrupt list 3. Make sure IPIs are EOI'ed before, not after, processing. Without this, a second IPI could be sent partway through processing the first one, get erroneously acknowledge by the EOI to the first, and be lost. In particular in the case of smp_rendezvous(), this can be fatal. In combination, this makes the PS3 boot SMP again. It probably also fixes some latent bugs elsewhere. Modified: stable/10/sys/powerpc/powerpc/intr_machdep.c stable/10/sys/powerpc/powerpc/mp_machdep.c stable/10/sys/powerpc/ps3/ps3pic.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/powerpc/powerpc/intr_machdep.c ============================================================================== --- stable/10/sys/powerpc/powerpc/intr_machdep.c Sun May 25 19:28:34 2014 (r266675) +++ stable/10/sys/powerpc/powerpc/intr_machdep.c Mon May 26 01:37:43 2014 (r266676) @@ -103,6 +103,7 @@ struct powerpc_intr { enum intr_trigger trig; enum intr_polarity pol; int fwcode; + int ipi; }; struct pic { @@ -203,6 +204,8 @@ intr_lookup(u_int irq) i->irq = irq; i->pic = NULL; i->vector = -1; + i->fwcode = 0; + i->ipi = 0; #ifdef SMP i->cpu = all_cpus; @@ -415,6 +418,15 @@ powerpc_enable_intr(void) printf("unable to setup IPI handler\n"); return (error); } + + /* + * Some subterfuge: disable late EOI and mark this + * as an IPI to the dispatch layer. + */ + i = intr_lookup(MAP_IRQ(piclist[n].node, + piclist[n].irqs)); + i->event->ie_post_filter = NULL; + i->ipi = 1; } } #endif @@ -568,6 +580,13 @@ powerpc_dispatch_intr(u_int vector, stru ie = i->event; KASSERT(ie != NULL, ("%s: interrupt without an event", __func__)); + /* + * IPIs are magical and need to be EOI'ed before filtering. + * This prevents races in IPI handling. + */ + if (i->ipi) + PIC_EOI(i->pic, i->intline); + if (intr_event_handle(ie, tf) != 0) { goto stray; } Modified: stable/10/sys/powerpc/powerpc/mp_machdep.c ============================================================================== --- stable/10/sys/powerpc/powerpc/mp_machdep.c Sun May 25 19:28:34 2014 (r266675) +++ stable/10/sys/powerpc/powerpc/mp_machdep.c Mon May 26 01:37:43 2014 (r266676) @@ -336,6 +336,7 @@ ipi_send(struct pcpu *pc, int ipi) pc, pc->pc_cpuid, ipi); atomic_set_32(&pc->pc_ipimask, (1 << ipi)); + powerpc_sync(); PIC_IPI(root_pic, pc->pc_cpuid); CTR1(KTR_SMP, "%s: sent", __func__); Modified: stable/10/sys/powerpc/ps3/ps3pic.c ============================================================================== --- stable/10/sys/powerpc/ps3/ps3pic.c Sun May 25 19:28:34 2014 (r266675) +++ stable/10/sys/powerpc/ps3/ps3pic.c Mon May 26 01:37:43 2014 (r266676) @@ -166,12 +166,13 @@ ps3pic_dispatch(device_t dev, struct tra sc = device_get_softc(dev); if (PCPU_GET(cpuid) == 0) { - bitmap = sc->bitmap_thread0[0]; + bitmap = atomic_readandclear_64(&sc->bitmap_thread0[0]); mask = sc->mask_thread0[0]; } else { - bitmap = sc->bitmap_thread1[0]; + bitmap = atomic_readandclear_64(&sc->bitmap_thread1[0]); mask = sc->mask_thread1[0]; } + powerpc_sync(); while ((irq = ffsl(bitmap & mask) - 1) != -1) { bitmap &= ~(1UL << irq);