From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: Simon Guinot <simon.guinot@sequanux.org>
Cc: Alan Cox <alan@linux.intel.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Vincent Pelletier <plr.vincent@gmail.com>,
Giel van Schijndel <me@mortis.eu>,
linux-gpio@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Vincent Donnefort <vdonnefort@gmail.com>,
Yoann Sculo <yoann@sculo.fr>,
Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH] kernel/resource.c: fix muxed resource handling in __request_region()
Date: Tue, 23 Feb 2016 09:19:05 -0800 [thread overview]
Message-ID: <56CC9489.7060706@virtuousgeek.org> (raw)
In-Reply-To: <20160223161920.GB3840@kw.sim.vm.gnt>
On 02/23/2016 08:19 AM, Simon Guinot wrote:
> On Mon, Feb 22, 2016 at 12:46:09PM -0800, Jesse Barnes wrote:
>> On 02/22/2016 05:49 AM, Alan Cox wrote:
>>>> we have some good alternatives in the form of bus and platform
>>>> drivers that
>>>> can manage the appropriate serialization and keep things from
>>>> stomping
>>>> on one another.
>>>
>>> It's not used much, especially nowdays. The use case is basically multi
>>> I/O chips on the ISA/LPC bus with magic shared config register ports.
>>>
>>> We have sufficiently few of those we could give muxed the boot and
>>> special case them if preferred.
>>
>> Ah that's right, now I remember the context. So where should we go from here then? Just leave the ugly fix in or hack on old stuff and hope not to break it?
>
> Hi Jesse,
>
> The fix is not ugly but only incomplete. And I have to say that the
> whole IORESOURCE_MUXED thing is not shiny either :)
Yeah definitely, I'm not casting stones at you, this whole problem is an
ugly one. :)
As Alan said, muxed is really intended for a pretty limited set of
cases. The "right" solution is a lot more work than its worth, so we
have this instead, which is fine. But obviously it's been a little
trickier to put in place than we hoped. :)
> The main problem in __request_region() is that we are dropping the
> spinlock of the resource list while holding a reference on a resource,
> waiting for a muxed resource to become available.
>
> From here, I can see two bugs:
>
> 1 - At wake-up, the next __request_resource() iteration will not detect
> a remaining conflict. To work properly, __request_resource() needs
> to be called with a parent of the conflicting resource. Instead we
> are passing the conflicting resource itself...
> 2 - At wake-up the resource pointer we are holding could have been
> freed. Since we are just about to use this pointer to insert a new
> resource in the linked list, it is broken...
>
> My patch fixes 1 and makes things better for 2.
>
> But I think Linus is right. If at wake-up we use the original parent
> resource to check again for a conflict, then we are safe.
>
> If you want, I can propose a such patch.
>
> Note that IORESOURCE_MUXED is mostly used by Super-I/Os drivers. A
> Super-I/O is a legacy I/O controller embedded on x86 motherboards. It is
> used to connect the low-bandwidth devices such as parallel ports, serial
> ports, keyboard controllers, hardware monitoring controllers, GPIO
> controllers, etc. While each logical device have its own memory region,
> a shared memory region is used for some configuration purpose.
> IORESOURCE_MUXED is a convenient way to deal with that. For some code
> examples you can look at the superio_* functions in the IT87 drivers:
> gpio/gpio-it87.c, hwmon/it87.c and watchdog/it87_wdt.c.
>
> I am not aware of any other users for IORESOURCE_MUXED.
>
> Let me know how you want to go and if you need my help.
I'd be happy if you proposed a patch. It would also be nice if we could
somehow more formally limit the MUXED usage to these super I/O devices,
just so other users don't get into trouble thinking it's more general
than it is.
Thanks,
Jesse
next prev parent reply other threads:[~2016-02-23 17:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-20 18:03 gpio-f7188x: Fix concurrent GPIO accesses (and minor improvements) Vincent Pelletier
2015-08-20 18:03 ` [1/4] gpio: gpio-f7188x: Use mutex for access serialisation Vincent Pelletier
2015-08-20 18:03 ` [2/4] gpio: gpio-f7188x: GPIO bank 0 bit 0 is not available on f71869a Vincent Pelletier
2015-08-20 18:03 ` [3/4] gpio: gpio-f7188x: "get" should retrieve sensed level when available Vincent Pelletier
2015-08-20 18:03 ` [4/4] gpio: gpio-f7188x: Implement get_direction Vincent Pelletier
2015-08-21 17:52 ` [1/4] gpio: gpio-f7188x: Use mutex for access serialisation Simon Guinot
2015-08-21 20:48 ` Vincent Pelletier
2015-08-22 17:04 ` Vincent Pelletier
2015-09-03 18:05 ` Vincent Pelletier
2015-09-04 7:39 ` Simon Guinot
2015-09-09 22:01 ` Simon Guinot
2015-09-09 22:15 ` [PATCH] kernel/resource.c: fix muxed resource handling in __request_region() Simon Guinot
2016-02-19 21:10 ` Vincent Pelletier
2016-02-19 23:25 ` Jesse Barnes
2016-02-20 17:11 ` Linus Torvalds
2016-02-20 22:15 ` Jesse Barnes
2016-02-20 22:15 ` Jesse Barnes
2016-02-22 13:49 ` Alan Cox
2016-02-22 20:46 ` Jesse Barnes
2016-02-23 16:19 ` Simon Guinot
2016-02-23 17:19 ` Jesse Barnes [this message]
2016-02-23 21:38 ` One Thousand Gnomes
2016-02-24 14:25 ` [PATCH] kernel/resource.c: ensure parent is not freed " Simon Guinot
2016-02-23 8:00 ` [PATCH] kernel/resource.c: fix muxed resource handling " Vincent Pelletier
2015-09-12 13:26 ` [1/4] gpio: gpio-f7188x: Use mutex for access serialisation Vincent Pelletier
2015-09-04 13:48 ` Vincent Donnefort
2015-09-05 7:43 ` Vincent Pelletier
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=56CC9489.7060706@virtuousgeek.org \
--to=jbarnes@virtuousgeek.org \
--cc=alan@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@mortis.eu \
--cc=plr.vincent@gmail.com \
--cc=simon.guinot@sequanux.org \
--cc=torvalds@linux-foundation.org \
--cc=vdonnefort@gmail.com \
--cc=yoann@sculo.fr \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.