All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrzej Hajda <a.hajda@samsung.com>
To: Lars-Peter Clausen <lars@metafoo.de>, Mark Brown <broonie@kernel.org>
Cc: ksummit-discuss@lists.linuxfoundation.org,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	"vegard.nossum@gmail.com" <vegard.nossum@gmail.com>,
	"rafael.j.wysocki" <rafael.j.wysocki@intel.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Valentin Rothberg <valentinrothberg@gmail.com>
Subject: Re: [Ksummit-discuss] [TECH TOPIC] Addressing complex dependencies and semantics (v2)
Date: Tue, 02 Aug 2016 13:45:12 +0200	[thread overview]
Message-ID: <57A087C8.4040805@samsung.com> (raw)
In-Reply-To: <8a7ddcd0-cbe6-2abe-eeb6-d1264af64c89@metafoo.de>

On 08/01/2016 08:21 PM, Lars-Peter Clausen wrote:
> On 08/01/2016 07:06 PM, Mark Brown wrote:
>> On Mon, Aug 01, 2016 at 06:18:55PM +0200, Andrzej Hajda wrote:
>>> On 08/01/2016 05:43 PM, Lars-Peter Clausen wrote:
>>>> On 08/01/2016 05:34 PM, Andrzej Hajda wrote:
>>>>> On 08/01/2016 04:54 PM, Lars-Peter Clausen wrote:
>>>>>> One option, which I think is currently the most used option in the kernel,
>>>>>> is to unregister the resource when the provider is removed, but keep the
>>>>>> resource object alive as long as there are users. Any further operation on
>>>>>> such object will fail with an error. This works to the point where things
>>>>>> don't crash, but it wont function in any meaningful way. There is no way to
>>>>>> automatically recover if the resource reappears.
>>>>> For me it is not a real solution, it is just dirty workaround to just avoid
>>>>> invalid pointers. It 'works' only because unbinding is rarely used.
>>>>> For example, how the device is supposed to work if its regulator or clock
>>>>> disappeared?
>> The device isn't supposed to work, just not crash - this is mainly used
>> for things that are exposed to userspace where we need to keep returning
>> errors to userspace until they free their reference.  I'm not sure we
>> can get out of that one.
>>
>>>>>> Other options are as you pointed out notifier callbacks that allows the
>>>>>> resource use to be aware that a resource has disappeared and it might adjust
>>>>>> and continue to function with limited functionality.
>>>>>> Another option is to teach the device core about critical resource
>>>>>> dependencies so that a consumer is automatically unbound by the core if any
>>>>>> of its resource dependencies are unregistered. The device can also
>>>>>> automatically be re-bound once the critical resources re-appear.
>>>>>> The most likely solution is probably a mixture of all of them.
>>>>> If we implement callbacks, we do not need other two 'options'.
>>>> Having to manually register callbacks for every resource in every driver
>>>> will result in a massive amount of boilerplate code. I'd rather avoid that.
>>> You can use helper to monitor multiple resources in one callback - it
>>> should not increase the code significantly. As I wrote in other e-mail I
>>> send already RFC in which the code in the driver was even shorter
>>> than before. See [1].
>> I think a lot of the difference between the two cases above is just
>> about where the default callback comes from and how it's presented to
>> users - having the driver core able to handle critical resources doesn't
>> seem hugely different to providing a list of resources and offsets into
>> driver_data in the struct driver and having a default callback that
>> calls probe() and remove() with an already allocated and initialized
>> driver_data.  That'd definitely cut down a lot on bolilerplate code, but
>> there's problems with the driver trying to clean up when removing (eg,
>> disabling things) when some of the resources it used are in the process
>> of being removed themselves.
> Yes, when I read callbacks I though about having to have individual
> callbacks for each resources and the driver needs to manually track which
> are already available. Whereas this is has the tracking implemented in a
> framework which is closer to what I meant by the core tracking option. In
> the end probe() is also just a callback.
>
> The question is just about what level of integration into the device driver
> core do we want.
>
> What restrack effectively does is split to split probe() into a top and a
> bottom half. The top half establishes the dependencies and the bottom half
> runs once all the dependencies are met. In this particular implementation th
> bottom half runs outside the scope of the device driver core. Which means
> the device driver core assumes that the device has successfully probed once
> the top half (the real probe() callback) finishes.
>
> Another place where ordering is important is suspend and resume. We want to
> avoid suspending a resource provider before the consumer. The default
> suspend/resume order that is established by the device driver core depends
> on the probe order of the devices. Suspend runs in the opposite oder, resume
> in the same. Together with EPROBE_DEFER this makes sure that a consumer is
> suspended before any providers it might depend on. Not waiting for the
> resources to become available before probe() succeeds will break this. So
> this is something that needs to be addressed by either by integrating pm
> support directly in restrack or extending the device driver core to natively
> support two stage probe with the device only being considered fully probed
> once the second stage has completed.
>

