linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: c_can: Fix bit clearing and message object read
@ 2014-04-08  9:46 Alexander Stein
  2014-04-08 13:07 ` Thomas Gleixner
  0 siblings, 1 reply; 8+ messages in thread
From: Alexander Stein @ 2014-04-08  9:46 UTC (permalink / raw)
  To: Wolfgang Grandegger, Marc Kleine-Budde, Thomas Gleixner
  Cc: Alexander Stein, linux-can

It seems that clearing some bits in a message object using COMMSK_REG and
reading this object afterwards using COMREQ_REG is not race free.
It might occur that the read message object still contains the
IF_MCONT_NEWDAT bit set while it was already cleared upon write to
COMMSK_REG. So insert a dummy read to the hardware.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
---
 drivers/net/can/c_can/c_can.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c
index 0e9f974..625f8e2 100644
--- a/drivers/net/can/c_can/c_can.c
+++ b/drivers/net/can/c_can/c_can.c
@@ -290,6 +290,13 @@ static inline void c_can_object_get(struct net_device *dev,
 	 */
 	priv->write_reg(priv, C_CAN_IFACE(COMMSK_REG, iface),
 			IFX_WRITE_LOW_16BIT(mask));
+
+	/*
+	 * Insert additional dummy read to let
+	 * the write to COMMSK_REG take effect
+	 */
+	priv->read_reg(priv, C_CAN_IFACE(COMREQ_REG, iface));
+
 	priv->write_reg(priv, C_CAN_IFACE(COMREQ_REG, iface),
 			IFX_WRITE_LOW_16BIT(objno));
 
@@ -832,12 +839,11 @@ static int c_can_read_objects(struct net_device *dev, struct c_can_priv *priv,
 		}
 
 		/*
-		 * This really should not happen, but this covers some
-		 * odd HW behaviour. Do not remove that unless you
-		 * want to brick your machine.
+		 * This really should not happen, but this warns about some
+		 * odd HW behaviour.
 		 */
-		if (!(ctrl & IF_MCONT_NEWDAT))
-			continue;
+		if ((ctrl & IF_MCONT_NEWDAT))
+			netdev_warn(dev, "IF_MCONT_NEWDAT still set on obj: %d", obj);
 
 		/* read the data from the message object */
 		c_can_read_msg_object(dev, IF_RX, ctrl);
-- 
1.8.3.2


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

end of thread, other threads:[~2014-04-09 10:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-08  9:46 [PATCH] can: c_can: Fix bit clearing and message object read Alexander Stein
2014-04-08 13:07 ` Thomas Gleixner
2014-04-08 14:02   ` Alexander Stein
2014-04-08 14:15     ` Thomas Gleixner
2014-04-08 14:24       ` Alexander Stein
2014-04-09  0:42         ` Thomas Gleixner
2014-04-09  7:40           ` Alexander Stein
2014-04-09 10:28             ` Alexander Stein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).