Etnaviv DRM driver - oops when unloading

2015-05-27 Thread Alexander Holler
00
7fc0: 01c09d58 7e868e68  0081 0001 7e869078 0002e1a0 
01c09d58
7fe0: 76e94400 7e868e14 000186d0 76e9440c 600e0010 01c09d8c 3136315b 
203a5d39
[<7f05d4f0>] (etnaviv_buffer_init [etnaviv]) from [<0001>] (0x1)
Code: eb4c93a7 e28dd014 e8bd8030 e5903050 (e5932058)
---[ end trace e3e10844e84f28b4 ]---

I've tried it two times, both ended with the same oops. So it seems to 
be reproducible (here).

I haven't had a deeper look at the source, but after a quick look I 
assume a fix isn't that hard.

Regards,

Alexander Holler


Etnaviv DRM driver - oops when unloading

2015-05-28 Thread Alexander Holler
Am 27.05.2015 um 19:35 schrieb Russell King - ARM Linux:
> On Wed, May 27, 2015 at 02:45:48PM +0200, Alexander Holler wrote:
>> Hello,
>>
>> I've just build and booted the Etnaviv driver as module with Kernel 4.0.4.
>
> You may wish to try using my patch set(s) at (url purposely obfuscated,
> sorry):
>
> http : // www . home . arm . linux . org . uk / ~rmk / cubox
>
> which is where I publish my Cubox-i/hummingboard patches.  My advice
> would be to grab the latest tarball (even though its against 4.1-rc1),
> and apply the etnaviv patches from it, and the appropriate DT update
> patches.
>
> This has all Lucas' API updates incorporated, but also a lot of fixes
> and other improvements.

Thanks,

Alexander Holler



[PATCH 00/21] On-demand device registration

2015-06-03 Thread Alexander Holler
Am 02.06.2015 um 10:48 schrieb Linus Walleij:
> On Mon, May 25, 2015 at 4:53 PM, Tomeu Vizoso
>  wrote:
> 
>> have looked into ordered probing as a
>> better way of solving this than moving nodes around in the DT or playing with
>> initcall levels.
>>
>> While reading the thread [1] that Alexander Holler started with his series to
>> make probing order deterministic, it occurred to me that it should be 
>> possible
>> to achieve the same by registering devices as they are referenced by other
>> devices.
> 
> This is pretty cool, but a too local solution to a global problem.
> 
> Deferred probe and initcall reordering, silly as they may seem,
> does not require you to use device tree.
> 
> The real solution, which I think I pointed out already when we
> added deferred probe, is to put dependency graphs in the drivers
> and have the kernel device driver core percolate dependecies by
> walking the graph on probing driver, removing driver (usually the
> inverse use case), [runtime] suspend and [runtime] resumeing
> a driver. Possibly the dependencies will even be different
> depending on use case.
> 
> This is what systemd is doing in userspace for starting services:
> ask for your dependencies and wait for them if they are not
> there. So drivers ask for resources and wait for them. It also
> needs to be abstract, so for example we need to be able to
> hang on regulator_get() until the driver is up and providing that
> regulator, and as long as everything is in slowpath it should
> be OK. (And vice versa mutatis mutandis for clk, gpio, pin
> control, interrupts (!) and DMA channels for example.)
> 
> 
> So if this should be solved it should be solved in an abstract way
> in the device driver core available for all, then have calls calling
> out to DT, ACPI, possibly even PCI or USB (as these
> enumerate devices themselves) to obtain a certain
> dependency.

I suggest to start with making it possible to identify (at least most)
drivers. I've already posted a patch for that around a year ago and now
Tomeu did almost the same.

However one wants to make a deterministic order to load drivers, there
will be always the need to know which drivers one has to sort.

Regards,

Alexander Holler


[PATCH 00/21] On-demand device registration

2015-06-04 Thread Alexander Holler
Am 03.06.2015 um 21:57 schrieb Grygorii.Strashko at linaro.org:

...

> So few comments from above:
> - registering devices later during the System boot may improve boot time.
>   But resolving of all deferred probes may NOT improve boot time ;) 
>   Have you seen smth like this?

If someone is out for boot time reduction, I think one of the best ways
would by making driver initialization parallel. Keep in mind that all
linked in drivers currently are initialized in series.

