Received: by 10.192.165.156 with SMTP id m28csp901498imm; Fri, 13 Apr 2018 09:44:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+gB1GgWBjt0wmuM0izxKRkN5MAdgTxUXJim1TEShz0raxPjFOEbkne8qeA0p4snpS+o39S X-Received: by 10.98.89.200 with SMTP id k69mr12269143pfj.100.1523637877661; Fri, 13 Apr 2018 09:44:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523637877; cv=none; d=google.com; s=arc-20160816; b=0bIxRtiIubF8hZZf5rgDIbyB0j24OiZBmigaNCFU+H3PhFOtC35MrILtbNSDJ1k74q oETc5//WG4qlHsQLOCCFtWliLW01Ng0lgXdqAV1gpiLrb6ffMG2BnHKWpobdW3IU5bO1 dp9uAX+FvNmXJEbkw5ilP0Ls0pBsbuboEY8lZ5Rdyj/CYKFycNBS0Yw+SRXY25qIKRMw N9sEc6n9bNhkaSQsRsVqk8mn1VWMoKXMzjuuPvu/1vKtYFHJamsfzrnSWNsBvXLLsWZU T8q29FUxjy1pCX+W3VEFdYh37fhPHB4sxl+uAn4OQHcoTfEENUztbq6QahOEzIkpWd7+ 3Ikw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=0I6UJoHGjzTK56pON+EGdg91X9dakGCgbkxEZcPPg7g=; b=qSSX+AjQPAlNHsRyHLEnz3n86q1zhxIoT9J3GlkOo0+JlDyKKfFsy+AEgh/gJRHVNd l06QO0UOVxD0mXSXK37HB7CxNFGEhmorIdxiiiSAZMLxqyMb0ue1qp9KiqWx2pSmyawT jqdERWJu6/sAZzWmTHNknRQxrHoQEMRIDxXhOg8K2Sf1ICzujnvnGx/XySwxXoa1CIv8 fs/b0bQ/S2sxgJ2gEQMj/p2foI0QYIc1nIJ2zQeT9mr19EDnG360+g3ZuPqFTToK8gZb 2R01GJtyQ3GT65FzgjwfBnZbFVyVXR9aH6iqvaiyLuPW5xW7mzkoPQynq7+6qDffxaXI 4f9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=QBKjhn3o; dkim=pass header.i=@codeaurora.org header.s=default header.b=K/EUYbXE; 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 u75si4886130pfd.183.2018.04.13.09.44.23; Fri, 13 Apr 2018 09:44:37 -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=pass header.i=@codeaurora.org header.s=default header.b=QBKjhn3o; dkim=pass header.i=@codeaurora.org header.s=default header.b=K/EUYbXE; 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 S1752696AbeDMQgk (ORCPT + 99 others); Fri, 13 Apr 2018 12:36:40 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:58450 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752410AbeDMQgh (ORCPT ); Fri, 13 Apr 2018 12:36:37 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E130360C67; Fri, 13 Apr 2018 16:36:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523637396; bh=RE+eupLpw84eANqvQ67LQoTJFvjxF4GRG/ETDuX857s=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=QBKjhn3ox8jPRq6JHTAe3fm3R5eJkiklHrqUhTBF61CU0dBhOIWezFTMG1pBmEWQ8 LqzyxZWbDOFxxX5vpBLlGSb34kMp8dYYcLxBp+P40GdjvNCYsafHpiptiP2yH7m6HU 10PDeH0cshtYYPmZZt8YX7oz6aGNaDZF2YO/f7R0= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.235.228.150] (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id CBF936072E; Fri, 13 Apr 2018 16:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1523637395; bh=RE+eupLpw84eANqvQ67LQoTJFvjxF4GRG/ETDuX857s=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=K/EUYbXEWZ2qiZosaLOcYs0Bm3QLw2W5CNAHRLLJ45Zo9hPY3IoUdUuPB5twbPSTf X4EKeS+aI+yVe5KFVLxbTG/s7Os13nm+SyLB4spDr71KjVr31mSVNradLXB+23+Won o2FK0bRLajpxcyKbuWWF6hNqf573QwlyXTmynKRM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org CBF936072E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org Subject: Re: [PATCH v3 2/2] MIPS: io: add a barrier after register read in readX() To: David Laight , 'James Hogan' Cc: "linux-mips@linux-mips.org" , "arnd@arndb.de" , "timur@codeaurora.org" , "sulrich@codeaurora.org" , "linux-arm-msm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Ralf Baechle , Paul Burton , "linux-kernel@vger.kernel.org" References: <1522760109-16497-1-git-send-email-okaya@codeaurora.org> <1522760109-16497-2-git-send-email-okaya@codeaurora.org> <20180412215149.GA27802@saruman> From: Sinan Kaya Message-ID: <3688d54c-85f3-6eba-7f13-1cef0a0b5d85@codeaurora.org> Date: Fri, 13 Apr 2018 12:36:33 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/13/2018 11:41 AM, David Laight wrote: > From: James Hogan >> Sent: 12 April 2018 22:52 >> On Tue, Apr 03, 2018 at 08:55:04AM -0400, Sinan Kaya wrote: >>> While a barrier is present in writeX() function before the register write, >>> a similar barrier is missing in the readX() function after the register >>> read. This could allow memory accesses following readX() to observe >>> stale data. >>> >>> Signed-off-by: Sinan Kaya >>> Reported-by: Arnd Bergmann >> >> Both patches look like obvious improvements to me, so I'm happy to apply >> to my fixes branch. > > Don't you also need at least barrier() between the register write in writeX() > and the register read in readX()? > On ppc you probably need eieio. > Or are drivers expected to insert that one? > If they need to insert that one then why not all the others?? > Good question. The volatile in here should prevent compiler from reordering the register read or write instructions. static inline type pfx##read##bwlq(const volatile void __iomem *mem) This is the solution all other architectures rely on especially via __raw_readX() and __raw_writeX() API. Now, things can get reordered when it leaves the CPU. This is guaranteed by embedding wmb() and rmb() into the writeX() and readX() functions in other architectures. This ordering guarantee has been agreed to be the responsibility of the architecture not drivers. -- Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.