Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2335253ybz; Thu, 23 Apr 2020 16:14:43 -0700 (PDT) X-Google-Smtp-Source: APiQypLpWtdomBcUqot3ajMk+WuuU8NcdGSbEiikjpdmv5CQDYdrJGmqF7fvxIlnFQXufN0QxJVq X-Received: by 2002:a17:906:f1c4:: with SMTP id gx4mr4534795ejb.171.1587683683283; Thu, 23 Apr 2020 16:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587683683; cv=none; d=google.com; s=arc-20160816; b=rTBe8whd4+S8PvS6O1QTgR/m+6KapyP2hiv6QQ/F78Y3WmIN81SwDqi3gR+9xp2NuI 8g0TtsmRckUiPSp4ii8RKZFgi7eofOck171GT963Ume6Oa7lwtGSOnI9/7uHPZJ7XWKA DtUq6SpJ0swNLeo6Gn+F9ykHTJD6fvw5RTm1hscWPrhIZJjw5Qr4CYeVC32F/MRCrW4s E53mT7BzCBfRajymGi5ZcqFt9izmYJEcrCKjUWt+j3Nhg6LU6TtIBl1AJ9Ok78C7iv9w cVHBytoobknWVH/rYSCMywybIE+s0YjHeM1HRbVzHvnEmnFyTQ4ZScWdYQVaPzNtMPbS piYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=oD+SNtwKhMD/ig3B8UCzY+8LaCJTvaCwfFV4PcC45zM=; b=ut1efq8BQsjsTXIh+vH+zm7HBpuFr18afNzjNAHgmVHl1vsUZaoq80HYdsmbyiZVUR KZFaNHhe19EUq1pvlsWdIguf30NZzPwwccFIeNb1MYWZjHPFZ1yIB/GEiDM6u4dczW8L 27p9yE3pTU0Vtzewh6WfnRyo/PKw0azxzj55doZW9o+NHpu0gZ0no/iCviswUSr2OmA5 GragnUyvMYhHfWknzjFWC73qfEgOlhT0+3tMQkIxWCavofl5WnScPS+4VmR0c5YQcprI XyOZyZNJXVpKsGoBaLCHZkVggYihKXb4Wz6Rpe/gT5sndWGWkGU7+69BRkvt1Kt1+sXH ogqg== 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 q1si2232528eja.190.2020.04.23.16.14.19; Thu, 23 Apr 2020 16:14:43 -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 S1728764AbgDWXLf (ORCPT + 99 others); Thu, 23 Apr 2020 19:11:35 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50232 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728558AbgDWXGw (ORCPT ); Thu, 23 Apr 2020 19:06:52 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvc-0004nR-Hv; Fri, 24 Apr 2020 00:06:44 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvY-00E6ye-H1; Fri, 24 Apr 2020 00:06:40 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "David S. Miller" , "Finn Thain" , "Stan Johnson" Date: Fri, 24 Apr 2020 00:07:11 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 204/245] net/sonic: Use MMIO accessors In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Finn Thain commit e3885f576196ddfc670b3d53e745de96ffcb49ab upstream. The driver accesses descriptor memory which is simultaneously accessed by the chip, so the compiler must not be allowed to re-order CPU accesses. sonic_buf_get() used 'volatile' to prevent that. sonic_buf_put() should have done so too but was overlooked. Fixes: efcce839360f ("[PATCH] macsonic/jazzsonic network drivers update") Tested-by: Stan Johnson Signed-off-by: Finn Thain Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- drivers/net/ethernet/natsemi/sonic.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) --- a/drivers/net/ethernet/natsemi/sonic.h +++ b/drivers/net/ethernet/natsemi/sonic.h @@ -342,30 +342,30 @@ static void sonic_tx_timeout(struct net_ as far as we can tell. */ /* OpenBSD calls this "SWO". I'd like to think that sonic_buf_put() is a much better name. */ -static inline void sonic_buf_put(void* base, int bitmode, +static inline void sonic_buf_put(u16 *base, int bitmode, int offset, __u16 val) { if (bitmode) #ifdef __BIG_ENDIAN - ((__u16 *) base + (offset*2))[1] = val; + __raw_writew(val, base + (offset * 2) + 1); #else - ((__u16 *) base + (offset*2))[0] = val; + __raw_writew(val, base + (offset * 2) + 0); #endif else - ((__u16 *) base)[offset] = val; + __raw_writew(val, base + (offset * 1) + 0); } -static inline __u16 sonic_buf_get(void* base, int bitmode, +static inline __u16 sonic_buf_get(u16 *base, int bitmode, int offset) { if (bitmode) #ifdef __BIG_ENDIAN - return ((volatile __u16 *) base + (offset*2))[1]; + return __raw_readw(base + (offset * 2) + 1); #else - return ((volatile __u16 *) base + (offset*2))[0]; + return __raw_readw(base + (offset * 2) + 0); #endif else - return ((volatile __u16 *) base)[offset]; + return __raw_readw(base + (offset * 1) + 0); } /* Inlines that you should actually use for reading/writing DMA buffers */