As it seems to have been forgotten or overread, I've mentioned in my
series of patches last year that, with a few changes, it's possible to
let the algorithm I've used (dfs) to spit out all drivers which can be
initialized in parallel.

But as I'm not paid for the work I've done and just did it out of
curiosity, interest or how ever you want name it, I haven't spend any
more time into that topic, especially as I'm missing the necessary
connections to get patches into the kernel. ;)

But, as said, it's easy (at least if aren't getting panic when it comes
to a bit of algorithm theory) to get a list drivers you can start in
parallel if you have such a complete list of dependencies as DT already
offers. Just look at the pictures generate by dtc (using my patches),
you will see, they already show which drivers can be initialized in
parallel.

So it would be easy to use e.g. all cores already very early at boot to
initialize drivers, not just after init got started. Besides that the
würgaround of defered init (which, btw. leads devs to supress error
messages, which is especially bad if you are searching a problem) isn't
needed anymore if you have a list of dependecies (however you get it,
I've used DT because the dependencies already are all there).

Regards,

Alexander Holler


[PATCH 00/21] On-demand device registration

2015-06-04 Thread Alexander Holler
Am 03.06.2015 um 23:12 schrieb Rob Clark:
> On Mon, May 25, 2015 at 10:53 AM, Tomeu Vizoso
>  wrote:
>> Hello,
>>
>> I have a problem with the panel on my Tegra Chromebook taking longer than
>> expected to be ready during boot (Stéphane Marchesin reported what is
>> basically the same issue in [0]), and have looked into ordered probing as a
>> better way of solving this than moving nodes around in the DT or playing with
>> initcall levels.
>>
>> While reading the thread [1] that Alexander Holler started with his series to
>> make probing order deterministic, it occurred to me that it should be 
>> possible
>> to achieve the same by registering devices as they are referenced by other
>> devices.
>>
>> This basically reuses the information that is already implicit in the probe()
>> implementations, saving us from refactoring existing drivers or adding
>> information to DTBs.
>>
>> Something I'm not completely happy with is that I have had to move the call 
>> to
>> of_platform_populate after all platform drivers have been registered.
>> Otherwise I don't see how I could register drivers on demand as we don't have
>> yet each driver's compatible strings.
>>
>> For machs that don't move of_platform_populate() to a later point, these
>> patches shouldn't cause any problems but it's not guaranteed that we'll avoid
>> all the deferred probes as some drivers may not be registered yet.
>>
>> I have tested this on boards with Tegra, iMX.6 and Exynos SoCs, and these
>> patches were enough to eliminate all the deferred probes.
>>
>> With this series I get the kernel to output to the panel in 0.5s, instead of 
>> 2.8s.
> 
> So, complete drive-by comment (and I won't claim to be a DT expert,
> etc, etc, so take this with a few grains of salt), but why not push
> the problem to the DT compiler (or a pre-process step that could be
> run on existing DT blobs), which generates an optional DT node that is
> the recommended probe order?  That seems like it avoids adding
> complexity into the early boot code (which seems like a good thing)..

I've played with that approach too (as my patches for dtc do contain the
same code I've put into the kernel, but decided that it doesn't make
much sense. The sort algorithm is really small (some dozen lines), very
fast (around 3-5ms on a omap) and might be later used to sort necessary
module loading too. So there would be no advantage to put a sorted list
into the DT. And having the sort algorithm in the kernel, would make it
possible to use it for acpi or something else too, if they manage it to
provide the necessary dependencies.

Regards,

Alexander Holler



[PATCH 00/21] On-demand device registration

2015-06-08 Thread Alexander Holler
Am 08.06.2015 um 14:26 schrieb Enrico Weigelt, metux IT consult:
> Am 04.06.2015 um 22:39 schrieb Alexander Holler:
>
>  > As it seems to have been forgotten or overread, I've mentioned in my
>> series of patches last year that, with a few changes, it's possible to
>> let the algorithm I've used (dfs) to spit out all drivers which can be
>> initialized in parallel.
>
> Unfortunately, I've missed that ... could you please resend you patches?
> Boot time reduction is one of the topics on my 2do in several weeks.

https://lkml.org/lkml/2014/5/12/452



[PATCH 00/21] On-demand device registration

2015-06-08 Thread Alexander Holler
Am 08.06.2015 um 20:14 schrieb Alexander Holler:
> Am 08.06.2015 um 14:26 schrieb Enrico Weigelt, metux IT consult:
>> Am 04.06.2015 um 22:39 schrieb Alexander Holler:
>>
>>  > As it seems to have been forgotten or overread, I've mentioned in my
>>> series of patches last year that, with a few changes, it's possible to
>>> let the algorithm I've used (dfs) to spit out all drivers which can be
>>> initialized in parallel.
>>
>> Unfortunately, I've missed that ... could you please resend you patches?
>> Boot time reduction is one of the topics on my 2do in several weeks.
>
> https://lkml.org/lkml/2014/5/12/452
>

And don't forget patch 10/9 which fixed a bug in my previous patch 
series and which alos was the reason for the large difference in boot 
times with and without deps:

https://lkml.org/lkml/2014/5/13/567


[PATCH 00/21] On-demand device registration

2015-06-10 Thread Alexander Holler
Am 10.06.2015 um 09:30 schrieb Linus Walleij:
> On Tue, Jun 2, 2015 at 12:14 PM, Tomeu Vizoso
>  wrote:
>> On 2 June 2015 at 10:48, Linus Walleij  wrote:
>
>>> This is what systemd is doing in userspace for starting services:
>>> ask for your dependencies and wait for them if they are not
>>> there. So drivers ask for resources and wait for them. It also
>>> needs to be abstract, so for example we need to be able to
>>> hang on regulator_get() until the driver is up and providing that
>>> regulator, and as long as everything is in slowpath it should
>>> be OK. (And vice versa mutatis mutandis for clk, gpio, pin
>>> control, interrupts (!) and DMA channels for example.)
>>
>> I understood above that you propose probing devices in order, but now
>> you mention that resource getters would block until the dependency is
>> fulfilled which confuses me because if we are probing in order then
>> all dependencies would be fulfilled before the device in question gets
>> probed.
>
> Sorry, the problem space is a bit convoluted so the answers
> get a bit convoluted. Maybe I'm thinking aloud and altering the course
> of my thoughts as I type...
>
> I guess there can be explicit dependencies for resources like this
> patch does, but another way would be for all resource fetch functions
> to be instrumented, so that you do not block until you try to take
> a resource that is not yet there, e.g.:
>
> regulator_get(...) -> not available, so:
> - identify target regulator provider - this will need instrumentation
> - probe it
>
> It then turns out the regulator driver is on the i2c bus, so we
> need to probe the i2c driver:
> - identify target i2c host for the regulator driver - this will need
>instrumentation
> - probe the i2c host driver
>
> i2c host comes out, probes the regulator driver, regulator driver
> probes and then the regulator_get() call returns.
>
> This requires instrumentation on anything providing a resource
> to another driver like those I mentioned and a lot of overhead
> infrastructure, but I think it's the right approach. However I don't
> know if I would ever be able to pull that off myself, I know talk
> is cheap and I should show the code instead.

You would end up with the same problem of deadlocks as currently, and 
you would still need something ugly like the defered probe brutforce to 
avoid them. So what would you win with that instrumentation?

Alexander Holler


[PATCH 00/21] On-demand device registration

2015-06-10 Thread Alexander Holler
Am 10.06.2015 um 14:23 schrieb Andrzej Hajda:
> On 06/10/2015 12:19 PM, Tomeu Vizoso wrote:
>> On 10 June 2015 at 09:30, Linus Walleij  wrote:
>>> On Tue, Jun 2, 2015 at 12:14 PM, Tomeu Vizoso
>>>  wrote:
>>>> On 2 June 2015 at 10:48, Linus Walleij  wrote:
>>>
>>>>> This is what systemd is doing in userspace for starting services:
>>>>> ask for your dependencies and wait for them if they are not
>>>>> there. So drivers ask for resources and wait for them. It also
>>>>> needs to be abstract, so for example we need to be able to
>>>>> hang on regulator_get() until the driver is up and providing that
>>>>> regulator, and as long as everything is in slowpath it should
>>>>> be OK. (And vice versa mutatis mutandis for clk, gpio, pin
>>>>> control, interrupts (!) and DMA channels for example.)
>>>>
>>>> I understood above that you propose probing devices in order, but now
>>>> you mention that resource getters would block until the dependency is
>>>> fulfilled which confuses me because if we are probing in order then
>>>> all dependencies would be fulfilled before the device in question gets
>>>> probed.
>>>
>>> Sorry, the problem space is a bit convoluted so the answers
>>> get a bit convoluted. Maybe I'm thinking aloud and altering the course
>>> of my thoughts as I type...
>>>
>>> I guess there can be explicit dependencies for resources like this
>>> patch does, but another way would be for all resource fetch functions
>>> to be instrumented, so that you do not block until you try to take
>>> a resource that is not yet there, e.g.:
>>>
>>> regulator_get(...) -> not available, so:
>>> - identify target regulator provider - this will need instrumentation
>>> - probe it
>>>
>>> It then turns out the regulator driver is on the i2c bus, so we
>>> need to probe the i2c driver:
>>> - identify target i2c host for the regulator driver - this will need
>>>   instrumentation
>>> - probe the i2c host driver
>>>
>>> i2c host comes out, probes the regulator driver, regulator driver
>>> probes and then the regulator_get() call returns.
>>
>> Hmm, if I understand correctly what you say, this is exactly what this
>> particular series does:
>>
>> regulator_get -> of_platform_device_ensure -> probe() on the platform
>> device that encloses the requested device node (i2c host) -> i2c slave
>> gets probed and the regulator registered -> regulator_get returns the
>> requested resource
> 
> The downside of this solution is that it will not work without device
> tree or even without device dependencies not explicitly specified in
> device tree.

Solution for what? The goal isn't to search another fancy
registration/initialization algorithm.

So I wonder which problem that would solve at all. It doesn't give you
some deterministic initialization order nor does it (re)solve
dependencies (besides directly from one driver to another, but that
isn't enough), nor does it solve the problem of identifying drivers (the
other end of such an instrumented on-demand-initialization-call). So all
it would be is some fancy on-demand initialization without having solved
any problem.

Sorry if that sounds hard. Maybe I miss something. But I don't see  any
currently existing problem the above described solution would solve,
besides beeing something different (which shouldn't be the goal).

Alexander Holler


[PATCH 00/21] On-demand device registration

2015-06-11 Thread Alexander Holler
Am 11.06.2015 um 10:12 schrieb Linus Walleij:
> On Wed, Jun 10, 2015 at 10:28 AM, Alexander Holler  
> wrote:
>> Am 10.06.2015 um 09:30 schrieb Linus Walleij:
>
>>> i2c host comes out, probes the regulator driver, regulator driver
>>> probes and then the regulator_get() call returns.
>>>
>>> This requires instrumentation on anything providing a resource
>>> to another driver like those I mentioned and a lot of overhead
>>> infrastructure, but I think it's the right approach. However I don't
>>> know if I would ever be able to pull that off myself, I know talk
>>> is cheap and I should show the code instead.
>>
>> You would end up with the same problem of deadlocks as currently, and you
>> would still need something ugly like the defered probe brutforce to avoid
>> them.
>
> Sorry I don't get that. Care to elaborate on why?

Because loading/initializing on demand doesn't give you any solved order 
of drivers to initialize. And it can't because it has no idea about the 
requirements of other drivers. The reason why it might work better in 
the case of the tegra is that it might give you another initialization 
order than the one which is currently choosen, which, by luck, might be 
a better one.

But maybe I missed something, I haven't looked at the patches at all. 
But just loading on demand, can't magically give you a working order of 
drivers to initialize. E.g. how do you choose the first driver to 
initialize?

Regards,

Alexander Holler


[PATCH 00/21] On-demand device registration

2015-06-11 Thread Alexander Holler
Am 11.06.2015 um 12:17 schrieb Alexander Holler:
> Am 11.06.2015 um 10:12 schrieb Linus Walleij:
>> On Wed, Jun 10, 2015 at 10:28 AM, Alexander Holler
>>  wrote:
>>> Am 10.06.2015 um 09:30 schrieb Linus Walleij:
>>
>>>> i2c host comes out, probes the regulator driver, regulator driver
>>>> probes and then the regulator_get() call returns.
>>>>
>>>> This requires instrumentation on anything providing a resource
>>>> to another driver like those I mentioned and a lot of overhead
>>>> infrastructure, but I think it's the right approach. However I don't
>>>> know if I would ever be able to pull that off myself, I know talk
>>>> is cheap and I should show the code instead.
>>>
>>> You would end up with the same problem of deadlocks as currently, and
>>> you
>>> would still need something ugly like the defered probe brutforce to
>>> avoid
>>> them.
>>
>> Sorry I don't get that. Care to elaborate on why?
>
> Because loading/initializing on demand doesn't give you any solved order
> of drivers to initialize. And it can't because it has no idea about the
> requirements of other drivers. The reason why it might work better in
> the case of the tegra is that it might give you another initialization
> order than the one which is currently choosen, which, by luck, might be
> a better one.
>
> But maybe I missed something, I haven't looked at the patches at all.
> But just loading on demand, can't magically give you a working order of
> drivers to initialize. E.g. how do you choose the first driver to
> initialize?

Other problems you will run into are time constraints and multithreaded 
drivers.

E.g. we all should know how tricky it sometimes is to avoid deadlocks. 
And with loading on demand, you are extending this problem over the 
initialization of maybe a whole bunch of other drivers which might be 
started by calling one function of another driver. And a function call 
might need a very long time to finish during which an unpredictable 
amount of things may happen.

It would make me wonder if that will end up with a good, usable and as 
simple as possible solution.

Regards,

Alexander Holler


[PATCH 00/21] On-demand device registration

2015-06-11 Thread Alexander Holler
Am 11.06.2015 um 13:24 schrieb Alexander Holler:
> Am 11.06.2015 um 12:17 schrieb Alexander Holler:
>> Am 11.06.2015 um 10:12 schrieb Linus Walleij:
>>> On Wed, Jun 10, 2015 at 10:28 AM, Alexander Holler
>>>  wrote:
>>>> Am 10.06.2015 um 09:30 schrieb Linus Walleij:
>>>
>>>>> i2c host comes out, probes the regulator driver, regulator driver
>>>>> probes and then the regulator_get() call returns.
>>>>>
>>>>> This requires instrumentation on anything providing a resource
>>>>> to another driver like those I mentioned and a lot of overhead
>>>>> infrastructure, but I think it's the right approach. However I don't
>>>>> know if I would ever be able to pull that off myself, I know talk
>>>>> is cheap and I should show the code instead.
>>>>
>>>> You would end up with the same problem of deadlocks as currently, and
>>>> you
>>>> would still need something ugly like the defered probe brutforce to
>>>> avoid
>>>> them.
>>>
>>> Sorry I don't get that. Care to elaborate on why?
>>
>> Because loading/initializing on demand doesn't give you any solved order
>> of drivers to initialize. And it can't because it has no idea about the
>> requirements of other drivers. The reason why it might work better in
>> the case of the tegra is that it might give you another initialization
>> order than the one which is currently choosen, which, by luck, might be
>> a better one.
>>
>> But maybe I missed something, I haven't looked at the patches at all.
>> But just loading on demand, can't magically give you a working order of
>> drivers to initialize. E.g. how do you choose the first driver to
>> initialize?
> 
> Other problems you will run into are time constraints and multithreaded
> drivers.
> 
> E.g. we all should know how tricky it sometimes is to avoid deadlocks.
> And with loading on demand, you are extending this problem over the
> initialization of maybe a whole bunch of other drivers which might be
> started by calling one function of another driver. And a function call
> might need a very long time to finish during which an unpredictable
> amount of things may happen.
> 
> It would make me wonder if that will end up with a good, usable and as
> simple as possible solution.

Besides that instrumenting every call to another driver in order to fix
a onetime operation (the initialization) sounds like an enormous
overhead. Initialization is done pnly once, regardless how long a system
runs, but the instrumentation to fix this onetime operation would slow
down the operation during the whole runtime of a system.

I don't think this is what should be done.

> 
> Regards,
> 
> Alexander Holler



[PATCH 00/21] On-demand device registration

2015-06-11 Thread Alexander Holler
Am 11.06.2015 um 14:30 schrieb Linus Walleij:
> On Thu, Jun 11, 2015 at 12:17 PM, Alexander Holler  
> wrote:
>> Am 11.06.2015 um 10:12 schrieb Linus Walleij:
>>> On Wed, Jun 10, 2015 at 10:28 AM, Alexander Holler 
>>> wrote:
>
>>>> You would end up with the same problem of deadlocks as currently, and you
>>>> would still need something ugly like the defered probe brutforce to avoid
>>>> them.
>>>
>>>
>>> Sorry I don't get that. Care to elaborate on why?
>>
>>
>> Because loading/initializing on demand doesn't give you any solved order of
>> drivers to initialize. And it can't because it has no idea about the
>> requirements of other drivers. The reason why it might work better in the
>> case of the tegra is that it might give you another initialization order
>> than the one which is currently choosen, which, by luck, might be a better
>> one.
>>
>> But maybe I missed something, I haven't looked at the patches at all. But
>> just loading on demand, can't magically give you a working order of drivers
>> to initialize. E.g. how do you choose the first driver to initialize?
>
> So the current patch set introduces dependencies (just for device tree)
> and Tomeu is working on a more generic dependency approach for
> any HW description.
>
> The first driver to initialize will be as usual the first one in the list for
> that initlevel, then walking up the initilevels.
>
> However if any driver runs into a resource roadblock it will postpone
> and wait for dependencies to probe first.
>
> Certainly it is possible to create deadlocks in this scenario, but the
> scope is not to create an ubreakable system.

IAnd what happens if you run into a deadlock? Do you print "you've lost, 
try changing your kernel config" in some output hidden by a 
splash-screen? ;)

That sounds like the fun with duck typed languages where you have to 
test any and every possible screnario (something which is almost 
impossible) in order to not run into something unexpected.

Anyway, have fun, good luck.

Alexander Holler


[PATCH 00/21] On-demand device registration

2015-06-12 Thread Alexander Holler
Am 12.06.2015 um 09:25 schrieb Linus Walleij:
> On Thu, Jun 11, 2015 at 6:40 PM, Alexander Holler  
> wrote:
>> Am 11.06.2015 um 14:30 schrieb Linus Walleij:
>
>>> Certainly it is possible to create deadlocks in this scenario, but the
>>> scope is not to create an ubreakable system.
>>
>> IAnd what happens if you run into a deadlock? Do you print "you've lost, try
>> changing your kernel config" in some output hidden by a splash-screen? ;)
>
> Sorry it sounds like a blanket argument, the fact that there are
> mutexes in the kernel makes it possible to deadlock, it doesn't
> mean we don't use mutexes. Some programming problems are
> just like such.

I'm not talking about specific deadlocks through mutexes. I'm talking 
about what happens when driver A needs driver B which needs driver A. 
How do you recognise and handle that with your instrumented on-demand 
device initialization? Such a circular dependency might happen by just 
adding a new fucntion call or by changing the kernel configuration. And 
with the on-demand stuff, the possibility that the developer introducing 
this new (maybe optional) call will never hit such a circular dependency 
is high. So you will end up with a never ending stream of problem 
reports whenever someone introduced such a circular dependecy without 
having noticed it.

And to come back to specific deadlocks, if you are extending function 
calls from something former simple to something which might initialize a 
whole bunch of drivers, needing maybe seconds, I wouldn't say this is a 
blanket argument, but a real thread.

Alexander Holler


[PATCH 00/21] On-demand device registration

2015-06-12 Thread Alexander Holler
Am 12.06.2015 um 13:19 schrieb Alexander Holler:
> Am 12.06.2015 um 09:25 schrieb Linus Walleij:
>> On Thu, Jun 11, 2015 at 6:40 PM, Alexander Holler
>>  wrote:
>>> Am 11.06.2015 um 14:30 schrieb Linus Walleij:
>>
>>>> Certainly it is possible to create deadlocks in this scenario, but the
>>>> scope is not to create an ubreakable system.
>>>
>>> IAnd what happens if you run into a deadlock? Do you print "you've
>>> lost, try
>>> changing your kernel config" in some output hidden by a
>>> splash-screen? ;)
>>
>> Sorry it sounds like a blanket argument, the fact that there are
>> mutexes in the kernel makes it possible to deadlock, it doesn't
>> mean we don't use mutexes. Some programming problems are
>> just like such.
>
> I'm not talking about specific deadlocks through mutexes. I'm talking
> about what happens when driver A needs driver B which needs driver A.
> How do you recognise and handle that with your instrumented on-demand
> device initialization? Such a circular dependency might happen by just
> adding a new fucntion call or by changing the kernel configuration. And
> with the on-demand stuff, the possibility that the developer introducing
> this new (maybe optional) call will never hit such a circular dependency
> is high. So you will end up with a never ending stream of problem
> reports whenever someone introduced such a circular dependecy without
> having noticed it.
>
> And to come back to specific deadlocks, if you are extending function
> calls from something former simple to something which might initialize a
> whole bunch of drivers, needing maybe seconds, I wouldn't say this is a
> blanket argument, but a real thread.

