From nobody Fri Apr 3 06:29:34 2026 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (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 E597732ABFF for ; Wed, 18 Feb 2026 14:45:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771425940; cv=none; b=u31DwMHu9qBmKJlJ9zxfLcmSZzEJy0Iuvd5MBZLNYMLuEd6VLPLCvRAmbqz82aFNWnULWgPIdRnaIbUdBVJSsuZ8xIovt+T8RIwCD3B4CboW2G9WCws1pnjGjeVbA4yD6Ks02ZV+ieswzEH1nTkAVBbVLdj8DrWOovbh003T7rM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771425940; c=relaxed/simple; bh=/qDCeM49X4+Z0bmDMqbc0ByiVKbp4U2j46DJfzQ6U2A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=juht2hPi695I/gQs+I/BhKIVDZkrCBmnSKrHJAQKio/trp1ZUJvleK9xZVzgEHPNQPUX2AdoCixPjhol5hneJl/6ILVbEMpAEs0EFaHbV+7zaZqPvrTJoAn2eYmB2aOusFRtZ8Wo35cpAj0LxVHuPWT/HDKwWiZi6hX5RQeNOoM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vsinu-0000zC-AU; Wed, 18 Feb 2026 15:45:26 +0100 Received: from moin.white.stw.pengutronix.de ([2a0a:edc0:0:b01:1d::7b] helo=bjornoya.blackshift.org) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vsi8x-001Pvh-22; Wed, 18 Feb 2026 15:03:09 +0100 Received: from hardanger.blackshift.org (p54b15bf8.dip0.t-ipconnect.de [84.177.91.248]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mkl-all@blackshift.org) by smtp.blackshift.org (Postfix) with ESMTPSA id AB3194EBB4F; Wed, 18 Feb 2026 14:03:08 +0000 (UTC) From: Marc Kleine-Budde Date: Wed, 18 Feb 2026 15:03:00 +0100 Subject: [PATCH] can: gs_usb: gs_can_open(): always configure bitrates before starting device Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260218-gs_usb-always-configure-bitrates-v1-1-6b4e0970b18a@pengutronix.de> X-B4-Tracking: v=1; b=H4sIAJPGlWkC/yXNQQrCMBBA0auUWTuQRijqVUQkk07iiKSSSapSe vdGXb7N/wsoZ2GFU7dA5llUptTQ7zrwN5cio4zNYI0djO0PGPValdA9Xu6j6KcUJNbMSFKyK6x I3rpAe2OPNEDLPDMHef8W58vfWunOvny7sK4b0hrIeYQAAAA= X-Change-ID: 20260218-gs_usb-always-configure-bitrates-bc2afb3029b6 To: Vincent Mailhol , Maximilian Schneider , Wolfgang Grandegger Cc: kernel@pengutronix.de, linux-can@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Marc Kleine-Budde X-Mailer: b4 0.15-dev-47773 X-Developer-Signature: v=1; a=openpgp-sha256; l=3561; i=mkl@pengutronix.de; h=from:subject:message-id; bh=/qDCeM49X4+Z0bmDMqbc0ByiVKbp4U2j46DJfzQ6U2A=; b=owGbwMvMwCV2xirl17qZay8xnlZLYsicemzWBN24+BdNl6+pLvzxNVZQvnmu5b2nXyL0r4pHL p1x0e/k6o5SFgYxLgZZMUWWpT9OKAoEOpT2vkyYBDOHlQlkCAMXpwBMZG4OI8O7R3Nzn+89d4tD Mluz9npNzp4dCnIiyuHLRFojkuJCHn9h+O9wuOfxJjPVmHrvCX+S1AQ/TpCIeVQuN8Vg4xHPlQE OM5gB X-Developer-Key: i=mkl@pengutronix.de; a=openpgp; fpr=C1400BA0B3989E6FBC7D5B5C2B5EE211C58AEA54 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org 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= ") Signed-off-by: Marc Kleine-Budde --- drivers/net/can/usb/gs_usb.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c index d8b2dd74b3a1..6a54fd0717f5 100644 --- a/drivers/net/can/usb/gs_usb.c +++ b/drivers/net/can/usb/gs_usb.c @@ -772,9 +772,8 @@ static void gs_usb_receive_bulk_callback(struct urb *ur= b) } } =20 -static int gs_usb_set_bittiming(struct net_device *netdev) +static int gs_usb_set_bittiming(struct gs_can *dev) { - struct gs_can *dev =3D netdev_priv(netdev); struct can_bittiming *bt =3D &dev->can.bittiming; struct gs_device_bittiming dbt =3D { .prop_seg =3D cpu_to_le32(bt->prop_seg), @@ -791,9 +790,8 @@ static int gs_usb_set_bittiming(struct net_device *netd= ev) GFP_KERNEL); } =20 -static int gs_usb_set_data_bittiming(struct net_device *netdev) +static int gs_usb_set_data_bittiming(struct gs_can *dev) { - struct gs_can *dev =3D netdev_priv(netdev); struct can_bittiming *bt =3D &dev->can.fd.data_bittiming; struct gs_device_bittiming dbt =3D { .prop_seg =3D cpu_to_le32(bt->prop_seg), @@ -1057,6 +1055,20 @@ static int gs_can_open(struct net_device *netdev) if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) flags |=3D GS_CAN_MODE_HW_TIMESTAMP; =20 + rc =3D gs_usb_set_bittiming(dev); + if (rc) { + netdev_err(netdev, "failed to set bittiming: %pe)\n", ERR_PTR(rc)); + goto out_usb_kill_anchored_urbs; + } + + if (ctrlmode & CAN_CTRLMODE_FD) { + rc =3D gs_usb_set_data_bittiming(dev); + if (rc) { + netdev_err(netdev, "failed to set data bittiming: %pe)\n", ERR_PTR(rc)); + goto out_usb_kill_anchored_urbs; + } + } + /* finally start device */ dev->can.state =3D CAN_STATE_ERROR_ACTIVE; dm.flags =3D cpu_to_le32(flags); @@ -1370,7 +1382,6 @@ static struct gs_can *gs_make_candev(unsigned int cha= nnel, dev->can.state =3D CAN_STATE_STOPPED; dev->can.clock.freq =3D le32_to_cpu(bt_const.fclk_can); dev->can.bittiming_const =3D &dev->bt_const; - dev->can.do_set_bittiming =3D gs_usb_set_bittiming; =20 dev->can.ctrlmode_supported =3D CAN_CTRLMODE_CC_LEN8_DLC; =20 @@ -1394,7 +1405,6 @@ static struct gs_can *gs_make_candev(unsigned int cha= nnel, * GS_CAN_FEATURE_BT_CONST_EXT is set. */ dev->can.fd.data_bittiming_const =3D &dev->bt_const; - dev->can.fd.do_set_data_bittiming =3D gs_usb_set_data_bittiming; } =20 if (feature & GS_CAN_FEATURE_TERMINATION) { --- base-commit: 77c5e3fdd2793f478e6fdae55c9ea85b21d06f8f change-id: 20260218-gs_usb-always-configure-bitrates-bc2afb3029b6 Best regards, -- =20 Marc Kleine-Budde