Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3319787pxf; Mon, 15 Mar 2021 07:04:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt9zL/XM+IAgjNfqHaFoov2AesLLFJHaFZ0djK6GE7Tf7XZ9LIq9qht+W15rb6SmaNpV+y X-Received: by 2002:a17:906:5918:: with SMTP id h24mr24177215ejq.501.1615817088285; Mon, 15 Mar 2021 07:04:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817088; cv=none; d=google.com; s=arc-20160816; b=vQ0MugazbChQ+ce+w9w4qPCUz88kebFDffAJiHTR7HqQzQNiJUl2+W+JGuApVQVvTa g+OTF0Q61VOAbEgTldJWbi2mu776AiVvcLNi3U/W91CFIbPhlcj+2mxxPjiz3KGV9bWV ZqLmHGXICzMvPbTZUoC6Bxn06+vDZLcPXuXnB9m0Ie9EK1OOH0hVMVtGZ1/BLJcYT7A2 FWJyeqjUU8NpbtQMRhzOccZX6Dm8SgQCb6nOypUTg8uXMPN7bSx3Tg4TTFZC4uXj41o1 /14zHhwTsU2xYW/T2df6ZSP0sSwXKmM06TwBQ5EvqoGxT5Rdc2vrT/M+KG1DWuqY9Mwg N3Tg== 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=TOaN6yK54rkymdkjj1jmMBxAADCk0/xh7UNslkYnAx0=; b=XIPHBjv0oHp+1E2ysxv1TDMiYQPbHInY9dnwyEcTWLdIkxNtryKdvsACitorMdSHSA qplvNwm6mrqSoGJz6q/aaEPKsNY5xjxduzrgbJj6u4hCavQQF1TyCgxpE24RcYkbH53H i8Ul2ptmKqxJNg/8VzUm3hk6/uJpnZdBXJeZ0lSt1d+E5VMaqAYC2znJgzxicUMxnM+Z oCFDi11436BMUv9ZVmohOQg+VA4RjM7HBKSxk8uvOempD7TUYfhV5mBY5kC1e7hEibYZ 2mPr+JXdyeyLsR9HPe0sWmrF7+d7DgBPLs0xhm+wjl3nod2R3xiDrBa8OX2nBE9PW6XX CHow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CCFf6gEa; 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 p10si10761420edw.62.2021.03.15.07.04.24; Mon, 15 Mar 2021 07:04:48 -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=CCFf6gEa; 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 S234037AbhCOOCt (ORCPT + 99 others); Mon, 15 Mar 2021 10:02:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:34020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231826AbhCON4z (ORCPT ); Mon, 15 Mar 2021 09:56:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1D1F764EF8; Mon, 15 Mar 2021 13:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816615; bh=lNNjEH3y75qU/3lNnN4IaqhItFZUyuGOmBkNvfUvis8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CCFf6gEacIpUydNdDwsd4CrFXjvSruOk4taQDZwBQgEHndcw0MYBXVxcxZyGXKuQk cVSIWAnA2j3ujhmp8FsryswSPlrBervuDEeVzxnhEywuF7F7ht3uDzBcGkajT4YvRf +Wlx9gK1+Ia4gd/nwbKgFDx7yMWO7BsLzfF95Yd0= 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.11 022/306] can: tcan4x5x: tcan4x5x_init(): fix initialization - clear MRAM before entering Normal Mode Date: Mon, 15 Mar 2021 14:51:25 +0100 Message-Id: <20210315135508.380452145@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 @@ -326,14 +326,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; }