* [PATCH 0/2] can: mcp251x: fix error handling and error frames bug @ 2010-10-20 10:02 Marc Kleine-Budde 2010-10-20 10:02 ` [PATCH 1/2] can: mcp251x: fix endless loop in interrupt handler if CANINTF_MERRF is set Marc Kleine-Budde [not found] ` <1287568946-32727-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 0 siblings, 2 replies; 9+ messages in thread From: Marc Kleine-Budde @ 2010-10-20 10:02 UTC (permalink / raw) To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w; +Cc: netdev-u79uwXL29TY76Z2rM5mHXA Hello, this series of patches fixes two bugs, one introduced by me in the other mcp251x series. Please test, especially the error handling, i.e. wrong bitrate, shortcut in CAN bus. I'm also interested in tests with non i.MX SPI can cores. cheers, Marc ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] can: mcp251x: fix endless loop in interrupt handler if CANINTF_MERRF is set 2010-10-20 10:02 [PATCH 0/2] can: mcp251x: fix error handling and error frames bug Marc Kleine-Budde @ 2010-10-20 10:02 ` Marc Kleine-Budde [not found] ` <1287568946-32727-2-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> [not found] ` <1287568946-32727-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 1 sibling, 1 reply; 9+ messages in thread From: Marc Kleine-Budde @ 2010-10-20 10:02 UTC (permalink / raw) To: socketcan-core; +Cc: netdev, Marc Kleine-Budde Commit d3cd15657516141adce387810be8cb377baf020e introduced a bug, the interrupt handler would loop endlessly if the CANINTF_MERRF bit is set, because it's not cleared. This patch fixes the problem by masking out the CANINTF_MERRF and all other non interesting bits. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> --- drivers/net/can/mcp251x.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c index c664be2..59f40bc 100644 --- a/drivers/net/can/mcp251x.c +++ b/drivers/net/can/mcp251x.c @@ -125,8 +125,9 @@ # define CANINTF_TX0IF 0x04 # define CANINTF_RX1IF 0x02 # define CANINTF_RX0IF 0x01 -# define CANINTF_ERR_TX \ - (CANINTF_ERRIF | CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF) +# define CANINTF_RX (CANINTF_RX0IF | CANINTF_RX1IF) +# define CANINTF_TX (CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF) +# define CANINTF_ERR (CANINTF_ERRIF) #define EFLG 0x2d # define EFLG_EWARN 0x01 # define EFLG_RXWAR 0x02 @@ -790,6 +791,9 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id) mcp251x_read_2regs(spi, CANINTF, &intf, &eflag); + /* mask out flags we don't care about */ + intf &= CANINTF_RX | CANINTF_TX | CANINTF_ERR; + /* receive buffer 0 */ if (intf & CANINTF_RX0IF) { mcp251x_hw_rx(spi, 0); @@ -810,8 +814,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id) } /* any error or tx interrupt we need to clear? */ - if (intf & CANINTF_ERR_TX) - clear_intf |= intf & CANINTF_ERR_TX; + if (intf & (CANINTF_ERR | CANINTF_TX)) + clear_intf |= intf & (CANINTF_ERR | CANINTF_TX); if (clear_intf) mcp251x_write_bits(spi, CANINTF, clear_intf, 0x00); @@ -887,7 +891,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id) if (intf == 0) break; - if (intf & (CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF)) { + if (intf & CANINTF_TX) { net->stats.tx_packets++; net->stats.tx_bytes += priv->tx_len - 1; if (priv->tx_len) { -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
[parent not found: <1287568946-32727-2-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>]
* Re: [PATCH 1/2] can: mcp251x: fix endless loop in interrupt handler if CANINTF_MERRF is set [not found] ` <1287568946-32727-2-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> @ 2010-10-21 11:32 ` David Miller 2010-10-21 12:08 ` David Jander 1 sibling, 0 replies; 9+ messages in thread From: David Miller @ 2010-10-21 11:32 UTC (permalink / raw) To: mkl-bIcnvbaLZ9MEGnE8C9+IrQ Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, netdev-u79uwXL29TY76Z2rM5mHXA From: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Date: Wed, 20 Oct 2010 12:02:25 +0200 > Commit d3cd15657516141adce387810be8cb377baf020e introduced a bug, the > interrupt handler would loop endlessly if the CANINTF_MERRF bit is set, > because it's not cleared. > > This patch fixes the problem by masking out the CANINTF_MERRF and all other > non interesting bits. > > Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Applied. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] can: mcp251x: fix endless loop in interrupt handler if CANINTF_MERRF is set [not found] ` <1287568946-32727-2-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2010-10-21 11:32 ` David Miller @ 2010-10-21 12:08 ` David Jander 2010-10-21 12:24 ` Marc Kleine-Budde 1 sibling, 1 reply; 9+ messages in thread From: David Jander @ 2010-10-21 12:08 UTC (permalink / raw) To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Marc Kleine-Budde On Wednesday 20 October 2010 12:02:25 pm Marc Kleine-Budde wrote: > Commit d3cd15657516141adce387810be8cb377baf020e introduced a bug, the > interrupt handler would loop endlessly if the CANINTF_MERRF bit is set, > because it's not cleared. > > This patch fixes the problem by masking out the CANINTF_MERRF and all other > non interesting bits. > > Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> > --- > drivers/net/can/mcp251x.c | 14 +++++++++----- > 1 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c > index c664be2..59f40bc 100644 > --- a/drivers/net/can/mcp251x.c > +++ b/drivers/net/can/mcp251x.c > @@ -125,8 +125,9 @@ > # define CANINTF_TX0IF 0x04 > # define CANINTF_RX1IF 0x02 > # define CANINTF_RX0IF 0x01 > -# define CANINTF_ERR_TX \ > - (CANINTF_ERRIF | CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF) > +# define CANINTF_RX (CANINTF_RX0IF | CANINTF_RX1IF) > +# define CANINTF_TX (CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF) > +# define CANINTF_ERR (CANINTF_ERRIF) Is it just me, or do you still miss MERRF? > #define EFLG 0x2d > # define EFLG_EWARN 0x01 > # define EFLG_RXWAR 0x02 > @@ -790,6 +791,9 @@ static irqreturn_t mcp251x_can_ist(int irq, void > *dev_id) > > mcp251x_read_2regs(spi, CANINTF, &intf, &eflag); > > + /* mask out flags we don't care about */ > + intf &= CANINTF_RX | CANINTF_TX | CANINTF_ERR; > + > /* receive buffer 0 */ > if (intf & CANINTF_RX0IF) { > mcp251x_hw_rx(spi, 0); > @@ -810,8 +814,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void > *dev_id) } > > /* any error or tx interrupt we need to clear? */ > - if (intf & CANINTF_ERR_TX) > - clear_intf |= intf & CANINTF_ERR_TX; > + if (intf & (CANINTF_ERR | CANINTF_TX)) > + clear_intf |= intf & (CANINTF_ERR | CANINTF_TX); > if (clear_intf) > mcp251x_write_bits(spi, CANINTF, clear_intf, 0x00); > > @@ -887,7 +891,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void > *dev_id) if (intf == 0) > break; > > - if (intf & (CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF)) { > + if (intf & CANINTF_TX) { > net->stats.tx_packets++; > net->stats.tx_bytes += priv->tx_len - 1; > if (priv->tx_len) { I've been staring at the changes for quite some time now, but I still don't understand how an "CANINTF" value of "0x80" is ever cleared (MERRF set). Granted, you don't loop anymore, but shouldn't that flag be handled properly? Best regards, -- David Jander Protonic Holland. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] can: mcp251x: fix endless loop in interrupt handler if CANINTF_MERRF is set 2010-10-21 12:08 ` David Jander @ 2010-10-21 12:24 ` Marc Kleine-Budde 0 siblings, 0 replies; 9+ messages in thread From: Marc Kleine-Budde @ 2010-10-21 12:24 UTC (permalink / raw) To: David Jander; +Cc: socketcan-core, netdev [-- Attachment #1: Type: text/plain, Size: 3259 bytes --] On 10/21/2010 02:08 PM, David Jander wrote: > On Wednesday 20 October 2010 12:02:25 pm Marc Kleine-Budde wrote: >> Commit d3cd15657516141adce387810be8cb377baf020e introduced a bug, the >> interrupt handler would loop endlessly if the CANINTF_MERRF bit is set, >> because it's not cleared. >> >> This patch fixes the problem by masking out the CANINTF_MERRF and all other >> non interesting bits. >> >> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> >> --- >> drivers/net/can/mcp251x.c | 14 +++++++++----- >> 1 files changed, 9 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c >> index c664be2..59f40bc 100644 >> --- a/drivers/net/can/mcp251x.c >> +++ b/drivers/net/can/mcp251x.c >> @@ -125,8 +125,9 @@ >> # define CANINTF_TX0IF 0x04 >> # define CANINTF_RX1IF 0x02 >> # define CANINTF_RX0IF 0x01 >> -# define CANINTF_ERR_TX \ >> - (CANINTF_ERRIF | CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF) >> +# define CANINTF_RX (CANINTF_RX0IF | CANINTF_RX1IF) >> +# define CANINTF_TX (CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF) >> +# define CANINTF_ERR (CANINTF_ERRIF) > > Is it just me, or do you still miss MERRF? > >> #define EFLG 0x2d >> # define EFLG_EWARN 0x01 >> # define EFLG_RXWAR 0x02 >> @@ -790,6 +791,9 @@ static irqreturn_t mcp251x_can_ist(int irq, void >> *dev_id) >> >> mcp251x_read_2regs(spi, CANINTF, &intf, &eflag); >> >> + /* mask out flags we don't care about */ >> + intf &= CANINTF_RX | CANINTF_TX | CANINTF_ERR; >> + >> /* receive buffer 0 */ >> if (intf & CANINTF_RX0IF) { >> mcp251x_hw_rx(spi, 0); >> @@ -810,8 +814,8 @@ static irqreturn_t mcp251x_can_ist(int irq, void >> *dev_id) } >> >> /* any error or tx interrupt we need to clear? */ >> - if (intf & CANINTF_ERR_TX) >> - clear_intf |= intf & CANINTF_ERR_TX; >> + if (intf & (CANINTF_ERR | CANINTF_TX)) >> + clear_intf |= intf & (CANINTF_ERR | CANINTF_TX); >> if (clear_intf) >> mcp251x_write_bits(spi, CANINTF, clear_intf, 0x00); >> >> @@ -887,7 +891,7 @@ static irqreturn_t mcp251x_can_ist(int irq, void >> *dev_id) if (intf == 0) >> break; >> >> - if (intf & (CANINTF_TX2IF | CANINTF_TX1IF | CANINTF_TX0IF)) { >> + if (intf & CANINTF_TX) { >> net->stats.tx_packets++; >> net->stats.tx_bytes += priv->tx_len - 1; >> if (priv->tx_len) { > > I've been staring at the changes for quite some time now, but I still don't > understand how an "CANINTF" value of "0x80" is ever cleared (MERRF set). > Granted, you don't loop anymore, but shouldn't that flag be handled properly? No need to clear the bit, because we don't get en interrupt when it's set. Because we don't enable it to trigger an interrupt: > /* Enable interrupts */ > mcp251x_write_reg(spi, CANINTE, > CANINTE_ERRIE | CANINTE_TX2IE | CANINTE_TX1IE | > CANINTE_TX0IE | CANINTE_RX1IE | CANINTE_RX0IE); cheers, 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: 262 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <1287568946-32727-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>]
* [PATCH 2/2] can: mcp251x: fix generation of error frames [not found] ` <1287568946-32727-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> @ 2010-10-20 10:02 ` Marc Kleine-Budde [not found] ` <1287568946-32727-3-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2010-10-20 10:11 ` [PATCH 0/2] can: mcp251x: fix error handling and error frames bug Wolfgang Grandegger 1 sibling, 1 reply; 9+ messages in thread From: Marc Kleine-Budde @ 2010-10-20 10:02 UTC (permalink / raw) To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Marc Kleine-Budde The function "mcp251x_error_skb" is used to generate error frames. They are identified by the "CAN_ERR_FLAG" in can_id. The function overwrites the can_id so that the frames show up as normal frames instead of error frames. This patch fixes the problem by or'ing the can_id instead of overwriting it. Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Tested-by: Jargalan Nermunkh <jargalan.nermunkh-wZX4cNJlHJ2sVWG7oymsAA@public.gmane.org> --- drivers/net/can/mcp251x.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c index 59f40bc..6aadc3e 100644 --- a/drivers/net/can/mcp251x.c +++ b/drivers/net/can/mcp251x.c @@ -705,7 +705,7 @@ static void mcp251x_error_skb(struct net_device *net, int can_id, int data1) skb = alloc_can_err_skb(net, &frame); if (skb) { - frame->can_id = can_id; + frame->can_id |= can_id; frame->data[1] = data1; netif_rx_ni(skb); } else { -- 1.7.0.4 ^ permalink raw reply related [flat|nested] 9+ messages in thread
[parent not found: <1287568946-32727-3-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>]
* Re: [PATCH 2/2] can: mcp251x: fix generation of error frames [not found] ` <1287568946-32727-3-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> @ 2010-10-21 11:33 ` David Miller 0 siblings, 0 replies; 9+ messages in thread From: David Miller @ 2010-10-21 11:33 UTC (permalink / raw) To: mkl-bIcnvbaLZ9MEGnE8C9+IrQ Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, netdev-u79uwXL29TY76Z2rM5mHXA From: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Date: Wed, 20 Oct 2010 12:02:26 +0200 > The function "mcp251x_error_skb" is used to generate error frames. > They are identified by the "CAN_ERR_FLAG" in can_id. The function > overwrites the can_id so that the frames show up as normal frames instead > of error frames. > > This patch fixes the problem by or'ing the can_id instead of overwriting it. > > Signed-off-by: Marc Kleine-Budde <mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> > Tested-by: Jargalan Nermunkh <jargalan.nermunkh-wZX4cNJlHJ2sVWG7oymsAA@public.gmane.org> Applied. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] can: mcp251x: fix error handling and error frames bug [not found] ` <1287568946-32727-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2010-10-20 10:02 ` [PATCH 2/2] can: mcp251x: fix generation of error frames Marc Kleine-Budde @ 2010-10-20 10:11 ` Wolfgang Grandegger [not found] ` <4CBEC06D.6000102-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> 1 sibling, 1 reply; 9+ messages in thread From: Wolfgang Grandegger @ 2010-10-20 10:11 UTC (permalink / raw) To: Marc Kleine-Budde Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, netdev-u79uwXL29TY76Z2rM5mHXA On 10/20/2010 12:02 PM, Marc Kleine-Budde wrote: > Hello, > > this series of patches fixes two bugs, one introduced by me in the other > mcp251x series. > > Please test, especially the error handling, i.e. wrong bitrate, shortcut in > CAN bus. I'm also interested in tests with non i.MX SPI can cores. You can add my Acked-by but more Tested-by's are definitely more useful. Unfortunately, I do not have that hardware at hand. Wolfgang. ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <4CBEC06D.6000102-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>]
* Re: [PATCH 0/2] can: mcp251x: fix error handling and error frames bug [not found] ` <4CBEC06D.6000102-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> @ 2010-10-20 10:16 ` Marc Kleine-Budde 0 siblings, 0 replies; 9+ messages in thread From: Marc Kleine-Budde @ 2010-10-20 10:16 UTC (permalink / raw) To: Wolfgang Grandegger Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w, netdev-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1.1: Type: text/plain, Size: 798 bytes --] On 10/20/2010 12:11 PM, Wolfgang Grandegger wrote: >> this series of patches fixes two bugs, one introduced by me in the other >> mcp251x series. >> >> Please test, especially the error handling, i.e. wrong bitrate, shortcut in >> CAN bus. I'm also interested in tests with non i.MX SPI can cores. > > You can add my Acked-by but more Tested-by's are definitely more useful. Thanks and ACK :) > Unfortunately, I do not have that hardware at hand. I'm sure Jargalan is going to test it. cheers, 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 #1.2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 262 bytes --] [-- Attachment #2: Type: text/plain, Size: 188 bytes --] _______________________________________________ Socketcan-core mailing list Socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org https://lists.berlios.de/mailman/listinfo/socketcan-core ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-10-21 12:24 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-10-20 10:02 [PATCH 0/2] can: mcp251x: fix error handling and error frames bug Marc Kleine-Budde 2010-10-20 10:02 ` [PATCH 1/2] can: mcp251x: fix endless loop in interrupt handler if CANINTF_MERRF is set Marc Kleine-Budde [not found] ` <1287568946-32727-2-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2010-10-21 11:32 ` David Miller 2010-10-21 12:08 ` David Jander 2010-10-21 12:24 ` Marc Kleine-Budde [not found] ` <1287568946-32727-1-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2010-10-20 10:02 ` [PATCH 2/2] can: mcp251x: fix generation of error frames Marc Kleine-Budde [not found] ` <1287568946-32727-3-git-send-email-mkl-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> 2010-10-21 11:33 ` David Miller 2010-10-20 10:11 ` [PATCH 0/2] can: mcp251x: fix error handling and error frames bug Wolfgang Grandegger [not found] ` <4CBEC06D.6000102-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org> 2010-10-20 10:16 ` 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).