Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3423528pxf; Mon, 29 Mar 2021 01:39:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUJVVQoPAn+epdu+SJvQJvMo/UpMo/jAMC3K22Cl+k4W7KcKzEQHK5lPiHKUfI2qGGP3kh X-Received: by 2002:a17:906:cb87:: with SMTP id mf7mr26855744ejb.81.1617007149034; Mon, 29 Mar 2021 01:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007149; cv=none; d=google.com; s=arc-20160816; b=bfrX/d9lJyrCYWBWW+caKp06gFzLKdHVIeXFOlgswRoO4UKAJntbOrEFccXojWHJG+ bDn/N2NHieK9Jrh8CBSoJUjlTjOKZYvB30483Tr5kIEvnEjtVDzIRJSXxO/814txce7c 4yjPNkmQceTB7xcm4fwvBEWJm+9+icAEgfeeK1P3rD7iRzfVTBJ8kZfSvo0DiLBWlz9H iJhdQuSwgrcLifn/xDEgFEDHrxccFgCKIhCJMyyiJ1OWYaa+60EHUgNMs3/XRkjK2KKu 4TpScw5njqw/y23efiey0+LZM3rnL2ttOvggHOiPQSw3on/GEH9BZWE3u1J4Yp83X/oj Mx7w== 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=ddfL0jfCtO3XAaWKVnOu6gO6m2C2jH3lLBlpn6AIz14=; b=C8tl/jCWo8/TYTLsIuzbfQ44dRSkHU5Vu+r+o3xcp/s0Uvf2wJQfR7fuf+TAkS77FS IOIXVX8A50zG1vN1bu5CAnxBQ9i078GdmivM2CrPZxWkxrJhrAlBNwFmXlTJQO4C7Qym ofyLNmAKYVmcZ1WsW2+H8o9nCcwButTDyqLCN5jUYWirMvUCyC/ysAjgslybjrtORNWF VjGYjV3jIjFu+9CnkesmLMSGK9LIgzx4cZO6YmhNRrG7WOm7yhOCB1tK7aN7+MB2nmcq Z/0hNqNRVaJyMOOkoyn62bM2UwiN1MxGhe7KbBbl8/LpQlyW/R9/vgT8ch+3ZL35cf30 nHnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Klfqmg/H"; 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 p18si12753488edx.311.2021.03.29.01.38.47; Mon, 29 Mar 2021 01:39:09 -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="Klfqmg/H"; 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 S233356AbhC2Ig1 (ORCPT + 99 others); Mon, 29 Mar 2021 04:36:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:39110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233731AbhC2IWQ (ORCPT ); Mon, 29 Mar 2021 04:22:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 33FC06044F; Mon, 29 Mar 2021 08:22:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006125; bh=WNjIOSWreC0GQTlW1iRMYz47SgwQa5dd35GM4wDeaeg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Klfqmg/HkYDWkARCOR9Gobsd3Rj4e1cO5zb1bccIuDceWxlyzyQnTCodG7tNNBpnQ ilfgBJH+D3mqAP0pXf35eQVE+SuMTg0oWpVkdf1KiTmlRodzoMIfTs3mquaaXKorvU yQkI3bhn2BolosA6MI8TK4nT5Fqgt5vhRWaIbAQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Angelo Dureghello , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.10 127/221] can: flexcan: flexcan_chip_freeze(): fix chip freeze for missing bitrate Date: Mon, 29 Mar 2021 09:57:38 +0200 Message-Id: <20210329075633.441753261@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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: Angelo Dureghello [ Upstream commit 47c5e474bc1e1061fb037d13b5000b38967eb070 ] For cases when flexcan is built-in, bitrate is still not set at registering. So flexcan_chip_freeze() generates: [ 1.860000] *** ZERO DIVIDE *** FORMAT=4 [ 1.860000] Current process id is 1 [ 1.860000] BAD KERNEL TRAP: 00000000 [ 1.860000] PC: [<402e70c8>] flexcan_chip_freeze+0x1a/0xa8 To allow chip freeze, using an hardcoded timeout when bitrate is still not set. Fixes: ec15e27cc890 ("can: flexcan: enable RX FIFO after FRZ/HALT valid") Link: https://lore.kernel.org/r/20210315231510.650593-1-angelo@kernel-space.org Signed-off-by: Angelo Dureghello [mkl: use if instead of ? operator] Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/flexcan.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index d712c6fdbc87..7cbaac238ff6 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -658,9 +658,15 @@ static int flexcan_chip_disable(struct flexcan_priv *priv) static int flexcan_chip_freeze(struct flexcan_priv *priv) { struct flexcan_regs __iomem *regs = priv->regs; - unsigned int timeout = 1000 * 1000 * 10 / priv->can.bittiming.bitrate; + unsigned int timeout; + u32 bitrate = priv->can.bittiming.bitrate; u32 reg; + if (bitrate) + timeout = 1000 * 1000 * 10 / bitrate; + else + timeout = FLEXCAN_TIMEOUT_US / 10; + reg = priv->read(®s->mcr); reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT; priv->write(reg, ®s->mcr); -- 2.30.1