All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikhail Kofanov <c5r@yandex.ru>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can <linux-can@vger.kernel.org>
Subject: Re: can: flexcan: patch
Date: Fri, 06 May 2016 16:47:32 +0300	[thread overview]
Message-ID: <629131462542452@web29o.yandex.ru> (raw)
In-Reply-To: <572C7149.6040307@pengutronix.de>

https://git.kernel.org/cgit/linux/kernel/git/mkl/linux-can-next.git/tree/?id=ffd461f80d536336811d573f197f3e6d9872d054




06.05.2016, 13:26, "Marc Kleine-Budde" <mkl@pengutronix.de>:
> On 05/05/2016 05:03 PM, Mikhail Kofanov wrote:
>>  Hello!
>>
>>  There is small patch for imx flexcan driver.
>>  1. Improve state change handling
>>  2. add tx/rx error counter to state change error frame
>>
>>  Tested on imx25 based custom board.
>
> Against which kernel version does this patch apply?
>
>>  diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
>>  index e2d7ded..84d1fd8 100644
>>  --- a/drivers/net/can/flexcan.c
>>  +++ b/drivers/net/can/flexcan.c
>>  @@ -581,11 +581,14 @@ static int flexcan_poll_state(struct net_device *dev, u32 reg_esr)
>>          struct flexcan_priv *priv = netdev_priv(dev);
>>          struct sk_buff *skb;
>>          struct can_frame *cf;
>>  + struct flexcan_regs __iomem *regs = priv->regs;
>>          enum can_state new_state = 0, rx_state = 0, tx_state = 0;
>>          int flt;
>>          struct can_berr_counter bec;
>>
>>          flt = reg_esr & FLEXCAN_ESR_FLT_CONF_MASK;
>>  + /* always send error counters in error frame */
>>  + __flexcan_get_berr_counter(dev, &bec);
>>          if (likely(flt == FLEXCAN_ESR_FLT_CONF_ACTIVE)) {
>>                  tx_state = unlikely(reg_esr & FLEXCAN_ESR_TX_WRN) ?
>>                          CAN_STATE_ERROR_WARNING : CAN_STATE_ERROR_ACTIVE;
>>  @@ -593,7 +596,6 @@ static int flexcan_poll_state(struct net_device *dev, u32 reg_esr)
>>                          CAN_STATE_ERROR_WARNING : CAN_STATE_ERROR_ACTIVE;
>>                  new_state = max(tx_state, rx_state);
>>          } else {
>>  - __flexcan_get_berr_counter(dev, &bec);
>>                  new_state = flt == FLEXCAN_ESR_FLT_CONF_PASSIVE ?
>>                          CAN_STATE_ERROR_PASSIVE : CAN_STATE_BUS_OFF;
>>                  rx_state = bec.rxerr >= bec.txerr ? new_state : 0;
>>  @@ -603,6 +605,8 @@ static int flexcan_poll_state(struct net_device *dev, u32 reg_esr)
>>          /* state hasn't changed */
>>          if (likely(new_state == priv->can.state))
>>                  return 0;
>>  + netdev_dbg(dev, "reg_esr=0x%x flt=0x%x ctrl=0x%08x new_state=%d\n", reg_esr, flt, flex
>>  + new_state);
>>
>>          skb = alloc_can_err_skb(dev, &cf);
>>          if (unlikely(!skb))
>>  @@ -613,6 +617,8 @@ static int flexcan_poll_state(struct net_device *dev, u32 reg_esr)
>>          if (unlikely(new_state == CAN_STATE_BUS_OFF))
>>                  can_bus_off(dev);
>>
>>  + cf->data[6] = bec.txerr;
>>  + cf->data[7] = bec.rxerr;
>>          dev->stats.rx_packets++;
>>          dev->stats.rx_bytes += cf->can_dlc;
>>          netif_receive_skb(skb);
>>  @@ -679,7 +685,7 @@ static int flexcan_poll(struct napi_struct *napi, int quota)
>>          /* The error bits are cleared on read,
>>           * use saved value from irq handler.
>>           */
>>  - reg_esr = flexcan_read(&regs->esr) | priv->reg_esr;
>>  + reg_esr = flexcan_read(&regs->esr) | (priv->reg_esr & FLEXCAN_ESR_ERR_BUS);
>>
>>          /* handle state changes */
>>          work_done += flexcan_poll_state(dev, reg_esr);
>>  @@ -721,24 +727,29 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
>>          if (reg_esr & FLEXCAN_ESR_ALL_INT)
>>                  flexcan_write(reg_esr & FLEXCAN_ESR_ALL_INT, &regs->esr);
>>
>>  +
>>          /* schedule NAPI in case of:
>>           * - rx IRQ
>>  - * - state change IRQ
>>  + * - tx/rx warning or bus-off
>>  + * - any state change
>>           * - bus error IRQ and bus error reporting is activated
>>           */
>>          if ((reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_AVAILABLE) ||
>>              (reg_esr & FLEXCAN_ESR_ERR_STATE) ||
>>  + ((reg_esr & FLEXCAN_ESR_FLT_CONF_MASK) != (priv->reg_esr & FLEXCAN_ESR_FLT_CONF_MAS
>
> There seems to be a problem with this mail, the rest of this line is
> missing.
>
> Marc
>
>>              flexcan_has_and_handle_berr(priv, reg_esr)) {
>>                  /* The error bits are cleared on read,
>>                   * save them for later use.
>>                   */
>>  - priv->reg_esr = reg_esr & FLEXCAN_ESR_ERR_BUS;
>>  + priv->reg_esr = reg_esr;
>>                  flexcan_write(FLEXCAN_IFLAG_DEFAULT &
>>                                ~FLEXCAN_IFLAG_RX_FIFO_AVAILABLE, &regs->imask1);
>>                  flexcan_write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL,
>>                                &regs->ctrl);
>>                  napi_schedule(&priv->napi);
>>          }
>>  + else
>>  + priv->reg_esr = reg_esr;
>>
>>          /* FIFO overflow */
>>          if (reg_iflag1 & FLEXCAN_IFLAG_RX_FIFO_OVERFLOW) {
>
> --
> 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 |

  reply	other threads:[~2016-05-06 13:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <14855451462460611@web29h.yandex.ru>
2016-05-06 10:26 ` can: flexcan: patch Marc Kleine-Budde
2016-05-06 13:47   ` Mikhail Kofanov [this message]
2016-05-06 15:56     ` 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=629131462542452@web29o.yandex.ru \
    --to=c5r@yandex.ru \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    /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 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.