mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/2] can: m_can: set init flag earlier in probe
@ 2024-09-19 11:27 Matthias Schiffer
  2024-09-19 11:27 ` [PATCH v2 2/2] can: m_can: fix missed interrupts with m_can_pci Matthias Schiffer
  2024-09-23  8:12 ` [PATCH v2 1/2] can: m_can: set init flag earlier in probe Markus Schneider-Pargmann
  0 siblings, 2 replies; 11+ messages in thread
From: Matthias Schiffer @ 2024-09-19 11:27 UTC (permalink / raw)
  To: Chandrasekar Ramakrishnan, Marc Kleine-Budde, Vincent Mailhol
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Martin Hundebøll, Markus Schneider-Pargmann,
	Felipe Balbi (Intel),
	Raymond Tan, Jarkko Nikula, linux-can, netdev, linux-kernel,
	linux, Matthias Schiffer

While an m_can controller usually already has the init flag from a
hardware reset, no such reset happens on the integrated m_can_pci of the
Intel Elkhart Lake. If the CAN controller is found in an active state,
m_can_dev_setup() would fail because m_can_niso_supported() calls
m_can_cccr_update_bits(), which refuses to modify any other configuration
bits when CCCR_INIT is not set.

To avoid this issue, set CCCR_INIT before attempting to modify any other
configuration flags.

Fixes: cd5a46ce6fa6 ("can: m_can: don't enable transceiver when probing")
Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
---

v2: no changes

 drivers/net/can/m_can/m_can.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 012c3d22b01dd..47481afb9add3 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1681,6 +1681,14 @@ static int m_can_dev_setup(struct m_can_classdev *cdev)
 		return -EINVAL;
 	}
 
+	/* Forcing standby mode should be redundant, as the chip should be in
+	 * standby after a reset. Write the INIT bit anyways, should the chip
+	 * be configured by previous stage.
+	 */
+	err = m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT);
+	if (err)
+		return err;
+
 	if (!cdev->is_peripheral)
 		netif_napi_add(dev, &cdev->napi, m_can_poll);
 
@@ -1732,11 +1740,7 @@ static int m_can_dev_setup(struct m_can_classdev *cdev)
 		return -EINVAL;
 	}
 
-	/* Forcing standby mode should be redundant, as the chip should be in
-	 * standby after a reset. Write the INIT bit anyways, should the chip
-	 * be configured by previous stage.
-	 */
-	return m_can_cccr_update_bits(cdev, CCCR_INIT, CCCR_INIT);
+	return 0;
 }
 
 static void m_can_stop(struct net_device *dev)
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-09-24  6:21 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-19 11:27 [PATCH v2 1/2] can: m_can: set init flag earlier in probe Matthias Schiffer
2024-09-19 11:27 ` [PATCH v2 2/2] can: m_can: fix missed interrupts with m_can_pci Matthias Schiffer
2024-09-23  8:03   ` Markus Schneider-Pargmann
2024-09-23  9:32     ` Matthias Schiffer
2024-09-23 10:07       ` Markus Schneider-Pargmann
2024-09-23 10:53         ` Marc Kleine-Budde
2024-09-23 10:30     ` Marc Kleine-Budde
2024-09-24  6:16       ` [PATCH DO_NOT_APPLY] net: can: m_can: Support tcan level with edge interrupts Markus Schneider-Pargmann
2024-09-23 10:17   ` [PATCH v2 2/2] can: m_can: fix missed interrupts with m_can_pci Marc Kleine-Budde
2024-09-23 11:06     ` Matthias Schiffer
2024-09-23  8:12 ` [PATCH v2 1/2] can: m_can: set init flag earlier in probe Markus Schneider-Pargmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®