Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3320135pxf; Mon, 15 Mar 2021 07:05:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrmnTRMMrRJonPbCB6f4V5tz8zTru2qLopsFO7vYJTECbvuKL/AfzErno+UVMqmQVSWyxk X-Received: by 2002:a17:906:894:: with SMTP id n20mr23496328eje.57.1615817108541; Mon, 15 Mar 2021 07:05:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817108; cv=none; d=google.com; s=arc-20160816; b=GKDOCJurURLjsvltQO4e/YYGVvVptp38QLOJxuAv8Y3LVGeAV1zFN9QrAOkSfqrhBL F5ZVBwNtT8pLFvsowo4SKZuq1bulgmMU6LjmR5fzPWTul1jcLGf5dtpF7qSmZUwJ5ezP nBVmGhDjyWZR1sdCT1pK/9pTZCGFz5QScmfqBSb8/h4nCTSstYXtIn0vn51PyqJnXL6A vPFyDzkgUW9tiCqyAdcEOxqlQ9UhKtUmy4H13f/vQDhKjrc0pFaC2+Ju+QgqrDsd0ylh Vf56V+RzkS+L6uZ/LwdNHiDC9PSJvWBNqdTFk+dy97QXVgfef+krBEj7h4JY6W0Xh+fU ZRig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U/y3Uaf1tfnx8xyNTdjC+gU9bWO0WickXA6Tx7GGSTU=; b=il6fyRUpq1YydgpXPum/2T025AO8O1JOHdqQqTPG3YUco0LoNYEu8iUsc1Ui8lSBpJ lpKrgoa9OryxbcsHCthQOa4/PZlEss3aji/L6Tnsc9RnE50iGkUn+ZNuOtXBWbLgBLOP T39Ar1ManFhMS27a5UANrtum2YZxF1ARrN/ljVOprnTzbSvRJGpCNX37qpMWwzYuZApv ZBTR8GOLXG1Cpg4nB1/UrlSppzemIVNdUXwZG3dHZW/j4RBEbuQrRCa0GWrvx/khDED5 lM/8TYPJtF7asoh1o+9oyxNcbJ6VGZjDCaKGv/X//zFsGp7HSuQpyxIiEZFU+73582d9 f0XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NmoQkCSM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s3si11270091edx.251.2021.03.15.07.04.45; Mon, 15 Mar 2021 07:05:08 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NmoQkCSM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234442AbhCOODW (ORCPT + 99 others); Mon, 15 Mar 2021 10:03:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:34534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231382AbhCON5J (ORCPT ); Mon, 15 Mar 2021 09:57:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 53E5764EFD; Mon, 15 Mar 2021 13:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816628; bh=/ARiGRTysZEO0zch14sIudIpLeSsRLsa8TZ0ZFfxbQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NmoQkCSMlfYCec+n8+h0wN9bI3/YaS+AtlxUaOHLMMus2mRYsqhTBEPjPDBDJmDDe E5Iy2tWf5FmYxzbD8ARtHFM/LutuHnzoSAkZgtoR9s3KqwHHCMkY84vo/YoyMcqole zbJ6iv3k5TI4J9ORMDqAOcNj0gPMU4znOwTY00Nw= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Kleine-Budde , Torin Cooper-Bennun Subject: [PATCH 5.4 013/168] can: tcan4x5x: tcan4x5x_init(): fix initialization - clear MRAM before entering Normal Mode Date: Mon, 15 Mar 2021 14:54:05 +0100 Message-Id: <20210315135550.775526741@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Torin Cooper-Bennun commit 2712625200ed69c642b9abc3a403830c4643364c upstream. This patch prevents a potentially destructive race condition. The device is fully operational on the bus after entering Normal Mode, so zeroing the MRAM after entering this mode may lead to loss of information, e.g. new received messages. This patch fixes the problem by first initializing the MRAM, then bringing the device into Normale Mode. Fixes: 5443c226ba91 ("can: tcan4x5x: Add tcan4x5x driver to the kernel") Link: https://lore.kernel.org/r/20210226163440.313628-1-torin@maxiluxsystems.com Suggested-by: Marc Kleine-Budde Signed-off-by: Torin Cooper-Bennun Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/m_can/tcan4x5x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/net/can/m_can/tcan4x5x.c +++ b/drivers/net/can/m_can/tcan4x5x.c @@ -325,14 +325,14 @@ static int tcan4x5x_init(struct m_can_cl if (ret) return ret; + /* Zero out the MCAN buffers */ + m_can_init_ram(cdev); + ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG, TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL); if (ret) return ret; - /* Zero out the MCAN buffers */ - m_can_init_ram(cdev); - return ret; }