* [PATCH 0/2] can: sun4i: bug fixes
@ 2017-08-17 13:59 GBert
2017-08-17 13:59 ` [PATCH 1/2] can: sun4i: fix overrun GBert
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: GBert @ 2017-08-17 13:59 UTC (permalink / raw)
To: linux-can; +Cc: Gerhard Bertelsmann
From: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
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(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] can: sun4i: fix overrun
2017-08-17 13:59 [PATCH 0/2] can: sun4i: bug fixes GBert
@ 2017-08-17 13:59 ` GBert
2017-10-19 12:10 ` Marc Kleine-Budde
2017-08-17 13:59 ` [PATCH 2/2] can: sun4i: fix loopback mode GBert
2017-10-19 11:32 ` [PATCH 0/2] can: sun4i: bug fixes Gerhard Bertelsmann
2 siblings, 1 reply; 6+ messages in thread
From: GBert @ 2017-08-17 13:59 UTC (permalink / raw)
To: linux-can; +Cc: Gerhard Bertelsmann
From: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
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
Signed-off-by: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
---
drivers/net/can/sun4i_can.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git drivers/net/can/sun4i_can.c drivers/net/can/sun4i_can.c
index 68ef0a4..0d673ff 100644
--- drivers/net/can/sun4i_can.c
+++ drivers/net/can/sun4i_can.c
@@ -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);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] can: sun4i: fix loopback mode
2017-08-17 13:59 [PATCH 0/2] can: sun4i: bug fixes GBert
2017-08-17 13:59 ` [PATCH 1/2] can: sun4i: fix overrun GBert
@ 2017-08-17 13:59 ` GBert
2017-10-24 11:04 ` Marc Kleine-Budde
2017-10-19 11:32 ` [PATCH 0/2] can: sun4i: bug fixes Gerhard Bertelsmann
2 siblings, 1 reply; 6+ messages in thread
From: GBert @ 2017-08-17 13:59 UTC (permalink / raw)
To: linux-can; +Cc: Gerhard Bertelsmann
From: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
fix loopback mode by setting the right flag and remove presume mode
Signed-off-by: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
---
drivers/net/can/sun4i_can.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git drivers/net/can/sun4i_can.c drivers/net/can/sun4i_can.c
index 0d673ff..c7413c5 100644
--- drivers/net/can/sun4i_can.c
+++ drivers/net/can/sun4i_can.c
@@ -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;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] can: sun4i: bug fixes
2017-08-17 13:59 [PATCH 0/2] can: sun4i: bug fixes GBert
2017-08-17 13:59 ` [PATCH 1/2] can: sun4i: fix overrun GBert
2017-08-17 13:59 ` [PATCH 2/2] can: sun4i: fix loopback mode GBert
@ 2017-10-19 11:32 ` Gerhard Bertelsmann
2 siblings, 0 replies; 6+ messages in thread
From: Gerhard Bertelsmann @ 2017-10-19 11:32 UTC (permalink / raw)
To: linux-can
Hi,
Am 2017-08-17 15:59, schrieb GBert:
> From: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
>
> 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(-)
any chance to get these fixes integrated into the Linux kernel ?
Regards
Gerd
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] can: sun4i: fix overrun
2017-08-17 13:59 ` [PATCH 1/2] can: sun4i: fix overrun GBert
@ 2017-10-19 12:10 ` Marc Kleine-Budde
0 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2017-10-19 12:10 UTC (permalink / raw)
To: GBert, linux-can
[-- Attachment #1.1: Type: text/plain, Size: 2410 bytes --]
On 08/17/2017 03:59 PM, GBert wrote:
> From: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
>
> 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?
> The fix resets the buffer for faster recovery - unrecoverable data in
> the buffer will be ignored
So already received CAN frames are dropped?
> Signed-off-by: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
> ---
> drivers/net/can/sun4i_can.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git drivers/net/can/sun4i_can.c drivers/net/can/sun4i_can.c
> index 68ef0a4..0d673ff 100644
> --- drivers/net/can/sun4i_can.c
> +++ drivers/net/can/sun4i_can.c
> @@ -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");
No need to print an error here set_{reset,normal}_mode() already do this.
> + 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);
>
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: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] can: sun4i: fix loopback mode
2017-08-17 13:59 ` [PATCH 2/2] can: sun4i: fix loopback mode GBert
@ 2017-10-24 11:04 ` Marc Kleine-Budde
0 siblings, 0 replies; 6+ messages in thread
From: Marc Kleine-Budde @ 2017-10-24 11:04 UTC (permalink / raw)
To: GBert, linux-can
[-- Attachment #1.1: Type: text/plain, Size: 569 bytes --]
On 08/17/2017 03:59 PM, GBert wrote:
> From: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
>
> fix loopback mode by setting the right flag and remove presume mode
>
> Signed-off-by: Gerhard Bertelsmann <info@gerhard-bertelsmann.de>
Added to can and added stable on Cc.
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: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-24 11:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-17 13:59 [PATCH 0/2] can: sun4i: bug fixes GBert
2017-08-17 13:59 ` [PATCH 1/2] can: sun4i: fix overrun GBert
2017-10-19 12:10 ` Marc Kleine-Budde
2017-08-17 13:59 ` [PATCH 2/2] can: sun4i: fix loopback mode GBert
2017-10-24 11:04 ` Marc Kleine-Budde
2017-10-19 11:32 ` [PATCH 0/2] can: sun4i: bug fixes Gerhard Bertelsmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.