linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: can: xilinx_can: fix extended frame handling
@ 2015-04-29 15:05 Jeppe Ledet-Pedersen
  2015-05-01  8:20 ` Marc Kleine-Budde
  0 siblings, 1 reply; 5+ messages in thread
From: Jeppe Ledet-Pedersen @ 2015-04-29 15:05 UTC (permalink / raw)
  To: wg, mkl, michal.simek, soren.brinkmann, appana.durga.rao
  Cc: linux-can, netdev, linux-kernel, Jeppe Ledet-Pedersen

Using IDR_SRR in RXFIFO_ID to test for the presence of data is only
valid for standard frames. For extended frames the bit is always 1 and
IDR_RTR should be used instead. This patch switches the check to use
CAN_RTR_FLAG which is correctly set when reading the ID.

The patch also changes the DW1/DW2 to be read unconditionally, since
this is necessary to remove the frame from the RXFIFO.

Signed-off-by: Jeppe Ledet-Pedersen <jlp@gomspace.com>
Acked-by: Kedareswara rao Appana <appanad@xilinx.com>
---
 drivers/net/can/xilinx_can.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 6c67643..0b27769 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -509,10 +509,11 @@ static int xcan_rx(struct net_device *ndev)
 			cf->can_id |= CAN_RTR_FLAG;
 	}
 
-	if (!(id_xcan & XCAN_IDR_SRR_MASK)) {
-		data[0] = priv->read_reg(priv, XCAN_RXFIFO_DW1_OFFSET);
-		data[1] = priv->read_reg(priv, XCAN_RXFIFO_DW2_OFFSET);
+	/* DW1/DW2 must always be read to remove message from RXFIFO */
+	data[0] = priv->read_reg(priv, XCAN_RXFIFO_DW1_OFFSET);
+	data[1] = priv->read_reg(priv, XCAN_RXFIFO_DW2_OFFSET);
 
+	if (!(cf->can_id & CAN_RTR_FLAG)) {
 		/* Change Xilinx CAN data format to socketCAN data format */
 		if (cf->can_dlc > 0)
 			*(__be32 *)(cf->data) = cpu_to_be32(data[0]);
-- 
2.1.0

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

* Re: [PATCH] net: can: xilinx_can: fix extended frame handling
  2015-04-29 15:05 [PATCH] net: can: xilinx_can: fix extended frame handling Jeppe Ledet-Pedersen
@ 2015-05-01  8:20 ` Marc Kleine-Budde
  0 siblings, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2015-05-01  8:20 UTC (permalink / raw)
  To: Jeppe Ledet-Pedersen, wg, michal.simek, soren.brinkmann,
	appana.durga.rao
  Cc: linux-can, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 916 bytes --]

On 04/29/2015 05:05 PM, Jeppe Ledet-Pedersen wrote:
> Using IDR_SRR in RXFIFO_ID to test for the presence of data is only
> valid for standard frames. For extended frames the bit is always 1 and
> IDR_RTR should be used instead. This patch switches the check to use
> CAN_RTR_FLAG which is correctly set when reading the ID.
> 
> The patch also changes the DW1/DW2 to be read unconditionally, since
> this is necessary to remove the frame from the RXFIFO.
> 
> Signed-off-by: Jeppe Ledet-Pedersen <jlp@gomspace.com>
> Acked-by: Kedareswara rao Appana <appanad@xilinx.com>

Applied to can. Added stable on Cc.

Thanks,
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

* pull-request: can 2015-05-01
@ 2015-05-01  8:28 Marc Kleine-Budde
  2015-05-01  8:28 ` [PATCH] net: can: xilinx_can: fix extended frame handling Marc Kleine-Budde
  2015-05-04  3:45 ` pull-request: can 2015-05-01 David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2015-05-01  8:28 UTC (permalink / raw)
  To: netdev; +Cc: davem, linux-can, kernel

Hello David,

this is a pull request of a single patch for net/master.

The patch is contributed by Jeppe Ledet-Pedersen, it fixes the extended frame
handling in the xilinx driver.

regards,
Marc

---

The following changes since commit e813bb2b955d9f72c94be7d592746b49929a499b:

  net: fec: Fix RGMII-ID mode (2015-04-30 16:48:53 -0400)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can.git tags/linux-can-fixes-for-4.1-20150501

