can: sun4i: bug fixes
cover can: sun4i: bug fixes
From: Gerhard Bertelsmann <[email protected]>
The patchset fixes two issues for Allwinner A10/A20 CAN IP
Gerhard Bertelsmann (2):
can: sun4i: fix overrun
can: sun4i: fix loopback mode
drivers/net/can/sun4i_can.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/2 can: sun4i: fix overrun
From: Gerhard Bertelsmann <[email protected]>
SUN4Is CAN IP has a 64 byte deep FIFO buffer. If the buffer is not drained fast enough (overrun) it's getting mangled. The fix resets the buffer for faster recovery - unrecoverable data in the buffer will be ignored
--- drivers/net/can/sun4i_can.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
net/can/sun4i_can.c +13 -2
@@ -531,6 +531,7 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) }if (isrc &SUN4I_INT_DATA_OR ) { +int err;/* data overrun interrupt */ netdev_dbg (dev,"data overrun interrupt\n" );if (likely (skb)) {
@@ -539,6 +540,15 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) } stats->rx_over_errors++; stats->rx_errors++; + +/* reset the CAN IP by entering reset mode */ + err =set_reset_mode (dev); +if (err) +netdev_err (dev,"could not enter reset mode\n" ); + err =set_normal_mode (dev); +if (err) +netdev_err (dev,"could not enter normal mode\n" ); +/* clear bit */ sun4i_can_write_cmdreg (priv,SUN4I_CMD_CLEAR_OR_FLAG ); }
@@ -653,8 +663,9 @@ static irqreturn_t sun4i_can_interrupt(int irq, void *dev_id)netif_wake_queue (dev);can_led_event (dev,CAN_LED_EVENT_TX ); } -if (isrc &SUN4I_INT_RBUF_VLD ) { -/* receive interrupt */ +if ((isrc &SUN4I_INT_RBUF_VLD ) && + !(isrc &SUN4I_INT_DATA_OR )) { +/* receive interrupt - don't read if overrun occurred */ while (status &SUN4I_STA_RBUF_RDY ) {/* RX buffer is not empty */ sun4i_can_rx (dev);
Signature · 1 line
1.7.9.5
PATCH 2/2 can: sun4i: fix loopback mode
In reply to GBertFrom: Gerhard Bertelsmann <[email protected]>
fix loopback mode by setting the right flag and remove presume mode
--- drivers/net/can/sun4i_can.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/can/sun4i_can.c +1 -2
@@ -342,7 +342,7 @@ static int sun4i_can_start(struct net_device *dev)/* enter the selected mode */ mod_reg_val =readl (priv->base +SUN4I_REG_MSEL_ADDR ); -if (priv->can.ctrlmode &CAN_CTRLMODE_PRESUME_ACK ) +if (priv->can.ctrlmode &CAN_CTRLMODE_LOOPBACK ) mod_reg_val |=SUN4I_MSEL_LOOPBACK_MODE ;else if (priv->can.ctrlmode &CAN_CTRLMODE_LISTENONLY ) mod_reg_val |=SUN4I_MSEL_LISTEN_ONLY_MODE ;
@@ -822,7 +822,6 @@ static int sun4ican_probe(struct platform_device *pdev) priv->can.ctrlmode_supported =CAN_CTRLMODE_BERR_REPORTING |CAN_CTRLMODE_LISTENONLY |CAN_CTRLMODE_LOOPBACK | -CAN_CTRLMODE_PRESUME_ACK |CAN_CTRLMODE_3_SAMPLES ; priv->base = addr; priv->clk = clk;
Signature · 1 line
1.7.9.5
Hi,
Am 2017-08-17 15:59, schrieb GBert:
Quoted 10 lines
From: Gerhard Bertelsmann <[email protected]>
The patchset fixes two issues for Allwinner A10/A20 CAN IP
Gerhard Bertelsmann (2):
can: sun4i: fix overrun
can: sun4i: fix loopback modedrivers/net/can/sun4i_can.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
any chance to get these fixes integrated into the Linux kernel ?
Regards
Gerd
Marc Kleine-Budde
maintainerRe: [PATCH 1/2] can: sun4i: fix overrun
In reply to GBertQuoted 4 lines · GBert
From: Gerhard Bertelsmann <[email protected]>
SUN4Is CAN IP has a 64 byte deep FIFO buffer. If the buffer is not drained fast enough (overrun) it's getting mangled.
What does that mean?
Quoted 2 lines
The fix resets the buffer for faster recovery - unrecoverable data in the buffer will be ignored
So already received CAN frames are dropped?
Quoted 18 lines
Signed-off-by Gerhard Bertelsmann <[email protected]>--- drivers/net/can/sun4i_can.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)net/can/sun4i_can.c +1
-0@@ -531,6 +531,7 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) }if (isrc &SUN4I_INT_DATA_OR ) { +int err;/* data overrun interrupt */ netdev_dbg (dev,"data overrun interrupt\n" );if (likely (skb)) {
net/can/sun4i_can.c static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) · line 547
Quoted 8 lines
net/can/sun4i_can.c +5
-0@@ -539,6 +540,15 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) } stats->rx_over_errors++; stats->rx_errors++; + +/* reset the CAN IP by entering reset mode */ + err =set_reset_mode (dev); +if (err) +netdev_err (dev,"could not enter reset mode\n" );
No need to print an error here set_{reset,normal}_mode() already do this.
Quoted 10 lines
net/can/sun4i_can.c +4
-0+ err =set_normal_mode (dev); +if (err) +netdev_err (dev,"could not enter normal mode\n" ); +/* clear bit */ sun4i_can_write_cmdreg (priv,SUN4I_CMD_CLEAR_OR_FLAG ); }@@ -653,8 +663,9 @@ static irqreturn_t sun4i_can_interrupt(int irq, void *dev_id)netif_wake_queue (dev);
net/can/sun4i_can.c static irqreturn_t sun4i_can_interrupt(int irq, void *dev_id) · line 671
Quoted 10 lines
net/can/sun4i_can.c +3
-2can_led_event (dev,CAN_LED_EVENT_TX ); } -if (isrc &SUN4I_INT_RBUF_VLD ) { -/* receive interrupt */ +if ((isrc &SUN4I_INT_RBUF_VLD ) && + !(isrc &SUN4I_INT_DATA_OR )) { +/* receive interrupt - don't read if overrun occurred */ while (status &SUN4I_STA_RBUF_RDY ) {/* RX buffer is not empty */ sun4i_can_rx (dev);
Marc
Signature · 4 lines
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 |
Marc Kleine-Budde
maintainerRe: [PATCH 2/2] can: sun4i: fix loopback mode
In reply to GBertQuoted 5 lines · GBert
From: Gerhard Bertelsmann <[email protected]>
fix loopback mode by setting the right flag and remove presume mode
Signed-off-by Gerhard Bertelsmann <[email protected]>
Added to can and added stable on Cc.
Marc
Signature · 4 lines
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 |