From owner-svn-src-all@freebsd.org Mon Feb 15 23:37:56 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E71C4AA9D31 for ; Mon, 15 Feb 2016 23:37:55 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from erouter6.ore.mailhop.org (erouter6.ore.mailhop.org [54.187.213.119]) (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 BBA5A1F7 for ; Mon, 15 Feb 2016 23:37:55 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: bc0d024a-d43c-11e5-a023-11ad6df26ed1 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.34.117.227 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.34.117.227]) by outbound3.ore.mailhop.org (Halon Mail Gateway) with ESMTPSA; Mon, 15 Feb 2016 23:35:01 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.14.9) with ESMTP id u1FNbkIH025611; Mon, 15 Feb 2016 16:37:46 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1455579466.12873.23.camel@freebsd.org> Subject: Re: svn commit: r295557 - head/sys/dev/uart From: Ian Lepore To: Bruce Evans , Michal Meloun Cc: src-committers@freebsd.org, Marius Strobl , svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Mon, 15 Feb 2016 16:37:46 -0700 In-Reply-To: <20160216080249.F1233@besplex.bde.org> References: <201602120514.u1C5EwWt053622@repo.freebsd.org> <20160212164755.GC4980@alchemy.franken.de> <20160213041246.V1974@besplex.bde.org> <20160213005801.GF15359@alchemy.franken.de> <56C1BDE2.8090300@freebsd.org> <20160216080249.F1233@besplex.bde.org> Content-Type: text/plain; charset="us-ascii" X-Mailer: Evolution 3.16.5 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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, 15 Feb 2016 23:37:56 -0000 On Tue, 2016-02-16 at 09:28 +1100, Bruce Evans wrote: > On Mon, 15 Feb 2016, Michal Meloun wrote: > > > [...] > > Please note that ARM architecture does not have vectored interrupts, > > CPU must read actual interrupt source from external interrupt > > controller (GIC) register. This register contain predefined value if > > none of interrupts are active. > > > > 1 - CPU1: enters ns8250_bus_transmit() and sets IER_ETXRDY. > > 2 - HW: UART interrupt is asserted, processed by GIC and signaled > > to CPU2. > > 3 - CPU2: enters interrupt service. > > It is blocked by uart_lock(), right? > > > 4 - CPU1: writes character to into REG_DATA register. > > 5 - HW: UART clear its interrupt request > > 6 - CPU2: reads interrupt source register. No active interrupt is > > found, spurious interrupt is signaled, and CPU leaves interrupted > > state. > > 7 - CPU1: executes uart_barrier(). This function is not empty on ARM, > > and can be slow in some cases. > > It is not empty even on x86, although it probably should be. > > BTW, if arm needs the barrier, then how does it work with > bus_space_barrier() referenced in just 25 files in all of /sys/dev? > With a hack, of course. In the arm interrupt-controller drivers we always call bus_space_barrier() right before doing an EOI. It's not a 100% solution, but in practice it seems to work pretty well. Spurious interrupts which are not caused by driver bugs on arm tend to happen when the interrupt controller and some peripheral are on different internal busses, especially when the peripheral is on a slow bus and access to the PIC's registers is faster. In that case it often happens that the clearing of the condition at the source goes slower than the EOI and the PIC immediately re-interrupts. By time we've re -vectored back to the PIC driver and read the pending-irq register the slow write to the peripheral has completed and the interrupt has been deasserted, so the PIC returns the spurious-irq indication. The hack code does a drain-write-buffer which doesn't g'tee that the slow peripheral write has made it all the way to the device, but it does at least g'tee that the write to the bus the perhiperal is on has been posted and ack'd by any bus<->bus bridge, and that seems to be good enough in practice. (If there were multiple bridged busses downstream it probably wouldn't be, but so far things aren't that complicated inside the socs we support.) The g'teed way is to do a readback of the register written-to, or some nearby register if it's write-only. That's a hard thing to do in a bus_space_barrier implementation that has no knowledge of things like which registers in a device might be write-only. And of course, then you're still left with the problem of hundreds of drivers that don't do any barrier calls at all. > [...] > > > Also, at this time, UART driver is last one known to generate spurious > > interrupts in ARM world. > > > > So, whats now? I can #ifdef __arm__ change made in r295557 (for maximum > > safety), if you want this. Or we can just wait to see if someone reports > > a problem ... > > Use better methods. > How about a dev.uart..broken_txrdy tunable sysctl that defaults to the new behavior but can be turned on by anyone with the buggy hardware? -- Ian