for you to fetch changes up to 5793affe8c723ece8114b898ab9003c7d97f86d1:

  net: can: xilinx_can: fix extended frame handling (2015-05-01 10:11:46 +0200)

----------------------------------------------------------------
linux-can-fixes-for-4.1-20150501

----------------------------------------------------------------
Jeppe Ledet-Pedersen (1):
      net: can: xilinx_can: fix extended frame handling

 drivers/net/can/xilinx_can.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)



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

* [PATCH] net: can: xilinx_can: fix extended frame handling
  2015-05-01  8:28 pull-request: can 2015-05-01 Marc Kleine-Budde
@ 2015-05-01  8:28 ` Marc Kleine-Budde
  2015-05-04  3:45 ` pull-request: can 2015-05-01 David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: Marc Kleine-Budde @ 2015-05-01  8:28 UTC (permalink / raw)
  To: netdev
  Cc: davem, linux-can, kernel, Jeppe Ledet-Pedersen, linux-stable,
	Marc Kleine-Budde

From: Jeppe Ledet-Pedersen <jlp@gomspace.com>

Using IDR_SRR in RXFIFO_ID to test for the presence of data is only
valid for standard frames. For extended frames the bit is always 1 and
IDR_RTR should be used instead. This patch switches the check to use
CAN_RTR_FLAG which is correctly set when reading the ID.

The patch also changes the DW1/DW2 to be read unconditionally, since
this is necessary to remove the frame from the RXFIFO.

Signed-off-by: Jeppe Ledet-Pedersen <jlp@gomspace.com>
Acked-by: Kedareswara rao Appana <appanad@xilinx.com>
Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/xilinx_can.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
index 6bddfe062b51..fc55e8e0351d 100644
--- a/drivers/net/can/xilinx_can.c
+++ b/drivers/net/can/xilinx_can.c
@@ -509,10 +509,11 @@ static int xcan_rx(struct net_device *ndev)
 			cf->can_id |= CAN_RTR_FLAG;
 	}
 
-	if (!(id_xcan & XCAN_IDR_SRR_MASK)) {
-		data[0] = priv->read_reg(priv, XCAN_RXFIFO_DW1_OFFSET);
-		data[1] = priv->read_reg(priv, XCAN_RXFIFO_DW2_OFFSET);
+	/* DW1/DW2 must always be read to remove message from RXFIFO */
+	data[0] = priv->read_reg(priv, XCAN_RXFIFO_DW1_OFFSET);
+	data[1] = priv->read_reg(priv, XCAN_RXFIFO_DW2_OFFSET);
 
+	if (!(cf->can_id & CAN_RTR_FLAG)) {
 		/* Change Xilinx CAN data format to socketCAN data format */
 		if (cf->can_dlc > 0)
 			*(__be32 *)(cf->data) = cpu_to_be32(data[0]);
-- 
2.1.4

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

* Re: pull-request: can 2015-05-01
  2015-05-01  8:28 pull-request: can 2015-05-01 Marc Kleine-Budde
  2015-05-01  8:28 ` [PATCH] net: can: xilinx_can: fix extended frame handling Marc Kleine-Budde
@ 2015-05-04  3:45 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2015-05-04  3:45 UTC (permalink / raw)
  To: mkl; +Cc: netdev, linux-can, kernel

From: Marc Kleine-Budde <mkl@pengutronix.de>
Date: Fri,  1 May 2015 10:28:57 +0200

> this is a pull request of a single patch for net/master.
> 
> The patch is contributed by Jeppe Ledet-Pedersen, it fixes the extended frame
> handling in the xilinx driver.

Pulled, thanks Marc.

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

end of thread, other threads:[~2015-05-04  3:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-01  8:28 pull-request: can 2015-05-01 Marc Kleine-Budde
2015-05-01  8:28 ` [PATCH] net: can: xilinx_can: fix extended frame handling Marc Kleine-Budde
2015-05-04  3:45 ` pull-request: can 2015-05-01 David Miller
  -- strict thread matches above, loose matches on Subject: below --
2015-04-29 15:05 [PATCH] net: can: xilinx_can: fix extended frame handling Jeppe Ledet-Pedersen
2015-05-01  8:20 ` Marc Kleine-Budde

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).