Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3537653imj; Tue, 19 Feb 2019 05:21:08 -0800 (PST) X-Google-Smtp-Source: AHgI3IasLW7+cAkxiwHzixesyXT6rrmeo6FceZP/moQUwE9NvoGOnw8MFq+oIDwm2LOGF5/+69gD X-Received: by 2002:aa7:8281:: with SMTP id s1mr29199137pfm.120.1550582468916; Tue, 19 Feb 2019 05:21:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550582468; cv=none; d=google.com; s=arc-20160816; b=ugWGyNAUNwM+ZPnc1OS6U613pFtl2OenSwe0RKnn5iA3VTkZJY7x888scOEBZ3U8Bk zvpTReteAuL7OD0vDVenhpYqmHa58sF3hdjERmzKeey6rXdXr5OLcHKmqhSr+3ueyZlf ZhZBrcSQ2w/9nPNECP5H+/vBDBnQ87jaUcERMgzEd1o0XO7jVe5Nbx5yYIbYrGb8W6Vu b92FNjs137Z0XMOjlVOSqtDzUI3DWCcKA3aE/+Wc3es+lC4XNvRDUUG47eV6ti3Vl3Ji Z4Jhv+XrVE4t1J7mQh4rJtGsf2cDRgf++smLkRMgsiKjhmTj4dBTsUQelwn2gFr08++T 6zdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=qYWz7PBd6F1f79CwRVoKGN+JHUEVrzsXxiOLTm5Fke4=; b=uiZlTDJYcTf56A14lNBVIBv39Ejv6f1EdX7hUkGrCZctRs0N1PNFTw3+beNBSNp+Sf fdPXyo0k5RgW1xYtNsBkyiV/E8RYyD8Pf+WRzNXXlNxIIKgyoRtNmKwsblPHU9C9ggvh 0Pkzn22q+m7LTVCsrmHWQJSb4zVfy5RFpkU1/LX9P7Swra9KidEj+a1BgkLg52gPx4Pk QqB7vVBDC1F35LDzugScPFNeE5IZ+rETXeF9zNsaDEgW/mC181bKMjMEwQlvX4mMk6r3 YnIfoFexCBkwPFVZ8DECJwkgs7mHVKA9WA83rfe8/W6cF4+rwGuNdDcYlvJKkCM89PSE V78Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q14si10356801pls.204.2019.02.19.05.20.53; Tue, 19 Feb 2019 05:21:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728644AbfBSNU1 (ORCPT + 99 others); Tue, 19 Feb 2019 08:20:27 -0500 Received: from foss.arm.com ([217.140.101.70]:45386 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726426AbfBSNU1 (ORCPT ); Tue, 19 Feb 2019 08:20:27 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8A0F1EBD; Tue, 19 Feb 2019 05:20:26 -0800 (PST) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0B69C3F675; Tue, 19 Feb 2019 05:20:23 -0800 (PST) Date: Tue, 19 Feb 2019 13:20:21 +0000 From: Will Deacon To: Arnd Bergmann Cc: Thomas Petazzoni , linux-arch , Linux Kernel Mailing List , "Paul E. McKenney" , Benjamin Herrenschmidt , Peter Zijlstra , Andrea Parri , Daniel Lustig , David Howells , Alan Stern , Linus Torvalds , Thomas Petazzoni , Gregory CLEMENT , Russell King - ARM Linux Subject: Re: [RFC PATCH] docs/memory-barriers.txt: Rewrite "KERNEL I/O BARRIER EFFECTS" section Message-ID: <20190219132021.GJ8501@fuggles.cambridge.arm.com> References: <20190211172948.3322-1-will.deacon@arm.com> <20190218162954.GB16713@fuggles.cambridge.arm.com> <20190218175625.GD16713@fuggles.cambridge.arm.com> <20190219112747.7db95e58@windsurf.home> <20190219113609.GC4027@fuggles.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 19, 2019 at 02:01:50PM +0100, Arnd Bergmann wrote: > On Tue, Feb 19, 2019 at 12:36 PM Will Deacon wrote: > > On Tue, Feb 19, 2019 at 12:31:50PM +0100, Arnd Bergmann wrote: > > > On Tue, Feb 19, 2019 at 11:27 AM Thomas Petazzoni > > > wrote: > > > > > > I think an example of this would be a driver using outb() to disable > > > an interrupt, and then relying on the the interrupt no longer happening > > > after the outb(). > > > > Isn't that racy already? i.e. the interrupt could fire just before you > > disabled it, but not get delivered by the irq controller until after you'd > > disabled it at the device? > > Probably, I had a hard enough time trying to come up with any example ;-) You and me both! > One reference to non-posted transaction in a comment is in > drivers/net/ethernet/dec/tulip/de4x5.c: > > /* > ** The DE4X5 interrupt handler. > ** > ** I/O Read/Writes through intermediate PCI bridges are never 'posted', > ** so that the asserted interrupt always has some real data to work with - > ** if these I/O accesses are ever changed to memory accesses, ensure the > ** STS write is read immediately to complete the transaction if the adapter > ** is not on bus 0. Lost interrupts can still occur when the PCI bus load > ** is high and descriptor status bits cannot be set before the associated > ** interrupt is asserted and this routine entered. > */ Thankfully, that driver is both old and non-portable: depends on VIRT_TO_BUS || ALPHA || PPC || SPARC so I'm not especially concerned about it. Judging by the comment, we'd need to add something like: diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c index 66535d1653f6..c85089f65b0e 100644 --- a/drivers/net/ethernet/dec/tulip/de4x5.c +++ b/drivers/net/ethernet/dec/tulip/de4x5.c @@ -1556,6 +1556,10 @@ de4x5_interrupt(int irq, void *dev_id) sts = inl(DE4X5_STS); /* Read IRQ status */ outl(sts, DE4X5_STS); /* Reset the board interrupts */ + /* Beware of PCI posted writes */ + if (IS_ENABLED(CONFIG_ARM64) && lp->bus_num) + inl(DE4X5_STS); + if (!(sts & lp->irq_mask)) break;/* All done */ handled = 1; if we wanted to get this working reliably on arm64. However, I'll be honest and say we haven't had much demand for supporting DEC PCI devices yet :) > I found another comment in the via-rhine driver: > > /* Beware of PCI posted writes */ > #define IOSYNC do { ioread8(ioaddr + StationAddr); } while (0) > > this one is used in the chip reset function, and in the transmit > path. Since this is doing a read-back, I take this comment as saying "posted writes are a thing, so perform a read-back to force the prior write to complete", which is fine. Will