Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1312328pxk; Fri, 25 Sep 2020 11:21:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSOWov0gEzYJD5RDFSmXeFz7p2zHzzLVddDV1GoOPl+B2XkKSkO5Jw4bLuzmqdyUKrz1vD X-Received: by 2002:a17:906:4b18:: with SMTP id y24mr3917909eju.471.1601058070847; Fri, 25 Sep 2020 11:21:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601058070; cv=none; d=google.com; s=arc-20160816; b=V2pOk4X2H1t1+jAh5uIvquY/YoGEnA++oX2H6S/kWTr1u6fInADCTrFtuLIvVtY8DA fM8NhToLBZNmskedca9wW8mzQ2m2ejMrzwhLBfBj9r8GiSnP0RLcVcOpg4XH28+BH5WP 5P8lDMAlbwzNYAQ472zYWZC5U3GIIWh64qhdVroQVDVLMbo/bIstpyTxp/j2gOCSZHDo VrrSe6a6SkIdcc2ODGrzlPf7X6IrWsIXrbuLKWTn9pnjWLeEJBtfBPwR01fvHYDiJwhV oTiUpowuIsvtRvWMbMyFY7CXiSChfYDW6xiaGIcihICodnC/j2S9dMu84XEEDMvR+F7Z nuzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KuVh4k0YGfuilvfXzIG5x1hy6J6bEoL8nlds5f010UI=; b=GxGT9hJkFvRsMtZPbOdKM8FzQttKenYzOVBHYwp1Owus0l3dC54fiiKcpUtilAyhtn 8XCqgYde4SJjIIE9YIZL93LUtjhqBjuQsA1fB+N4oW97KBDPxyLjVFYCu2BcN8iic8No yOUFkX1eDX0YXdoYOvYtUPhlY7/dojAGMeQ1RM9hgDPIQZZOZau3VEQ7EiXgtuKVpC13 DcIs7+CA/F8Idhihh/ukKvP8MqqGn3r8KsBfVIjICpNFGHyyS86or7EruDhecPGE2q5I ucNCEYNDot2IqYNRRyFGt+BNb5hrAkYcz9bvYZOJOf15OTg0mh7kc23YpEUvOyO6M7gj 9C7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v23si2419650ejf.312.2020.09.25.11.20.47; Fri, 25 Sep 2020 11:21:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729697AbgIYSSN (ORCPT + 99 others); Fri, 25 Sep 2020 14:18:13 -0400 Received: from mail.baikalelectronics.com ([87.245.175.226]:49158 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728069AbgIYSSN (ORCPT ); Fri, 25 Sep 2020 14:18:13 -0400 Received: from localhost (unknown [127.0.0.1]) by mail.baikalelectronics.ru (Postfix) with ESMTP id 3C2B7803202A; Fri, 25 Sep 2020 18:18:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at baikalelectronics.ru Received: from mail.baikalelectronics.ru ([127.0.0.1]) by localhost (mail.baikalelectronics.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M9ydMZeshDge; Fri, 25 Sep 2020 21:18:03 +0300 (MSK) Date: Fri, 25 Sep 2020 21:18:02 +0300 From: Serge Semin To: Jiaxun Yang CC: Thomas Bogendoerfer , Alexey Malahov , Pavel Parkhomenko , Vadim Vlasov , "Maciej W . Rozycki" , , Subject: Re: [PATCH 1/2] mips: Add strong UC ordering config Message-ID: <20200925181802.bfhtu5ozxc6wkt6g@mobilestation> References: <20200920110010.16796-1-Sergey.Semin@baikalelectronics.ru> <20200920110010.16796-2-Sergey.Semin@baikalelectronics.ru> <57fb837a-d884-b368-7a72-d010b5e52f2a@flygoat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <57fb837a-d884-b368-7a72-d010b5e52f2a@flygoat.com> X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 25, 2020 at 11:54:20AM +0800, Jiaxun Yang wrote: > > > 在 2020/9/20 19:00, Serge Semin 写道: > > In accordance with [1, 2] memory transactions using CCA=2 (Uncached > > Cacheability and Coherency Attribute) are always strongly ordered. This > > means the younger memory accesses using CCA=2 are never allowed to be > > executed before older memory accesses using CCA=2 (no bypassing is > > allowed), and Loads and Stores using CCA=2 are never speculative. It is > > expected by the specification that the rest of the system maintains these > > properties for processor initiated uncached accesses. So the system IO > > interconnect doesn't reorder uncached transactions once they have left the > > processor subsystem. Taking into account these properties and what [3] > > says about the relaxed IO-accessors we can infer that normal Loads and > > Stores from/to CCA=2 memory and without any additional execution barriers > > will fully comply with the {read,write}X_relaxed() methods requirements. > > > > Let's convert then currently generated relaxed IO-accessors to being pure > > Loads and Stores. Seeing the commit 3d474dacae72 ("MIPS: Enforce strong > > ordering for MMIO accessors") and commit 8b656253a7a4 ("MIPS: Provide > > actually relaxed MMIO accessors") have already made a preparation in the > > corresponding macro, we can do that just by replacing the "barrier" > > parameter utilization with the "relax" one. Note the "barrier" macro > > argument can be removed, since it isn't fully used anyway other than being > > always assigned to 1. > > > > Of course it would be fullish to believe that all the available MIPS-based > > CPUs completely follow the denoted specification, especially considering > > how old the architecture is. Instead we introduced a dedicated kernel > > config, which when enabled will convert the relaxed IO-accessors to being > > pure Loads and Stores without any additional barriers around. So if some > > CPU supports the strongly ordered UC memory access, it can enable that > > config and use a fully optimized relaxed IO-methods. For instance, > > Baikal-T1 architecture support code will do that. > > > > [1] MIPS Coherence Protocol Specification, Document Number: MD00605, > > Revision 01.01. September 14, 2015, 4.2 Execution Order Behavior, > > p. 33 > > > > [2] MIPS Coherence Protocol Specification, Document Number: MD00605, > > Revision 01.01. September 14, 2015, 4.8.1 IO Device Access, p. 58 > > > > [3] "LINUX KERNEL MEMORY BARRIERS", Documentation/memory-barriers.txt, > > Section "KERNEL I/O BARRIER EFFECTS" > > > > Signed-off-by: Serge Semin > > Cc: Maciej W. Rozycki > Reviewed-by: Jiaxun Yang > > > Based on #mipslinus discussions, I suspect this option can be selected by > most modern MIPS processors including all IMG/MTI cores, > Ingenic and Loongson. Thanks for reviewing the patch. Regarding the option. Alas it's not that easy and we must be very careful with assumption whether some processor supports the denoted feature. Even if the MIPS cores do imply the strict UC load/stores ordering, the system interconnects may still perform the out-of-order requests execution. For instance, the P5600 cores installed into our Baikal-T1 SoC do support the strong UC ordering, but there is a cascade of the OCP2AXI, AXI2AXI and AXI2APB bridges behind the CPU memory interface, each of which is equipped with an internal FIFO and some complicated logic of the traffic routing. So each platform should be carefully analyzed and tested (if it's possible) before enabling the suggested feature, otherwise we'll risk to end up with in general working, but at some point buggy, systems. Needless to say, that out-of-order exec problems is very hard to track and debug due to a random nature of impact on the system. -Sergey > > Thanks. > > - Jiaxun > > > --- > > arch/mips/Kconfig | 8 ++++++++ > > arch/mips/include/asm/io.h | 20 ++++++++++---------- > > 2 files changed, 18 insertions(+), 10 deletions(-) > >