From owner-svn-src-head@FreeBSD.ORG Thu Feb 21 14:08:28 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 2F56E27C for ; Thu, 21 Feb 2013 14:08:28 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from mail-ia0-x236.google.com (ia-in-x0236.1e100.net [IPv6:2607:f8b0:4001:c02::236]) by mx1.freebsd.org (Postfix) with ESMTP id F3F4D711 for ; Thu, 21 Feb 2013 14:08:27 +0000 (UTC) Received: by mail-ia0-f182.google.com with SMTP id k38so1558967iah.27 for ; Thu, 21 Feb 2013 06:08:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer:x-gm-message-state; bh=TDMT7EEa64ZRrxY32cx6MpP40Pw+ySwUNWe1sKSxkXA=; b=kbUxlDWhLEolW8S+ljwYshT1zmQKzwIWxb3rC1WiqgTGofRUAVO675uKE6f6ZQ11eF m8hB+m78N4vHpsm/dAypui8tLLEBTddkm8ODshGpDeNzAmXG3EArzNQ8c4nUyVTYYURn WVfJT4lg97ZkM5k8NQ6vR7JMKnlPsRDWT46VoLVekNqA8Y6jyiZWFA+HanFY1cgRfTY1 vdzskHzXCb1lp4iR36oCtDBfxjDyas+9+abF6K4IQCMbw5XWIKdcehag7h9OFNkg1eK6 R8HKwK3mjRxwbpzeL4vcikcFh8axbzftc5YEn/rA1NxySMsniQcfdTL/rJL3bxb3fokr Z2Jg== X-Received: by 10.50.88.233 with SMTP id bj9mr13230772igb.55.1361455707680; Thu, 21 Feb 2013 06:08:27 -0800 (PST) Received: from 53.imp.bsdimp.com (50-78-194-198-static.hfc.comcastbusiness.net. [50.78.194.198]) by mx.google.com with ESMTPS id xd4sm18683351igb.3.2013.02.21.06.08.25 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Feb 2013 06:08:26 -0800 (PST) Sender: Warner Losh Subject: Re: svn commit: r247066 - head/sys/dev/ppc Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <20130221132659.GS72813@FreeBSD.org> Date: Thu, 21 Feb 2013 07:08:24 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <63ACAB54-24F4-4EB7-B7F6-54683E016848@bsdimp.com> References: <201302210027.r1L0Rqv3091748@svn.freebsd.org> <5125E465.20700@FreeBSD.org> <20130221132659.GS72813@FreeBSD.org> To: Gleb Smirnoff X-Mailer: Apple Mail (2.1085) X-Gm-Message-State: ALoCoQmMiNl5OTZN0hSkiMfP8QHy5qwXAXHCHkzCOUiEwxVpgrbfDEbpeS0LGmz6laMUptts1AIu Cc: svn-src-head@freebsd.org, Andrey Zonov , src-committers@freebsd.org, Warner Losh , svn-src-all@freebsd.org 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 14:08:28 -0000 On Feb 21, 2013, at 6:26 AM, Gleb Smirnoff wrote: > 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> >=20 > A> > Modified: > A> > head/sys/dev/ppc/ppc.c > A> >=20 > A> > Modified: head/sys/dev/ppc/ppc.c > A> > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > 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> > =20 > A> > #define DEVTOSOFTC(dev) ((struct ppc_data = *)device_get_softc(dev)) > A> > =20 > 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>=20 > A> s/critical_leave/critical_exit/? >=20 > Already fixed. >=20 > However, question to Warner. >=20 > 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? There's a timing window that needs to be hit with these chips. Warner=