mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	Alexandre Courbot <acourbot@nvidia.com>,
	Lan Tianyu <tianyu.lan@intel.com>, Lv Zheng <lv.zheng@intel.com>,
	Alan Cox <alan.cox@intel.com>,
	Mathias Nyman <mathias.nyman@linux.intel.com>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/6] gpiolib: Allow GPIO chips to request their own GPIOs
Date: Wed, 05 Mar 2014 14:07:43 +0100	[thread overview]
Message-ID: <8377171.cpEJInc4ro@vostro.rjw.lan> (raw)
In-Reply-To: <20140305120550.GO5018@intel.com>

On Wednesday, March 05, 2014 02:05:50 PM Mika Westerberg wrote:
> On Wed, Mar 05, 2014 at 10:49:41AM +0800, Linus Walleij wrote:
> > On Tue, Feb 25, 2014 at 12:00 AM, Mika Westerberg
> > <mika.westerberg@linux.intel.com> wrote:
> > 
> > > Sometimes it is useful to allow GPIO chips themselves to request GPIOs they
> > > own through gpiolib API. One usecase is ACPI ASL code that should be able
> > > to toggle GPIOs through GPIO operation regions.
> > >
> > > We can't really use gpio_request() and its counterparts because it will pin
> > > the module to the kernel forever (as it calls module_get()). Instead we
> > > provide a gpiolib internal functions gpiochip_request/free_own_desc() that
> > > work the same as gpio_request() but don't manipulate module refrence count.
> > >
> > > Since it's the GPIO chip driver who requests the GPIOs in the first place
> > > we can be sure that it cannot be unloaded without the driver knowing about
> > > that. Furthermore we only limit this functionality to be available only
> > > inside gpiolib.
> > >
> > > Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> > 
> > I fully trust you in doing the ACPI stuff in patches 2-n but on this patch
> > in particular I want Alexandre's review tag as well, as he's working
> > actively with the descriptor API and I don't want to add too many quirks
> > without his consent.
> 
> Thanks for your trust :)
> 
> > So Alexandre, what do you say about this?
> 
> I'm about to send v2 of the series with Rafael's comments taken into
> account. However, I stumbled to another locking problem:
> 
> I'm going to move taking the gpio_lock outside of __gpiod_request() and
> have __gpiod_request() to release that lock, so that we can call
> chip->request() safely.
> 
> Since we are using _irqsave()/_irqrestore() versions, it means that I need
> to pass flags as a pointer from gpiod_request() to __gpiod_request() like:
> 
> 	spin_lock_irqsave(&gpio_lock, flags);
> 	if (try_module_get(chip->owner)) {
> 		ret = __gpiod_request(desc, label, &flags);

Ouch.  Sorry for overlooking that.

> 		...
> 
> Is that acceptable or can you guys suggest some alternative? One
> alternative that I can think about is to have __gpiod_request() to take the
> lock and move try_module_get() outside to gpiod_request():
> 
> __gpiod_request()
> {
> 	unsigned long flags;
> 
> 	spin_lock_irqsave(&gpio_lock, flags);
> 	...
> }
> 
> gpiod_request():
> {
> 	...
> 	if (try_module_get(chip->owner)) {
> 		ret = __gpiod_request(desc, label);
> 		...
> }
> 
> Thoughts?

If that works, it would be better than passing the flags IMO.

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

  reply	other threads:[~2014-03-05 12:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-24 16:00 [PATCH 0/6] gpio / ACPI: Rework ACPI GPIO events and add support for operation regions Mika Westerberg
2014-02-24 16:00 ` [PATCH 1/6] gpiolib: Allow GPIO chips to request their own GPIOs Mika Westerberg
2014-02-25 14:10   ` Rafael J. Wysocki
2014-02-26  9:05     ` Mika Westerberg
2014-02-26 13:47       ` Rafael J. Wysocki
2014-02-27  9:48         ` Mika Westerberg
2014-03-05  2:49   ` Linus Walleij
2014-03-05 12:05     ` Mika Westerberg
2014-03-05 13:07       ` Rafael J. Wysocki [this message]
2014-03-06  2:16     ` Alexandre Courbot
2014-02-24 16:00 ` [PATCH 2/6] gpio / ACPI: Allocate ACPI specific data directly in acpi_gpiochip_add() Mika Westerberg
2014-02-25 14:21   ` Rafael J. Wysocki
2014-02-26  9:08     ` Mika Westerberg
2014-02-24 16:00 ` [PATCH 3/6] gpio / ACPI: Rename acpi_gpio_evt_pin to acpi_gpio_event Mika Westerberg
2014-02-25 14:23   ` Rafael J. Wysocki
2014-02-26  9:09     ` Mika Westerberg
2014-02-24 16:00 ` [PATCH 4/6] gpio / ACPI: Embed events list directly into struct acpi_gpio_chip Mika Westerberg
2014-02-25 14:26   ` Rafael J. Wysocki
2014-02-26  9:10     ` Mika Westerberg
2014-02-24 16:00 ` [PATCH 5/6] gpio / ACPI: Rework ACPI GPIO event handling Mika Westerberg
2014-02-25 14:44   ` Rafael J. Wysocki
2014-02-26  9:10     ` Mika Westerberg
2014-02-24 16:00 ` [PATCH 6/6] gpio / ACPI: Add support for ACPI GPIO operation regions Mika Westerberg
2014-02-25 14:55   ` Rafael J. Wysocki
2014-02-26  9:11     ` Mika Westerberg

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=8377171.cpEJInc4ro@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=acourbot@nvidia.com \
    --cc=alan.cox@intel.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lv.zheng@intel.com \
    --cc=mathias.nyman@linux.intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=tianyu.lan@intel.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

all inboxes | Powered by JetHome®