Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2518625ybi; Sun, 26 May 2019 02:29:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXQhLtYAcgIYkMREfe2rO+PeBxfoJmmKOyt1BHjhsaTW0+ftimR8irCJYHo3aMd8QtfEQb X-Received: by 2002:a62:ab10:: with SMTP id p16mr94603596pff.222.1558862986747; Sun, 26 May 2019 02:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558862986; cv=none; d=google.com; s=arc-20160816; b=uCok+XIEGS4Kk//mukbVixzVzBdihlspPyx+16Qn/Gl2A0FgMffboH+wQyOPfYepZK 4mZ1w3foP8PaUk/EU2MXJCYVJCcBN9tarRLkyY93XcLpIBN+gYgl2CX2iRUVw/hZOEp9 yO493NV45luHV8M+cpI3fROEKXfFIcKmwwDwsDrjtbMtEh2ak5ZEaRiIGkcQ4hsQwdqM q9929C7U96rcOOnrwsjGzf3KIA1tNiEoePp6TtnjL1ARLFkskj70QzTxsPinkvM9wUHR BUvxqy2QWgx+f/VIJo+roJmDJ7W+YRxM1TTLJSoKHcyiVFYi2PBvXw8uUxQN/xQ9nOcP rA+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:cc:to:from; bh=VolgcPjnxGuGDBIFdhhXXzBPbQzoziL/Qxy1asboS8c=; b=xhfku4GqrBIBiIAg/uVTKSzRuCoGZq2+MiJNrFcjtPDVkihtTcPeYm3Ay//ZraRf2+ bBhepzOk4owSKvNbOcJr+HrGaK2LLlK4SkPPeSdwdD4UoR/ZUkjxU1Hr9sb8gHmZcOur Bcs1xw1WPoxB9qKmOHBkGZpbg3GrmnV6O97w1r2dZKfCCoUVxQqILLLzhktmpiNaT8CO kH7omXgOsVyCGN1sTziPuiG8nM1RreKdNMCf6aXTxUA+JvFEfRuONWucw3zg8bOlUfXu i9tni2kBjmxd6AC/E7+ogcMX8IM+MdobBKx2kFejnY8w7kCC1SBVAsHp8dlRPNjdeJsz AN5A== 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 j93si12555269plb.32.2019.05.26.02.29.31; Sun, 26 May 2019 02:29:46 -0700 (PDT) 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 S1727688AbfEZJ23 convert rfc822-to-8bit (ORCPT + 99 others); Sun, 26 May 2019 05:28:29 -0400 Received: from linux-libre.fsfla.org ([209.51.188.54]:49130 "EHLO linux-libre.fsfla.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbfEZJ23 (ORCPT ); Sun, 26 May 2019 05:28:29 -0400 X-Greylist: delayed 466 seconds by postgrey-1.27 at vger.kernel.org; Sun, 26 May 2019 05:28:28 EDT Received: from free.home (home.lxoliva.fsfla.org [172.31.160.164]) by linux-libre.fsfla.org (8.15.2/8.15.2/Debian-3) with ESMTP id x4Q9JdKg031188; Sun, 26 May 2019 09:19:41 GMT Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTP id x4Q9J058102102; Sun, 26 May 2019 06:19:01 -0300 From: Alexandre Oliva To: "Maciej W. Rozycki" Cc: Aaro Koskinen , Tom Li , James Hogan , Jiaxun Yang , Huacai Chen , Ralf Baechle , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC] On the Current Troubles of Mainlining Loongson Platform Drivers Organization: Free thinker, not speaking for FSF Latin America References: <20190208083038.GA1433@localhost.localdomain> <20190211125506.GA21280@localhost.localdomain> <20190211230614.GB22242@darkstar.musicnaut.iki.fi> <20190217235951.GA20700@darkstar.musicnaut.iki.fi> Date: Sun, 26 May 2019 06:19:00 -0300 In-Reply-To: (Maciej W. Rozycki's message of "Fri, 8 Mar 2019 23:56:03 +0000 (GMT)") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Scanned-By: MIMEDefang 2.84 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mar 8, 2019, "Maciej W. Rozycki" wrote: > Anyway I meant: does `war_io_reorder_wmb' expand to `wmb' on your system? No, it expands to `barrier' on the yeeloong: CONFIG_CPU_LOONGSON2F=y CONFIG_CPU_LOONGSON2F_WORKAROUNDS=y CONFIG_CPU_LOONGSON2=y CONFIG_SYS_HAS_CPU_LOONGSON2F=y I've finally managed to do the bisection on object files I mentioned I'd do to try to pinpoint where __BUILT_IOPORT_PFX with barrier rather than !barrier regressed. I found that forcing barrier off for drivers/irqchip/irq-i8259 was enough to avoid the problem. (I further narrowed it down to byte I/O, which is no surprise considering irq-i8259 doesn't seem to use any non-byte I/O.) Then I narrowed it down to output only. A Loongson2F kernel built with the patch below works at normal speed. I've also keyed the -1 barrier selector to compiling the irq-i8259 driver only, and that got me a functional kernel, but I'm not confident that the same issues that affect the interrupt controller, preventing it from initializing correctly, is not also affecting other drivers, just in less visible ways, so the patch conservatively reverts to the older barriers for all I/O (i.e., non-mem) out primitives. I've tested this on a yeeloong on top of v5.1.5. I'm tempted to start using this patch in my Freeloong builds of GNU Linux-libre for gnewsense/yeeloong of 5.0 and 5.1 stable releases, to try to make them usable. Can anyone suggest any reason why it might be risky to do so, moving on as much as I could to the new barriers, sticking to the 4.19-one only for non-mem out? As in, could mixing the barriers be riskier than reverting to the 4.19 barriers everywhere? Thanks in advance for any insights and recommendations, diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h index 845fbbc7a2e3..04be4758d4ff 100644 --- a/arch/mips/include/asm/io.h +++ b/arch/mips/include/asm/io.h @@ -416,7 +416,7 @@ static inline void pfx##out##bwlq##p(type val, unsigned long port) \ volatile type *__addr; \ type __val; \ \ - if (barrier) \ + if (barrier > 0) \ iobarrier_rw(); \ else \ war_io_reorder_wmb(); \ @@ -467,13 +467,22 @@ BUILDIO_MEM(w, u16) BUILDIO_MEM(l, u32) BUILDIO_MEM(q, u64) -#define __BUILD_IOPORT_PFX(bus, bwlq, type) \ - __BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0,) \ - __BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0, _p) +#define __BUILD_IOPORT_PFX(bus, bwlq, type, barrier) \ + __BUILD_IOPORT_SINGLE(bus, bwlq, type, barrier, 0,) \ + __BUILD_IOPORT_SINGLE(bus, bwlq, type, barrier, 0, _p) + +/* Choose the kind of barrier used for out in __BUILD_IOPORT_SINGLE in + non-__mem_ variants. On Loongson2F, irq-i8259 fails to initialize + when this is defined to 1. */ +#if defined(CONFIG_CPU_LOONGSON2) +#define USE_IO_BARRIER_FOR_NON_MEM_OUT -1 +#else +#define USE_IO_BARRIER_FOR_NON_MEM_OUT 1 +#endif #define BUILDIO_IOPORT(bwlq, type) \ - __BUILD_IOPORT_PFX(, bwlq, type) \ - __BUILD_IOPORT_PFX(__mem_, bwlq, type) + __BUILD_IOPORT_PFX(, bwlq, type, USE_IO_BARRIER_FOR_NON_MEM_OUT) \ + __BUILD_IOPORT_PFX(__mem_, bwlq, type, 2) BUILDIO_IOPORT(b, u8) BUILDIO_IOPORT(w, u16) -- Alexandre Oliva, freedom fighter he/him https://FSFLA.org/blogs/lxo Be the change, be Free! FSF Latin America board member GNU Toolchain Engineer Free Software Evangelist Hay que enGNUrecerse, pero sin perder la terGNUra jamás - Che GNUevara