Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3321773pxf; Mon, 15 Mar 2021 07:06:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8bRCBUvXcYg20J6OOj7N3c7eWg1GYBvFN5iD32Xx62do2CNDkUVP2lhpn3QF/KYSsjBwg X-Received: by 2002:aa7:d416:: with SMTP id z22mr29869170edq.239.1615817212073; Mon, 15 Mar 2021 07:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817212; cv=none; d=google.com; s=arc-20160816; b=BMcvx/bPlpxkwXqxzF5QyDBX05ICfAju5GV5XTglAmMzXSGzgzOkoM+TcZbIDp9h3d Y7PgOzvNX+nZgQHbjMjxNzXMVUsSRvKqmho755FjjRp8wFf5dg8XoXA+S2AVDqYSoGpN BJIC2aean1/1XQuE6S/NG2UAzQko4mJjigQATYUewuQK2FQ7NMcPTSbsF77beJO4GWno istwEyLUDelZHfNCG2Z3JZbEaTSoJ7WHIcATgymnzjy4izSBYvjmVQmMzBAJ3e4tGVNw DYpDpkZ9ZT6sNSKsHoWmd4fbhPAvJkDIWmjZUGwWwnV8Tlwd/UCQDHzY+rL6PBB7hZ5H HZxw== 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=M+UGm7yXqTbOMAG2FfUdSXV2LvW8T23RNKkCMXWNZEg=; b=IhlOzDm+TFxQM7CWUhNBxSpZV81lopKBcYjSVr1Y4P4djRBFqtoCsb0HCMCYY2vHuv IrqTkRCGmij0a3VMNQg+lm5GH9pdxS75Khzle39LGB9Z4P598kjalhPBFpWsoR8/Zk/Z I+bCixjVGVln4wjTcf3yb6twCkJQ4c6ZOYKAc9GbFb9D5fVvAKd6RJI87yCRch8QPoR6 YATPhoYadXMGk7rP0ufi1+hgTR37Fyu4h+7gwmxbmyXLg6+cIsBpb196hg2vuHN6VWEP AD3Tx5ytsi2n2LLrD5VwBqdQOXCT/p3znuZyuBJ3+8eVswiMJJvRsFjCRen3HazM8gz5 6bGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jzv223T2; 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 h6si7789168ejc.211.2021.03.15.07.06.28; Mon, 15 Mar 2021 07:06:52 -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=jzv223T2; 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 S234080AbhCOOCy (ORCPT + 99 others); Mon, 15 Mar 2021 10:02:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:34042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231840AbhCON44 (ORCPT ); Mon, 15 Mar 2021 09:56:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8181B64EEE; Mon, 15 Mar 2021 13:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816616; bh=zvC60x0TDrgUee+EUTxBvbrcxT8cqVWicznokVysHn0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jzv223T2jdY8U+PjpTlrHr3Q+qN5kKC70m1OsnJnY5SGoi6Z2m//fMYHlqa4CwuDR UOn4brgBApI7Te4ZoximKrU70OaVjMHIN5i5W18UlgAIQYpwZznbfGTAeBR7FcWqjO y5xGK76MkhvMgF4zfk1y/cIwxtVYD2xXZMm63MTk= 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.10 015/290] can: tcan4x5x: tcan4x5x_init(): fix initialization - clear MRAM before entering Normal Mode Date: Mon, 15 Mar 2021 14:51:48 +0100 Message-Id: <20210315135542.459949146@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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 @@ -328,14 +328,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; }