I guess integrating suspend/resume into restrack should be quite
straightforward.
Just another callback, or the same with some parameter, called before
entering suspend and after resuming of resource provider.

Regards
Andrzej

  reply	other threads:[~2016-08-02 11:45 UTC|newest]

Thread overview: 111+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-27 16:50 [Ksummit-discuss] [TECH TOPIC] Addressing complex dependencies and semantics (v2) Luis R. Rodriguez
2016-07-27 17:26 ` Mark Brown
2016-07-27 17:58   ` Luis R. Rodriguez
2016-07-27 18:03     ` Mark Brown
2016-07-27 19:20       ` Luis R. Rodriguez
2016-07-28  0:54         ` Rafael J. Wysocki
2016-07-28 10:41           ` Laurent Pinchart
2016-07-28 10:54             ` Hans Verkuil
2016-07-28 11:03               ` Laurent Pinchart
2016-07-28 11:46                 ` Jan Kara
2016-07-28 15:16                   ` Mark Brown
2016-07-28 16:00                   ` Laurent Pinchart
2016-08-02  8:32                     ` Jan Kara
2016-08-03 14:17                     ` Alexandre Belloni
2016-07-30  1:59                   ` Steven Rostedt
2016-08-01 13:12                     ` Laurent Pinchart
2016-07-28 20:12                 ` Lars-Peter Clausen
2016-07-28 20:38                   ` Mark Brown
2016-08-01 13:15                   ` Laurent Pinchart
2016-07-28 14:36               ` Rafael J. Wysocki
2016-07-29  7:33             ` Hans Verkuil
2016-08-01 13:03               ` Laurent Pinchart
2016-08-01 13:17                 ` Hans Verkuil
2016-08-04  8:22             ` Jani Nikula
2016-08-04  9:50               ` Greg KH
2016-08-04 10:20                 ` Mark Brown
2016-08-04 10:27                   ` Jani Nikula
2016-08-05  2:59                   ` Rob Herring
2016-08-05  9:01                     ` Arnd Bergmann
2016-08-05 10:54                       ` Greg KH
2016-08-05 11:31                         ` Andrzej Hajda
2016-08-05 11:58                           ` Mark Brown
2016-08-05 13:43                           ` Greg KH
2016-08-05 19:27                         ` Rob Herring
2016-08-09  8:08                 ` Daniel Vetter
2016-08-09  8:17                   ` Greg KH
2016-08-09 12:04                     ` Daniel Vetter
2016-08-04 12:37       ` Geert Uytterhoeven
2016-08-04 15:53         ` Mark Brown
2016-07-28 21:49     ` Lars-Peter Clausen
2016-07-29  3:50       ` Greg KH
2016-07-29  7:45       ` Hans Verkuil
2016-07-29  7:55         ` Lars-Peter Clausen
2016-08-01 13:06           ` Laurent Pinchart
2016-07-29 11:13         ` Mark Brown
2016-08-01 13:09           ` Laurent Pinchart
2016-08-01 13:14             ` Lars-Peter Clausen
2016-08-01 13:19               ` Laurent Pinchart
2016-08-01 13:21             ` Hans Verkuil
2016-08-01 13:26               ` Laurent Pinchart
2016-08-01 13:35                 ` Hans Verkuil
2016-08-01 13:38                   ` Laurent Pinchart
2016-08-01 13:51                     ` Hans Verkuil
2016-08-01 17:15                       ` Laurent Pinchart
2016-08-01 13:33               ` Lars-Peter Clausen
2016-08-01 13:55                 ` Mauro Carvalho Chehab
2016-08-01 14:41                   ` Lars-Peter Clausen
2016-08-01 14:44                   ` Andrzej Hajda
2016-08-01 14:54                     ` Lars-Peter Clausen
2016-08-01 15:20                       ` Mark Brown
2016-08-01 15:34                       ` Andrzej Hajda
2016-08-01 15:43                         ` Lars-Peter Clausen
2016-08-01 16:18                           ` Andrzej Hajda
2016-08-01 17:06                             ` Mark Brown
2016-08-01 18:21                               ` Lars-Peter Clausen
2016-08-02 11:45                                 ` Andrzej Hajda [this message]
2016-08-01 18:33                               ` Andrzej Hajda
2016-08-01 18:48                                 ` Mark Brown
2016-08-01 19:42                                   ` Andrzej Hajda
2016-08-01 20:05                                     ` Lars-Peter Clausen
2016-08-02  8:57                                       ` Takashi Iwai
2016-08-01 17:40                       ` Laurent Pinchart
2016-08-02  7:38                     ` Greg KH
2016-08-01 19:03           ` Luis R. Rodriguez
2016-08-02  0:01             ` Rafael J. Wysocki
2016-08-02  0:56               ` Luis R. Rodriguez
2016-08-02  1:03                 ` Dmitry Torokhov
2016-08-02  8:30                   ` Jiri Kosina
2016-08-02  9:41                 ` Hannes Reinecke
2016-08-02  9:48                   ` Jiri Kosina
2016-08-02 11:50                     ` Takashi Iwai
2016-08-09  9:57             ` Jörg Rödel
2016-08-09 16:08               ` James Bottomley
2016-08-09 16:11                 ` James Bottomley
2016-08-09 16:51                   ` Luis R. Rodriguez
2016-08-09 17:05                     ` David Woodhouse
2016-08-09 17:12                     ` James Bottomley
2016-08-09 16:53                   ` Jörg Rödel
2016-08-09 18:06               ` Luis R. Rodriguez
2016-08-10 15:21                 ` Jörg Rödel
2016-08-10 16:42                   ` Luis R. Rodriguez
2016-08-10 21:37                     ` Jörg Rödel
2016-08-12  7:33               ` Linus Walleij
2016-07-27 18:50 ` Dmitry Torokhov
2016-07-28 10:43 ` Marc Zyngier
2016-07-28 10:51 ` Laurent Pinchart
2016-07-28 23:43   ` Luis R. Rodriguez
2016-08-01 12:44     ` Laurent Pinchart
2016-07-28 11:18 ` Mauro Carvalho Chehab
2016-07-28 11:24   ` Laurent Pinchart
2016-07-28 12:25     ` Mauro Carvalho Chehab
2016-07-28 16:04       ` Laurent Pinchart
2016-07-29  0:00         ` Luis R. Rodriguez
2016-08-01 12:50           ` Laurent Pinchart
2016-08-01 20:32             ` Luis R. Rodriguez
2016-07-29 13:57 ` Andrzej Hajda
2016-09-07 16:40   ` Kevin Hilman
2016-08-01 14:03 ` Marek Szyprowski
2016-11-03 18:43   ` Laurent Pinchart
2016-11-04  6:53     ` Marek Szyprowski
2016-09-08 21:03 ` Frank Rowand

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=57A087C8.4040805@samsung.com \
    --to=a.hajda@samsung.com \
    --cc=broonie@kernel.org \
    --cc=ksummit-discuss@lists.linuxfoundation.org \
    --cc=lars@metafoo.de \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@osg.samsung.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=valentinrothberg@gmail.com \
    --cc=vegard.nossum@gmail.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 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.