Keep in mind, that the possibility that a function call ends up with 
initializing a whole bunch of other drivers, is not determined 
statically, but depends on the configuration and runtime behaviour of 
the actual system the on-demand stuff actually happens.

E.g. if driver A is faster one system that driver B, the whole bunch of 
drivers might become initialized by a call in driver A. But if driver B 
was faster on the developers system (or the system is configured to 
first init driver B), than the whole bunch of drivers might have become 
initialized by driver B on the developers system. Thus he never might 
have hit a possible problem when the whole bunch of drivers got 
initialized in driver A.

That means it isn't always a good idea to create dynamic systems (like 
on-demand device initialization), because it's very hard to foresee and 
correctly handle their runtime behaviour.

> Alexander Holler


[PATCH 00/21] On-demand device registration

2015-06-13 Thread Alexander Holler
Am 12.06.2015 um 13:36 schrieb Alexander Holler:
> Am 12.06.2015 um 13:19 schrieb Alexander Holler:
>> Am 12.06.2015 um 09:25 schrieb Linus Walleij:
>>> On Thu, Jun 11, 2015 at 6:40 PM, Alexander Holler
>>>  wrote:
>>>> Am 11.06.2015 um 14:30 schrieb Linus Walleij:
>>>
>>>>> Certainly it is possible to create deadlocks in this scenario, but the
>>>>> scope is not to create an ubreakable system.
>>>>
>>>> IAnd what happens if you run into a deadlock? Do you print "you've
>>>> lost, try
>>>> changing your kernel config" in some output hidden by a
>>>> splash-screen? ;)
>>>
>>> Sorry it sounds like a blanket argument, the fact that there are
>>> mutexes in the kernel makes it possible to deadlock, it doesn't
>>> mean we don't use mutexes. Some programming problems are
>>> just like such.
>>
>> I'm not talking about specific deadlocks through mutexes. I'm talking
>> about what happens when driver A needs driver B which needs driver A.
>> How do you recognise and handle that with your instrumented on-demand
>> device initialization? Such a circular dependency might happen by just
>> adding a new fucntion call or by changing the kernel configuration. And
>> with the on-demand stuff, the possibility that the developer introducing
>> this new (maybe optional) call will never hit such a circular dependency
>> is high. So you will end up with a never ending stream of problem
>> reports whenever someone introduced such a circular dependecy without
>> having noticed it.
>>
>> And to come back to specific deadlocks, if you are extending function
>> calls from something former simple to something which might initialize a
>> whole bunch of drivers, needing maybe seconds, I wouldn't say this is a
>> blanket argument, but a real thread.
>
> Keep in mind, that the possibility that a function call ends up with
> initializing a whole bunch of other drivers, is not determined
> statically, but depends on the configuration and runtime behaviour of
> the actual system the on-demand stuff actually happens.
>
> E.g. if driver A is faster one system that driver B, the whole bunch of
> drivers might become initialized by a call in driver A. But if driver B
> was faster on the developers system (or the system is configured to
> first init driver B), than the whole bunch of drivers might have become
> initialized by driver B on the developers system. Thus he never might
> have hit a possible problem when the whole bunch of drivers got
> initialized in driver A.
>
> That means it isn't always a good idea to create dynamic systems (like
> on-demand device initialization), because it's very hard to foresee and
> correctly handle their runtime behaviour.

