netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>,
	linux-omap@vger.kernel.org, netdev@vger.kernel.org,
	kernel@pengutronix.de
Subject: Re: [PATCH 2/2] net: davinci_cpdma: reduce time holding chan->lock in cpdma_chan_submit
Date: Wed, 27 Jul 2016 09:12:28 +0200	[thread overview]
Message-ID: <20160727071228.GH5368@pengutronix.de> (raw)
In-Reply-To: <66d886a4-4852-096c-a3b3-3faec3eb167f@ti.com>

Hello,

On Tue, Jul 26, 2016 at 05:25:58PM +0300, Grygorii Strashko wrote:
> On 07/26/2016 03:02 PM, Uwe Kleine-König wrote:
> > Allocating and preparing a dma descriptor doesn't need to happen under
> > the channel's lock. So do this before taking the channel's lock. The only
> > down side is that the dma descriptor might be allocated even though the
> > channel is about to be stopped. This is unlikely though.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > ---
> >  drivers/net/ethernet/ti/davinci_cpdma.c | 38 +++++++++++++++++----------------
> >  1 file changed, 20 insertions(+), 18 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
> > index 5ffa04a306c6..ba3462707ae3 100644
> > --- a/drivers/net/ethernet/ti/davinci_cpdma.c
> > +++ b/drivers/net/ethernet/ti/davinci_cpdma.c
> > @@ -542,24 +542,10 @@ int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data,
> >  	u32				mode;
> >  	int				ret = 0;
> >  
> > -	spin_lock_irqsave(&chan->lock, flags);
> > -
> > -	if (chan->state == CPDMA_STATE_TEARDOWN) {
> > -		ret = -EINVAL;
> > -		goto unlock_ret;
> > -	}
> > -
> > -	if (chan->count >= chan->desc_num)	{
> > -		chan->stats.desc_alloc_fail++;
> > -		ret = -ENOMEM;
> > -		goto unlock_ret;
> > -	}
> 
> I'm not sure this is right thing to do. This check is expected to be strict
> and means "channel has exhausted the available descriptors, so further descs allocation does not allowed".

I developed this patch basing on a 4.4 kernel which doesn't have
742fb20fd4c7 ("net: ethernet: ti: cpdma: switch to use genalloc"). There
my patch is more obviously correct. As currently chan->count is
protected by chan->lock we must hold the lock for this check. If a
failing check means we must not call cpdma_desc_alloc in the first
place, that's bad.

But I'm not sure this is the case here. After all cpdma_desc_alloc
doesn't do anything relevant for the hardware, right?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  reply	other threads:[~2016-07-27  7:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-26 12:02 [PATCH 0/2] net: davinci_cpdma: reduce latency on -rt Uwe Kleine-König
2016-07-26 12:02 ` [PATCH 1/2] net: davinci_cpdma: reduce time holding ctlr->lock in cpdma_control_set Uwe Kleine-König
2016-08-04 15:22   ` Grygorii Strashko
2016-08-09  8:27   ` Mugunthan V N
2016-07-26 12:02 ` [PATCH 2/2] net: davinci_cpdma: reduce time holding chan->lock in cpdma_chan_submit Uwe Kleine-König
2016-07-26 14:25   ` Grygorii Strashko
2016-07-27  7:12     ` Uwe Kleine-König [this message]
2016-07-27 14:08       ` Grygorii Strashko
2016-07-27 18:11         ` Ivan Khoronzhuk
2016-07-26 14:36 ` [PATCH 0/2] net: davinci_cpdma: reduce latency on -rt Grygorii Strashko
2016-07-27  7:03   ` Uwe Kleine-König
2016-07-27 14:11     ` Grygorii Strashko
2016-07-27 14:38       ` Uwe Kleine-König
2016-07-28  9:34         ` Grygorii Strashko
2016-07-28 12:12           ` Uwe Kleine-König

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=20160727071228.GH5368@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=grygorii.strashko@ti.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-omap@vger.kernel.org \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev@vger.kernel.org \
    /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).