[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <VI1PR0402MB28009F24026451524BFD7235E09B0@VI1PR0402MB2800.eurprd04.prod.outlook.com>
Date: Mon, 7 Oct 2019 10:49:39 +0000
From: Ioana Ciornei <ioana.ciornei@....com>
To: Andrew Lunn <andrew@...n.ch>
CC: "davem@...emloft.net" <davem@...emloft.net>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Ioana Ciocoi Radulescu <ruxandra.radulescu@....com>
Subject: RE: [PATCH 3/3] dpaa2-eth: Avoid unbounded while loops
> Subject: Re: [PATCH 3/3] dpaa2-eth: Avoid unbounded while loops
>
> On Fri, Oct 04, 2019 at 12:21:33PM +0300, Ioana Ciornei wrote:
> > From: Ioana Radulescu <ruxandra.radulescu@....com>
> >
> > Throughout the driver there are several places where we wait
> > indefinitely for DPIO portal commands to be executed, while the portal
> > returns a busy response code.
> >
> > Even though in theory we are guaranteed the portals become available
> > eventually, in practice the QBMan hardware module may become
> > unresponsive in various corner cases.
> >
> > Make sure we can never get stuck in an infinite while loop by adding a
> > retry counter for all portal commands.
> >
> > Signed-off-by: Ioana Radulescu <ruxandra.radulescu@....com>
> > Signed-off-by: Ioana Ciornei <ioana.ciornei@....com>
> > ---
> > drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 30
> > ++++++++++++++++++++----
> > drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.h | 8 +++++++
> > 2 files changed, 33 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > index 2c5072fa9aa0..29702756734c 100644
> > --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> > @@ -221,6 +221,7 @@ static void xdp_release_buf(struct dpaa2_eth_priv
> *priv,
> > struct dpaa2_eth_channel *ch,
> > dma_addr_t addr)
> > {
> > + int retries = 0;
> > int err;
> >
> > ch->xdp.drop_bufs[ch->xdp.drop_cnt++] = addr; @@ -229,8 +230,11
> @@
> > static void xdp_release_buf(struct dpaa2_eth_priv *priv,
> >
> > while ((err = dpaa2_io_service_release(ch->dpio, priv->bpid,
> > ch->xdp.drop_bufs,
> > - ch->xdp.drop_cnt)) == -EBUSY)
> > + ch->xdp.drop_cnt)) == -EBUSY) {
> > + if (retries++ >= DPAA2_ETH_SWP_BUSY_RETRIES)
> > + break;
> > cpu_relax();
> > + }
> >
> > if (err) {
> > free_bufs(priv, ch->xdp.drop_bufs, ch->xdp.drop_cnt); @@ -
> 458,7
> > +462,7 @@ static int consume_frames(struct dpaa2_eth_channel *ch,
> > struct dpaa2_eth_fq *fq = NULL;
> > struct dpaa2_dq *dq;
> > const struct dpaa2_fd *fd;
> > - int cleaned = 0;
> > + int cleaned = 0, retries = 0;
> > int is_last;
> >
> > do {
> > @@ -469,6 +473,11 @@ static int consume_frames(struct dpaa2_eth_channel
> *ch,
> > * the store until we get some sort of valid response
> > * token (either a valid frame or an "empty dequeue")
> > */
> > + if (retries++ >= DPAA2_ETH_SWP_BUSY_RETRIES) {
> > + netdev_err_once(priv->net_dev,
> > + "Unable to read a valid
> dequeue response\n");
> > + return 0;
> > + }
> > continue;
>
> Hi Ioana
>
> It seems a bit odd that here you could return -ETIMEDOUT, but you print an
> error, and return 0. But in the two cases above in void functions, you don't print
> anything.
>
> Please at least return -ETIMEDOUT when you can.
Hi Andrew,
That's a good point. I'll send out a v2 fixing this.
Thanks,
Ioana
>
> Andrew
Powered by blists - more mailing lists