And because you've said that "problem space is a bit convoluted" and I 
disagree, here's a summary from my point of view:

1. All the necessary information (dependencies between drivers) already 
exists at compile time. The set of dependencies between drivers might 
become smaller by configuration, but will not become larger. So there 
should be NO need to collect them at runtime, e.g. by instrumenting 
function calls. I've described the problems I see with that above. I've 
choosen DT as source of dependencies because it offers an easy 
accessible and almost complete set of dependencies. I just had to add 
some type information to the dtb in order to identify the dependencies 
(phandles). But other ways to collect the dependencies would work too. 
Even the most simple way to add a static list of dependencies to each 
driver (which later on might be automated by some more clever stuff than 
adding them manually) would do the trick.

2. The problem to sort a set of nodes (drivers) with dependencies is 
solved since a long time and almost any developers uses it regularly in 
form of make. And everyone who used make -jN knows that the possible 
parallel initialization of drivers I've talked about, is already solved too.

3. In order to initialize the drivers in some specific order, their 
initcalls must be identified. I've offered a possible solution to that 
without much changes, but many other, even better ways, are possible 
too. It just depends on how much you want to change and on how much of 
these changes you will be able to feed into mainline kernel (which 
depends on your connections/relations inside the core kernel crew). E.g. 
instead of still just relying on one-dimensional arrays with (anonymous) 
pointers to initcalls, a multidimensional array of initcalls and 
drivername (and maybe more information) might be thinkable.

