From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F591C43613 for ; Mon, 24 Jun 2019 10:00:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F57A208E3 for ; Mon, 24 Jun 2019 10:00:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561370417; bh=YESTF+djnPXlhFHCOy0pYzKxfYTjxk33iochzxG71zY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TShNv6XcMiU8Ay02DTMCPJBl7EbUJq0cDspnof28vhn3tT5R5wToQBgvy2XMQHwgy 8kYHRP9FkcdYUWpSwpxeAez9btGXwxvsxyxSRt9gsnXl3rar/uQilZtrpxzvyGhnlz VPce7ySRFYO9nXCmu5w9Nq3mD04T3hXUnV2euWMI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728425AbfFXJ7t (ORCPT ); Mon, 24 Jun 2019 05:59:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:59190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729284AbfFXJ7s (ORCPT ); Mon, 24 Jun 2019 05:59:48 -0400 Received: from localhost (f4.8f.5177.ip4.static.sl-reverse.com [119.81.143.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 48B06205ED; Mon, 24 Jun 2019 09:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561370387; bh=YESTF+djnPXlhFHCOy0pYzKxfYTjxk33iochzxG71zY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vvHK/3l3T3hRObjPwjKGm80bW6OIzSxCYyamNvFrVnzcL62PJYYgtJa3A/xMBz/Dn tq/HvFXJ0yOSBZb8NiTZqIT1MFpfUG84J98ekFpL8cDeH64BfNhzwW80cIWsML5cxB bTYiZnmjU7nlGk20QS0JcwGVKWEVoriRcx5blUiQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joakim Zhang , Dong Aisheng , Marc Kleine-Budde Subject: [PATCH 4.14 40/51] can: flexcan: fix timeout when set small bitrate Date: Mon, 24 Jun 2019 17:56:58 +0800 Message-Id: <20190624092310.686118575@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624092305.919204959@linuxfoundation.org> References: <20190624092305.919204959@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Joakim Zhang commit 247e5356a709eb49a0d95ff2a7f07dac05c8252c upstream. Current we can meet timeout issue when setting a small bitrate like 10000 as follows on i.MX6UL EVK board (ipg clock = 66MHZ, per clock = 30MHZ): | root@imx6ul7d:~# ip link set can0 up type can bitrate 10000 A link change request failed with some changes committed already. Interface can0 may have been left with an inconsistent configuration, please check. | RTNETLINK answers: Connection timed out It is caused by calling of flexcan_chip_unfreeze() timeout. Originally the code is using usleep_range(10, 20) for unfreeze operation, but the patch (8badd65 can: flexcan: avoid calling usleep_range from interrupt context) changed it into udelay(10) which is only a half delay of before, there're also some other delay changes. After double to FLEXCAN_TIMEOUT_US to 100 can fix the issue. Meanwhile, Rasmus Villemoes reported that even with a timeout of 100, flexcan_probe() fails on the MPC8309, which requires a value of at least 140 to work reliably. 250 works for everyone. Signed-off-by: Joakim Zhang Reviewed-by: Dong Aisheng Cc: linux-stable Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/flexcan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -177,7 +177,7 @@ #define FLEXCAN_MB_CNT_LENGTH(x) (((x) & 0xf) << 16) #define FLEXCAN_MB_CNT_TIMESTAMP(x) ((x) & 0xffff) -#define FLEXCAN_TIMEOUT_US (50) +#define FLEXCAN_TIMEOUT_US (250) /* FLEXCAN hardware feature flags *