netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Francois Romieu <romieu@fr.zoreil.com>
Cc: netdev@vger.kernel.org, mcgrof@do-not-panic.com,
	kvalo@adurom.com, adrian.chadd@gmail.com
Subject: Re: [PATCH] alx: add a simple AR816x/AR817x device driver
Date: Thu, 13 Jun 2013 23:52:22 +0200	[thread overview]
Message-ID: <1371160342.8335.22.camel@jlt4.sipsolutions.net> (raw)
In-Reply-To: <20130612230257.GB21234@electric-eye.fr.zoreil.com>

Thanks again :-)

> > +int alx_read_phy_reg(struct alx_hw *hw, u16 reg, u16 *phy_data)
> > +{
> > +	int err;
> > +
> > +	spin_lock(&hw->mdio_lock);
> > +	err = __alx_read_phy_reg(hw, reg, phy_data);
> > +	spin_unlock(&hw->mdio_lock);
> 
> Isn't it possible to remove the phy ops from any irq / napi / tasklet
> context ?

I don't think they're actually called there.

> If you only need it in user / workqueue context you'll be able to trade
> the spinlock for a mutex (and push it in the common core methods ?).

Yes, I suppose I could, but is it worth it? It's held only for a very
short amount of time to get the indirect register access correct. I
don't really see any reason to prefer a mutex here?

Not sure what you mean by "push it in the common core methods"? I
actually suspect that this lock can't ever be contended because the
callers hold the RTNL anyway, but I don't really want to rely on just
that.


> > +		for (i = 0; i < ALX_SLD_MAX_TO; i++) {
> > +			mdelay(1);
> > +			val = alx_read_mem32(hw, ALX_SLD);
> > +			if ((val & ALX_SLD_START) == 0)
> > +				break;
> > +		}
> 
> You may add an helper for the loops above.
> 
> > +		if (i == ALX_SLD_MAX_TO)
> > +			return -EIO;
> > +		loaded_intn = true;
> > +		goto read_mcadr;
> 
> (I don't dislike it but it verges on goto fetishismi :o) )

It is pretty ugly ... I've now rewritten it using two helper functions.

> > +static irqreturn_t alx_intr_handle(struct alx_priv *alx, u32 intr)
> > +{
> > +	struct alx_hw *hw = &alx->hw;
> > +	bool write_int_mask = false;
> > +
> > +	spin_lock(&alx->irq_lock);
> 
> Do yourself a favor: avoid any work in the irq handler.
> 
> Forget the lock. Mask irqs, insert mmiowb and memory barrier, then
> schedule napi if there is any event.
> 
> In the napi handler, enable napi polling then irq.

Hmm, yeah, I'll have to think about that. I don't really care about the
performance all that much ... just want the device to work :-)

Would I really want to rely on NAPI for error interrupts and the like
though? I thought NAPI could potentially be deferred due to budget etc.

johannes

  parent reply	other threads:[~2013-06-13 21:52 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-10 21:26 [PATCH 0/1] alx driver Johannes Berg
2013-06-10 21:26 ` [PATCH 1/1] alx: add a simple AR816x/AR817x device driver Johannes Berg
2013-06-10 21:29 ` [PATCH v2 " Johannes Berg
2013-06-11 22:23   ` Francois Romieu
2013-06-12 18:02     ` Johannes Berg
2013-06-18  1:18   ` Ben Hutchings
2013-06-20 21:40     ` Johannes Berg
2013-06-20 21:58       ` Ben Hutchings
2013-06-20 22:09         ` Johannes Berg
2013-06-21 12:45           ` Ben Hutchings
2013-06-21 20:42             ` Johannes Berg
2013-06-21 21:39               ` Ben Hutchings
2013-06-22 10:17       ` Johannes Stezenbach
2013-06-22 14:21         ` Ben Hutchings
2013-06-25 18:24         ` Johannes Berg
2013-06-12  7:11 ` [PATCH 0/1] alx driver Johannes Stezenbach
2013-06-12 18:00   ` Johannes Berg
2013-06-12 20:33 ` [PATCH] alx: add a simple AR816x/AR817x device driver Johannes Berg
2013-06-12 20:48   ` Stephen Hemminger
2013-06-12 20:51     ` Johannes Berg
2013-06-12 23:02   ` Francois Romieu
2013-06-13  3:46     ` Joe Perches
2013-06-13  6:47       ` Francois Romieu
2013-06-13 21:52     ` Johannes Berg [this message]
2013-06-13 23:03       ` Francois Romieu
2013-06-15 18:38         ` Johannes Berg
2013-06-13 22:24   ` Johannes Stezenbach
2013-06-13 22:29     ` Johannes Berg
2013-06-14  5:53       ` Johannes Stezenbach
2013-06-15 18:26         ` Johannes Berg
2013-06-15 20:15           ` Johannes Berg
2013-06-16  9:49             ` Johannes Stezenbach
2013-06-16 11:17               ` Johannes Berg
2013-06-16 17:48                 ` Johannes Stezenbach
2013-06-16 18:06                   ` Johannes Stezenbach
2013-06-16 18:42                   ` Johannes Stezenbach
2013-06-16 19:41                     ` Johannes Berg
2013-06-16 20:37                       ` Johannes Stezenbach
2013-06-16 12:14               ` Johannes Berg
2013-06-17 20:44 ` [PATCH v4] " Johannes Berg
2013-06-17 23:05   ` David Miller

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=1371160342.8335.22.camel@jlt4.sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=adrian.chadd@gmail.com \
    --cc=kvalo@adurom.com \
    --cc=mcgrof@do-not-panic.com \
    --cc=netdev@vger.kernel.org \
    --cc=romieu@fr.zoreil.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).