netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: Brandon Streiff <brandon.streiff@ni.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
	Richard Cochran <richardcochran@gmail.com>,
	Erik Hons <erik.hons@ni.com>
Subject: Re: [PATCH net-next RFC 3/9] net: dsa: mv88e6xxx: add support for GPIO configuration
Date: Thu, 28 Sep 2017 20:01:11 +0200	[thread overview]
Message-ID: <20170928180111.GF14940@lunn.ch> (raw)
In-Reply-To: <659c4254-d0b7-52dc-dd9b-3921cd2f20c0@gmail.com>

On Thu, Sep 28, 2017 at 10:45:03AM -0700, Florian Fainelli wrote:
> On 09/28/2017 08:25 AM, Brandon Streiff wrote:
> > The Scratch/Misc register is a windowed interface that provides access
> > to the GPIO configuration. Provide a new method for configuration of
> > GPIO functions.
> > 
> > Signed-off-by: Brandon Streiff <brandon.streiff@ni.com>
> > ---
> 
> > +/* Offset 0x1A: Scratch and Misc. Register */
> > +static int mv88e6xxx_g2_scratch_reg_read(struct mv88e6xxx_chip *chip,
> > +					 int reg, u8 *data)
> > +{
> > +	int err;
> > +	u16 value;
> > +
> > +	err = mv88e6xxx_g2_write(chip, MV88E6XXX_G2_SCRATCH_MISC_MISC,
> > +				 reg << 8);
> > +	if (err)
> > +		return err;
> > +
> > +	err = mv88e6xxx_g2_read(chip, MV88E6XXX_G2_SCRATCH_MISC_MISC, &value);
> > +	if (err)
> > +		return err;
> > +
> > +	*data = (value & MV88E6XXX_G2_SCRATCH_MISC_DATA_MASK);
> > +
> > +	return 0;
> > +}
> 
> With the write and read acquiring and then releasing the lock
> immediately, is no there room for this sequence to be interrupted in the
> middle and end-up returning inconsistent reads?

Hi Florian

The general pattern in this code is that the lock chip->reg_lock is
taken at a higher level. That protects against other threads. The
driver tends to do that at the highest levels, at the entry points
into the driver. I've not yet checked this code follows the pattern
yet. However, we have a check in the low level to ensure the lock has
been taken. So it seems likely the lock is held.
 
> Would there be any value in implementing a proper gpiochip structure
> here such that other pieces of SW can see this GPIO controller as a
> provider and you can reference it from e.g: Device Tree using GPIO
> descriptors?

That would be my preference as well, or maybe a pinctrl driver.

     Andrew

  reply	other threads:[~2017-09-28 18:01 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28 15:25 [PATCH net-next RFC 0/9] net: dsa: PTP timestamping for mv88e6xxx Brandon Streiff
2017-09-28 15:25 ` [PATCH net-next RFC 1/9] net: dsa: mv88e6xxx: add accessors for PTP/TAI registers Brandon Streiff
2017-09-28 16:29   ` Vivien Didelot
2017-10-10 13:59     ` Vivien Didelot
2017-10-08 14:32   ` Richard Cochran
2017-09-28 15:25 ` [PATCH net-next RFC 2/9] net: dsa: mv88e6xxx: expose switch time as a PTP hardware clock Brandon Streiff
2017-09-28 16:56   ` Andrew Lunn
2017-09-29 15:28     ` Brandon Streiff
2017-10-08 11:59       ` Richard Cochran
2017-09-28 17:03   ` Andrew Lunn
2017-09-29 15:17     ` Brandon Streiff
2017-10-08 12:07       ` Richard Cochran
2017-10-08 14:52   ` Richard Cochran
2017-09-28 15:25 ` [PATCH net-next RFC 3/9] net: dsa: mv88e6xxx: add support for GPIO configuration Brandon Streiff
2017-09-28 17:45   ` Florian Fainelli
2017-09-28 18:01     ` Andrew Lunn [this message]
2017-09-28 19:57       ` Vivien Didelot
2017-09-29 15:30       ` Brandon Streiff
2017-09-28 15:25 ` [PATCH net-next RFC 4/9] net: dsa: mv88e6xxx: add support for event capture Brandon Streiff
2017-10-08 15:06   ` Richard Cochran
2017-10-09 22:08     ` Levi Pearson
2017-10-10  1:53       ` Richard Cochran
2017-09-28 15:25 ` [PATCH net-next RFC 5/9] net: dsa: forward hardware timestamping ioctls to switch driver Brandon Streiff
2017-09-28 17:25   ` Florian Fainelli
2017-10-08 13:12     ` Richard Cochran
2017-09-28 19:31   ` Vivien Didelot
2017-09-28 15:25 ` [PATCH net-next RFC 6/9] net: dsa: forward timestamping callbacks to switch drivers Brandon Streiff
2017-09-28 17:40   ` Florian Fainelli
2017-09-29 15:30     ` Brandon Streiff
2017-09-28 15:25 ` [PATCH net-next RFC 7/9] ptp: add offset for reserved field to header Brandon Streiff
2017-09-28 15:25 ` [PATCH net-next RFC 8/9] net: dsa: mv88e6xxx: add rx/tx timestamping support Brandon Streiff
2017-10-08 14:24   ` Richard Cochran
2017-10-08 15:12   ` Richard Cochran
2017-10-08 15:29   ` Richard Cochran
2017-09-28 15:25 ` [PATCH net-next RFC 9/9] net: dsa: mv88e6xxx: add workaround for 6341 timestamping Brandon Streiff
2017-09-28 17:36 ` [PATCH net-next RFC 0/9] net: dsa: PTP timestamping for mv88e6xxx Andrew Lunn
2017-09-28 17:51   ` Florian Fainelli
2017-09-29 15:34   ` Brandon Streiff
2017-09-29  9:43 ` Richard Cochran
2017-10-08 15:38   ` Richard Cochran
2017-11-06 14:55     ` Richard Cochran
2017-11-06 15:04       ` Andrew Lunn
2017-11-07 18:15         ` Richard Cochran
2017-11-07 18:13       ` Richard Cochran
2017-11-07 20:56         ` Brandon Streiff
2017-11-08  0:09           ` Andrew Lunn
2017-11-08  3:02           ` Andrew Lunn
2017-11-08  3:23             ` Richard Cochran
2017-12-04  1:13               ` Richard Cochran

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=20170928180111.GF14940@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=brandon.streiff@ni.com \
    --cc=davem@davemloft.net \
    --cc=erik.hons@ni.com \
    --cc=f.fainelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=vivien.didelot@savoirfairelinux.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).