Received: by 10.213.65.68 with SMTP id h4csp436744imn; Fri, 30 Mar 2018 08:20:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx48HU2w2X77uSDXmF0rxHQGm8W0qikIveTfrNXMu39I5Vo9UGf57Hx6QumfFq2vJCSfH3n5d X-Received: by 2002:a17:902:7087:: with SMTP id z7-v6mr13166809plk.315.1522423203090; Fri, 30 Mar 2018 08:20:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522423203; cv=none; d=google.com; s=arc-20160816; b=gCgJ4BlaYmX1BCgtcBGfcf+1D2ykZ+FoXdU9AZeo8lKHI8LtJJtQWtlEu2cb0y+PX7 0kKlLRDzjA/ZxWJ7H9sEgsM3Lpr8TjkE3LkuRLzDOwTzU1He3Re7q28SjD4qUONS0/9v 5UGvXT70F4U8I700jFza/4g7gJPuyimiIZRZtBu8puzFdM6KgPfbHy93lybnogTor7li P4/idMUDxFLFLiJNfA8+kD7URE8zCwJ3/lkyu2defuAppmUVNENHyNmRMrCbX77I5bkM vCcsFjZm1LgneUYA+EVGy0bzG1wX8ty7mtblzeI2ygyrDxIy4cIUYbrfBvKGJWVghFYA pVDA== 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:dkim-signature:arc-authentication-results; bh=CoHijwv8uo7Fi4+L7TS6aiR8+2DA4o9nS2DhcinTr3w=; b=q412aaYBCPFVmF8QGqTVo75JmwCkPJQCnYJs+gbzeagePxCYszHm34WIvynztqw+UV TZx1oDJ06h109Zlx1RXidu9qcHXqhm1QAgzg0hp6L7GQ++EcqcE2FgYjEQ4dP1m3JaZj U+uI3VnbdfpGC6KEgM4eGhzsWUZ7spFfZg7m6m+GI8OuFmJ7uNYh8DX2e1F5hgJz35/L xp0tMsMxp5t1wMM4SoZ5hU9U526bQ65TAXC4HXzfI8Z4GEPjLy2VSUp74eKlU9agB09T xG5VPwwNkopVD4y6ybg9SauFVQhpazXzUOj364XB1X4huCf3BP5r224RcFNBOQoRnumP Qatg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=J2tZnOyp; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13si6233557pfi.404.2018.03.30.08.19.17; Fri, 30 Mar 2018 08:20:03 -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; dkim=fail header.i=@armlinux.org.uk header.s=pandora-2014 header.b=J2tZnOyp; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751368AbeC3PQd (ORCPT + 99 others); Fri, 30 Mar 2018 11:16:33 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:55026 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751215AbeC3PQb (ORCPT ); Fri, 30 Mar 2018 11:16:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=CoHijwv8uo7Fi4+L7TS6aiR8+2DA4o9nS2DhcinTr3w=; b=J2tZnOyp80nGUPbHp9jNDQVnTseHf4XTWgLyNgkBuA6STDqalk3RtH7FDCRVGnAl2AdtXrbILCAK8yErCLDHoBBDmL7xQZxJQjuZrnz8asVGBwUi1jEyYfTlQAO0IkaaV1A3I1HI9tgSlBVOqbPHcSaQe6c1kmkSvAeESgjV0y8=; Received: from n2100.armlinux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:42157) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1f1vlM-0005fv-CP; Fri, 30 Mar 2018 16:16:23 +0100 Received: from linux by n2100.armlinux.org.uk with local (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1f1vlK-0002S2-AR; Fri, 30 Mar 2018 16:16:18 +0100 Date: Fri, 30 Mar 2018 16:16:17 +0100 From: Russell King - ARM Linux To: Sinan Kaya Cc: arnd@arndb.de, timur@codeaurora.org, sulrich@codeaurora.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org Subject: Re: [PATCH] io: prevent compiler reordering on the default writeX() implementation Message-ID: <20180330151617.GI16141@n2100.armlinux.org.uk> References: <1522420199-23548-1-git-send-email-okaya@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1522420199-23548-1-git-send-email-okaya@codeaurora.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 30, 2018 at 10:29:58AM -0400, Sinan Kaya wrote: > The default implementation of mapping writeX() to __raw_writeX() is wrong. > writeX() has stronger ordering semantics. Compiler is allowed to reorder > __raw_writeX(). > > In the abscence of a write barrier or when using a strongly ordered > architecture, writeX() should at least have a compiler barrier in > it to prevent commpiler from clobbering the execution order. You want the barrier _before_ the call to __raw_writel() - you need to ensure that writes to memory are emitted by the compiler _before_ the write to the hardware - the write to the hardware may start DMA, and it may be reading data that the program thinks it previously wrote. Similarly, for readl(), you need the barrier after __raw_readl() to ensure that other reads in the program aren't scheduled before a potential DMA status register read. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up