From: David Jander <david@protonic.nl>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Wolfgang Grandegger <wg@grandegger.com>,
linux-can@vger.kernel.org,
Alexander Stein <alexander.stein@systec-electronic.com>
Subject: Re: [PATCH 11/15] can: rx-fifo: Add support for can state tracking and error polling
Date: Wed, 5 Nov 2014 18:16:12 +0100 [thread overview]
Message-ID: <20141105181612.569be441@archvile> (raw)
In-Reply-To: <5457822B.5090200@pengutronix.de>
On Mon, 03 Nov 2014 14:24:59 +0100
Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> On 11/03/2014 02:09 PM, David Jander wrote:
> > On Mon, 03 Nov 2014 13:58:43 +0100
> > Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> >
> >> On 11/03/2014 01:51 PM, David Jander wrote:
> >>>> On 10/10/2014 05:46 PM, David Jander wrote:
> >>>>> The interrupt handler should store the error flags if needed and call
> >>>>> can_rx_fifo_irq_error() if there was an error flag set. This will
> >>>>> trigger a napi-poll that will call poll_can_state() and
> >>>>> poll_bus_error() callbacks. Those should handle can state machine and
> >>>>> send error frames as needed.
> >>>>>
> >>>>> Signed-off-by: David Jander <david@protonic.nl>
> >>>>> ---
> >>>>> drivers/net/can/dev.c | 23 ++++++++++++++++++++---
> >>>>> include/linux/can/dev.h | 9 +++++++++
> >>>>> 2 files changed, 29 insertions(+), 3 deletions(-)
> >>>>>
> >>>>> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> >>>>> index fc35d28..dac7579 100644
> >>>>> --- a/drivers/net/can/dev.c
> >>>>> +++ b/drivers/net/can/dev.c
> >>>>> @@ -352,6 +352,9 @@ static int can_rx_fifo_napi_poll(struct napi_struct
> >>>>> *napi, int quota) unsigned int tail;
> >>>>>
> >>>>> restart_poll:
> >>>>> + if (work_done < quota)
> >>>>> + work_done += fifo->poll_can_state(fifo);
> >>>>> +
> >>>>
> >>>> Do we need two callbacks in the poll-loop? I think one should be enough.
> >>>> The driver can call as many non-rx related functions as needed then.
> >>>> E.g. state change, bus error handling, tx-completion handling, etc...
> >>>
> >>> Ok. I split it into two handlers, because I saw most drivers doing first
> >>> state-handling then message reception and last error handling... in this
> >>> particular order. If that order is not important, we can use one poll()
> >>> function for both state- and error-handling.
> >>> In that case... should the poll() handler be called _before_ or _after_
> >>> handling the mailboxes?
> >>
> >> Following the general rule zero-one-infinity ("Allow none of foo, one of
> >> foo, or any number of foo" [1]) one callback should be fine. As we are
> >> optimizing for not loosing RX CAN frames I tend to say it should come
> >> after rx.
> >
> > Hahaha, ok, I got it :)
> > Any idea on how to call this function? Just "poll" seems a little bit
> > under-documented...
>
> Yes, what about extra_poll, poll_extra?
Oops. I just realized this isn't so easy... nor is this really a
zero-one-infinity case. On top of that the solution will get quite ugly too:
poll_can_state() and poll_bus_error() have two distinct functions and _both_
can generate a (error-) CAN frame. If I consolidate this into just one
handler, that handler could potentially generate 0, 1 or 2 CAN frames, so I'd
be forced to introduce an extra parameter to keep track of NAPI quota inside
the driver callback! This seems quite ugly to me, don't you think?
Any ideas?
Best regards,
--
David Jander
Protonic Holland.
next prev parent reply other threads:[~2014-11-05 17:15 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-10 15:46 [RFC PATCH V3 00/15] CAN: Add rx-fifo support and port flexcan to it David Jander
2014-10-10 15:46 ` [PATCH 01/15] can: flexcan: add documentation about mailbox organizaiton David Jander
2014-10-10 15:46 ` [PATCH 02/15] can: flexcan: rename crl2 -> ctrl2 David Jander
2014-10-10 15:46 ` [PATCH 03/15] can: flexcan: replace open coded mailbox code by proper defines David Jander
2014-10-10 15:46 ` [PATCH 04/15] can: flexcan: Re-write receive path to use MB queue instead of FIFO David Jander
2014-10-10 15:46 ` [PATCH 05/15] can: dev: add preliminary rx-fifo David Jander
2014-10-10 15:46 ` [PATCH 06/15] can: rx-fifo: Increase MB size limit from 32 to 64 David Jander
2014-10-19 21:25 ` Marc Kleine-Budde
2014-10-20 6:14 ` David Jander
2014-10-10 15:46 ` [PATCH 07/15] can: rx-fifo: Change to do controller off-load in interrupt and NAPI poll David Jander
2014-10-19 22:09 ` Marc Kleine-Budde
2014-10-20 7:06 ` David Jander
2014-11-03 11:10 ` Marc Kleine-Budde
2014-11-03 12:44 ` David Jander
2014-10-10 15:46 ` [PATCH 08/15] can: rx-fifo: fix long lines David Jander
2014-10-19 21:18 ` Marc Kleine-Budde
2014-10-20 7:09 ` David Jander
2014-10-10 15:46 ` [PATCH 09/15] can: rx-fifo: Add can_rx_fifo_reset() function David Jander
2014-11-03 11:16 ` Marc Kleine-Budde
2014-11-03 12:46 ` David Jander
2014-11-03 12:51 ` Marc Kleine-Budde
2014-10-10 15:46 ` [PATCH 10/15] can: rx-fifo: remove obsolete comment David Jander
2014-10-10 15:46 ` [PATCH 11/15] can: rx-fifo: Add support for can state tracking and error polling David Jander
2014-11-03 11:24 ` Marc Kleine-Budde
2014-11-03 12:51 ` David Jander
2014-11-03 12:58 ` Marc Kleine-Budde
2014-11-03 13:09 ` David Jander
2014-11-03 13:24 ` Marc Kleine-Budde
2014-11-05 17:16 ` David Jander [this message]
2014-11-06 10:20 ` Marc Kleine-Budde
2014-11-06 11:07 ` David Jander
2014-10-10 15:46 ` [PATCH 12/15] can: flexcan: Add support for RX-FIFO David Jander
2014-11-03 11:26 ` Marc Kleine-Budde
2014-11-03 12:55 ` David Jander
2014-11-03 13:34 ` Marc Kleine-Budde
2014-10-10 15:46 ` [PATCH 13/15] can: rx-fifo: Add support for simple irq offloading David Jander
2014-11-03 11:59 ` Marc Kleine-Budde
2014-10-10 15:46 ` [PATCH 14/15] can: flexcan: Add MB/Fifo specific column to comment table of IP versions David Jander
2014-10-10 15:47 ` [PATCH 15/15] can: flexcan: Re-enable RTR reception support for older flexcan IPs David Jander
2014-11-03 12:02 ` Marc Kleine-Budde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141105181612.569be441@archvile \
--to=david@protonic.nl \
--cc=alexander.stein@systec-electronic.com \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=wg@grandegger.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).