From owner-svn-src-head@FreeBSD.ORG Thu Feb 21 13:27:02 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 43CCE635; Thu, 21 Feb 2013 13:27:02 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.69.10]) by mx1.freebsd.org (Postfix) with ESMTP id 2ED73273; Thu, 21 Feb 2013 13:27:00 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.6/8.14.6) with ESMTP id r1LDQxP5086027; Thu, 21 Feb 2013 17:26:59 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.6/8.14.6/Submit) id r1LDQxOS086026; Thu, 21 Feb 2013 17:26:59 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Thu, 21 Feb 2013 17:26:59 +0400 From: Gleb Smirnoff To: Andrey Zonov Subject: Re: svn commit: r247066 - head/sys/dev/ppc Message-ID: <20130221132659.GS72813@FreeBSD.org> References: <201302210027.r1L0Rqv3091748@svn.freebsd.org> <5125E465.20700@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <5125E465.20700@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Warner Losh X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Feb 2013 13:27:02 -0000 On Thu, Feb 21, 2013 at 01:09:57PM +0400, Andrey Zonov wrote: A> > Log: A> > Replace splhigh() with critical_enter()/leave() to ensure we write the A> > config mode unlock sequence quickly enough. This likely isn't too critical, A> > since splhigh() has been a noop for a decade... A> > A> > Modified: A> > head/sys/dev/ppc/ppc.c A> > A> > Modified: head/sys/dev/ppc/ppc.c A> > ============================================================================== A> > --- head/sys/dev/ppc/ppc.c Thu Feb 21 00:26:31 2013 (r247065) A> > +++ head/sys/dev/ppc/ppc.c Thu Feb 21 00:27:51 2013 (r247066) A> > @@ -74,6 +74,22 @@ static void ppcintr(void *arg); A> > A> > #define DEVTOSOFTC(dev) ((struct ppc_data *)device_get_softc(dev)) A> > A> > +/* A> > + * We use critical enter/leave for the simple config locking needed to A> > + * detect the devices. We just want to make sure that both of our writes A> > + * happen without someone else also writing to those config registers. Since A> > + * we just do this at startup, Giant keeps multiple threads from executing, A> > + * and critical_enter() then is all that's needed to keep us from being preempted A> > + * during the critical sequences with the hardware. A> > + * A> > + * Note: this doesn't prevent multiple threads from putting the chips into A> > + * config mode, but since we only do that to detect the type at startup the A> > + * extra overhead isn't needed since Giant protects us from multiple entry A> > + * and no other code changes these registers. A> > + */ A> > +#define PPC_CONFIG_LOCK(ppc) critical_enter() A> > +#define PPC_CONFIG_UNLOCK(ppc) critical_leave() A> > + A> A> s/critical_leave/critical_exit/? Already fixed. However, question to Warner. Since code already executes under Giant, what is the reason for critical_section? What's the problem if couple of outb instructions are split (assuming they are properly serialized) across two CPUs? -- Totus tuus, Glebius.