* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-04 17:18 ` Olof Johansson
@ 2014-05-04 17:27 ` Guenter Roeck
2014-05-04 22:02 ` Rafael J. Wysocki
2014-05-05 2:52 ` Pantelis Antoniou
2014-05-04 21:33 ` Rafael J. Wysocki
` (2 subsequent siblings)
3 siblings, 2 replies; 90+ messages in thread
From: Guenter Roeck @ 2014-05-04 17:27 UTC (permalink / raw)
To: Olof Johansson, Catalin Marinas
Cc: dvhart, ksummit-discuss, Georgi Vlaev, Greg Kroah-Hartman,
Rafael J. Wysocki, Pantelis Antoniou
On 05/04/2014 10:18 AM, Olof Johansson wrote:
> Hi,
>
> [BTW, I forgot to mention that BenH of course would be one person we need
> involved in all this. Adding him to the cc list here, but I know he's seen the
> thread already :)]
>
> On Sun, May 04, 2014 at 12:14:36PM +0100, Catalin Marinas wrote:
>> On Sat, May 03, 2014 at 04:14:51PM +0100, Arnd Bergmann wrote:
>>> On Saturday 03 May 2014 02:05:21 Rafael J. Wysocki wrote:
>>>> On Friday, May 02, 2014 02:42:07 PM Olof Johansson wrote:
>>>>> * Converting either of them to use platform device model
>>>>> (platform_data) to register drivers, and leave them unaware of either
>>>>> hardware description
>>>>> * [... I'm likely missing something here as well]
>>>
>>> Olof, funny you missed the proposal you made yourself:
>>>
>>> * convert ACPI data into DT format at boot time
>>
>> I thought this was discussed at length and agreed it's not a way
>> forward, given the differences between ACPI and DT, especially on the
>> AML feature which DT does not have (making one-off boot-time conversion
>> not feasible).
>
> I'm explicitly choosing to not discuss the ARM64 situation here myself,
> I am more interested in solving the issues around Intel's forage into
> embedded.
>
> ACPI on ARM64/SBSA is in many ways a different problem, and one that
> I don't know what there is to talk about, to be honest. Mostly because
> we're still talking hypotheticals and not-yet-published docs, and all
> vendors are still under deep NDA on product plans and what they're
> planning on doing. It means we're playing games of telephone right now
> and it's better to just wait until we have something concrete to center
> the discussions around.
>
> Intel, on the other hand, are already shipping this hardware, and have
> a platforms to do the work on (Minnowboard and Galieo, for example).
>
> So, to address Arnd's original question:
>
> Yes, it could make more sense to translate the data to a common
> format and use the existing accessors for that data format, instead
> of reinventing the accessors and still needing to represent the data
> some way. I think it depends on how some of the other things develop --
> I don't know enough about what Darren's current approach is, for example,
> to tell if it would be easier to do it that way.
>
> Also, even if we do a common API with different backends, there will
> need to be some knowledge somewhere about custom bindings and what they mean,
> how to translate them and how the different descriptions correlate.
> I personally think we're best off putting that in the drivers, instead of
> making some part of the driver core aware of a bunch of quirks/hooks for
> various devices.
>
>>>> For what it's worth, we are working on extending ACPI to allow DT-style
>>>> information to be included into ACPI tables.
>>>
>>> I think it's important to understand that we have people coming from
>>> two sides here: Intel x86 embedded systems with ACPI wanting to the
>>> same things we do on embbeded PowerPC and ARM systems with DT, and ARM64
>>> servers trying to do the same things that x86 servers do by moving
>>> to ACPI.
>>>
>>> These two have very different requirements and while there is some
>>> overlap, I suspect we will end up with different solutions as well.
>>
>> I think the middle ground is that for x86 to get into embedded and ARM64
>> into servers, the ACPI spec is not enough as hardware description.
>> Traditionally, the x86 hardware is rather standard and ACPI didn't need
>> to describe so many things. On ARM, OTOH, we have lots of variation and
>> DT provides such flexibility. Even if ARM is pushing for more standard
>> server hardware like SBSA, it's still relaxed enough not to look like a
>> PC platform. So even if the aims are different, the x86 efforts on more
>> hw description in ACPI help both Intel and ARM. Given the collaboration
>> between the two on ACPI forums already, I think there are good chances
>> of ending up with a common solution for Linux. Of course, x86 may decide
>> to go the DT route all the way (and ARM in the other direction ;)).
>
> I think it's very optimistic to assume that there will ever be a common
> solution for both ends of the spectrum (embedded - enterprise), but we
> should make sure we can stay sane and not have more solutions than we need
> in parallel, and that things will work together where there is overlap.
>
We (Juniper) are moving towards a partial conversion from ACPI to DT, pretty
much just enough to let us work with DT overlays on X86. If there is interest
to discuss this, it might make sense to invite Pantelis Antoniou and possibly
Georgi Vlaev, since both are instrumental to making it work.
Guenter
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-04 17:27 ` Guenter Roeck
@ 2014-05-04 22:02 ` Rafael J. Wysocki
2014-05-05 2:44 ` Pantelis Antoniou
2014-05-05 2:52 ` Pantelis Antoniou
1 sibling, 1 reply; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-04 22:02 UTC (permalink / raw)
To: ksummit-discuss
Cc: dvhart, Georgi Vlaev, Rafael J. Wysocki, Pantelis Antoniou,
Greg Kroah-Hartman
Hi,
On Sunday, May 04, 2014 10:27:59 AM Guenter Roeck wrote:
> On 05/04/2014 10:18 AM, Olof Johansson wrote:
[cut]
> > I think it's very optimistic to assume that there will ever be a common
> > solution for both ends of the spectrum (embedded - enterprise), but we
> > should make sure we can stay sane and not have more solutions than we need
> > in parallel, and that things will work together where there is overlap.
> >
> We (Juniper) are moving towards a partial conversion from ACPI to DT, pretty
> much just enough to let us work with DT overlays on X86. If there is interest
> to discuss this, it might make sense to invite Pantelis Antoniou and possibly
> Georgi Vlaev, since both are instrumental to making it work.
I actually wonder how you are going to handle things like references from
a DT overlay to ACPI device objects in the namespace (like various things
controllers etc).
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-04 22:02 ` Rafael J. Wysocki
@ 2014-05-05 2:44 ` Pantelis Antoniou
2014-05-05 11:22 ` Rafael J. Wysocki
0 siblings, 1 reply; 90+ messages in thread
From: Pantelis Antoniou @ 2014-05-05 2:44 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: dvhart, ksummit-discuss, Georgi Vlaev, Rafael J. Wysocki,
Greg Kroah-Hartman
Hi Rafael,
On May 4, 2014, at 3:02 PM, Rafael J. Wysocki wrote:
> Hi,
>
> On Sunday, May 04, 2014 10:27:59 AM Guenter Roeck wrote:
>> On 05/04/2014 10:18 AM, Olof Johansson wrote:
>
> [cut]
>
>>> I think it's very optimistic to assume that there will ever be a common
>>> solution for both ends of the spectrum (embedded - enterprise), but we
>>> should make sure we can stay sane and not have more solutions than we need
>>> in parallel, and that things will work together where there is overlap.
>>>
>> We (Juniper) are moving towards a partial conversion from ACPI to DT, pretty
>> much just enough to let us work with DT overlays on X86. If there is interest
>> to discuss this, it might make sense to invite Pantelis Antoniou and possibly
>> Georgi Vlaev, since both are instrumental to making it work.
>
> I actually wonder how you are going to handle things like references from
> a DT overlay to ACPI device objects in the namespace (like various things
> controllers etc).
>
At the moment we got dynamic PCI DT node creation; i.e. the PCI bus(es) is probed
and the platform's pci bios creates DT nodes; PCI nodes that already defined do not
get created from scratch, rather DT properties are appended to them.
It is not a whole-sale conversion (yet), but it seems to work find as a target for
DT overlays.
All this is on vanilla x86-64 btw, with very small fixes to get booted using an DT blob.
So far we didn't have to deal with ACPI device objects; perhaps it will be required
for when we tackle pure platform devices. But TBH it doesn't seem that difficult.
> Thanks!
>
> --
> I speak only for myself.
> Rafael J. Wysocki, Intel Open Source Technology Center.
Regards
-- Pantelis
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 2:44 ` Pantelis Antoniou
@ 2014-05-05 11:22 ` Rafael J. Wysocki
0 siblings, 0 replies; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-05 11:22 UTC (permalink / raw)
To: Pantelis Antoniou
Cc: dvhart, ksummit-discuss, Georgi Vlaev, Rafael J. Wysocki,
Greg Kroah-Hartman
On Sunday, May 04, 2014 07:44:27 PM Pantelis Antoniou wrote:
> Hi Rafael,
>
> On May 4, 2014, at 3:02 PM, Rafael J. Wysocki wrote:
>
> > Hi,
> >
> > On Sunday, May 04, 2014 10:27:59 AM Guenter Roeck wrote:
> >> On 05/04/2014 10:18 AM, Olof Johansson wrote:
> >
> > [cut]
> >
> >>> I think it's very optimistic to assume that there will ever be a common
> >>> solution for both ends of the spectrum (embedded - enterprise), but we
> >>> should make sure we can stay sane and not have more solutions than we need
> >>> in parallel, and that things will work together where there is overlap.
> >>>
> >> We (Juniper) are moving towards a partial conversion from ACPI to DT, pretty
> >> much just enough to let us work with DT overlays on X86. If there is interest
> >> to discuss this, it might make sense to invite Pantelis Antoniou and possibly
> >> Georgi Vlaev, since both are instrumental to making it work.
> >
> > I actually wonder how you are going to handle things like references from
> > a DT overlay to ACPI device objects in the namespace (like various things
> > controllers etc).
> >
>
> At the moment we got dynamic PCI DT node creation; i.e. the PCI bus(es) is probed
> and the platform's pci bios creates DT nodes; PCI nodes that already defined do not
> get created from scratch, rather DT properties are appended to them.
Well, what you're describing is not a DT overlay on top of an otherwise ACPI-based
system. It is DT support for PCI.
> It is not a whole-sale conversion (yet), but it seems to work find as a target for
> DT overlays.
>
> All this is on vanilla x86-64 btw, with very small fixes to get booted using an DT blob.
>
> So far we didn't have to deal with ACPI device objects; perhaps it will be required
> for when we tackle pure platform devices. But TBH it doesn't seem that difficult.
In the context of DT-over-ACPI overlays it doesn't matter what devices you're
considering. The problem is the translation of phandles into ACPI device object
pointers (paths) or the other way around.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-04 17:27 ` Guenter Roeck
2014-05-04 22:02 ` Rafael J. Wysocki
@ 2014-05-05 2:52 ` Pantelis Antoniou
2014-05-05 4:21 ` Guenter Roeck
1 sibling, 1 reply; 90+ messages in thread
From: Pantelis Antoniou @ 2014-05-05 2:52 UTC (permalink / raw)
To: Guenter Roeck
Cc: dvhart, ksummit-discuss, Georgi Vlaev, Rafael J. Wysocki,
Greg Kroah-Hartman
Hi Guenter,
Replies inline.
On May 4, 2014, at 10:27 AM, Guenter Roeck wrote:
> On 05/04/2014 10:18 AM, Olof Johansson wrote:
>> Hi,
>>
>> [BTW, I forgot to mention that BenH of course would be one person we need
>> involved in all this. Adding him to the cc list here, but I know he's seen the
>> thread already :)]
>>
>> On Sun, May 04, 2014 at 12:14:36PM +0100, Catalin Marinas wrote:
>>> On Sat, May 03, 2014 at 04:14:51PM +0100, Arnd Bergmann wrote:
>>>> On Saturday 03 May 2014 02:05:21 Rafael J. Wysocki wrote:
>>>>> On Friday, May 02, 2014 02:42:07 PM Olof Johansson wrote:
>>>>>> * Converting either of them to use platform device model
>>>>>> (platform_data) to register drivers, and leave them unaware of either
>>>>>> hardware description
>>>>>> * [... I'm likely missing something here as well]
>>>>
>>>> Olof, funny you missed the proposal you made yourself:
>>>>
>>>> * convert ACPI data into DT format at boot time
>>>
>>> I thought this was discussed at length and agreed it's not a way
>>> forward, given the differences between ACPI and DT, especially on the
>>> AML feature which DT does not have (making one-off boot-time conversion
>>> not feasible).
>>
>> I'm explicitly choosing to not discuss the ARM64 situation here myself,
>> I am more interested in solving the issues around Intel's forage into
>> embedded.
>>
>> ACPI on ARM64/SBSA is in many ways a different problem, and one that
>> I don't know what there is to talk about, to be honest. Mostly because
>> we're still talking hypotheticals and not-yet-published docs, and all
>> vendors are still under deep NDA on product plans and what they're
>> planning on doing. It means we're playing games of telephone right now
>> and it's better to just wait until we have something concrete to center
>> the discussions around.
>>
>> Intel, on the other hand, are already shipping this hardware, and have
>> a platforms to do the work on (Minnowboard and Galieo, for example).
>>
>> So, to address Arnd's original question:
>>
>> Yes, it could make more sense to translate the data to a common
>> format and use the existing accessors for that data format, instead
>> of reinventing the accessors and still needing to represent the data
>> some way. I think it depends on how some of the other things develop --
>> I don't know enough about what Darren's current approach is, for example,
>> to tell if it would be easier to do it that way.
>>
>> Also, even if we do a common API with different backends, there will
>> need to be some knowledge somewhere about custom bindings and what they mean,
>> how to translate them and how the different descriptions correlate.
>> I personally think we're best off putting that in the drivers, instead of
>> making some part of the driver core aware of a bunch of quirks/hooks for
>> various devices.
>>
As far as I can tell, if you forgo ACPI's AML execution hooks a conversion of the
ACPI tables to DT is completely doable. The standard PC platform is not that diverse
really, especially compared with the wild differences between ARM platforms.
>>>>> For what it's worth, we are working on extending ACPI to allow DT-style
>>>>> information to be included into ACPI tables.
>>>>
>>>> I think it's important to understand that we have people coming from
>>>> two sides here: Intel x86 embedded systems with ACPI wanting to the
>>>> same things we do on embbeded PowerPC and ARM systems with DT, and ARM64
>>>> servers trying to do the same things that x86 servers do by moving
>>>> to ACPI.
>>>>
>>>> These two have very different requirements and while there is some
>>>> overlap, I suspect we will end up with different solutions as well.
>>>
>>> I think the middle ground is that for x86 to get into embedded and ARM64
>>> into servers, the ACPI spec is not enough as hardware description.
>>> Traditionally, the x86 hardware is rather standard and ACPI didn't need
>>> to describe so many things. On ARM, OTOH, we have lots of variation and
>>> DT provides such flexibility. Even if ARM is pushing for more standard
>>> server hardware like SBSA, it's still relaxed enough not to look like a
>>> PC platform. So even if the aims are different, the x86 efforts on more
>>> hw description in ACPI help both Intel and ARM. Given the collaboration
>>> between the two on ACPI forums already, I think there are good chances
>>> of ending up with a common solution for Linux. Of course, x86 may decide
>>> to go the DT route all the way (and ARM in the other direction ;)).
>>
>> I think it's very optimistic to assume that there will ever be a common
>> solution for both ends of the spectrum (embedded - enterprise), but we
>> should make sure we can stay sane and not have more solutions than we need
>> in parallel, and that things will work together where there is overlap.
>>
> We (Juniper) are moving towards a partial conversion from ACPI to DT, pretty
> much just enough to let us work with DT overlays on X86. If there is interest
> to discuss this, it might make sense to invite Pantelis Antoniou and possibly
> Georgi Vlaev, since both are instrumental to making it work.
>
I can see that Intel makes yet another push to embedded. It remains to be seen
how committed they are this time. A lot of people got burned the last time
when Intel abandoned the market, so expect lots of skepticism this time.
Due to the crazy variety in embedded applications any rigid solution is going to
have a hard time/lead to hacks that for ever shall be maintained out of mainline.
> Guenter
>
Regards
-- Pantelis
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 2:52 ` Pantelis Antoniou
@ 2014-05-05 4:21 ` Guenter Roeck
2014-05-05 23:05 ` Pantelis Antoniou
0 siblings, 1 reply; 90+ messages in thread
From: Guenter Roeck @ 2014-05-05 4:21 UTC (permalink / raw)
To: Pantelis Antoniou
Cc: dvhart, ksummit-discuss, Georgi Vlaev, Rafael J. Wysocki,
Greg Kroah-Hartman
Hi Pantelis,
On 05/04/2014 07:52 PM, Pantelis Antoniou wrote:
>
> I can see that Intel makes yet another push to embedded. It remains to be seen
> how committed they are this time. A lot of people got burned the last time
> when Intel abandoned the market, so expect lots of skepticism this time.
>
<soapbox>
Intel marketing is like BMW marketing ... Intel doesn't sell the CPUs I would
buy (like affordable 6- or 8-core Haswell CPUs), just like BMW doesn't sell
the cars I would buy (like the 50 mpg 5-series they only sell in Germany).
</soapbox>
Cheers,
Guenter
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 4:21 ` Guenter Roeck
@ 2014-05-05 23:05 ` Pantelis Antoniou
0 siblings, 0 replies; 90+ messages in thread
From: Pantelis Antoniou @ 2014-05-05 23:05 UTC (permalink / raw)
To: Guenter Roeck
Cc: dvhart, ksummit-discuss, Georgi Vlaev, Rafael J. Wysocki,
Greg Kroah-Hartman
On May 4, 2014, at 9:21 PM, Guenter Roeck wrote:
> Hi Pantelis,
>
> On 05/04/2014 07:52 PM, Pantelis Antoniou wrote:
>>
>> I can see that Intel makes yet another push to embedded. It remains to be seen
>> how committed they are this time. A lot of people got burned the last time
>> when Intel abandoned the market, so expect lots of skepticism this time.
>>
>
> <soapbox>
>
> Intel marketing is like BMW marketing ... Intel doesn't sell the CPUs I would
> buy (like affordable 6- or 8-core Haswell CPUs), just like BMW doesn't sell
> the cars I would buy (like the 50 mpg 5-series they only sell in Germany).
>
> </soapbox>
>
It's not easy working on BMW stuff, let me tell you stories :)
> Cheers,
> Guenter
>
>
Regards
-- Pantelis
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-04 17:18 ` Olof Johansson
2014-05-04 17:27 ` Guenter Roeck
@ 2014-05-04 21:33 ` Rafael J. Wysocki
2014-05-05 8:43 ` Benjamin Herrenschmidt
2014-05-05 8:39 ` Benjamin Herrenschmidt
2014-05-17 1:54 ` Darren Vincent Hart
3 siblings, 1 reply; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-04 21:33 UTC (permalink / raw)
To: ksummit-discuss; +Cc: dvhart, Rafael J. Wysocki, Greg Kroah-Hartman
On Sunday, May 04, 2014 10:18:07 AM Olof Johansson wrote:
> Hi,
Hi,
> [BTW, I forgot to mention that BenH of course would be one person we need
> involved in all this. Adding him to the cc list here, but I know he's seen the
> thread already :)]
>
> On Sun, May 04, 2014 at 12:14:36PM +0100, Catalin Marinas wrote:
> > On Sat, May 03, 2014 at 04:14:51PM +0100, Arnd Bergmann wrote:
> > > On Saturday 03 May 2014 02:05:21 Rafael J. Wysocki wrote:
> > > > On Friday, May 02, 2014 02:42:07 PM Olof Johansson wrote:
> > > > > * Converting either of them to use platform device model
> > > > > (platform_data) to register drivers, and leave them unaware of either
> > > > > hardware description
> > > > > * [... I'm likely missing something here as well]
> > >
> > > Olof, funny you missed the proposal you made yourself:
> > >
> > > * convert ACPI data into DT format at boot time
> >
> > I thought this was discussed at length and agreed it's not a way
> > forward, given the differences between ACPI and DT, especially on the
> > AML feature which DT does not have (making one-off boot-time conversion
> > not feasible).
>
> I'm explicitly choosing to not discuss the ARM64 situation here myself,
> I am more interested in solving the issues around Intel's forage into
> embedded.
>
> ACPI on ARM64/SBSA is in many ways a different problem, and one that
> I don't know what there is to talk about, to be honest. Mostly because
> we're still talking hypotheticals and not-yet-published docs, and all
> vendors are still under deep NDA on product plans and what they're
> planning on doing. It means we're playing games of telephone right now
> and it's better to just wait until we have something concrete to center
> the discussions around.
>
> Intel, on the other hand, are already shipping this hardware, and have
> a platforms to do the work on (Minnowboard and Galieo, for example).
>
> So, to address Arnd's original question:
>
> Yes, it could make more sense to translate the data to a common
> format and use the existing accessors for that data format, instead
> of reinventing the accessors and still needing to represent the data
> some way. I think it depends on how some of the other things develop --
> I don't know enough about what Darren's current approach is, for example,
> to tell if it would be easier to do it that way.
>
> Also, even if we do a common API with different backends, there will
> need to be some knowledge somewhere about custom bindings and what they mean,
> how to translate them and how the different descriptions correlate.
> I personally think we're best off putting that in the drivers, instead of
> making some part of the driver core aware of a bunch of quirks/hooks for
> various devices.
But we have such quirks for some bus types already, like PCI and PNP.
> > > > For what it's worth, we are working on extending ACPI to allow DT-style
> > > > information to be included into ACPI tables.
> > >
> > > I think it's important to understand that we have people coming from
> > > two sides here: Intel x86 embedded systems with ACPI wanting to the
> > > same things we do on embbeded PowerPC and ARM systems with DT, and ARM64
> > > servers trying to do the same things that x86 servers do by moving
> > > to ACPI.
> > >
> > > These two have very different requirements and while there is some
> > > overlap, I suspect we will end up with different solutions as well.
> >
> > I think the middle ground is that for x86 to get into embedded and ARM64
> > into servers, the ACPI spec is not enough as hardware description.
> > Traditionally, the x86 hardware is rather standard and ACPI didn't need
> > to describe so many things. On ARM, OTOH, we have lots of variation and
> > DT provides such flexibility. Even if ARM is pushing for more standard
> > server hardware like SBSA, it's still relaxed enough not to look like a
> > PC platform. So even if the aims are different, the x86 efforts on more
> > hw description in ACPI help both Intel and ARM. Given the collaboration
> > between the two on ACPI forums already, I think there are good chances
> > of ending up with a common solution for Linux. Of course, x86 may decide
> > to go the DT route all the way (and ARM in the other direction ;)).
>
> I think it's very optimistic to assume that there will ever be a common
> solution for both ends of the spectrum (embedded - enterprise), but we
> should make sure we can stay sane and not have more solutions than we need
> in parallel, and that things will work together where there is overlap.
Agreed.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-04 21:33 ` Rafael J. Wysocki
@ 2014-05-05 8:43 ` Benjamin Herrenschmidt
2014-05-05 11:32 ` Rafael J. Wysocki
` (2 more replies)
0 siblings, 3 replies; 90+ messages in thread
From: Benjamin Herrenschmidt @ 2014-05-05 8:43 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Sun, 2014-05-04 at 23:33 +0200, Rafael J. Wysocki wrote:
>
>
> But we have such quirks for some bus types already, like PCI and PNP.
And they suck big time. They duplicate definitions from the driver,
they get missed at grep time, they bit rot, etc...
There are a few cases where that's justified simply because the driver
can be a module but the quirk needs to run early and always, but mostly
these quirks are about working around HW bugs that would otherwise cause
the system to misbehave even in absence of the driver.
For example, bad class code in bridges, BAR issues, etc...
Generally speaking though, quirks like that are a bad idea and in this
case, totally unjustified since the code performing whatever translation
is necessary (or interpretation) is entirely specific to the driver
anyway.
Also if the bindings evolve, you just created a 3rd way dependency.
Instead of just having to deal with DT/ACPI binding version vs. driver
version, we now have to also handle quirk versioning.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 8:43 ` Benjamin Herrenschmidt
@ 2014-05-05 11:32 ` Rafael J. Wysocki
2014-05-05 11:31 ` Benjamin Herrenschmidt
2014-05-05 15:09 ` Rob Herring
2014-05-17 2:32 ` Darren Vincent Hart
2 siblings, 1 reply; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-05 11:32 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Monday, May 05, 2014 06:43:55 PM Benjamin Herrenschmidt wrote:
> On Sun, 2014-05-04 at 23:33 +0200, Rafael J. Wysocki wrote:
> >
> >
> > But we have such quirks for some bus types already, like PCI and PNP.
>
> And they suck big time. They duplicate definitions from the driver,
> they get missed at grep time, they bit rot, etc...
>
> There are a few cases where that's justified simply because the driver
> can be a module but the quirk needs to run early and always, but mostly
> these quirks are about working around HW bugs that would otherwise cause
> the system to misbehave even in absence of the driver.
>
> For example, bad class code in bridges, BAR issues, etc...
>
> Generally speaking though, quirks like that are a bad idea and in this
> case, totally unjustified since the code performing whatever translation
> is necessary (or interpretation) is entirely specific to the driver
> anyway.
The interpretation - yes, the translation - not necessarily. By putting
the translation part into drivers we'll duplicate a lot of code used for
that. In my opinion there needs to be a layer doing the translation
automatically.
> Also if the bindings evolve, you just created a 3rd way dependency.
> Instead of just having to deal with DT/ACPI binding version vs. driver
> version, we now have to also handle quirk versioning.
The bindings should not depend on the translation. In the end the bindings
are what the driver will ask for. If it asks for an integer property called
"fred", for example, it should get that property from the upper layer
regardless of the firmware interface used on that platform (if the property
is there, of course).
Otherwise every driver has to know about all of the possible firmware interfaces
that can be used with it and may I call that suboptimal? With two of them on
the table it would be workable I guess, but what if someone invents a *third*
firmware interface to use with device drivers? Are we going to change all of
them, then?
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 11:32 ` Rafael J. Wysocki
@ 2014-05-05 11:31 ` Benjamin Herrenschmidt
2014-05-06 12:18 ` Rafael J. Wysocki
0 siblings, 1 reply; 90+ messages in thread
From: Benjamin Herrenschmidt @ 2014-05-05 11:31 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Mon, 2014-05-05 at 13:32 +0200, Rafael J. Wysocki wrote:
> The interpretation - yes, the translation - not necessarily. By putting
> the translation part into drivers we'll duplicate a lot of code used for
> that. In my opinion there needs to be a layer doing the translation
> automatically.
I'm afraid I don't understand. How can you do the translation
automatically if you have fundamentally different representation of
device-specific concepts ?
> > Also if the bindings evolve, you just created a 3rd way dependency.
> > Instead of just having to deal with DT/ACPI binding version vs. driver
> > version, we now have to also handle quirk versioning.
>
> The bindings should not depend on the translation. In the end the bindings
> are what the driver will ask for. If it asks for an integer property called
> "fred", for example, it should get that property from the upper layer
> regardless of the firmware interface used on that platform (if the property
> is there, of course).
Except that the DT will have something like ibm,fred as a 32-bit cell
and ACPI will have it named subtly differently in a different format and
thing will not be consistent accross devices, bindings or even FW
variants.
> Otherwise every driver has to know about all of the possible firmware interfaces
> that can be used with it and may I call that suboptimal?
Well as I said, it depends what we are talking about here. For well
defined resources such as MMIO regions, interrupts, and we might
possibly manage to classify things like GPIO, etc... in that bucket, yes
we can most definitely find a common ground.
However in that case it's less likely to be a "translation" from one
representation to another than it is to be the core interpreting both
representation and turning them into something linux specific such as
struct resource or higher level representations of linkage between
subsystems.
But then there's everything else ... The various device specific
properties which *are* going to be represented differently left right
and center, the buggy firmwares with bad ACPI tables or bad device-tree,
the representation for some new linkage to a subsytem that doesn't have
stable bindings yet, etc...
In the end, it's an evolutionary process. That stuff starts in the
drivers. If enough drivers do the same thing for a given category of
"properties" (in the generic meaning of the word, not specifically a
device-tree prop), then we can move that part into the core, either in
the form of helpers, or pre-parsing into some new type of struct
resource or whatever else match.
It's time and experience that will tell us what works. There is only so
much we can "design" for when what we're going to deal with is vendor
firwmare mostly developed behind closed doors.
> With two of them on
> the table it would be workable I guess, but what if someone invents a *third*
> firmware interface to use with device drivers? Are we going to change all of
> them, then?
Yes. Though the odds of that happening are fairly low at this point.
Ben.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 11:31 ` Benjamin Herrenschmidt
@ 2014-05-06 12:18 ` Rafael J. Wysocki
2014-05-06 13:35 ` Arnd Bergmann
0 siblings, 1 reply; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-06 12:18 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Monday, May 05, 2014 09:31:04 PM Benjamin Herrenschmidt wrote:
> On Mon, 2014-05-05 at 13:32 +0200, Rafael J. Wysocki wrote:
> > The interpretation - yes, the translation - not necessarily. By putting
> > the translation part into drivers we'll duplicate a lot of code used for
> > that. In my opinion there needs to be a layer doing the translation
> > automatically.
>
> I'm afraid I don't understand. How can you do the translation
> automatically if you have fundamentally different representation of
> device-specific concepts ?
I'm not entirely sure how fundamentally different it is to be honest, but in
any case I'm talking about the situation in which the hardware is the same
and the driver is the same, only the firmware interface is different. In
that case either the firmware supplies the information the driver needs, or
it doesn't (and as long as the information is supplied, the format doesn't
really matter, because it only is a matter of translation).
Now, the problem, as I see it, is that in many cases ACPI actually doesn't
supply information that is expected by drivers. There may be two reasons
for that.
The first reason is when ACPI provides methods to be used for manipulating
things that aren't explicitly exposed. I *think* this only is the case in
the power management area, where clocks and voltage regulators are often
hidden behind ACPI power resources and methods to switch device power states.
In this particular case, however, drivers are not supposed to execute those
methods and operate ACPI power resources directly anyway (there are other
layers of code taking care of that), so they simply need not touch things
that cannot be found.
The second reason is when ACPI doesn't have means to provide the expected
information to drivers and *that* is a real problem in my view. To address
it, we might try to extend the ACPI spec to cover all of the things that
are covered by driver bindings for Device Trees, but that is impractical
for two reasons. First, it would be trying to open a door that's already
opened. Second, it wouldn't cover future additions to (or generally future
modifications of) those bindings. Thus the only viable approach is to use
those bindings directly and put them into the ACPI tables (or generally into
the ACPI namespace) somehow.
Of course, there are obstacles to that. First, ACPI already has its own ways
to describe things like GPIOs, I2C/SPI connections etc. which are not
compatible with the existing DT bindings. That may be addressed by adding
extra "bindings" to map the information that ACPI already provides into what
drivers expect and adding some extra library code to process that. Second,
vendors may not add the DT-style information to the ACPI tables they ship
(for example, because the machines in question ship with Windows and the
vendor doesn't care about Linux on them), which may be addressed by allowing
ACPI definition block overlays to be used to provide that information and
add it to the ACPI namespace during initialization. In principle, such
overlays may be supplied along with the kernel and loaded during boot (kind
of like dts files).
Bottom line: I'd like to avoid modifying drivers that use the of_ interface
today if possible. Instead, I'd prefer to modify the firmware layer so that
those drivers can get what they ask for regardless of what firmware interface
the platform is using.
> > > Also if the bindings evolve, you just created a 3rd way dependency.
> > > Instead of just having to deal with DT/ACPI binding version vs. driver
> > > version, we now have to also handle quirk versioning.
> >
> > The bindings should not depend on the translation. In the end the bindings
> > are what the driver will ask for. If it asks for an integer property called
> > "fred", for example, it should get that property from the upper layer
> > regardless of the firmware interface used on that platform (if the property
> > is there, of course).
>
> Except that the DT will have something like ibm,fred as a 32-bit cell
> and ACPI will have it named subtly differently in a different format and
> thing will not be consistent accross devices, bindings or even FW
> variants.
>
> > Otherwise every driver has to know about all of the possible firmware interfaces
> > that can be used with it and may I call that suboptimal?
>
> Well as I said, it depends what we are talking about here. For well
> defined resources such as MMIO regions, interrupts, and we might
> possibly manage to classify things like GPIO, etc... in that bucket, yes
> we can most definitely find a common ground.
>
> However in that case it's less likely to be a "translation" from one
> representation to another than it is to be the core interpreting both
> representation and turning them into something linux specific such as
> struct resource or higher level representations of linkage between
> subsystems.
>
> But then there's everything else ... The various device specific
> properties which *are* going to be represented differently left right
> and center, the buggy firmwares with bad ACPI tables or bad device-tree,
> the representation for some new linkage to a subsytem that doesn't have
> stable bindings yet, etc...
>
> In the end, it's an evolutionary process. That stuff starts in the
> drivers. If enough drivers do the same thing for a given category of
> "properties" (in the generic meaning of the word, not specifically a
> device-tree prop), then we can move that part into the core, either in
> the form of helpers, or pre-parsing into some new type of struct
> resource or whatever else match.
>
> It's time and experience that will tell us what works. There is only so
> much we can "design" for when what we're going to deal with is vendor
> firwmare mostly developed behind closed doors.
I agree. That's why I think that the firmware layer has to be able to
evolve along with everything else and the driver bindings should define
what information the firmware is expected to provide.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-06 12:18 ` Rafael J. Wysocki
@ 2014-05-06 13:35 ` Arnd Bergmann
2014-05-08 0:16 ` Rafael J. Wysocki
` (2 more replies)
0 siblings, 3 replies; 90+ messages in thread
From: Arnd Bergmann @ 2014-05-06 13:35 UTC (permalink / raw)
To: ksummit-discuss; +Cc: dvhart, Rafael J. Wysocki, Greg Kroah-Hartman
On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
> On Monday, May 05, 2014 09:31:04 PM Benjamin Herrenschmidt wrote:
> > On Mon, 2014-05-05 at 13:32 +0200, Rafael J. Wysocki wrote:
> > > The interpretation - yes, the translation - not necessarily. By putting
> > > the translation part into drivers we'll duplicate a lot of code used for
> > > that. In my opinion there needs to be a layer doing the translation
> > > automatically.
> >
> > I'm afraid I don't understand. How can you do the translation
> > automatically if you have fundamentally different representation of
> > device-specific concepts ?
>
> I'm not entirely sure how fundamentally different it is to be honest, but in
> any case I'm talking about the situation in which the hardware is the same
> and the driver is the same, only the firmware interface is different. In
> that case either the firmware supplies the information the driver needs, or
> it doesn't (and as long as the information is supplied, the format doesn't
> really matter, because it only is a matter of translation).
One example for something that is fundamentally different between an
embedded system using DT and any ACPI system is how a PCI(e) host bridge
gets treated, we are currently having long discussions about this elsewhere.
With ACPI (or a server running OF for that matter), you assume that the
PCI host is operational and all buses are fully probed and then you
have methods for doing hotplugging, you just look at the device that
are already initialized by the firmware.
With embedded systems, you (in general, some steps may get skipped
in practice) go through a lot more steps:
- detect the presence of the host bridge device
- enable clocks, voltages, phys, resets, etc.
- set up inbound and outbound MMIO and PIO address translation windows
- perform a full bus scan and assign bus and device resources
We probably woulnd't go through that hassle on ACPI systems. I think
we shouldn't attempt any translation here, and keep the code completely
separate, with the common parts being handled by the PCI core as we
do today.
An example about a subsystem where translate complex information
from both DT and ACPI into a common format is the dmaengine: We can
have references to dma channels in completely incompatible ways
but still use the same dma_request_slave_channel() interface for
both. The ACPI path currently is lacking a bit (e.g. there is no
way to specify the channel name in ACPI, so the code makes
assumptions that don't hold true in general), but that's fixable.
I assume we will see more of the second kind in the future, and this
would be limited to embedded systems on both ACPI and DT, since you
shouldn't see dma slave devices on general purpose systems with
either.
> Bottom line: I'd like to avoid modifying drivers that use the of_ interface
> today if possible. Instead, I'd prefer to modify the firmware layer so that
> those drivers can get what they ask for regardless of what firmware interface
> the platform is using.
Looking at the most trivial example:
bool of_property_read_bool(const struct device_node *np, const char *propname);
We should definitely be able to have an interface like this for
ACPI, but you don't have a 'struct device_node' pointer then.
We can add a new
bool dev_property_read_bool(const struct device *dev,
const char *propname);
that handles both, but then you have to change every driver
that is already using of_property_read_bool() and that can
get used with ACPI. An advantage of the dev_property_read_bool()
interface however is that it would also work for platform
devices that are created in platform code using
platform_device_register_full() or similar if we add a way
to define simple properties in C code. That would also simplify
a lot of drivers that use both (simple) platform_data and DT
today.
Arnd
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-06 13:35 ` Arnd Bergmann
@ 2014-05-08 0:16 ` Rafael J. Wysocki
2014-05-12 6:21 ` Benjamin Herrenschmidt
2014-05-13 21:14 ` Olof Johansson
2 siblings, 0 replies; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-08 0:16 UTC (permalink / raw)
To: Arnd Bergmann
Cc: dvhart, Rafael J. Wysocki, ksummit-discuss, Greg Kroah-Hartman
On Tuesday, May 06, 2014 03:35:41 PM Arnd Bergmann wrote:
> On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
> > On Monday, May 05, 2014 09:31:04 PM Benjamin Herrenschmidt wrote:
> > > On Mon, 2014-05-05 at 13:32 +0200, Rafael J. Wysocki wrote:
> > > > The interpretation - yes, the translation - not necessarily. By putting
> > > > the translation part into drivers we'll duplicate a lot of code used for
> > > > that. In my opinion there needs to be a layer doing the translation
> > > > automatically.
> > >
> > > I'm afraid I don't understand. How can you do the translation
> > > automatically if you have fundamentally different representation of
> > > device-specific concepts ?
> >
> > I'm not entirely sure how fundamentally different it is to be honest, but in
> > any case I'm talking about the situation in which the hardware is the same
> > and the driver is the same, only the firmware interface is different. In
> > that case either the firmware supplies the information the driver needs, or
> > it doesn't (and as long as the information is supplied, the format doesn't
> > really matter, because it only is a matter of translation).
>
> One example for something that is fundamentally different between an
> embedded system using DT and any ACPI system is how a PCI(e) host bridge
> gets treated, we are currently having long discussions about this elsewhere.
Well, that's rather an extreme example. :-)
The PCI host bridge is also special, because there already is an ACPI drvier
for it, so that is not a case when we have a driver using DTs and would
like to modify it to add ACPI-specific handling. This one is a different
problem.
> With ACPI (or a server running OF for that matter), you assume that the
> PCI host is operational and all buses are fully probed and then you
> have methods for doing hotplugging, you just look at the device that
> are already initialized by the firmware.
>
> With embedded systems, you (in general, some steps may get skipped
> in practice) go through a lot more steps:
> - detect the presence of the host bridge device
> - enable clocks, voltages, phys, resets, etc.
> - set up inbound and outbound MMIO and PIO address translation windows
> - perform a full bus scan and assign bus and device resources
>
> We probably woulnd't go through that hassle on ACPI systems. I think
> we shouldn't attempt any translation here, and keep the code completely
> separate, with the common parts being handled by the PCI core as we
> do today.
I agree.
> An example about a subsystem where translate complex information
> from both DT and ACPI into a common format is the dmaengine: We can
> have references to dma channels in completely incompatible ways
> but still use the same dma_request_slave_channel() interface for
> both. The ACPI path currently is lacking a bit (e.g. there is no
> way to specify the channel name in ACPI, so the code makes
> assumptions that don't hold true in general), but that's fixable.
>
> I assume we will see more of the second kind in the future, and this
> would be limited to embedded systems on both ACPI and DT, since you
> shouldn't see dma slave devices on general purpose systems with
> either.
>
> > Bottom line: I'd like to avoid modifying drivers that use the of_ interface
> > today if possible. Instead, I'd prefer to modify the firmware layer so that
> > those drivers can get what they ask for regardless of what firmware interface
> > the platform is using.
>
> Looking at the most trivial example:
>
> bool of_property_read_bool(const struct device_node *np, const char *propname);
>
> We should definitely be able to have an interface like this for
> ACPI, but you don't have a 'struct device_node' pointer then.
> We can add a new
>
> bool dev_property_read_bool(const struct device *dev,
> const char *propname);
>
> that handles both, but then you have to change every driver
> that is already using of_property_read_bool() and that can
> get used with ACPI.
Yes, but that's not a very difficult change to make, arguably.
> An advantage of the dev_property_read_bool()
> interface however is that it would also work for platform
> devices that are created in platform code using
> platform_device_register_full() or similar if we add a way
> to define simple properties in C code. That would also simplify
> a lot of drivers that use both (simple) platform_data and DT
> today.
Yes.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-06 13:35 ` Arnd Bergmann
2014-05-08 0:16 ` Rafael J. Wysocki
@ 2014-05-12 6:21 ` Benjamin Herrenschmidt
2014-05-13 21:14 ` Olof Johansson
2 siblings, 0 replies; 90+ messages in thread
From: Benjamin Herrenschmidt @ 2014-05-12 6:21 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Tue, 2014-05-06 at 15:35 +0200, Arnd Bergmann wrote:
>
> With ACPI (or a server running OF for that matter), you assume that the
> PCI host is operational and all buses are fully probed and then you
> have methods for doing hotplugging, you just look at the device that
> are already initialized by the firmware.
>
> With embedded systems, you (in general, some steps may get skipped
> in practice) go through a lot more steps:
> - detect the presence of the host bridge device
> - enable clocks, voltages, phys, resets, etc.
> - set up inbound and outbound MMIO and PIO address translation windows
> - perform a full bus scan and assign bus and device resources
>
> We probably woulnd't go through that hassle on ACPI systems. I think
> we shouldn't attempt any translation here, and keep the code completely
> separate, with the common parts being handled by the PCI core as we
> do today.
Well, you said it "or a server running OF for that matter" ...
PCI Hotplug is a whole separate can of worms, let's not get there :-)
Even on OF machine, it's very platform specific. I don't think we can
use it as an example of something that's widely different between DT
and ACPI per-se as it's going to be widely different between everything
non-ACPI.
This is a case of ACPI-does-methods being actually somewhat useful.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-06 13:35 ` Arnd Bergmann
2014-05-08 0:16 ` Rafael J. Wysocki
2014-05-12 6:21 ` Benjamin Herrenschmidt
@ 2014-05-13 21:14 ` Olof Johansson
2014-05-13 21:40 ` Rafael J. Wysocki
` (3 more replies)
2 siblings, 4 replies; 90+ messages in thread
From: Olof Johansson @ 2014-05-13 21:14 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Tue, May 06, 2014 at 03:35:41PM +0200, Arnd Bergmann wrote:
> On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
> > On Monday, May 05, 2014 09:31:04 PM Benjamin Herrenschmidt wrote:
> > > On Mon, 2014-05-05 at 13:32 +0200, Rafael J. Wysocki wrote:
> > > > The interpretation - yes, the translation - not necessarily. By putting
> > > > the translation part into drivers we'll duplicate a lot of code used for
> > > > that. In my opinion there needs to be a layer doing the translation
> > > > automatically.
> > >
> > > I'm afraid I don't understand. How can you do the translation
> > > automatically if you have fundamentally different representation of
> > > device-specific concepts ?
> >
> > I'm not entirely sure how fundamentally different it is to be honest, but in
> > any case I'm talking about the situation in which the hardware is the same
> > and the driver is the same, only the firmware interface is different. In
> > that case either the firmware supplies the information the driver needs, or
> > it doesn't (and as long as the information is supplied, the format doesn't
> > really matter, because it only is a matter of translation).
>
> One example for something that is fundamentally different between an
> embedded system using DT and any ACPI system is how a PCI(e) host bridge
> gets treated, we are currently having long discussions about this elsewhere.
>
> With ACPI (or a server running OF for that matter), you assume that the
> PCI host is operational and all buses are fully probed and then you
> have methods for doing hotplugging, you just look at the device that
> are already initialized by the firmware.
>
> With embedded systems, you (in general, some steps may get skipped
> in practice) go through a lot more steps:
> - detect the presence of the host bridge device
> - enable clocks, voltages, phys, resets, etc.
> - set up inbound and outbound MMIO and PIO address translation windows
> - perform a full bus scan and assign bus and device resources
>
> We probably woulnd't go through that hassle on ACPI systems. I think
> we shouldn't attempt any translation here, and keep the code completely
> separate, with the common parts being handled by the PCI core as we
> do today.
>
> An example about a subsystem where translate complex information
> from both DT and ACPI into a common format is the dmaengine: We can
> have references to dma channels in completely incompatible ways
> but still use the same dma_request_slave_channel() interface for
> both. The ACPI path currently is lacking a bit (e.g. there is no
> way to specify the channel name in ACPI, so the code makes
> assumptions that don't hold true in general), but that's fixable.
>
> I assume we will see more of the second kind in the future, and this
> would be limited to embedded systems on both ACPI and DT, since you
> shouldn't see dma slave devices on general purpose systems with
> either.
>
> > Bottom line: I'd like to avoid modifying drivers that use the of_ interface
> > today if possible. Instead, I'd prefer to modify the firmware layer so that
> > those drivers can get what they ask for regardless of what firmware interface
> > the platform is using.
>
> Looking at the most trivial example:
>
> bool of_property_read_bool(const struct device_node *np, const char *propname);
>
> We should definitely be able to have an interface like this for
> ACPI, but you don't have a 'struct device_node' pointer then.
> We can add a new
>
> bool dev_property_read_bool(const struct device *dev,
> const char *propname);
>
> that handles both, but then you have to change every driver
> that is already using of_property_read_bool() and that can
> get used with ACPI.
It's actually not that easy in practice. There's not a one-to-one
correspondence between device tree nodes and struct devices in the
kernel. There are many bindings that use subnodes for sections of their
information, and so on.
> An advantage of the dev_property_read_bool()
> interface however is that it would also work for platform
> devices that are created in platform code using
> platform_device_register_full() or similar if we add a way
> to define simple properties in C code. That would also simplify
> a lot of drivers that use both (simple) platform_data and DT
> today.
I'm not a fan of this "grand unified abstraction layer". Driver writes are
already complaining that things are too complicated with the move to device
tree, and we're making things even more abstracted and complicated here. People
will need to peel back even more layers to figure out what's actually going on.
For the truly trivial stuff, there are some quite simple ways to handle this:
1. Make sure that anything that can be a named IORESOURCE_* is so. Which could
mean moving over GPIO and possibly clocks to that, and use those for lookup.
2. If Rafael's arguments are to be believed, that the translation should be
trivial and easy to do, then we might as well reuse the structures and APIs
that are already in the kernel. In other words, allocate a struct
device_node, populate it with the properties from the ACPI structure, and
attach it to the struct device. Then there's no need for any churn in the
drivers (until they need ACPI-specific tweaks, which they will all need).
The real problem is the non-trivial stuff. There, I think there's no real
alternative than to teach the drivers about both firmware interfaces.
-Olof
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-13 21:14 ` Olof Johansson
@ 2014-05-13 21:40 ` Rafael J. Wysocki
2014-05-13 21:28 ` Olof Johansson
2014-05-14 12:06 ` Arnd Bergmann
` (2 subsequent siblings)
3 siblings, 1 reply; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-13 21:40 UTC (permalink / raw)
To: Olof Johansson
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Tuesday, May 13, 2014 02:14:42 PM Olof Johansson wrote:
> On Tue, May 06, 2014 at 03:35:41PM +0200, Arnd Bergmann wrote:
> > On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
> > > On Monday, May 05, 2014 09:31:04 PM Benjamin Herrenschmidt wrote:
> > > > On Mon, 2014-05-05 at 13:32 +0200, Rafael J. Wysocki wrote:
> > > > > The interpretation - yes, the translation - not necessarily. By putting
> > > > > the translation part into drivers we'll duplicate a lot of code used for
> > > > > that. In my opinion there needs to be a layer doing the translation
> > > > > automatically.
> > > >
> > > > I'm afraid I don't understand. How can you do the translation
> > > > automatically if you have fundamentally different representation of
> > > > device-specific concepts ?
> > >
> > > I'm not entirely sure how fundamentally different it is to be honest, but in
> > > any case I'm talking about the situation in which the hardware is the same
> > > and the driver is the same, only the firmware interface is different. In
> > > that case either the firmware supplies the information the driver needs, or
> > > it doesn't (and as long as the information is supplied, the format doesn't
> > > really matter, because it only is a matter of translation).
> >
> > One example for something that is fundamentally different between an
> > embedded system using DT and any ACPI system is how a PCI(e) host bridge
> > gets treated, we are currently having long discussions about this elsewhere.
> >
> > With ACPI (or a server running OF for that matter), you assume that the
> > PCI host is operational and all buses are fully probed and then you
> > have methods for doing hotplugging, you just look at the device that
> > are already initialized by the firmware.
> >
> > With embedded systems, you (in general, some steps may get skipped
> > in practice) go through a lot more steps:
> > - detect the presence of the host bridge device
> > - enable clocks, voltages, phys, resets, etc.
> > - set up inbound and outbound MMIO and PIO address translation windows
> > - perform a full bus scan and assign bus and device resources
> >
> > We probably woulnd't go through that hassle on ACPI systems. I think
> > we shouldn't attempt any translation here, and keep the code completely
> > separate, with the common parts being handled by the PCI core as we
> > do today.
> >
> > An example about a subsystem where translate complex information
> > from both DT and ACPI into a common format is the dmaengine: We can
> > have references to dma channels in completely incompatible ways
> > but still use the same dma_request_slave_channel() interface for
> > both. The ACPI path currently is lacking a bit (e.g. there is no
> > way to specify the channel name in ACPI, so the code makes
> > assumptions that don't hold true in general), but that's fixable.
> >
> > I assume we will see more of the second kind in the future, and this
> > would be limited to embedded systems on both ACPI and DT, since you
> > shouldn't see dma slave devices on general purpose systems with
> > either.
> >
> > > Bottom line: I'd like to avoid modifying drivers that use the of_ interface
> > > today if possible. Instead, I'd prefer to modify the firmware layer so that
> > > those drivers can get what they ask for regardless of what firmware interface
> > > the platform is using.
> >
> > Looking at the most trivial example:
> >
> > bool of_property_read_bool(const struct device_node *np, const char *propname);
> >
> > We should definitely be able to have an interface like this for
> > ACPI, but you don't have a 'struct device_node' pointer then.
> > We can add a new
> >
> > bool dev_property_read_bool(const struct device *dev,
> > const char *propname);
>
> >
> > that handles both, but then you have to change every driver
> > that is already using of_property_read_bool() and that can
> > get used with ACPI.
>
> It's actually not that easy in practice. There's not a one-to-one
> correspondence between device tree nodes and struct devices in the
> kernel. There are many bindings that use subnodes for sections of their
> information, and so on.
>
> > An advantage of the dev_property_read_bool()
> > interface however is that it would also work for platform
> > devices that are created in platform code using
> > platform_device_register_full() or similar if we add a way
> > to define simple properties in C code. That would also simplify
> > a lot of drivers that use both (simple) platform_data and DT
> > today.
>
> I'm not a fan of this "grand unified abstraction layer". Driver writes are
> already complaining that things are too complicated with the move to device
> tree, and we're making things even more abstracted and complicated here. People
> will need to peel back even more layers to figure out what's actually going on.
>
>
> For the truly trivial stuff, there are some quite simple ways to handle this:
>
> 1. Make sure that anything that can be a named IORESOURCE_* is so. Which could
> mean moving over GPIO and possibly clocks to that, and use those for lookup.
>
> 2. If Rafael's arguments are to be believed, that the translation should be
> trivial and easy to do, then we might as well reuse the structures and APIs
> that are already in the kernel. In other words, allocate a struct
> device_node, populate it with the properties from the ACPI structure, and
> attach it to the struct device. Then there's no need for any churn in the
> drivers (until they need ACPI-specific tweaks, which they will all need).
The problem with that is that we have either device_node or acpi_node.companion
under struct device and they are mutually exclusive. So this isn't going to fly.
[And it doesn't make sense to duplicate information already available from
acpi_node.companion this way IMHO.]
Also device references are problematic here, because both interfaces use
different ways to do that (phandles vs object paths in the ACPI namespace).
So actually, what Arnd proposed seems to be the simplest approach.
> The real problem is the non-trivial stuff. There, I think there's no real
> alternative than to teach the drivers about both firmware interfaces.
I'm not sure about that. I won't say "this isn't the case" until I actually
try things out, but it *may* be avoidable AFAICS today.
Rafael
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-13 21:40 ` Rafael J. Wysocki
@ 2014-05-13 21:28 ` Olof Johansson
2014-05-13 21:51 ` Rafael J. Wysocki
0 siblings, 1 reply; 90+ messages in thread
From: Olof Johansson @ 2014-05-13 21:28 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Tue, May 13, 2014 at 2:40 PM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Tuesday, May 13, 2014 02:14:42 PM Olof Johansson wrote:
>> On Tue, May 06, 2014 at 03:35:41PM +0200, Arnd Bergmann wrote:
>> > On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
>> > > On Monday, May 05, 2014 09:31:04 PM Benjamin Herrenschmidt wrote:
>> > > > On Mon, 2014-05-05 at 13:32 +0200, Rafael J. Wysocki wrote:
>> > > > > The interpretation - yes, the translation - not necessarily. By putting
>> > > > > the translation part into drivers we'll duplicate a lot of code used for
>> > > > > that. In my opinion there needs to be a layer doing the translation
>> > > > > automatically.
>> > > >
>> > > > I'm afraid I don't understand. How can you do the translation
>> > > > automatically if you have fundamentally different representation of
>> > > > device-specific concepts ?
>> > >
>> > > I'm not entirely sure how fundamentally different it is to be honest, but in
>> > > any case I'm talking about the situation in which the hardware is the same
>> > > and the driver is the same, only the firmware interface is different. In
>> > > that case either the firmware supplies the information the driver needs, or
>> > > it doesn't (and as long as the information is supplied, the format doesn't
>> > > really matter, because it only is a matter of translation).
>> >
>> > One example for something that is fundamentally different between an
>> > embedded system using DT and any ACPI system is how a PCI(e) host bridge
>> > gets treated, we are currently having long discussions about this elsewhere.
>> >
>> > With ACPI (or a server running OF for that matter), you assume that the
>> > PCI host is operational and all buses are fully probed and then you
>> > have methods for doing hotplugging, you just look at the device that
>> > are already initialized by the firmware.
>> >
>> > With embedded systems, you (in general, some steps may get skipped
>> > in practice) go through a lot more steps:
>> > - detect the presence of the host bridge device
>> > - enable clocks, voltages, phys, resets, etc.
>> > - set up inbound and outbound MMIO and PIO address translation windows
>> > - perform a full bus scan and assign bus and device resources
>> >
>> > We probably woulnd't go through that hassle on ACPI systems. I think
>> > we shouldn't attempt any translation here, and keep the code completely
>> > separate, with the common parts being handled by the PCI core as we
>> > do today.
>> >
>> > An example about a subsystem where translate complex information
>> > from both DT and ACPI into a common format is the dmaengine: We can
>> > have references to dma channels in completely incompatible ways
>> > but still use the same dma_request_slave_channel() interface for
>> > both. The ACPI path currently is lacking a bit (e.g. there is no
>> > way to specify the channel name in ACPI, so the code makes
>> > assumptions that don't hold true in general), but that's fixable.
>> >
>> > I assume we will see more of the second kind in the future, and this
>> > would be limited to embedded systems on both ACPI and DT, since you
>> > shouldn't see dma slave devices on general purpose systems with
>> > either.
>> >
>> > > Bottom line: I'd like to avoid modifying drivers that use the of_ interface
>> > > today if possible. Instead, I'd prefer to modify the firmware layer so that
>> > > those drivers can get what they ask for regardless of what firmware interface
>> > > the platform is using.
>> >
>> > Looking at the most trivial example:
>> >
>> > bool of_property_read_bool(const struct device_node *np, const char *propname);
>> >
>> > We should definitely be able to have an interface like this for
>> > ACPI, but you don't have a 'struct device_node' pointer then.
>> > We can add a new
>> >
>> > bool dev_property_read_bool(const struct device *dev,
>> > const char *propname);
>>
>> >
>> > that handles both, but then you have to change every driver
>> > that is already using of_property_read_bool() and that can
>> > get used with ACPI.
>>
>> It's actually not that easy in practice. There's not a one-to-one
>> correspondence between device tree nodes and struct devices in the
>> kernel. There are many bindings that use subnodes for sections of their
>> information, and so on.
>>
>> > An advantage of the dev_property_read_bool()
>> > interface however is that it would also work for platform
>> > devices that are created in platform code using
>> > platform_device_register_full() or similar if we add a way
>> > to define simple properties in C code. That would also simplify
>> > a lot of drivers that use both (simple) platform_data and DT
>> > today.
>>
>> I'm not a fan of this "grand unified abstraction layer". Driver writes are
>> already complaining that things are too complicated with the move to device
>> tree, and we're making things even more abstracted and complicated here. People
>> will need to peel back even more layers to figure out what's actually going on.
>>
>>
>> For the truly trivial stuff, there are some quite simple ways to handle this:
>>
>> 1. Make sure that anything that can be a named IORESOURCE_* is so. Which could
>> mean moving over GPIO and possibly clocks to that, and use those for lookup.
>>
>> 2. If Rafael's arguments are to be believed, that the translation should be
>> trivial and easy to do, then we might as well reuse the structures and APIs
>> that are already in the kernel. In other words, allocate a struct
>> device_node, populate it with the properties from the ACPI structure, and
>> attach it to the struct device. Then there's no need for any churn in the
>> drivers (until they need ACPI-specific tweaks, which they will all need).
>
> The problem with that is that we have either device_node or acpi_node.companion
> under struct device and they are mutually exclusive. So this isn't going to fly.
> [And it doesn't make sense to duplicate information already available from
> acpi_node.companion this way IMHO.]
>
> Also device references are problematic here, because both interfaces use
> different ways to do that (phandles vs object paths in the ACPI namespace).
>
> So actually, what Arnd proposed seems to be the simplest approach.
Again, that suggestion assumes a 1:1 mapping between device nodes and
struct devices, which does not exist. And we won't churn bindings nor
drivers to make it fit since the whole point of your proposal is to
avoid doing that.
>> The real problem is the non-trivial stuff. There, I think there's no real
>> alternative than to teach the drivers about both firmware interfaces.
>
> I'm not sure about that. I won't say "this isn't the case" until I actually
> try things out, but it *may* be avoidable AFAICS today.
Do you have a rough idea of when you can do that?
-Olof
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-13 21:28 ` Olof Johansson
@ 2014-05-13 21:51 ` Rafael J. Wysocki
2014-05-17 3:22 ` Darren Vincent Hart
0 siblings, 1 reply; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-13 21:51 UTC (permalink / raw)
To: Olof Johansson
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Tuesday, May 13, 2014 02:28:05 PM Olof Johansson wrote:
> On Tue, May 13, 2014 at 2:40 PM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> > On Tuesday, May 13, 2014 02:14:42 PM Olof Johansson wrote:
> >> On Tue, May 06, 2014 at 03:35:41PM +0200, Arnd Bergmann wrote:
> >> > On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
> >> > > On Monday, May 05, 2014 09:31:04 PM Benjamin Herrenschmidt wrote:
> >> > > > On Mon, 2014-05-05 at 13:32 +0200, Rafael J. Wysocki wrote:
> >> > > > > The interpretation - yes, the translation - not necessarily. By putting
> >> > > > > the translation part into drivers we'll duplicate a lot of code used for
> >> > > > > that. In my opinion there needs to be a layer doing the translation
> >> > > > > automatically.
> >> > > >
> >> > > > I'm afraid I don't understand. How can you do the translation
> >> > > > automatically if you have fundamentally different representation of
> >> > > > device-specific concepts ?
> >> > >
> >> > > I'm not entirely sure how fundamentally different it is to be honest, but in
> >> > > any case I'm talking about the situation in which the hardware is the same
> >> > > and the driver is the same, only the firmware interface is different. In
> >> > > that case either the firmware supplies the information the driver needs, or
> >> > > it doesn't (and as long as the information is supplied, the format doesn't
> >> > > really matter, because it only is a matter of translation).
> >> >
> >> > One example for something that is fundamentally different between an
> >> > embedded system using DT and any ACPI system is how a PCI(e) host bridge
> >> > gets treated, we are currently having long discussions about this elsewhere.
> >> >
> >> > With ACPI (or a server running OF for that matter), you assume that the
> >> > PCI host is operational and all buses are fully probed and then you
> >> > have methods for doing hotplugging, you just look at the device that
> >> > are already initialized by the firmware.
> >> >
> >> > With embedded systems, you (in general, some steps may get skipped
> >> > in practice) go through a lot more steps:
> >> > - detect the presence of the host bridge device
> >> > - enable clocks, voltages, phys, resets, etc.
> >> > - set up inbound and outbound MMIO and PIO address translation windows
> >> > - perform a full bus scan and assign bus and device resources
> >> >
> >> > We probably woulnd't go through that hassle on ACPI systems. I think
> >> > we shouldn't attempt any translation here, and keep the code completely
> >> > separate, with the common parts being handled by the PCI core as we
> >> > do today.
> >> >
> >> > An example about a subsystem where translate complex information
> >> > from both DT and ACPI into a common format is the dmaengine: We can
> >> > have references to dma channels in completely incompatible ways
> >> > but still use the same dma_request_slave_channel() interface for
> >> > both. The ACPI path currently is lacking a bit (e.g. there is no
> >> > way to specify the channel name in ACPI, so the code makes
> >> > assumptions that don't hold true in general), but that's fixable.
> >> >
> >> > I assume we will see more of the second kind in the future, and this
> >> > would be limited to embedded systems on both ACPI and DT, since you
> >> > shouldn't see dma slave devices on general purpose systems with
> >> > either.
> >> >
> >> > > Bottom line: I'd like to avoid modifying drivers that use the of_ interface
> >> > > today if possible. Instead, I'd prefer to modify the firmware layer so that
> >> > > those drivers can get what they ask for regardless of what firmware interface
> >> > > the platform is using.
> >> >
> >> > Looking at the most trivial example:
> >> >
> >> > bool of_property_read_bool(const struct device_node *np, const char *propname);
> >> >
> >> > We should definitely be able to have an interface like this for
> >> > ACPI, but you don't have a 'struct device_node' pointer then.
> >> > We can add a new
> >> >
> >> > bool dev_property_read_bool(const struct device *dev,
> >> > const char *propname);
> >>
> >> >
> >> > that handles both, but then you have to change every driver
> >> > that is already using of_property_read_bool() and that can
> >> > get used with ACPI.
> >>
> >> It's actually not that easy in practice. There's not a one-to-one
> >> correspondence between device tree nodes and struct devices in the
> >> kernel. There are many bindings that use subnodes for sections of their
> >> information, and so on.
> >>
> >> > An advantage of the dev_property_read_bool()
> >> > interface however is that it would also work for platform
> >> > devices that are created in platform code using
> >> > platform_device_register_full() or similar if we add a way
> >> > to define simple properties in C code. That would also simplify
> >> > a lot of drivers that use both (simple) platform_data and DT
> >> > today.
> >>
> >> I'm not a fan of this "grand unified abstraction layer". Driver writes are
> >> already complaining that things are too complicated with the move to device
> >> tree, and we're making things even more abstracted and complicated here. People
> >> will need to peel back even more layers to figure out what's actually going on.
> >>
> >>
> >> For the truly trivial stuff, there are some quite simple ways to handle this:
> >>
> >> 1. Make sure that anything that can be a named IORESOURCE_* is so. Which could
> >> mean moving over GPIO and possibly clocks to that, and use those for lookup.
> >>
> >> 2. If Rafael's arguments are to be believed, that the translation should be
> >> trivial and easy to do, then we might as well reuse the structures and APIs
> >> that are already in the kernel. In other words, allocate a struct
> >> device_node, populate it with the properties from the ACPI structure, and
> >> attach it to the struct device. Then there's no need for any churn in the
> >> drivers (until they need ACPI-specific tweaks, which they will all need).
> >
> > The problem with that is that we have either device_node or acpi_node.companion
> > under struct device and they are mutually exclusive. So this isn't going to fly.
> > [And it doesn't make sense to duplicate information already available from
> > acpi_node.companion this way IMHO.]
> >
> > Also device references are problematic here, because both interfaces use
> > different ways to do that (phandles vs object paths in the ACPI namespace).
> >
> > So actually, what Arnd proposed seems to be the simplest approach.
>
> Again, that suggestion assumes a 1:1 mapping between device nodes and
> struct devices, which does not exist.
I suppose your concern is that there may be device nodes without struct device,
right? So drivers may need to access those device nodes directly?
Can you please point me to code where this is the case?
> And we won't churn bindings nor drivers to make it fit since the whole point
> of your proposal is to avoid doing that.
Yes.
> >> The real problem is the non-trivial stuff. There, I think there's no real
> >> alternative than to teach the drivers about both firmware interfaces.
> >
> > I'm not sure about that. I won't say "this isn't the case" until I actually
> > try things out, but it *may* be avoidable AFAICS today.
>
> Do you have a rough idea of when you can do that?
Next month? That time frame, more or less.
Surely before August. :-)
Rafael
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-13 21:51 ` Rafael J. Wysocki
@ 2014-05-17 3:22 ` Darren Vincent Hart
0 siblings, 0 replies; 90+ messages in thread
From: Darren Vincent Hart @ 2014-05-17 3:22 UTC (permalink / raw)
To: Rafael J. Wysocki; +Cc: Greg Kroah-Hartman, ksummit-discuss
On Tue, 2014-05-13 at 23:51 +0200, Rafael J. Wysocki wrote:
> On Tuesday, May 13, 2014 02:28:05 PM Olof Johansson wrote:
> > On Tue, May 13, 2014 at 2:40 PM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> > > On Tuesday, May 13, 2014 02:14:42 PM Olof Johansson wrote:
> > >> On Tue, May 06, 2014 at 03:35:41PM +0200, Arnd Bergmann wrote:
> > >> > On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
> > >> > > On Monday, May 05, 2014 09:31:04 PM Benjamin Herrenschmidt wrote:
> > >> > > > On Mon, 2014-05-05 at 13:32 +0200, Rafael J. Wysocki wrote:
> > >> > > > > The interpretation - yes, the translation - not necessarily. By putting
> > >> > > > > the translation part into drivers we'll duplicate a lot of code used for
> > >> > > > > that. In my opinion there needs to be a layer doing the translation
> > >> > > > > automatically.
> > >> > > >
> > >> > > > I'm afraid I don't understand. How can you do the translation
> > >> > > > automatically if you have fundamentally different representation of
> > >> > > > device-specific concepts ?
> > >> > >
> > >> > > I'm not entirely sure how fundamentally different it is to be honest, but in
> > >> > > any case I'm talking about the situation in which the hardware is the same
> > >> > > and the driver is the same, only the firmware interface is different. In
> > >> > > that case either the firmware supplies the information the driver needs, or
> > >> > > it doesn't (and as long as the information is supplied, the format doesn't
> > >> > > really matter, because it only is a matter of translation).
> > >> >
> > >> > One example for something that is fundamentally different between an
> > >> > embedded system using DT and any ACPI system is how a PCI(e) host bridge
> > >> > gets treated, we are currently having long discussions about this elsewhere.
> > >> >
> > >> > With ACPI (or a server running OF for that matter), you assume that the
> > >> > PCI host is operational and all buses are fully probed and then you
> > >> > have methods for doing hotplugging, you just look at the device that
> > >> > are already initialized by the firmware.
> > >> >
> > >> > With embedded systems, you (in general, some steps may get skipped
> > >> > in practice) go through a lot more steps:
> > >> > - detect the presence of the host bridge device
> > >> > - enable clocks, voltages, phys, resets, etc.
> > >> > - set up inbound and outbound MMIO and PIO address translation windows
> > >> > - perform a full bus scan and assign bus and device resources
> > >> >
> > >> > We probably woulnd't go through that hassle on ACPI systems. I think
> > >> > we shouldn't attempt any translation here, and keep the code completely
> > >> > separate, with the common parts being handled by the PCI core as we
> > >> > do today.
> > >> >
> > >> > An example about a subsystem where translate complex information
> > >> > from both DT and ACPI into a common format is the dmaengine: We can
> > >> > have references to dma channels in completely incompatible ways
> > >> > but still use the same dma_request_slave_channel() interface for
> > >> > both. The ACPI path currently is lacking a bit (e.g. there is no
> > >> > way to specify the channel name in ACPI, so the code makes
> > >> > assumptions that don't hold true in general), but that's fixable.
> > >> >
> > >> > I assume we will see more of the second kind in the future, and this
> > >> > would be limited to embedded systems on both ACPI and DT, since you
> > >> > shouldn't see dma slave devices on general purpose systems with
> > >> > either.
> > >> >
> > >> > > Bottom line: I'd like to avoid modifying drivers that use the of_ interface
> > >> > > today if possible. Instead, I'd prefer to modify the firmware layer so that
> > >> > > those drivers can get what they ask for regardless of what firmware interface
> > >> > > the platform is using.
> > >> >
> > >> > Looking at the most trivial example:
> > >> >
> > >> > bool of_property_read_bool(const struct device_node *np, const char *propname);
> > >> >
> > >> > We should definitely be able to have an interface like this for
> > >> > ACPI, but you don't have a 'struct device_node' pointer then.
> > >> > We can add a new
> > >> >
> > >> > bool dev_property_read_bool(const struct device *dev,
> > >> > const char *propname);
> > >>
> > >> >
> > >> > that handles both, but then you have to change every driver
> > >> > that is already using of_property_read_bool() and that can
> > >> > get used with ACPI.
> > >>
> > >> It's actually not that easy in practice. There's not a one-to-one
> > >> correspondence between device tree nodes and struct devices in the
> > >> kernel. There are many bindings that use subnodes for sections of their
> > >> information, and so on.
> > >>
> > >> > An advantage of the dev_property_read_bool()
> > >> > interface however is that it would also work for platform
> > >> > devices that are created in platform code using
> > >> > platform_device_register_full() or similar if we add a way
> > >> > to define simple properties in C code. That would also simplify
> > >> > a lot of drivers that use both (simple) platform_data and DT
> > >> > today.
> > >>
> > >> I'm not a fan of this "grand unified abstraction layer". Driver writes are
> > >> already complaining that things are too complicated with the move to device
> > >> tree, and we're making things even more abstracted and complicated here. People
> > >> will need to peel back even more layers to figure out what's actually going on.
> > >>
> > >>
> > >> For the truly trivial stuff, there are some quite simple ways to handle this:
> > >>
> > >> 1. Make sure that anything that can be a named IORESOURCE_* is so. Which could
> > >> mean moving over GPIO and possibly clocks to that, and use those for lookup.
> > >>
> > >> 2. If Rafael's arguments are to be believed, that the translation should be
> > >> trivial and easy to do, then we might as well reuse the structures and APIs
> > >> that are already in the kernel. In other words, allocate a struct
> > >> device_node, populate it with the properties from the ACPI structure, and
> > >> attach it to the struct device. Then there's no need for any churn in the
> > >> drivers (until they need ACPI-specific tweaks, which they will all need).
> > >
> > > The problem with that is that we have either device_node or acpi_node.companion
> > > under struct device and they are mutually exclusive. So this isn't going to fly.
> > > [And it doesn't make sense to duplicate information already available from
> > > acpi_node.companion this way IMHO.]
> > >
> > > Also device references are problematic here, because both interfaces use
> > > different ways to do that (phandles vs object paths in the ACPI namespace).
> > >
> > > So actually, what Arnd proposed seems to be the simplest approach.
> >
> > Again, that suggestion assumes a 1:1 mapping between device nodes and
> > struct devices, which does not exist.
>
> I suppose your concern is that there may be device nodes without struct device,
> right? So drivers may need to access those device nodes directly?
>
> Can you please point me to code where this is the case?
gpio-keys.c is a good example, and the one I chose for the MinnowBoard
example last year.
This is a really good point. My thinking was that we iterate through the
devices - but I had my ACPI glasses on at the time and wasn't thinking
about how that iteration would work for DT in with the properties
abstraction.
The ACPI sub-devices do have something in common with the DT sub-nodes,
they are not themselves "compatible" with a specific driver, nor are the
known by the acpi_platform match table.
So in both cases we have effectively a hierarchy of properties. Could we
not support such a concept in the properties interface? The basic
signature might be something more like:
device_get_property(dev, NULL, "foo") // for the top level properties
We could have some kind of a foreach iterator for children, and
device_get_property(dev, child, "baz")
Thoughts?
--
Darren Hart
Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-13 21:14 ` Olof Johansson
2014-05-13 21:40 ` Rafael J. Wysocki
@ 2014-05-14 12:06 ` Arnd Bergmann
2014-05-14 12:25 ` Mark Brown
` (2 more replies)
2014-05-17 2:57 ` Darren Vincent Hart
2014-05-18 16:31 ` Linus Walleij
3 siblings, 3 replies; 90+ messages in thread
From: Arnd Bergmann @ 2014-05-14 12:06 UTC (permalink / raw)
To: Olof Johansson
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Tuesday 13 May 2014 14:14:42 Olof Johansson wrote:
> On Tue, May 06, 2014 at 03:35:41PM +0200, Arnd Bergmann wrote:
> > On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
> >
> > We should definitely be able to have an interface like this for
> > ACPI, but you don't have a 'struct device_node' pointer then.
> > We can add a new
> >
> > bool dev_property_read_bool(const struct device *dev,
> > const char *propname);
>
> >
> > that handles both, but then you have to change every driver
> > that is already using of_property_read_bool() and that can
> > get used with ACPI.
>
> It's actually not that easy in practice. There's not a one-to-one
> correspondence between device tree nodes and struct devices in the
> kernel. There are many bindings that use subnodes for sections of their
> information, and so on.
I also don't think we can have a grand unified solution to the general
problem, but doing the above would solve a lot of individual problems
for all the simple drivers that don't use sub-nodes in DT.
I really don't see any downsides to using a common named property
API for simple values in drivers that can.
Devices with sub-nodes are by definition complex to handle, and
I think we will always have cases that are too complex to use
a common interface. At the moment, we can share drivers that
have only memory and irq resources, which is a significant share
already. We can over time extend this to drivers that use strings,
booleans, integers, or arrays of those. We can also extend it
for things like gpios and dma-channels (both of which partly work
already but are limited when it comes to naming) and a few other
things.
> > An advantage of the dev_property_read_bool()
> > interface however is that it would also work for platform
> > devices that are created in platform code using
> > platform_device_register_full() or similar if we add a way
> > to define simple properties in C code. That would also simplify
> > a lot of drivers that use both (simple) platform_data and DT
> > today.
>
> I'm not a fan of this "grand unified abstraction layer". Driver writes are
> already complaining that things are too complicated with the move to device
> tree, and we're making things even more abstracted and complicated here. People
> will need to peel back even more layers to figure out what's actually going on.
>
>
> For the truly trivial stuff, there are some quite simple ways to handle this:
>
> 1. Make sure that anything that can be a named IORESOURCE_* is so. Which could
> mean moving over GPIO and possibly clocks to that, and use those for lookup.
We are actually moving away from IORESOURCE_* for things that are not
originally handled as resources. I don't think we should reverse that
course.
For both the examples I mentioned above (GPIO and DMA), people have in the
past put them into resource structures with a platform specific
interpretation. With the move to DT, we have actually broken this
because there is no longer a global number space for them in general.
Instead, you have a device pointer and a local name that you can use
to resolve a pointer to a structure (gpio descriptor or dma channel).
For GPIOs, we keep the integer based API for compatibility, but it would
be nice to move to the descriptor interface over time.
If it were not so much work, we'd probably also move away from IRQ numbers
towards passing IRQ descriptor pointers.
The way I see things moving forward for ACPI is to add a standard way to
name things (GPIOs, IRQs, DMAs, ...) so we can have a generic 'give me
a pointer to the X object for this device' for each subsystem we want to
have it for. Note that this would probably not be a combined interface
across subsystems though.
> The real problem is the non-trivial stuff. There, I think there's no real
> alternative than to teach the drivers about both firmware interfaces.
Agreed.
Arnd
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-14 12:06 ` Arnd Bergmann
@ 2014-05-14 12:25 ` Mark Brown
2014-05-18 16:34 ` Linus Walleij
2014-05-14 12:31 ` Rafael J. Wysocki
2014-05-17 3:02 ` Darren Vincent Hart
2 siblings, 1 reply; 90+ messages in thread
From: Mark Brown @ 2014-05-14 12:25 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
[-- Attachment #1: Type: text/plain, Size: 577 bytes --]
On Wed, May 14, 2014 at 02:06:10PM +0200, Arnd Bergmann wrote:
> The way I see things moving forward for ACPI is to add a standard way to
> name things (GPIOs, IRQs, DMAs, ...) so we can have a generic 'give me
> a pointer to the X object for this device' for each subsystem we want to
> have it for. Note that this would probably not be a combined interface
> across subsystems though.
And indeed we already have that interface in the kernel for most APIs
newer than GPIOs so in implementation terms this normally boils down to
adding an ACPI backend for looking things up.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-14 12:25 ` Mark Brown
@ 2014-05-18 16:34 ` Linus Walleij
0 siblings, 0 replies; 90+ messages in thread
From: Linus Walleij @ 2014-05-18 16:34 UTC (permalink / raw)
To: Mark Brown; +Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Wed, May 14, 2014 at 2:25 PM, Mark Brown <broonie@kernel.org> wrote:
> On Wed, May 14, 2014 at 02:06:10PM +0200, Arnd Bergmann wrote:
>
>> The way I see things moving forward for ACPI is to add a standard way to
>> name things (GPIOs, IRQs, DMAs, ...) so we can have a generic 'give me
>> a pointer to the X object for this device' for each subsystem we want to
>> have it for. Note that this would probably not be a combined interface
>> across subsystems though.
>
> And indeed we already have that interface in the kernel for most APIs
> newer than GPIOs so in implementation terms this normally boils down to
> adding an ACPI backend for looking things up.
We have this for GPIO too, just need to continue to roll it out.
And we have backends for DT and ACPI alike.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-14 12:06 ` Arnd Bergmann
2014-05-14 12:25 ` Mark Brown
@ 2014-05-14 12:31 ` Rafael J. Wysocki
2014-05-17 3:02 ` Darren Vincent Hart
2 siblings, 0 replies; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-14 12:31 UTC (permalink / raw)
To: ksummit-discuss; +Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki
On Wednesday, May 14, 2014 02:06:10 PM Arnd Bergmann wrote:
> On Tuesday 13 May 2014 14:14:42 Olof Johansson wrote:
> > On Tue, May 06, 2014 at 03:35:41PM +0200, Arnd Bergmann wrote:
> > > On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
> > >
> > > We should definitely be able to have an interface like this for
> > > ACPI, but you don't have a 'struct device_node' pointer then.
> > > We can add a new
> > >
> > > bool dev_property_read_bool(const struct device *dev,
> > > const char *propname);
> >
> > >
> > > that handles both, but then you have to change every driver
> > > that is already using of_property_read_bool() and that can
> > > get used with ACPI.
> >
> > It's actually not that easy in practice. There's not a one-to-one
> > correspondence between device tree nodes and struct devices in the
> > kernel. There are many bindings that use subnodes for sections of their
> > information, and so on.
>
> I also don't think we can have a grand unified solution to the general
> problem, but doing the above would solve a lot of individual problems
> for all the simple drivers that don't use sub-nodes in DT.
>
> I really don't see any downsides to using a common named property
> API for simple values in drivers that can.
I agree.
> Devices with sub-nodes are by definition complex to handle, and
> I think we will always have cases that are too complex to use
> a common interface. At the moment, we can share drivers that
> have only memory and irq resources, which is a significant share
> already. We can over time extend this to drivers that use strings,
> booleans, integers, or arrays of those. We can also extend it
> for things like gpios and dma-channels (both of which partly work
> already but are limited when it comes to naming) and a few other
> things.
Yes.
> > > An advantage of the dev_property_read_bool()
> > > interface however is that it would also work for platform
> > > devices that are created in platform code using
> > > platform_device_register_full() or similar if we add a way
> > > to define simple properties in C code. That would also simplify
> > > a lot of drivers that use both (simple) platform_data and DT
> > > today.
> >
> > I'm not a fan of this "grand unified abstraction layer". Driver writes are
> > already complaining that things are too complicated with the move to device
> > tree, and we're making things even more abstracted and complicated here. People
> > will need to peel back even more layers to figure out what's actually going on.
> >
> >
> > For the truly trivial stuff, there are some quite simple ways to handle this:
> >
> > 1. Make sure that anything that can be a named IORESOURCE_* is so. Which could
> > mean moving over GPIO and possibly clocks to that, and use those for lookup.
>
> We are actually moving away from IORESOURCE_* for things that are not
> originally handled as resources. I don't think we should reverse that
> course.
>
> For both the examples I mentioned above (GPIO and DMA), people have in the
> past put them into resource structures with a platform specific
> interpretation. With the move to DT, we have actually broken this
> because there is no longer a global number space for them in general.
>
> Instead, you have a device pointer and a local name that you can use
> to resolve a pointer to a structure (gpio descriptor or dma channel).
> For GPIOs, we keep the integer based API for compatibility, but it would
> be nice to move to the descriptor interface over time.
>
> If it were not so much work, we'd probably also move away from IRQ numbers
> towards passing IRQ descriptor pointers.
>
> The way I see things moving forward for ACPI is to add a standard way to
> name things (GPIOs, IRQs, DMAs, ...) so we can have a generic 'give me
> a pointer to the X object for this device' for each subsystem we want to
> have it for. Note that this would probably not be a combined interface
> across subsystems though.
That's my idea too.
Rafael
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-14 12:06 ` Arnd Bergmann
2014-05-14 12:25 ` Mark Brown
2014-05-14 12:31 ` Rafael J. Wysocki
@ 2014-05-17 3:02 ` Darren Vincent Hart
2 siblings, 0 replies; 90+ messages in thread
From: Darren Vincent Hart @ 2014-05-17 3:02 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Greg Kroah-Hartman, Rafael J. Wysocki, ksummit-discuss
On Wed, 2014-05-14 at 14:06 +0200, Arnd Bergmann wrote:
> On Tuesday 13 May 2014 14:14:42 Olof Johansson wrote:
> > On Tue, May 06, 2014 at 03:35:41PM +0200, Arnd Bergmann wrote:
> > > On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
> > >
> > > We should definitely be able to have an interface like this for
> > > ACPI, but you don't have a 'struct device_node' pointer then.
> > > We can add a new
> > >
> > > bool dev_property_read_bool(const struct device *dev,
> > > const char *propname);
> >
> > >
> > > that handles both, but then you have to change every driver
> > > that is already using of_property_read_bool() and that can
> > > get used with ACPI.
> >
> > It's actually not that easy in practice. There's not a one-to-one
> > correspondence between device tree nodes and struct devices in the
> > kernel. There are many bindings that use subnodes for sections of their
> > information, and so on.
>
> I also don't think we can have a grand unified solution to the general
> problem, but doing the above would solve a lot of individual problems
> for all the simple drivers that don't use sub-nodes in DT.
>
> I really don't see any downsides to using a common named property
> API for simple values in drivers that can.
>
> Devices with sub-nodes are by definition complex to handle, and
> I think we will always have cases that are too complex to use
> a common interface. At the moment, we can share drivers that
> have only memory and irq resources, which is a significant share
> already. We can over time extend this to drivers that use strings,
> booleans, integers, or arrays of those. We can also extend it
> for things like gpios and dma-channels (both of which partly work
> already but are limited when it comes to naming) and a few other
> things.
Agreed, well said.
--
Darren Hart
Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-13 21:14 ` Olof Johansson
2014-05-13 21:40 ` Rafael J. Wysocki
2014-05-14 12:06 ` Arnd Bergmann
@ 2014-05-17 2:57 ` Darren Vincent Hart
2014-05-18 16:31 ` Linus Walleij
3 siblings, 0 replies; 90+ messages in thread
From: Darren Vincent Hart @ 2014-05-17 2:57 UTC (permalink / raw)
To: Olof Johansson; +Cc: Rafael J. Wysocki, ksummit-discuss
On Tue, 2014-05-13 at 14:14 -0700, Olof Johansson wrote:
> On Tue, May 06, 2014 at 03:35:41PM +0200, Arnd Bergmann wrote:
> > On Tuesday 06 May 2014 14:18:56 Rafael J. Wysocki wrote:
> > > On Monday, May 05, 2014 09:31:04 PM Benjamin Herrenschmidt wrote:
> > > > On Mon, 2014-05-05 at 13:32 +0200, Rafael J. Wysocki wrote:
> > > > > The interpretation - yes, the translation - not necessarily. By putting
> > > > > the translation part into drivers we'll duplicate a lot of code used for
> > > > > that. In my opinion there needs to be a layer doing the translation
> > > > > automatically.
> > > >
> > > > I'm afraid I don't understand. How can you do the translation
> > > > automatically if you have fundamentally different representation of
> > > > device-specific concepts ?
> > >
> > > I'm not entirely sure how fundamentally different it is to be honest, but in
> > > any case I'm talking about the situation in which the hardware is the same
> > > and the driver is the same, only the firmware interface is different. In
> > > that case either the firmware supplies the information the driver needs, or
> > > it doesn't (and as long as the information is supplied, the format doesn't
> > > really matter, because it only is a matter of translation).
> >
> > One example for something that is fundamentally different between an
> > embedded system using DT and any ACPI system is how a PCI(e) host bridge
> > gets treated, we are currently having long discussions about this elsewhere.
> >
> > With ACPI (or a server running OF for that matter), you assume that the
> > PCI host is operational and all buses are fully probed and then you
> > have methods for doing hotplugging, you just look at the device that
> > are already initialized by the firmware.
> >
> > With embedded systems, you (in general, some steps may get skipped
> > in practice) go through a lot more steps:
> > - detect the presence of the host bridge device
> > - enable clocks, voltages, phys, resets, etc.
> > - set up inbound and outbound MMIO and PIO address translation windows
> > - perform a full bus scan and assign bus and device resources
> >
> > We probably woulnd't go through that hassle on ACPI systems. I think
> > we shouldn't attempt any translation here, and keep the code completely
> > separate, with the common parts being handled by the PCI core as we
> > do today.
> >
> > An example about a subsystem where translate complex information
> > from both DT and ACPI into a common format is the dmaengine: We can
> > have references to dma channels in completely incompatible ways
> > but still use the same dma_request_slave_channel() interface for
> > both. The ACPI path currently is lacking a bit (e.g. there is no
> > way to specify the channel name in ACPI, so the code makes
> > assumptions that don't hold true in general), but that's fixable.
> >
> > I assume we will see more of the second kind in the future, and this
> > would be limited to embedded systems on both ACPI and DT, since you
> > shouldn't see dma slave devices on general purpose systems with
> > either.
> >
> > > Bottom line: I'd like to avoid modifying drivers that use the of_ interface
> > > today if possible. Instead, I'd prefer to modify the firmware layer so that
> > > those drivers can get what they ask for regardless of what firmware interface
> > > the platform is using.
> >
> > Looking at the most trivial example:
> >
> > bool of_property_read_bool(const struct device_node *np, const char *propname);
> >
> > We should definitely be able to have an interface like this for
> > ACPI, but you don't have a 'struct device_node' pointer then.
> > We can add a new
> >
> > bool dev_property_read_bool(const struct device *dev,
> > const char *propname);
>
> >
> > that handles both, but then you have to change every driver
> > that is already using of_property_read_bool() and that can
> > get used with ACPI.
>
> It's actually not that easy in practice. There's not a one-to-one
> correspondence between device tree nodes and struct devices in the
> kernel. There are many bindings that use subnodes for sections of their
> information, and so on.
This is the approach that we have prototyped and demonstrated for some
admittedly trivial examples. One gap in my original approach was how to
deal with the DT sub-nodes - or rather didn't. The latest approach uses
a 1:1 device tree node to ACPI DEVICE object (which can also be nested
inside parent DEVICE objects in much the same way) and provide
properties to these sub nodes as well. This will at least provide us
with the ability to us the same schema with the same hiearchy.
>
> > An advantage of the dev_property_read_bool()
> > interface however is that it would also work for platform
> > devices that are created in platform code using
> > platform_device_register_full() or similar if we add a way
> > to define simple properties in C code. That would also simplify
> > a lot of drivers that use both (simple) platform_data and DT
> > today.
>
> I'm not a fan of this "grand unified abstraction layer". Driver writes are
> already complaining that things are too complicated with the move to device
> tree, and we're making things even more abstracted and complicated here. People
> will need to peel back even more layers to figure out what's actually going on.
>
I guess I can't argue with that since when I first started into this I
said very much the same thing about driver code being simple - but the
APIs being complicated (vs core kernel code which tends have very simple
APIs with some pretty complicated algorithms and such).
>
> For the truly trivial stuff, there are some quite simple ways to handle this:
>
> 1. Make sure that anything that can be a named IORESOURCE_* is so. Which could
> mean moving over GPIO and possibly clocks to that, and use those for lookup.
That's seems consistent with what one of our guiding principles has
been: We're looking to fill the gaps in ACPI, not replace the existing
mechanism. I will need to look into the IORESOURCE_* in more detail to
make sure I fully understand the implications.
>
> 2. If Rafael's arguments are to be believed, that the translation should be
> trivial and easy to do, then we might as well reuse the structures and APIs
> that are already in the kernel. In other words, allocate a struct
> device_node, populate it with the properties from the ACPI structure, and
> attach it to the struct device. Then there's no need for any churn in the
> drivers (until they need ACPI-specific tweaks, which they will all need).
>
There is some missing context that I think is confusing this issue.
Current ACPI tables don't translate like this. The new ACPI Device
Properties stuff in the works will provide the flexibility we need to
provide the missing properties in a format which is much more trivial to
translate. That is only part of the problem though.
>
> The real problem is the non-trivial stuff. There, I think there's no real
> alternative than to teach the drivers about both firmware interfaces.
I think it would help me a great deal to pick a driver and discuss it
specifically.
Olof - could you recommend one where you feel specific knowledge of
firmware interfaces is really unavoidable?
--
Darren Hart
Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-13 21:14 ` Olof Johansson
` (2 preceding siblings ...)
2014-05-17 2:57 ` Darren Vincent Hart
@ 2014-05-18 16:31 ` Linus Walleij
3 siblings, 0 replies; 90+ messages in thread
From: Linus Walleij @ 2014-05-18 16:31 UTC (permalink / raw)
To: Olof Johansson
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Tue, May 13, 2014 at 11:14 PM, Olof Johansson <olof@lixom.net> wrote:
> For the truly trivial stuff, there are some quite simple ways to handle this:
>
> 1. Make sure that anything that can be a named IORESOURCE_* is so. Which could
> mean moving over GPIO and possibly clocks to that, and use those for lookup.
GPIO consumers shall use devm_gpiod_get() or devm_gpiod_get_index()
to get an abstract GPIO descriptor. This already works with DT and ACPI
alike, driver authors just haven't caught up. Yes we have to patch ourselves
through this entire GPIO number exodus ...
Documentation/gpio/consumer.txt
GPIOs, clocks, regulators and pins are already on abstract handles
tied into the device model, so what am I missing?
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 8:43 ` Benjamin Herrenschmidt
2014-05-05 11:32 ` Rafael J. Wysocki
@ 2014-05-05 15:09 ` Rob Herring
2014-05-05 16:02 ` Jason Cooper
2014-05-05 22:55 ` Benjamin Herrenschmidt
2014-05-17 2:32 ` Darren Vincent Hart
2 siblings, 2 replies; 90+ messages in thread
From: Rob Herring @ 2014-05-05 15:09 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Mon, May 5, 2014 at 3:43 AM, Benjamin Herrenschmidt <benh@au1.ibm.com> wrote:
> On Sun, 2014-05-04 at 23:33 +0200, Rafael J. Wysocki wrote:
>>
>>
>> But we have such quirks for some bus types already, like PCI and PNP.
>
> And they suck big time. They duplicate definitions from the driver,
> they get missed at grep time, they bit rot, etc...
>
> There are a few cases where that's justified simply because the driver
> can be a module but the quirk needs to run early and always, but mostly
> these quirks are about working around HW bugs that would otherwise cause
> the system to misbehave even in absence of the driver.
>
> For example, bad class code in bridges, BAR issues, etc...
>
> Generally speaking though, quirks like that are a bad idea and in this
> case, totally unjustified since the code performing whatever translation
> is necessary (or interpretation) is entirely specific to the driver
> anyway.
On the flip side, DT entirely lacks any sort of infrastructure for
quirks other than match table data, and it handles various quirks
inline mostly. It's not so much of a problem now as much of PPC is
pretty stable and ARM is still a newcomer to DT, but I worry that we
have an impending problem as ARM DTs start to mature. So what is the
direction we want to go with quirks which can't be self-contained
within drivers?
Rob
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 15:09 ` Rob Herring
@ 2014-05-05 16:02 ` Jason Cooper
2014-05-05 16:41 ` Thomas Petazzoni
2014-05-05 22:55 ` Benjamin Herrenschmidt
1 sibling, 1 reply; 90+ messages in thread
From: Jason Cooper @ 2014-05-05 16:02 UTC (permalink / raw)
To: Rob Herring, Thomas Petazzoni, Gregory CLEMENT, Ezequiel Garcia,
Andrew Lunn, Sebastian Hesselbarth
Cc: Greg Kroah-Hartman, dvhart, Benjamin Herrenschmidt,
Rafael J. Wysocki, ksummit-discuss
On Mon, May 05, 2014 at 10:09:04AM -0500, Rob Herring wrote:
> On Mon, May 5, 2014 at 3:43 AM, Benjamin Herrenschmidt <benh@au1.ibm.com> wrote:
> > On Sun, 2014-05-04 at 23:33 +0200, Rafael J. Wysocki wrote:
> >>
> >>
> >> But we have such quirks for some bus types already, like PCI and PNP.
> >
> > And they suck big time. They duplicate definitions from the driver,
> > they get missed at grep time, they bit rot, etc...
> >
> > There are a few cases where that's justified simply because the driver
> > can be a module but the quirk needs to run early and always, but mostly
> > these quirks are about working around HW bugs that would otherwise cause
> > the system to misbehave even in absence of the driver.
> >
> > For example, bad class code in bridges, BAR issues, etc...
> >
> > Generally speaking though, quirks like that are a bad idea and in this
> > case, totally unjustified since the code performing whatever translation
> > is necessary (or interpretation) is entirely specific to the driver
> > anyway.
>
> On the flip side, DT entirely lacks any sort of infrastructure for
> quirks other than match table data, and it handles various quirks
> inline mostly. It's not so much of a problem now as much of PPC is
> pretty stable and ARM is still a newcomer to DT, but I worry that we
> have an impending problem as ARM DTs start to mature. So what is the
> direction we want to go with quirks which can't be self-contained
> within drivers?
regrettably, soc code. We (mvebu) have the good fortune to be
integrating mainline support for brand new SoCs from Marvell, as they
ship. Unfortunately, this means that the free-electron's guys
(contracted by Marvell to mainline the code) are having to work with
pre-release SoCs (Z1 stepping).
There are several quirks in the Z1 stepping that have required
workarounds, sometimes across subsystems. You can see some examples in
arch/arm/mach-mvebu/board-v7.c, eg:
static void __init mvebu_dt_init(void)
{
if (of_machine_is_compatible("plathome,openblocks-ax3-4"))
i2c_quirk();
if (of_machine_is_compatible("marvell,a375-db"))
thermal_quirk();
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
}
the quirk code then uses runtime detection to determine which SoC
stepping it is on, adjusts the compatible string and any other DT
nodes, as necessary.
The driver then gets the correct information from the DT, and we don't
have to maintain two dts files for a given board. The bigger benefit is
that the user never has to figure out which SoC stepping they have.
thx,
Jason.
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 16:02 ` Jason Cooper
@ 2014-05-05 16:41 ` Thomas Petazzoni
0 siblings, 0 replies; 90+ messages in thread
From: Thomas Petazzoni @ 2014-05-05 16:41 UTC (permalink / raw)
To: Jason Cooper
Cc: dvhart, Benjamin Herrenschmidt, ksummit-discuss,
Greg Kroah-Hartman, Rafael J. Wysocki, Sebastian Hesselbarth,
Ezequiel Garcia
Dear Jason Cooper,
On Mon, 5 May 2014 12:02:37 -0400, Jason Cooper wrote:
> > On the flip side, DT entirely lacks any sort of infrastructure for
> > quirks other than match table data, and it handles various quirks
> > inline mostly. It's not so much of a problem now as much of PPC is
> > pretty stable and ARM is still a newcomer to DT, but I worry that we
> > have an impending problem as ARM DTs start to mature. So what is the
> > direction we want to go with quirks which can't be self-contained
> > within drivers?
>
> regrettably, soc code. We (mvebu) have the good fortune to be
> integrating mainline support for brand new SoCs from Marvell, as they
> ship. Unfortunately, this means that the free-electron's guys
> (contracted by Marvell to mainline the code) are having to work with
> pre-release SoCs (Z1 stepping).
On the other hand, Rob was asking about "quirks which can't be
self-contained within drivers". And the two quirks below:
> static void __init mvebu_dt_init(void)
> {
> if (of_machine_is_compatible("plathome,openblocks-ax3-4"))
> i2c_quirk();
> if (of_machine_is_compatible("marvell,a375-db"))
> thermal_quirk();
could perfectly be fine be self-contained into the respective device
drivers. Actually, for the I2C quirk, it was even the original
implementation that my colleague Gregory Clement proposed. But this
approach was rejected, and we were asked to replace that by the current
approach: a quirk in the mach-mvebu SoC code that changes the
compatible string.
I continue to have the feeling that the strategy we have been asked to
use is going against the principle of having less stuff in mach-<foo>
directories.
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 15:09 ` Rob Herring
2014-05-05 16:02 ` Jason Cooper
@ 2014-05-05 22:55 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 90+ messages in thread
From: Benjamin Herrenschmidt @ 2014-05-05 22:55 UTC (permalink / raw)
To: Rob Herring
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Mon, 2014-05-05 at 10:09 -0500, Rob Herring wrote:
> On the flip side, DT entirely lacks any sort of infrastructure for
> quirks other than match table data, and it handles various quirks
> inline mostly. It's not so much of a problem now as much of PPC is
> pretty stable and ARM is still a newcomer to DT, but I worry that we
> have an impending problem as ARM DTs start to mature. So what is the
> direction we want to go with quirks which can't be self-contained
> within drivers?
I have a few cases with real OF already indeed. On Mac, I have a few
fixups where I "correct" bad device-trees. Additionally in the macio
device framework, I have additional workarounds. I would rather have
those in the drivers but that was the price of getting even the basic
resources right (those old Apple DTs were really really bad).
If we ever need to do things like that, I'd rather it's done in a
per-board fixup file that does the fixups once at boot.
Ben.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 8:43 ` Benjamin Herrenschmidt
2014-05-05 11:32 ` Rafael J. Wysocki
2014-05-05 15:09 ` Rob Herring
@ 2014-05-17 2:32 ` Darren Vincent Hart
2 siblings, 0 replies; 90+ messages in thread
From: Darren Vincent Hart @ 2014-05-17 2:32 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Mon, 2014-05-05 at 18:43 +1000, Benjamin Herrenschmidt wrote:
> On Sun, 2014-05-04 at 23:33 +0200, Rafael J. Wysocki wrote:
> >
> >
> > But we have such quirks for some bus types already, like PCI and PNP.
>
> And they suck big time. They duplicate definitions from the driver,
> they get missed at grep time, they bit rot, etc...
>
> There are a few cases where that's justified simply because the driver
> can be a module but the quirk needs to run early and always, but mostly
> these quirks are about working around HW bugs that would otherwise cause
> the system to misbehave even in absence of the driver.
>
> For example, bad class code in bridges, BAR issues, etc...
>
> Generally speaking though, quirks like that are a bad idea and in this
> case, totally unjustified since the code performing whatever translation
> is necessary (or interpretation) is entirely specific to the driver
> anyway.
>
> Also if the bindings evolve, you just created a 3rd way dependency.
> Instead of just having to deal with DT/ACPI binding version vs. driver
> version, we now have to also handle quirk versioning.
Hrm, I think I might have been answering only half of the question
earlier, and I might be confused about what Arnd, Olof, and you are
saying here.
I think the scope is larger than the specific problem I have been
focused on (which is the arbitrary device properties not covered by the
irq/mmio/gpio/etc mechanisms we already have), and making that
compatible with DT bindings.
Of course DT bindings include more than those arbitrary properties, and
I think it's here where we entered this format translation discussion?
As in:
ACPI:GpioIO and DT:gpios being possibly wrapped by another
representation? That is then translated into using the gpiod framework?
If so... yeah, that doesn't appeal to me very much either :-)
I said earlier that I would like to be able to collect this information
without having to know about the underlying firmware implementation in
the driver itself, ... is this necessarily the same thing as that third
representation?
It seems to me rather than parsing gpios or GpioIO representation,
drivers could instead ask dev_get_property_gpiod("volume_up"), and get
back a gpio descriptor, which is the interface they ultimately need to
use to do anything with it anyway.
I fear I might have veered way off into the weeds here... are we talking
past eachother?
> Yes, it could make more sense to translate the data to a common
> format and use the existing accessors for that data format, instead
> of reinventing the accessors and still needing to represent the data
> some way. I think it depends on how some of the other things develop
--
Darren Hart
Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-04 17:18 ` Olof Johansson
2014-05-04 17:27 ` Guenter Roeck
2014-05-04 21:33 ` Rafael J. Wysocki
@ 2014-05-05 8:39 ` Benjamin Herrenschmidt
2014-05-05 11:37 ` Rafael J. Wysocki
2014-05-07 11:05 ` David Woodhouse
2014-05-17 1:54 ` Darren Vincent Hart
3 siblings, 2 replies; 90+ messages in thread
From: Benjamin Herrenschmidt @ 2014-05-05 8:39 UTC (permalink / raw)
To: Olof Johansson
Cc: dvhart, ksummit-discuss, Rafael J. Wysocki, Greg Kroah-Hartman
On Sun, 2014-05-04 at 10:18 -0700, Olof Johansson wrote:
>
> Also, even if we do a common API with different backends, there will
> need to be some knowledge somewhere about custom bindings and what they mean,
> how to translate them and how the different descriptions correlate.
> I personally think we're best off putting that in the drivers, instead of
> making some part of the driver core aware of a bunch of quirks/hooks for
> various devices.
I tend to agree.
In the end, there is no silver bullet, however, it would make things easier
of the drivers could be structured such that for most things, when they need
a piece of information they use a single accessor to get named properties,
and if needed, they can have a single conversion function that converts ACPI
"stuff" into these (provided the ACPI extension for passing properties isn't
present, or possibly for translating "keys" between the bindings etc...).
IE. A single point of translation is less messy imho than sprinkling things
all over the driver, and we *will* need translation.
Now for standard stuff such as MMIO ranges etc... we all agree I believe to
stick to the existing Linux struct resource & co and have the parsing happen
at the core level, but for everything else, the trick is to see what we can
do to make driver life easier.
They *will* have to deal with the dual world, we can't completely hide it,
but we can make it less painful via good practices.
The other option is to have both the DT representation and the ACPI
representation reach the drivers and leave it to the them (the drivers) to get
through two different functions at probe time to "translates" that into a
"3rd" driver private one (a structure, in a way akin to the old platform data
but of course completely local to the driver scope).
I know of the drawbacks but for many drivers who already just pick these
things up at probe time just to copy/encode them into their driver private
structure, that's a fairly workable and simple approach.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 8:39 ` Benjamin Herrenschmidt
@ 2014-05-05 11:37 ` Rafael J. Wysocki
2014-05-07 11:05 ` David Woodhouse
1 sibling, 0 replies; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-05 11:37 UTC (permalink / raw)
To: ksummit-discuss; +Cc: dvhart, Rafael J. Wysocki, Greg Kroah-Hartman
On Monday, May 05, 2014 06:39:16 PM Benjamin Herrenschmidt wrote:
> On Sun, 2014-05-04 at 10:18 -0700, Olof Johansson wrote:
> >
> > Also, even if we do a common API with different backends, there will
> > need to be some knowledge somewhere about custom bindings and what they mean,
> > how to translate them and how the different descriptions correlate.
> > I personally think we're best off putting that in the drivers, instead of
> > making some part of the driver core aware of a bunch of quirks/hooks for
> > various devices.
>
> I tend to agree.
>
> In the end, there is no silver bullet, however, it would make things easier
> of the drivers could be structured such that for most things, when they need
> a piece of information they use a single accessor to get named properties,
> and if needed, they can have a single conversion function that converts ACPI
> "stuff" into these (provided the ACPI extension for passing properties isn't
> present, or possibly for translating "keys" between the bindings etc...).
>
> IE. A single point of translation is less messy imho than sprinkling things
> all over the driver, and we *will* need translation.
Precisely.
> Now for standard stuff such as MMIO ranges etc... we all agree I believe to
> stick to the existing Linux struct resource & co and have the parsing happen
> at the core level, but for everything else, the trick is to see what we can
> do to make driver life easier.
>
> They *will* have to deal with the dual world, we can't completely hide it,
> but we can make it less painful via good practices.
Probably.
> The other option is to have both the DT representation and the ACPI
> representation reach the drivers and leave it to the them (the drivers) to get
> through two different functions at probe time to "translates" that into a
> "3rd" driver private one (a structure, in a way akin to the old platform data
> but of course completely local to the driver scope).
>
> I know of the drawbacks but for many drivers who already just pick these
> things up at probe time just to copy/encode them into their driver private
> structure, that's a fairly workable and simple approach.
It may be workable from an individual driver point of view, but not from
a framework perspective. At least duplication of code has to be avoided.
Thanks!
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-05 8:39 ` Benjamin Herrenschmidt
2014-05-05 11:37 ` Rafael J. Wysocki
@ 2014-05-07 11:05 ` David Woodhouse
2014-05-07 13:06 ` Rafael J. Wysocki
2014-05-08 3:27 ` Benjamin Herrenschmidt
1 sibling, 2 replies; 90+ messages in thread
From: David Woodhouse @ 2014-05-07 11:05 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
[-- Attachment #1: Type: text/plain, Size: 878 bytes --]
On Mon, 2014-05-05 at 18:39 +1000, Benjamin Herrenschmidt wrote:
>
> The other option is to have both the DT representation and the ACPI
> representation reach the drivers and leave it to the them (the drivers) to get
> through two different functions at probe time to "translates" that into a
> "3rd" driver private one (a structure, in a way akin to the old platform data
> but of course completely local to the driver scope).
I don't like that much. For "leaf-node" device drivers, I think we're
better off with a simple set of "device_get_property" functions which
are a little more type-safe than the existing of_* ones, thus helping us
to deal with the details of 32-bit cells vs. ACPI integers, etc.
--
David Woodhouse Open Source Technology Centre
David.Woodhouse@intel.com Intel Corporation
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5745 bytes --]
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-07 11:05 ` David Woodhouse
@ 2014-05-07 13:06 ` Rafael J. Wysocki
2014-05-08 3:27 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-07 13:06 UTC (permalink / raw)
To: ksummit-discuss; +Cc: dvhart, Rafael J. Wysocki, Greg Kroah-Hartman
On Wednesday, May 07, 2014 12:05:02 PM David Woodhouse wrote:
>
> --===============1197259587839153410==
> Content-Type: multipart/signed; micalg="sha-1"; protocol="application/x-pkcs7-signature";
> boundary="=-0RE4bWH9BSP3Smq+x4xP"
>
>
> --=-0RE4bWH9BSP3Smq+x4xP
> Content-Type: text/plain; charset="UTF-8"
> Content-Transfer-Encoding: quoted-printable
>
> On Mon, 2014-05-05 at 18:39 +1000, Benjamin Herrenschmidt wrote:
> >=20
> > The other option is to have both the DT representation and the ACPI
> > representation reach the drivers and leave it to the them (the drivers) t=
> o get
> > through two different functions at probe time to "translates" that into a
> > "3rd" driver private one (a structure, in a way akin to the old platform =
> data
> > but of course completely local to the driver scope).
>
> I don't like that much. For "leaf-node" device drivers, I think we're
> better off with a simple set of "device_get_property" functions which
> are a little more type-safe than the existing of_* ones, thus helping us
> to deal with the details of 32-bit cells vs. ACPI integers, etc.
I agree.
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-07 11:05 ` David Woodhouse
2014-05-07 13:06 ` Rafael J. Wysocki
@ 2014-05-08 3:27 ` Benjamin Herrenschmidt
2014-05-17 2:05 ` Darren Vincent Hart
1 sibling, 1 reply; 90+ messages in thread
From: Benjamin Herrenschmidt @ 2014-05-08 3:27 UTC (permalink / raw)
To: David Woodhouse
Cc: Greg Kroah-Hartman, dvhart, Rafael J. Wysocki, ksummit-discuss
On Wed, 2014-05-07 at 12:05 +0100, David Woodhouse wrote:
> On Mon, 2014-05-05 at 18:39 +1000, Benjamin Herrenschmidt wrote:
> >
> > The other option is to have both the DT representation and the ACPI
> > representation reach the drivers and leave it to the them (the drivers) to get
> > through two different functions at probe time to "translates" that into a
> > "3rd" driver private one (a structure, in a way akin to the old platform data
> > but of course completely local to the driver scope).
>
> I don't like that much. For "leaf-node" device drivers, I think we're
> better off with a simple set of "device_get_property" functions which
> are a little more type-safe than the existing of_* ones, thus helping us
> to deal with the details of 32-bit cells vs. ACPI integers, etc.
Fair enough. I was mostly putting all options on the table. It is still
not completely clear on my mind how we'll get the properties from ACPI
(via that new scheme Darren's working on ?) and how good we'll manage to
keep the bindings in sync sufficiently to avoid a bunch of:
if (OF)
get_property("foo"...)
else
get_property("bar"...)
Because of subtle differences in property names, format, content, etc...
It might end up working out ... but it's going to be a constant battle
at least initially.
I'm mostly concerned here about device specific random attributes. I
think we all agree that the "common" stuff such as memory and irq is
going to be translated by the core into Linux native representation.
Of course there is going to be a pile of work defining the right
representation & translation for some of that "common" stuff in areas
like clocks, gpios, etc...
Cheers,
Ben.
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-08 3:27 ` Benjamin Herrenschmidt
@ 2014-05-17 2:05 ` Darren Vincent Hart
0 siblings, 0 replies; 90+ messages in thread
From: Darren Vincent Hart @ 2014-05-17 2:05 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: dvhart, ksummit-discuss, Greg Kroah-Hartman, Rafael J. Wysocki
On Thu, 2014-05-08 at 13:27 +1000, Benjamin Herrenschmidt wrote:
> On Wed, 2014-05-07 at 12:05 +0100, David Woodhouse wrote:
> > On Mon, 2014-05-05 at 18:39 +1000, Benjamin Herrenschmidt wrote:
> > >
> > > The other option is to have both the DT representation and the ACPI
> > > representation reach the drivers and leave it to the them (the drivers) to get
> > > through two different functions at probe time to "translates" that into a
> > > "3rd" driver private one (a structure, in a way akin to the old platform data
> > > but of course completely local to the driver scope).
> >
> > I don't like that much. For "leaf-node" device drivers, I think we're
> > better off with a simple set of "device_get_property" functions which
> > are a little more type-safe than the existing of_* ones, thus helping us
> > to deal with the details of 32-bit cells vs. ACPI integers, etc.
>
> Fair enough. I was mostly putting all options on the table. It is still
> not completely clear on my mind how we'll get the properties from ACPI
> (via that new scheme Darren's working on ?) and how good we'll manage to
> keep the bindings in sync sufficiently to avoid a bunch of:
>
> if (OF)
> get_property("foo"...)
> else
> get_property("bar"...)
>
> Because of subtle differences in property names, format, content, etc...
>
Right, we have to avoid this. I'd rather see:
get_of_pdata() and get_acpi_pdata() than a slew of if/else blocks
implementing slightly skewed schemas.
> It might end up working out ... but it's going to be a constant battle
> at least initially.
>
For the of-capable platform devices we have today, the above doesn't
even become an option. We switch to the new API dev_get_property("foo")
and people wanting to use these drivers with ACPI WILL use that schema.
I'm talking with a few of these folks a lot lately, and they absolutely
do not want to have to special case / rewrite all these drivers. All
they will have to do is add the DEVICE and Package() to the ASL and the
driver works. So it is in their best interest NOT to fragment the
schema.
> I'm mostly concerned here about device specific random attributes. I
Right, and this the area we're focused on with the new ACPI properties
mechanism. If ACPI already provides a specific object type, like for
GPIO, we continue to use that.
> think we all agree that the "common" stuff such as memory and irq is
> going to be translated by the core into Linux native representation.
>
> Of course there is going to be a pile of work defining the right
> representation & translation for some of that "common" stuff in areas
> like clocks, gpios, etc...
Nodding... :-)
--
Darren
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-04 17:18 ` Olof Johansson
` (2 preceding siblings ...)
2014-05-05 8:39 ` Benjamin Herrenschmidt
@ 2014-05-17 1:54 ` Darren Vincent Hart
2014-05-17 23:03 ` Benjamin Herrenschmidt
3 siblings, 1 reply; 90+ messages in thread
From: Darren Vincent Hart @ 2014-05-17 1:54 UTC (permalink / raw)
To: Olof Johansson
Cc: dvhart, ksummit-discuss, Rafael J. Wysocki, Greg Kroah-Hartman
On Sun, 2014-05-04 at 10:18 -0700, Olof Johansson wrote:
...
> Intel, on the other hand, are already shipping this hardware, and have
> a platforms to do the work on (Minnowboard and Galieo, for example).
>
> So, to address Arnd's original question:
>
> Yes, it could make more sense to translate the data to a common
> format and use the existing accessors for that data format, instead
> of reinventing the accessors and still needing to represent the data
In my opinion, the common dev_get_property() interface which calls the
appropriate firmware accessor function makes the most sense. Creating
another intermediate format which we then have to make into something
useful (like pdata) strikes me as unnecessary and likely limiting.
> some way. I think it depends on how some of the other things develop --
> I don't know enough about what Darren's current approach is, for example,
> to tell if it would be easier to do it that way.
Right, so let me give a trivial example indicating what this looks like.
In ASL (DSDT that ships with the board, or an SSDT that we add after the
fact - another discussion on how to integrate that at boot time, table
that for now), under the Device objection, you have a named object (not
a method) that provides a Package in a known format, something like:
Package () {
Package (2) { "label", "foo" },
Package (2) { "value", 1}
Package (2) { "devs_indices", Package { _SB.DEV1, 1, _SB.DEV2, 0 }
}
NOTE: I've pared off some implementation detail above just to focus on
what's relevant to this discussion. We're in a mad rush right now
between working group meetings, writing documentation to explain all
this, and discussing things here while we have people's attention. All
important, all time sensitive. I apologize for not just having a
complete wiki page to point everyone to - but we'll have something a lot
more concrete *very* shortly.
When the platform driver discovers pdata is NULL and that there is
firmware to be probed (dev exists), it starts populating a pdata
structure with calls like:
pdata.label = dev_get_property_string("label");
This would go through ACPICA to get the property on this device, but
could also go through OF on a different system, without any change to
the driver.
>
> Also, even if we do a common API with different backends, there will
> need to be some knowledge somewhere about custom bindings and what they mean,
> how to translate them and how the different descriptions correlate.
Of course there will be exceptions in the way certain things are
represented in each firmware type, but we already have accessors per
firmware type, so we have the groundwork to deal with those via
specific-property-type accessors.
> I personally think we're best off putting that in the drivers, instead of
> making some part of the driver core aware of a bunch of quirks/hooks for
> various devices.
Hrm, I was hoping to see it in the properties core (driver core I guess)
so we didn't have to see every driver. I suppose we could approach this
like we do subsystems in general. If we see something repeated enough,
we abstract it and move it down a level :-)
For example, DT and ACPI handle device references differently - but that
isn't a quirky device-specific kind of thing, it's a firmware
representation thing, and that should be abstracted away from the driver
IMO.
GPIO is another example (which is actually dependent on the phandle/ACPI
namespace difference).
Thanks,
--
Darren
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-17 1:54 ` Darren Vincent Hart
@ 2014-05-17 23:03 ` Benjamin Herrenschmidt
2014-05-18 20:28 ` Linus Walleij
0 siblings, 1 reply; 90+ messages in thread
From: Benjamin Herrenschmidt @ 2014-05-17 23:03 UTC (permalink / raw)
To: Darren Vincent Hart
Cc: dvhart, ksummit-discuss, Rafael J. Wysocki, Greg Kroah-Hartman
On Fri, 2014-05-16 at 18:54 -0700, Darren Vincent Hart wrote:
> In my opinion, the common dev_get_property() interface which calls the
> appropriate firmware accessor function makes the most sense. Creating
> another intermediate format which we then have to make into something
> useful (like pdata) strikes me as unnecessary and likely limiting.
So in the end it will really depend on whether people are good enough to
use the same property/value "names" and format accross the
representations.
So yes, maybe something like dev_get_property() would work fine for
most cases, which would be great. And for the always necessary quirks
where for example the ACPI variant used a wrong spelling or the DT
variant used a different size or something, the driver can either
openly call different of and acpi variants or we could have quirks in
the driver itself... ie, a pointer in struct device to a quirk table,
possibly based on hash of the name for fast lookup. But let's wait
for some real implementations to see how necessary that really is.
Ben.
> Right, so let me give a trivial example indicating what this looks like.
>
> In ASL (DSDT that ships with the board, or an SSDT that we add after the
> fact - another discussion on how to integrate that at boot time, table
> that for now), under the Device objection, you have a named object (not
> a method) that provides a Package in a known format, something like:
>
> Package () {
> Package (2) { "label", "foo" },
> Package (2) { "value", 1}
> Package (2) { "devs_indices", Package { _SB.DEV1, 1, _SB.DEV2, 0 }
> }
>
> NOTE: I've pared off some implementation detail above just to focus on
> what's relevant to this discussion. We're in a mad rush right now
> between working group meetings, writing documentation to explain all
> this, and discussing things here while we have people's attention. All
> important, all time sensitive. I apologize for not just having a
> complete wiki page to point everyone to - but we'll have something a lot
> more concrete *very* shortly.
>
> When the platform driver discovers pdata is NULL and that there is
> firmware to be probed (dev exists), it starts populating a pdata
> structure with calls like:
>
> pdata.label = dev_get_property_string("label");
>
> This would go through ACPICA to get the property on this device, but
> could also go through OF on a different system, without any change to
> the driver.
Very minor detail ... do we return the const string pointer or do we
return a copy of it that must be freed ? The latter give more latitude
for quirks or fancy ways to retrieve it in case it's not readily
available but at the expense of more driver complexity and resulting
mistakes causing leaks.
> Of course there will be exceptions in the way certain things are
> represented in each firmware type, but we already have accessors per
> firmware type, so we have the groundwork to deal with those via
> specific-property-type accessors.
Yes.
> > I personally think we're best off putting that in the drivers, instead of
> > making some part of the driver core aware of a bunch of quirks/hooks for
> > various devices.
>
> Hrm, I was hoping to see it in the properties core (driver core I guess)
> so we didn't have to see every driver. I suppose we could approach this
> like we do subsystems in general. If we see something repeated enough,
> we abstract it and move it down a level :-)
:-)
> For example, DT and ACPI handle device references differently - but that
> isn't a quirky device-specific kind of thing, it's a firmware
> representation thing, and that should be abstracted away from the driver
> IMO.
Yes. I agree. I was more thinking of "oops, this thing is an int on OF
and a string on ACPI" kind of accidental difference in device specific
properties, or spelling mistakes in property names (_ vs - etc...)
> GPIO is another example (which is actually dependent on the phandle/ACPI
> namespace difference).
Yes, anything that is generic such as resources, references etc...
should be handled there. What is related to a given subsystem (and
common accross drivers of that subsystem) should be handled at the
subsystem level of course, so GPIO fits that category.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-17 23:03 ` Benjamin Herrenschmidt
@ 2014-05-18 20:28 ` Linus Walleij
2014-05-18 16:12 ` Darren Vincent Hart
0 siblings, 1 reply; 90+ messages in thread
From: Linus Walleij @ 2014-05-18 20:28 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: dvhart, Rafael J. Wysocki, ksummit-discuss, Greg Kroah-Hartman
On Sun, May 18, 2014 at 1:03 AM, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> On Fri, 2014-05-16 at 18:54 -0700, Darren Vincent Hart wrote:
>
>> In my opinion, the common dev_get_property() interface which calls the
>> appropriate firmware accessor function makes the most sense. Creating
>> another intermediate format which we then have to make into something
>> useful (like pdata) strikes me as unnecessary and likely limiting.
>
> So in the end it will really depend on whether people are good enough to
> use the same property/value "names" and format accross the
> representations.
>
> So yes, maybe something like dev_get_property() would work fine for
> most cases, which would be great. And for the always necessary quirks
> where for example the ACPI variant used a wrong spelling or the DT
> variant used a different size or something, the driver can either
> openly call different of and acpi variants or we could have quirks in
> the driver itself... ie, a pointer in struct device to a quirk table,
> possibly based on hash of the name for fast lookup. But let's wait
> for some real implementations to see how necessary that really is.
This has already happened with GPIO as DT had named GPIOs
and ACPI yet had not, but could get GPIOs from a certain
index, which DT also could.
So:
gpios = <a, b>;
or:
foo-gpio = <a>;
bar-gpio = <b>;
Whereas in ACPI it would only be the former representation.
So the prototype had to be something like:
GPIO = gpiod_get_index(device, name, index);
So we first look for a named GPIO and if that doesn't work
we look for an indexed GPIO. All fine.
Anyway, then ACPI said they are going to introduce named
GPIOs so all is good. Or is it?
No, they can still choose a totally different name from what
DT is using. So we end up with code like this:
if (gpio = gpiod_get_index(device, "foo", index))
...
else if (gpio = giod_get_index(device, "bar", index))
...
That is however not enough since they can also disagree
with indexed values so that whereas the two GPIO pins
may be gpios = <a, b>; in DT nothing stops the ACPI
guys from putting it in order <b, a> and we get code to
compensate for that instead.
So there are, with the simple example of GPIO, already
a multitude of ways of shooting oneself in the foot, defining
bindings for the same hardware in incompatible ways and
generally screwing up.
And this almost already happened for RFkill but luckily
eventually we stayed clear of some of it by managing
to DEFINE that the RESET GPIO comes at index 0 and
SHUTDOWN GPIO comes at index 1, in BOTH
representations UNLESS they are named, and in that
case the name takes precedence and this file:
net/rfkill/rfkill-gpio.c
Is actually a good example of how things should look.
Looking at that file, do we all think this looks good?
And this is just until the day someone comes along
and admits they shipped a firmware with the GPIOs
swapped.
Beware that GPIO is a *simple* example...
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 90+ messages in thread
* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-18 20:28 ` Linus Walleij
@ 2014-05-18 16:12 ` Darren Vincent Hart
2014-05-19 20:53 ` Rafael J. Wysocki
0 siblings, 1 reply; 90+ messages in thread
From: Darren Vincent Hart @ 2014-05-18 16:12 UTC (permalink / raw)
To: Linus Walleij
Cc: dvhart, Rafael J. Wysocki, ksummit-discuss, Greg Kroah-Hartman
On Sun, 2014-05-18 at 22:28 +0200, Linus Walleij wrote:
> On Sun, May 18, 2014 at 1:03 AM, Benjamin Herrenschmidt
> <benh@kernel.crashing.org> wrote:
> > On Fri, 2014-05-16 at 18:54 -0700, Darren Vincent Hart wrote:
> >
> >> In my opinion, the common dev_get_property() interface which calls the
> >> appropriate firmware accessor function makes the most sense. Creating
> >> another intermediate format which we then have to make into something
> >> useful (like pdata) strikes me as unnecessary and likely limiting.
> >
> > So in the end it will really depend on whether people are good enough to
> > use the same property/value "names" and format accross the
> > representations.
> >
> > So yes, maybe something like dev_get_property() would work fine for
> > most cases, which would be great. And for the always necessary quirks
> > where for example the ACPI variant used a wrong spelling or the DT
> > variant used a different size or something, the driver can either
> > openly call different of and acpi variants or we could have quirks in
> > the driver itself... ie, a pointer in struct device to a quirk table,
> > possibly based on hash of the name for fast lookup. But let's wait
> > for some real implementations to see how necessary that really is.
>
> This has already happened with GPIO as DT had named GPIOs
> and ACPI yet had not, but could get GPIOs from a certain
> index, which DT also could.
>
> So:
>
> gpios = <a, b>;
>
> or:
>
> foo-gpio = <a>;
> bar-gpio = <b>;
>
> Whereas in ACPI it would only be the former representation.
> So the prototype had to be something like:
>
> GPIO = gpiod_get_index(device, name, index);
>
> So we first look for a named GPIO and if that doesn't work
> we look for an indexed GPIO. All fine.
>
> Anyway, then ACPI said they are going to introduce named
> GPIOs so all is good. Or is it?
>
> No, they can still choose a totally different name from what
> DT is using. So we end up with code like this:
>
> if (gpio = gpiod_get_index(device, "foo", index))
> ...
> else if (gpio = giod_get_index(device, "bar", index))
> ...
>
> That is however not enough since they can also disagree
> with indexed values so that whereas the two GPIO pins
> may be gpios = <a, b>; in DT nothing stops the ACPI
> guys from putting it in order <b, a> and we get code to
> compensate for that instead.
I see two distinct problems being raised. One on equivalent mechanisms,
and one on parameterization.
With respect to mechanism, it is my understanding that ACPI 5.0 does
provide for GpioIO pin lists, but for some reason, those are rarely used
(and not implemented in the Linux ACPICA). However, it seems to me those
could be used in the same way as <function>-gpios in DT land.
While independent from the ACPI Device Properties work we have been
working on, I wonder if we could address this in some of the
documentation we're preparing as well - as it is intended to document
best practice, and the properties need to interact with the already
defined resource types, such as GPIO.
Rafael - what do you think?
As for parameterization like the function name ("foo" or "bar"), or
which "index", that is what the DT and ACPI Device Properties are meant
to abstract, so I don't see this as a problem. Rather than if/else
blocks in the code as you've described above, those names and indexes
should be read from the device properties.
>
> So there are, with the simple example of GPIO, already
> a multitude of ways of shooting oneself in the foot, defining
> bindings for the same hardware in incompatible ways and
> generally screwing up.
>
> And this almost already happened for RFkill but luckily
> eventually we stayed clear of some of it by managing
> to DEFINE that the RESET GPIO comes at index 0 and
> SHUTDOWN GPIO comes at index 1, in BOTH
> representations UNLESS they are named, and in that
> case the name takes precedence and this file:
> net/rfkill/rfkill-gpio.c
>
> Is actually a good example of how things should look.
>
> Looking at that file, do we all think this looks good?
Thanks, concrete examples are usually helpful.
It is a good example I think. The only bit I don't like is that
acpi_find_gpio ignores con_id. I'm sure there is a lot of context here
as to why - probably mostly surrounding the fact that while ACPI *CAN*
do this, there hasn't been a standard way of doing it and therefor
nothing we could reliably abstract... I'd like to see if we can improve
that.
--
Darren Hart
Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 90+ messages in thread* Re: [Ksummit-discuss] [TECH TOPIC] Driver model/resources, ACPI, DT, etc (sigh)
2014-05-18 16:12 ` Darren Vincent Hart
@ 2014-05-19 20:53 ` Rafael J. Wysocki
0 siblings, 0 replies; 90+ messages in thread
From: Rafael J. Wysocki @ 2014-05-19 20:53 UTC (permalink / raw)
To: ksummit-discuss; +Cc: Rafael J. Wysocki, dvhart, Greg Kroah-Hartman
On Sunday, May 18, 2014 09:12:21 AM Darren Vincent Hart wrote:
> On Sun, 2014-05-18 at 22:28 +0200, Linus Walleij wrote:
> > On Sun, May 18, 2014 at 1:03 AM, Benjamin Herrenschmidt
> > <benh@kernel.crashing.org> wrote:
> > > On Fri, 2014-05-16 at 18:54 -0700, Darren Vincent Hart wrote:
> > >
> > >> In my opinion, the common dev_get_property() interface which calls the
> > >> appropriate firmware accessor function makes the most sense. Creating
> > >> another intermediate format which we then have to make into something
> > >> useful (like pdata) strikes me as unnecessary and likely limiting.
> > >
> > > So in the end it will really depend on whether people are good enough to
> > > use the same property/value "names" and format accross the
> > > representations.
> > >
> > > So yes, maybe something like dev_get_property() would work fine for
> > > most cases, which would be great. And for the always necessary quirks
> > > where for example the ACPI variant used a wrong spelling or the DT
> > > variant used a different size or something, the driver can either
> > > openly call different of and acpi variants or we could have quirks in
> > > the driver itself... ie, a pointer in struct device to a quirk table,
> > > possibly based on hash of the name for fast lookup. But let's wait
> > > for some real implementations to see how necessary that really is.
> >
> > This has already happened with GPIO as DT had named GPIOs
> > and ACPI yet had not, but could get GPIOs from a certain
> > index, which DT also could.
> >
> > So:
> >
> > gpios = <a, b>;
> >
> > or:
> >
> > foo-gpio = <a>;
> > bar-gpio = <b>;
> >
> > Whereas in ACPI it would only be the former representation.
> > So the prototype had to be something like:
> >
> > GPIO = gpiod_get_index(device, name, index);
> >
> > So we first look for a named GPIO and if that doesn't work
> > we look for an indexed GPIO. All fine.
> >
> > Anyway, then ACPI said they are going to introduce named
> > GPIOs so all is good. Or is it?
> >
> > No, they can still choose a totally different name from what
> > DT is using. So we end up with code like this:
> >
> > if (gpio = gpiod_get_index(device, "foo", index))
> > ...
> > else if (gpio = giod_get_index(device, "bar", index))
> > ...
> >
> > That is however not enough since they can also disagree
> > with indexed values so that whereas the two GPIO pins
> > may be gpios = <a, b>; in DT nothing stops the ACPI
> > guys from putting it in order <b, a> and we get code to
> > compensate for that instead.
>
> I see two distinct problems being raised. One on equivalent mechanisms,
> and one on parameterization.
>
> With respect to mechanism, it is my understanding that ACPI 5.0 does
> provide for GpioIO pin lists, but for some reason, those are rarely used
> (and not implemented in the Linux ACPICA). However, it seems to me those
> could be used in the same way as <function>-gpios in DT land.
>
> While independent from the ACPI Device Properties work we have been
> working on, I wonder if we could address this in some of the
> documentation we're preparing as well - as it is intended to document
> best practice, and the properties need to interact with the already
> defined resource types, such as GPIO.
>
> Rafael - what do you think?
That depends on what part of the spec you're referring to in particular.
Care to be more specific?
> As for parameterization like the function name ("foo" or "bar"), or
> which "index", that is what the DT and ACPI Device Properties are meant
> to abstract, so I don't see this as a problem. Rather than if/else
> blocks in the code as you've described above, those names and indexes
> should be read from the device properties.
Well, gpiod_get() takes a *name* and that's the preferred interface if
my understanding is correct. There's no mechanism in ACPI I'm aware of that
can allow a name to be associated with a GPIO pin (or a list of pins for
that matter).
> > So there are, with the simple example of GPIO, already
> > a multitude of ways of shooting oneself in the foot, defining
> > bindings for the same hardware in incompatible ways and
> > generally screwing up.
> >
> > And this almost already happened for RFkill but luckily
> > eventually we stayed clear of some of it by managing
> > to DEFINE that the RESET GPIO comes at index 0 and
> > SHUTDOWN GPIO comes at index 1, in BOTH
> > representations UNLESS they are named, and in that
> > case the name takes precedence and this file:
> > net/rfkill/rfkill-gpio.c
Well, yeah.
> > Is actually a good example of how things should look.
> >
> > Looking at that file, do we all think this looks good?
>
> Thanks, concrete examples are usually helpful.
>
> It is a good example I think. The only bit I don't like is that
> acpi_find_gpio ignores con_id.
Precisely. And it can't do anything else ATM.
> I'm sure there is a lot of context here
> as to why - probably mostly surrounding the fact that while ACPI *CAN*
Or can it? How exactly?
> do this, there hasn't been a standard way of doing it and therefor
> nothing we could reliably abstract... I'd like to see if we can improve
> that.
Well, me too. :-)
Rafael
^ permalink raw reply [flat|nested] 90+ messages in thread