4. x86/amd64/ACPI-people, so most longtime and core kernel maintainers 
obviously don't have much interest until you've solved 1. in a way they 
can use too. So the necessary changes for 2. or 3. will have a big 
hurdle to take if 1. isn't solved usable for them too.

>> Alexander Holler



[PATCH 00/21] On-demand device registration

2015-06-15 Thread Alexander Holler
Am 15.06.2015 um 10:58 schrieb Linus Walleij:
> On Sat, Jun 13, 2015 at 8:27 PM, Alexander Holler  
> wrote:
>
>> And because you've said that "problem space is a bit convoluted" and I
>> disagree, here's a summary from my point of view:
>>
>> 1. All the necessary information (dependencies between drivers) already
>> exists at compile time. The set of dependencies between drivers might become
>> smaller by configuration, but will not become larger. So there should be NO
>> need to collect them at runtime, e.g. by instrumenting function calls.
>
> I think you arrived at the core of the crux here.

I've hoped so, that's why I've written it.

> I guess your suggested approach then need to introduce a special
> build tool to order the initcalls accordingly.
>
> Again this will fall short if you don't know at compile time exactly
> *which* board file will be executed.

I've just tried to describe the facts in order to make the problem space 
more clear, because, as said, I don't think it's convoluted.

Besides that, I didn't want to suggest anything else other than what 
I've already posted working patches for. What I've mentioned as possible 
other solutions above is stuff which might be possible too in order to 
give some starting points for people which are searching another 
solution. But I wouldn't have written my patches as they are, if I would 
think there is another more easier solution.

And of course, there is still a bit to resolve at runtime, even in the 
DT case (look at the "compatible" attribute). But there is already a 
runtime solution to find the right driver (in case of DT) and I haven't 
mentioned it in order to no confuse people again. Mentioning every 
little detail doesn't make sense if you want to describe something 
understandable (which is what I've tried).

> So the only practical way to solve this at compile time is to predict
> an initcall ordering sequence for all possible boot paths, compile in
> all of them, and choose the right one at boot. But the number of boot
> paths is equal to the number of device trees / ACPI tables or
> board files supported, and that space is uncontrolled and ordered
> infinite.

You just need one working ordered sequence which includes all options. 
This one will work for all others too.

> Basically I think the root problem with your approach is that you
> assume we know what hardware we will boot on at compile time. We

Totally wrong. If you assume that I assume this, than either I was 
totally unable to describe something clearly, or you were unable or 
unwilling to understand what I've written. And as the result is the 
same, we don't need to find out which was reason.

Anyway, have fun. I'm quitting the discussion here as I don't have any 
business with the kernel and already decided some time again to not post 
patches anymore as it seems to be a waste of my (and maybe others) time.

Regards,

Alexander Holler