From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99AA626FD9A for ; Mon, 16 Mar 2026 19:13:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773688387; cv=none; b=ibxtVqrFCEs6Sxtpi3IsdiH7c0cFF+XMvo/IWIpZjvPHFnsI6OEOzcJK9Ithpiuj/56nPMru5B9lX5YW4GJJMY3b2U5FBMHJRAhz+cR1y5mNAL691LBvmbWmYYig551svn5Q4bWs5eEiJ7JR8lwA/VpsTfDPpcEnZtED8zRfHv8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773688387; c=relaxed/simple; bh=NfCSE9h/2bOnZR0TWgrG4JwGUuCEnTTaFIrYrhZl+Q4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A9msZI29LHK8mf3X1Dwc7gQrjy4x7nqteREyzUDlV1gF5Ko/k5RFB3UtWmil2U5eaiiksctuU0lXAUpb6fm9fcTnA8u3vkrzVUdt48lsqYPtjcT8eLy5euOGpRp9cPddJ/1NZ9aQ/w9d0ym1AVhZGOV0y2JLcstVf/CjoAm1xFw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i0Pbpg3Q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="i0Pbpg3Q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3C8BC19421; Mon, 16 Mar 2026 19:13:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773688387; bh=NfCSE9h/2bOnZR0TWgrG4JwGUuCEnTTaFIrYrhZl+Q4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i0Pbpg3QSrIi9RXQxv7kRZYLHEA68tog1pFi8MmofPWRdZ2JOoyeu3FPW1FeCOezc oYJk29g7zslheAfE4wpql0hx3sygvG6rqekIMXZkmaFyUB4mw8daxFimhMy3+eI4U0 OPR/oaf00eysb6PFfOtEC1HUJZaALrJi7FG8e831cGphNuo23af1/fDANgbGOGamWc sWTvRMJfE2qlwhjF/+sUidPZz0py8MPaS32X8ww7yYBQSI9FjD5w1iEiFZUCdQYJbp P/60l9tk76Oqu2Fk5eF6QzIktryH6uatEZ/XDEx7q98cJOHLlfWpycCmLI/PSNR5v+ bq4s1AdddopoQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.15.y] can: gs_usb: gs_can_open(): always configure bitrates before starting device Date: Mon, 16 Mar 2026 15:13:04 -0400 Message-ID: <20260316191304.1345441-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026031635-revocable-cyclic-cf21@gregkh> References: <2026031635-revocable-cyclic-cf21@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Marc Kleine-Budde [ Upstream commit 2df6162785f31f1bbb598cfc3b08e4efc88f80b6 ] So far the driver populated the struct can_priv::do_set_bittiming() and struct can_priv::fd::do_set_data_bittiming() callbacks. Before bringing up the interface, user space has to configure the bitrates. With these callbacks the configuration is directly forwarded into the CAN hardware. Then the interface can be brought up. An ifdown-ifup cycle (without changing the bit rates) doesn't re-configure the bitrates in the CAN hardware. This leads to a problem with the CANable-2.5 [1] firmware, which resets the configured bit rates during ifdown. To fix the problem remove both bit timing callbacks and always configure the bitrates in the struct net_device_ops::ndo_open() callback. [1] https://github.com/Elmue/CANable-2.5-firmware-Slcan-and-Candlelight Cc: stable@vger.kernel.org Fixes: d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices") Link: https://patch.msgid.link/20260219-gs_usb-always-configure-bitrates-v2-1-671f8ba5b0a5@pengutronix.de Signed-off-by: Marc Kleine-Budde [ No CAN-FD ] Signed-off-by: Sasha Levin --- drivers/net/can/usb/gs_usb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c index ffa2a4d92d010..73a3dc6de434f 100644 --- a/drivers/net/can/usb/gs_usb.c +++ b/drivers/net/can/usb/gs_usb.c @@ -414,9 +414,8 @@ static void gs_usb_receive_bulk_callback(struct urb *urb) } } -static int gs_usb_set_bittiming(struct net_device *netdev) +static int gs_usb_set_bittiming(struct gs_can *dev) { - struct gs_can *dev = netdev_priv(netdev); struct can_bittiming *bt = &dev->can.bittiming; struct usb_interface *intf = dev->iface; int rc; @@ -446,7 +445,7 @@ static int gs_usb_set_bittiming(struct net_device *netdev) kfree(dbt); if (rc < 0) - dev_err(netdev->dev.parent, "Couldn't set bittimings (err=%d)", + dev_err(dev->netdev->dev.parent, "Couldn't set bittimings (err=%d)", rc); return (rc > 0) ? 0 : rc; @@ -677,6 +676,13 @@ static int gs_can_open(struct net_device *netdev) if (ctrlmode & CAN_CTRLMODE_3_SAMPLES) flags |= GS_CAN_MODE_TRIPLE_SAMPLE; + rc = gs_usb_set_bittiming(dev); + if (rc) { + netdev_err(netdev, "failed to set bittiming: %pe\n", ERR_PTR(rc)); + kfree(dm); + return rc; + } + /* finally start device */ dev->can.state = CAN_STATE_ERROR_ACTIVE; dm->mode = cpu_to_le32(GS_CAN_MODE_START); @@ -890,7 +896,6 @@ static struct gs_can *gs_make_candev(unsigned int channel, dev->can.state = CAN_STATE_STOPPED; dev->can.clock.freq = le32_to_cpu(bt_const->fclk_can); dev->can.bittiming_const = &dev->bt_const; - dev->can.do_set_bittiming = gs_usb_set_bittiming; dev->can.ctrlmode_supported = CAN_CTRLMODE_CC_LEN8_DLC; -- 2.51.0