From owner-svn-src-projects@FreeBSD.ORG Mon Jan 6 01:51:09 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 324732B6; Mon, 6 Jan 2014 01:51:09 +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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 049FC17C1; Mon, 6 Jan 2014 01:51:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s061p8N7085831; Mon, 6 Jan 2014 01:51:08 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s061p8gj085830; Mon, 6 Jan 2014 01:51:08 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <201401060151.s061p8gj085830@svn.freebsd.org> From: Marcel Moolenaar Date: Mon, 6 Jan 2014 01:51:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r260362 - projects/altix2/sys/ia64/sgisn X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jan 2014 01:51:09 -0000 Author: marcel Date: Mon Jan 6 01:51:08 2014 New Revision: 260362 URL: http://svnweb.freebsd.org/changeset/base/260362 Log: Fix precious commit. In "productizing" the code, the following went wrong: 1. The loop termination check was removed, resulting in an infinite loop. 2. The loop termination changed from a return to a break, actually causing the tail end of the shub_ptc() function to execute and causing panics there due to sc being re-used. Now that we properly wait for the PTC operation to complete, fix the loop termination condition by masking off bits we don't care for. Without it we end up in another infinite loop. Sheez... Modified: projects/altix2/sys/ia64/sgisn/sgisn_shub.c Modified: projects/altix2/sys/ia64/sgisn/sgisn_shub.c ============================================================================== --- projects/altix2/sys/ia64/sgisn/sgisn_shub.c Mon Jan 6 00:52:39 2014 (r260361) +++ projects/altix2/sys/ia64/sgisn/sgisn_shub.c Mon Jan 6 01:51:08 2014 (r260362) @@ -613,7 +613,7 @@ void shub_ptc(vm_offset_t va, u_int rid) { device_t dev; - struct sgisn_shub_softc *sc; + struct sgisn_shub_softc *sc, *scx; uint64_t cfg0, cfg1, ptc, ws, wsreg; u_int mynas, nasid, shub1; @@ -640,16 +640,18 @@ shub_ptc(vm_offset_t va, u_int rid) if (nasid == mynas) goto next; dev = devclass_get_device(sgisn_shub_devclass, nasid >> 1); - sc = (dev != NULL) ? device_get_softc(dev) : NULL; - if (sc == NULL) + if (dev == NULL) + break; + scx = device_get_softc(dev); + if (scx == NULL) goto next; if (shub1) { - bus_space_write_8(sc->sc_tag, sc->sc_hndl, + bus_space_write_8(scx->sc_tag, scx->sc_hndl, SHUB_MMR_PTC_CFG0, cfg0); - bus_space_write_8(sc->sc_tag, sc->sc_hndl, + bus_space_write_8(scx->sc_tag, scx->sc_hndl, SHUB_MMR_PTC_CFG1, cfg1); } else - bus_space_write_8(sc->sc_tag, sc->sc_hndl, + bus_space_write_8(scx->sc_tag, scx->sc_hndl, SHUB_MMR_PTC(rid), ptc); next: nasid += 2; @@ -668,7 +670,7 @@ shub_ptc(vm_offset_t va, u_int rid) while (1) { ws = bus_space_read_8(sc->sc_tag, sc->sc_hndl, wsreg); KASSERT((ws & 2) == 0, ("%s: deadlock detected", __func__)); - if ((ws >> 56) == ((shub1) ? 0x3f : 0)) + if (((ws >> 56) & 0x3f) == ((shub1) ? 0x3f : 0)) return; cpu_spinwait(); }