Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1471046 > unrolled thread

Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver

Started byDave Gerlach <d-gerlach@ti.com>
First post2016-08-27 01:40 +0200
Last post2016-09-08 11:20 +0200
Articles 10 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver Dave Gerlach <d-gerlach@ti.com> - 2016-08-27 01:40 +0200
    Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver Dave Gerlach <d-gerlach@ti.com> - 2016-08-30 21:50 +0200
      Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver Ulf Hansson <ulf.hansson@linaro.org> - 2016-08-30 22:30 +0200
        Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver Dave Gerlach <d-gerlach@ti.com> - 2016-09-06 22:30 +0200
          Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver Kevin Hilman <khilman@baylibre.com> - 2016-09-07 20:40 +0200
            Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver Ulf Hansson <ulf.hansson@linaro.org> - 2016-09-08 11:30 +0200
              Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver Kevin Hilman <khilman@baylibre.com> - 2016-09-08 19:40 +0200
                Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver Dave Gerlach <d-gerlach@ti.com> - 2016-09-08 20:10 +0200
                Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver Ulf Hansson <ulf.hansson@linaro.org> - 2016-09-09 10:40 +0200
          Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver Ulf Hansson <ulf.hansson@linaro.org> - 2016-09-08 11:20 +0200

#1471046 — Re: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver

FromDave Gerlach <d-gerlach@ti.com>
Date2016-08-27 01:40 +0200
SubjectRe: [PATCH 3/3] soc: ti: Add ti_sci_pm_domains driver
Message-ID<sayT7-5gm-9@gated-at.bofh.it>
Hi,
On 08/25/2016 02:27 AM, Ulf Hansson wrote:
> + Jon
>
> [...]
>
>> +
>> +static int ti_sci_pm_domains_probe(struct platform_device *pdev)
>> +{
>> +       struct device *dev = &pdev->dev;
>> +       struct device_node *np = dev->of_node;
>> +       struct ti_sci_genpd_data *ti_sci_genpd;
>> +
>> +       ti_sci_genpd = devm_kzalloc(dev, sizeof(*ti_sci_genpd), GFP_KERNEL);
>> +       if (!ti_sci_genpd)
>> +               return -ENOMEM;
>> +
>> +       ti_sci_genpd->ti_sci = devm_ti_sci_get_handle(dev);
>> +       if (IS_ERR(ti_sci_genpd->ti_sci))
>> +               return PTR_ERR(ti_sci_genpd->ti_sci);
>> +
>> +       ti_sci_genpd->dev = dev;
>> +
>> +       INIT_LIST_HEAD(&ti_sci_genpd->pd_list);
>> +       mutex_init(&ti_sci_genpd->pd_list_mutex);
>> +
>> +       return __of_genpd_add_provider(np, of_ti_sci_genpd_xlate_onecell,
>> +                                      ti_sci_genpd);
>
> Jon Hunter are working on adding robust method to be able to remove
> initialized genpds [1].
>
> In that series we intend to remove the __of_genpd_add_provider() API,
> and instead only have of_genpd_add_provider_onecell() and
> of_genpd_add_provider_simple(). Could you please convert to use any of
> these APIs instead?

Thanks for pointing this out. I took at look at the series you've linked and the
short answer is that I see no good way to directly convert what we've done to
use those APIs.

On this platform each device has it's power state controlled through the SCI
protocol described in the cover letter. The system makes a request for powering
on or off the device using a unique ID number for each device, as provided in
patches 1 and 2. These operations map to those of a genpd, so we decided to do a
1:1 device to genpd mapping, where each device has it's own genpd.

The split that we took from the provided simple and onecell xlate functions
arises from this mapping. The IDs are not necessarily linear and also they are
not necessarily defined in a fixed way for all SoCs, they are entirely data
driven based on the provided device ID. To make use of these IDs, I created a
new xlate function that takes a onecell value but instead dynamically allocates
a new genpd, at probe time, to give us a genpd that contains the necessary SoC
specific data for that device that probed and is mapped directly to the device.
This lets us only create the genpds we need without having to redefine a static
list of all possible genpds and duplicate the data.

So my question back would be, how critical is it to be able to drop the ability
to provide custom xlate functions?

Regards,
Dave

>
> Kind regards
> Uffe
>
> [1]
> http://www.spinics.net/lists/arm-kernel/msg524151.html
>

[toc] | [next] | [standalone]


#1472816

FromDave Gerlach <d-gerlach@ti.com>
Date2016-08-30 21:50 +0200
Message-ID<sbXcJ-L7-13@gated-at.bofh.it>
In reply to#1471046
Jon, Ulf,
On 08/26/2016 06:37 PM, Dave Gerlach wrote:
> Hi,
> On 08/25/2016 02:27 AM, Ulf Hansson wrote:
>> + Jon
>>
>> [...]
>>
>>> +
>>> +static int ti_sci_pm_domains_probe(struct platform_device *pdev)
>>> +{
>>> +       struct device *dev = &pdev->dev;
>>> +       struct device_node *np = dev->of_node;
>>> +       struct ti_sci_genpd_data *ti_sci_genpd;
>>> +
>>> +       ti_sci_genpd = devm_kzalloc(dev, sizeof(*ti_sci_genpd), GFP_KERNEL);
>>> +       if (!ti_sci_genpd)
>>> +               return -ENOMEM;
>>> +
>>> +       ti_sci_genpd->ti_sci = devm_ti_sci_get_handle(dev);
>>> +       if (IS_ERR(ti_sci_genpd->ti_sci))
>>> +               return PTR_ERR(ti_sci_genpd->ti_sci);
>>> +
>>> +       ti_sci_genpd->dev = dev;
>>> +
>>> +       INIT_LIST_HEAD(&ti_sci_genpd->pd_list);
>>> +       mutex_init(&ti_sci_genpd->pd_list_mutex);
>>> +
>>> +       return __of_genpd_add_provider(np, of_ti_sci_genpd_xlate_onecell,
>>> +                                      ti_sci_genpd);
>>
>> Jon Hunter are working on adding robust method to be able to remove
>> initialized genpds [1].
>>
>> In that series we intend to remove the __of_genpd_add_provider() API,
>> and instead only have of_genpd_add_provider_onecell() and
>> of_genpd_add_provider_simple(). Could you please convert to use any of
>> these APIs instead?
>
> Thanks for pointing this out. I took at look at the series you've linked and the
> short answer is that I see no good way to directly convert what we've done to
> use those APIs.
>
> On this platform each device has it's power state controlled through the SCI
> protocol described in the cover letter. The system makes a request for powering
> on or off the device using a unique ID number for each device, as provided in
> patches 1 and 2. These operations map to those of a genpd, so we decided to do a
> 1:1 device to genpd mapping, where each device has it's own genpd.
>
> The split that we took from the provided simple and onecell xlate functions
> arises from this mapping. The IDs are not necessarily linear and also they are
> not necessarily defined in a fixed way for all SoCs, they are entirely data
> driven based on the provided device ID. To make use of these IDs, I created a
> new xlate function that takes a onecell value but instead dynamically allocates
> a new genpd, at probe time, to give us a genpd that contains the necessary SoC
> specific data for that device that probed and is mapped directly to the device.
> This lets us only create the genpds we need without having to redefine a static
> list of all possible genpds and duplicate the data.
>
> So my question back would be, how critical is it to be able to drop the ability
> to provide custom xlate functions?

After thinking about this a bit more, I believe I see a way we can use 
the of_genpd_add_provider_onecell, although not optimally. The device 
IDs, and therefore the genpd IDs (in the last email I mentioned we are 
doing a 1:1 device to genpd mapping) are fixed and defined by the 
hardware, and are not linear, there can be gaps and we won't necessarily 
always start at 0 even though we do on this SoC. However, we could build 
an array of genpds that map to our IDs similar to how several have done 
it, like in drivers/soc/bcm/raspberrypi-power.c, but because our IDs can 
have gaps, there will be unused struct generic_pm_domains that get 
allocated and are never touched because the index of the element doesn't 
correspond to a genpd ID.

Based on the ID set provided in patch 2 of this series I see 12 gaps, so 
we'd be wasting space the size of 12 genpds. The ID mapping will change 
on future SoCs, so this number could be larger. Do you think this is an 
acceptable solution? It allows us to play nice with the new genpd 
framework changes at the cost of wasting some space allocated to filler 
genpds.

Regards,
Dave

>
> Regards,
> Dave
>
>>
>> Kind regards
>> Uffe
>>
>> [1]
>> http://www.spinics.net/lists/arm-kernel/msg524151.html
>>
>

[toc] | [prev] | [next] | [standalone]


#1472844

FromUlf Hansson <ulf.hansson@linaro.org>
Date2016-08-30 22:30 +0200
Message-ID<sbXPr-1hr-13@gated-at.bofh.it>
In reply to#1472816
On 30 August 2016 at 21:43, Dave Gerlach <d-gerlach@ti.com> wrote:
> Jon, Ulf,
>
> On 08/26/2016 06:37 PM, Dave Gerlach wrote:
>>
>> Hi,
>> On 08/25/2016 02:27 AM, Ulf Hansson wrote:
>>>
>>> + Jon
>>>
>>> [...]
>>>
>>>> +
>>>> +static int ti_sci_pm_domains_probe(struct platform_device *pdev)
>>>> +{
>>>> +       struct device *dev = &pdev->dev;
>>>> +       struct device_node *np = dev->of_node;
>>>> +       struct ti_sci_genpd_data *ti_sci_genpd;
>>>> +
>>>> +       ti_sci_genpd = devm_kzalloc(dev, sizeof(*ti_sci_genpd),
>>>> GFP_KERNEL);
>>>> +       if (!ti_sci_genpd)
>>>> +               return -ENOMEM;
>>>> +
>>>> +       ti_sci_genpd->ti_sci = devm_ti_sci_get_handle(dev);
>>>> +       if (IS_ERR(ti_sci_genpd->ti_sci))
>>>> +               return PTR_ERR(ti_sci_genpd->ti_sci);
>>>> +
>>>> +       ti_sci_genpd->dev = dev;
>>>> +
>>>> +       INIT_LIST_HEAD(&ti_sci_genpd->pd_list);
>>>> +       mutex_init(&ti_sci_genpd->pd_list_mutex);
>>>> +
>>>> +       return __of_genpd_add_provider(np,
>>>> of_ti_sci_genpd_xlate_onecell,
>>>> +                                      ti_sci_genpd);
>>>
>>>
>>> Jon Hunter are working on adding robust method to be able to remove
>>> initialized genpds [1].
>>>
>>> In that series we intend to remove the __of_genpd_add_provider() API,
>>> and instead only have of_genpd_add_provider_onecell() and
>>> of_genpd_add_provider_simple(). Could you please convert to use any of
>>> these APIs instead?
>>
>>
>> Thanks for pointing this out. I took at look at the series you've linked
>> and the
>> short answer is that I see no good way to directly convert what we've done
>> to
>> use those APIs.
>>
>> On this platform each device has it's power state controlled through the
>> SCI
>> protocol described in the cover letter. The system makes a request for
>> powering
>> on or off the device using a unique ID number for each device, as provided
>> in
>> patches 1 and 2. These operations map to those of a genpd, so we decided
>> to do a
>> 1:1 device to genpd mapping, where each device has it's own genpd.
>>
>> The split that we took from the provided simple and onecell xlate
>> functions
>> arises from this mapping. The IDs are not necessarily linear and also they
>> are
>> not necessarily defined in a fixed way for all SoCs, they are entirely
>> data
>> driven based on the provided device ID. To make use of these IDs, I
>> created a
>> new xlate function that takes a onecell value but instead dynamically
>> allocates
>> a new genpd, at probe time, to give us a genpd that contains the necessary
>> SoC
>> specific data for that device that probed and is mapped directly to the
>> device.
>> This lets us only create the genpds we need without having to redefine a
>> static
>> list of all possible genpds and duplicate the data.
>>
>> So my question back would be, how critical is it to be able to drop the
>> ability
>> to provide custom xlate functions?
>
>
> After thinking about this a bit more, I believe I see a way we can use the
> of_genpd_add_provider_onecell, although not optimally. The device IDs, and
> therefore the genpd IDs (in the last email I mentioned we are doing a 1:1
> device to genpd mapping) are fixed and defined by the hardware, and are not
> linear, there can be gaps and we won't necessarily always start at 0 even
> though we do on this SoC. However, we could build an array of genpds that
> map to our IDs similar to how several have done it, like in
> drivers/soc/bcm/raspberrypi-power.c, but because our IDs can have gaps,
> there will be unused struct generic_pm_domains that get allocated and are
> never touched because the index of the element doesn't correspond to a genpd
> ID.

There are a couple of ways to solve your problem without having to
create one genpd instance for each of the platform devices. As a
matter of fact, I think that approach should be avoided if possible.
Genpd isn't designed for these kind purposes, even if it can be done
like that.

Here are some ideas which could be used to solve the problem differently.

*)
Assuming each platform device has a driver for it!?
Then why don't you implement the ->runtime_suspend|resume() callbacks
on the driver level and call the SCI interface to power on/off the
device from there? This ought to be the most straight forward
solution.


**)
You may also use genpd's (struct generic_pm_domain)
->attach|detach_dev() callbacks to create the device specific data
(the SCI device ID). The ->attach_dev() callback are invoked when a
device gets attached to its PM domain (genpd) at probe time.

Currently these callbacks are already being used by SoCs that uses the
PM clk API from a genpd client. That is needed to create the device
specific PM clock list. We would have to do something similar here for
the SCI device IDs.

Then, you must also assign/implement the ->start() and ->stop()
callbacks of the struct gpd_dev_ops, which is a part of the genpd
struct. These callbacks can then easily invoke SoC specific code/APIs
and perhaps that is the issue with my first suggested approach!?

>
> Based on the ID set provided in patch 2 of this series I see 12 gaps, so
> we'd be wasting space the size of 12 genpds. The ID mapping will change on
> future SoCs, so this number could be larger. Do you think this is an
> acceptable solution? It allows us to play nice with the new genpd framework
> changes at the cost of wasting some space allocated to filler genpds.

There are other issues as well, which mostly has do to with a
unnecessary long execution path, involving taking mutexes etc in
genpd.

All you actually need, is to be able to power on/off a device from a
driver's ->runtime_suspend|resume() callback. Don't you think?

Kind regards
Uffe

[toc] | [prev] | [next] | [standalone]


#1477807

FromDave Gerlach <d-gerlach@ti.com>
Date2016-09-06 22:30 +0200
Message-ID<sevai-6LS-15@gated-at.bofh.it>
In reply to#1472844
On 08/30/2016 03:26 PM, Ulf Hansson wrote:
> On 30 August 2016 at 21:43, Dave Gerlach <d-gerlach@ti.com> wrote:
>> Jon, Ulf,
>>
>> On 08/26/2016 06:37 PM, Dave Gerlach wrote:
>>>
>>> Hi,
>>> On 08/25/2016 02:27 AM, Ulf Hansson wrote:
>>>>
>>>> + Jon
>>>>
>>>> [...]
>>>>
>>>>> +
>>>>> +static int ti_sci_pm_domains_probe(struct platform_device *pdev)
>>>>> +{
>>>>> +       struct device *dev = &pdev->dev;
>>>>> +       struct device_node *np = dev->of_node;
>>>>> +       struct ti_sci_genpd_data *ti_sci_genpd;
>>>>> +
>>>>> +       ti_sci_genpd = devm_kzalloc(dev, sizeof(*ti_sci_genpd),
>>>>> GFP_KERNEL);
>>>>> +       if (!ti_sci_genpd)
>>>>> +               return -ENOMEM;
>>>>> +
>>>>> +       ti_sci_genpd->ti_sci = devm_ti_sci_get_handle(dev);
>>>>> +       if (IS_ERR(ti_sci_genpd->ti_sci))
>>>>> +               return PTR_ERR(ti_sci_genpd->ti_sci);
>>>>> +
>>>>> +       ti_sci_genpd->dev = dev;
>>>>> +
>>>>> +       INIT_LIST_HEAD(&ti_sci_genpd->pd_list);
>>>>> +       mutex_init(&ti_sci_genpd->pd_list_mutex);
>>>>> +
>>>>> +       return __of_genpd_add_provider(np,
>>>>> of_ti_sci_genpd_xlate_onecell,
>>>>> +                                      ti_sci_genpd);
>>>>
>>>>
>>>> Jon Hunter are working on adding robust method to be able to remove
>>>> initialized genpds [1].
>>>>
>>>> In that series we intend to remove the __of_genpd_add_provider() API,
>>>> and instead only have of_genpd_add_provider_onecell() and
>>>> of_genpd_add_provider_simple(). Could you please convert to use any of
>>>> these APIs instead?
>>>
>>>
>>> Thanks for pointing this out. I took at look at the series you've linked
>>> and the
>>> short answer is that I see no good way to directly convert what we've done
>>> to
>>> use those APIs.
>>>
>>> On this platform each device has it's power state controlled through the
>>> SCI
>>> protocol described in the cover letter. The system makes a request for
>>> powering
>>> on or off the device using a unique ID number for each device, as provided
>>> in
>>> patches 1 and 2. These operations map to those of a genpd, so we decided
>>> to do a
>>> 1:1 device to genpd mapping, where each device has it's own genpd.
>>>
>>> The split that we took from the provided simple and onecell xlate
>>> functions
>>> arises from this mapping. The IDs are not necessarily linear and also they
>>> are
>>> not necessarily defined in a fixed way for all SoCs, they are entirely
>>> data
>>> driven based on the provided device ID. To make use of these IDs, I
>>> created a
>>> new xlate function that takes a onecell value but instead dynamically
>>> allocates
>>> a new genpd, at probe time, to give us a genpd that contains the necessary
>>> SoC
>>> specific data for that device that probed and is mapped directly to the
>>> device.
>>> This lets us only create the genpds we need without having to redefine a
>>> static
>>> list of all possible genpds and duplicate the data.
>>>
>>> So my question back would be, how critical is it to be able to drop the
>>> ability
>>> to provide custom xlate functions?
>>
>>
>> After thinking about this a bit more, I believe I see a way we can use the
>> of_genpd_add_provider_onecell, although not optimally. The device IDs, and
>> therefore the genpd IDs (in the last email I mentioned we are doing a 1:1
>> device to genpd mapping) are fixed and defined by the hardware, and are not
>> linear, there can be gaps and we won't necessarily always start at 0 even
>> though we do on this SoC. However, we could build an array of genpds that
>> map to our IDs similar to how several have done it, like in
>> drivers/soc/bcm/raspberrypi-power.c, but because our IDs can have gaps,
>> there will be unused struct generic_pm_domains that get allocated and are
>> never touched because the index of the element doesn't correspond to a genpd
>> ID.
>
> There are a couple of ways to solve your problem without having to
> create one genpd instance for each of the platform devices. As a
> matter of fact, I think that approach should be avoided if possible.
> Genpd isn't designed for these kind purposes, even if it can be done
> like that.
>

Yes, ok. For K2G and future devices, the kernel will just request the 
device over the TI_SCI protocol and the firmware will guarantee 
everything that it needs it on. So we thought the 1:1 device to genpd 
mapping made sense in that regard, but maybe it is a stretch of the 
framework in the wrong way.

> Here are some ideas which could be used to solve the problem differently.
>
> *)
> Assuming each platform device has a driver for it!?
> Then why don't you implement the ->runtime_suspend|resume() callbacks
> on the driver level and call the SCI interface to power on/off the
> device from there? This ought to be the most straight forward
> solution.

Straightforward yes but not a realistic option as we are using shared 
drivers from other platforms so sticking in platform specific code won't 
work.

>
>
> **)
> You may also use genpd's (struct generic_pm_domain)
> ->attach|detach_dev() callbacks to create the device specific data
> (the SCI device ID). The ->attach_dev() callback are invoked when a
> device gets attached to its PM domain (genpd) at probe time.
>
> Currently these callbacks are already being used by SoCs that uses the
> PM clk API from a genpd client. That is needed to create the device
> specific PM clock list. We would have to do something similar here for
> the SCI device IDs.
>
> Then, you must also assign/implement the ->start() and ->stop()
> callbacks of the struct gpd_dev_ops, which is a part of the genpd
> struct. These callbacks can then easily invoke SoC specific code/APIs
> and perhaps that is the issue with my first suggested approach!?

I've taken a look at what you have suggested here and I think it could 
work for us, thanks for the suggestion, I will give it a shot, I think 
that this will work just as well from a functional perspective.

>
>>
>> Based on the ID set provided in patch 2 of this series I see 12 gaps, so
>> we'd be wasting space the size of 12 genpds. The ID mapping will change on
>> future SoCs, so this number could be larger. Do you think this is an
>> acceptable solution? It allows us to play nice with the new genpd framework
>> changes at the cost of wasting some space allocated to filler genpds.
>
> There are other issues as well, which mostly has do to with a
> unnecessary long execution path, involving taking mutexes etc in
> genpd.
>
> All you actually need, is to be able to power on/off a device from a
> driver's ->runtime_suspend|resume() callback. Don't you think?

Yes, but I thought the point of these frameworks was that they let us 
avoid doing it manually with platform specific code inside the drivers. 
I'll look at the callbacks in the genpd framework instead, that seems 
like a good place to do it.

Regards,
Dave

>
> Kind regards
> Uffe
>

[toc] | [prev] | [next] | [standalone]


#1478547

FromKevin Hilman <khilman@baylibre.com>
Date2016-09-07 20:40 +0200
Message-ID<sePVo-3mn-7@gated-at.bofh.it>
In reply to#1477807
Dave Gerlach <d-gerlach@ti.com> writes:

> On 08/30/2016 03:26 PM, Ulf Hansson wrote:
>> On 30 August 2016 at 21:43, Dave Gerlach <d-gerlach@ti.com> wrote:
>>> Jon, Ulf,
>>>
>>> On 08/26/2016 06:37 PM, Dave Gerlach wrote:
>>>>
>>>> Hi,
>>>> On 08/25/2016 02:27 AM, Ulf Hansson wrote:
>>>>>
>>>>> + Jon
>>>>>
>>>>> [...]
>>>>>
>>>>>> +
>>>>>> +static int ti_sci_pm_domains_probe(struct platform_device *pdev)
>>>>>> +{
>>>>>> +       struct device *dev = &pdev->dev;
>>>>>> +       struct device_node *np = dev->of_node;
>>>>>> +       struct ti_sci_genpd_data *ti_sci_genpd;
>>>>>> +
>>>>>> +       ti_sci_genpd = devm_kzalloc(dev, sizeof(*ti_sci_genpd),
>>>>>> GFP_KERNEL);
>>>>>> +       if (!ti_sci_genpd)
>>>>>> +               return -ENOMEM;
>>>>>> +
>>>>>> +       ti_sci_genpd->ti_sci = devm_ti_sci_get_handle(dev);
>>>>>> +       if (IS_ERR(ti_sci_genpd->ti_sci))
>>>>>> +               return PTR_ERR(ti_sci_genpd->ti_sci);
>>>>>> +
>>>>>> +       ti_sci_genpd->dev = dev;
>>>>>> +
>>>>>> +       INIT_LIST_HEAD(&ti_sci_genpd->pd_list);
>>>>>> +       mutex_init(&ti_sci_genpd->pd_list_mutex);
>>>>>> +
>>>>>> +       return __of_genpd_add_provider(np,
>>>>>> of_ti_sci_genpd_xlate_onecell,
>>>>>> +                                      ti_sci_genpd);
>>>>>
>>>>>
>>>>> Jon Hunter are working on adding robust method to be able to remove
>>>>> initialized genpds [1].
>>>>>
>>>>> In that series we intend to remove the __of_genpd_add_provider() API,
>>>>> and instead only have of_genpd_add_provider_onecell() and
>>>>> of_genpd_add_provider_simple(). Could you please convert to use any of
>>>>> these APIs instead?
>>>>
>>>>
>>>> Thanks for pointing this out. I took at look at the series you've linked
>>>> and the
>>>> short answer is that I see no good way to directly convert what we've done
>>>> to
>>>> use those APIs.
>>>>
>>>> On this platform each device has it's power state controlled through the
>>>> SCI
>>>> protocol described in the cover letter. The system makes a request for
>>>> powering
>>>> on or off the device using a unique ID number for each device, as provided
>>>> in
>>>> patches 1 and 2. These operations map to those of a genpd, so we decided
>>>> to do a
>>>> 1:1 device to genpd mapping, where each device has it's own genpd.
>>>>
>>>> The split that we took from the provided simple and onecell xlate
>>>> functions
>>>> arises from this mapping. The IDs are not necessarily linear and also they
>>>> are
>>>> not necessarily defined in a fixed way for all SoCs, they are entirely
>>>> data
>>>> driven based on the provided device ID. To make use of these IDs, I
>>>> created a
>>>> new xlate function that takes a onecell value but instead dynamically
>>>> allocates
>>>> a new genpd, at probe time, to give us a genpd that contains the necessary
>>>> SoC
>>>> specific data for that device that probed and is mapped directly to the
>>>> device.
>>>> This lets us only create the genpds we need without having to redefine a
>>>> static
>>>> list of all possible genpds and duplicate the data.
>>>>
>>>> So my question back would be, how critical is it to be able to drop the
>>>> ability
>>>> to provide custom xlate functions?
>>>
>>>
>>> After thinking about this a bit more, I believe I see a way we can use the
>>> of_genpd_add_provider_onecell, although not optimally. The device IDs, and
>>> therefore the genpd IDs (in the last email I mentioned we are doing a 1:1
>>> device to genpd mapping) are fixed and defined by the hardware, and are not
>>> linear, there can be gaps and we won't necessarily always start at 0 even
>>> though we do on this SoC. However, we could build an array of genpds that
>>> map to our IDs similar to how several have done it, like in
>>> drivers/soc/bcm/raspberrypi-power.c, but because our IDs can have gaps,
>>> there will be unused struct generic_pm_domains that get allocated and are
>>> never touched because the index of the element doesn't correspond to a genpd
>>> ID.
>>
>> There are a couple of ways to solve your problem without having to
>> create one genpd instance for each of the platform devices. As a
>> matter of fact, I think that approach should be avoided if possible.
>> Genpd isn't designed for these kind purposes, even if it can be done
>> like that.
>>
>
> Yes, ok. For K2G and future devices, the kernel will just request the
> device over the TI_SCI protocol and the firmware will guarantee
> everything that it needs it on. So we thought the 1:1 device to genpd
> mapping made sense in that regard, but maybe it is a stretch of the
> framework in the wrong way.
>
>> Here are some ideas which could be used to solve the problem differently.
>>
>> *)
>> Assuming each platform device has a driver for it!?
>> Then why don't you implement the ->runtime_suspend|resume() callbacks
>> on the driver level and call the SCI interface to power on/off the
>> device from there? This ought to be the most straight forward
>> solution.
>
> Straightforward yes but not a realistic option as we are using shared
> drivers from other platforms so sticking in platform specific code
> won't work.
>
>>
>>
>> **)
>> You may also use genpd's (struct generic_pm_domain)
>> ->attach|detach_dev() callbacks to create the device specific data
>> (the SCI device ID). The ->attach_dev() callback are invoked when a
>> device gets attached to its PM domain (genpd) at probe time.
>>
>> Currently these callbacks are already being used by SoCs that uses the
>> PM clk API from a genpd client. That is needed to create the device
>> specific PM clock list. We would have to do something similar here for
>> the SCI device IDs.
>>
>> Then, you must also assign/implement the ->start() and ->stop()
>> callbacks of the struct gpd_dev_ops, which is a part of the genpd
>> struct. These callbacks can then easily invoke SoC specific code/APIs
>> and perhaps that is the issue with my first suggested approach!?
>
> I've taken a look at what you have suggested here and I think it could
> work for us, thanks for the suggestion, I will give it a shot, I think
> that this will work just as well from a functional perspective.
>
>>
>>>
>>> Based on the ID set provided in patch 2 of this series I see 12 gaps, so
>>> we'd be wasting space the size of 12 genpds. The ID mapping will change on
>>> future SoCs, so this number could be larger. Do you think this is an
>>> acceptable solution? It allows us to play nice with the new genpd framework
>>> changes at the cost of wasting some space allocated to filler genpds.
>>
>> There are other issues as well, which mostly has do to with a
>> unnecessary long execution path, involving taking mutexes etc in
>> genpd.
>>
>> All you actually need, is to be able to power on/off a device from a
>> driver's ->runtime_suspend|resume() callback. Don't you think?
>
> Yes, but I thought the point of these frameworks was that they let us
> avoid doing it manually with platform specific code inside the
> drivers. I'll look at the callbacks in the genpd framework instead,
> that seems like a good place to do it.

One more idea...

Since you don't really have a domain (a group of devices), what you
really have is each device having an independent power switch, so as Ulf
suggested, what you really need is for all the devices to share the same
set of runtime PM callbacks that call SCI.  The only difference is the
unique ID.

Rather than using all of genpd, you could also just use a pm_domain
which is what genpd is built on top of (and also omap_device, which
you're probably familiar with also.)

That would allow you to keep the drivers completely generic, yet share
all the SCI specific "domain" code inside a pm_domain.

Kevin

[toc] | [prev] | [next] | [standalone]


#1478966

FromUlf Hansson <ulf.hansson@linaro.org>
Date2016-09-08 11:30 +0200
Message-ID<sf3OF-3Y8-1@gated-at.bofh.it>
In reply to#1478547
[...]

>
> One more idea...
>
> Since you don't really have a domain (a group of devices), what you
> really have is each device having an independent power switch, so as Ulf
> suggested, what you really need is for all the devices to share the same
> set of runtime PM callbacks that call SCI.  The only difference is the
> unique ID.
>
> Rather than using all of genpd, you could also just use a pm_domain
> which is what genpd is built on top of (and also omap_device, which
> you're probably familiar with also.)

Even if this would work as well, the downside would be that you need
to re-invent the parts related to the DT parsing, the probing/removal
and attaching/detaching of the device to the PM domain.

You probably don't want to go there... :-)

>
> That would allow you to keep the drivers completely generic, yet share
> all the SCI specific "domain" code inside a pm_domain.
>
> Kevin

Kind regards
Uffe

[toc] | [prev] | [next] | [standalone]


#1479397

FromKevin Hilman <khilman@baylibre.com>
Date2016-09-08 19:40 +0200
Message-ID<sfbsS-hA-13@gated-at.bofh.it>
In reply to#1478966
Ulf Hansson <ulf.hansson@linaro.org> writes:

> [...]
>
>>
>> One more idea...
>>
>> Since you don't really have a domain (a group of devices), what you
>> really have is each device having an independent power switch, so as Ulf
>> suggested, what you really need is for all the devices to share the same
>> set of runtime PM callbacks that call SCI.  The only difference is the
>> unique ID.
>>
>> Rather than using all of genpd, you could also just use a pm_domain
>> which is what genpd is built on top of (and also omap_device, which
>> you're probably familiar with also.)
>
> Even if this would work as well, the downside would be that you need
> to re-invent the parts related to the DT parsing, the probing/removal
> and attaching/detaching of the device to the PM domain.
>
> You probably don't want to go there... :-)

All you'd need to read from DT would be the device-specific ID for
TI-SCI, and that could be done at bind time with a notifier.  The, in
that same notifier, if a TI-SCI ID exists, it would get added to the
pm_domain.

Anyways, your original proposal is much preferred if it can work.  I'm
just throwing out another option because I really don't like one genpd
per device.

Kevin

[toc] | [prev] | [next] | [standalone]


#1479411

FromDave Gerlach <d-gerlach@ti.com>
Date2016-09-08 20:10 +0200
Message-ID<sfbVT-HP-1@gated-at.bofh.it>
In reply to#1479397
Hi,
On 09/08/2016 12:38 PM, Kevin Hilman wrote:
> Ulf Hansson <ulf.hansson@linaro.org> writes:
>
>> [...]
>>
>>>
>>> One more idea...
>>>
>>> Since you don't really have a domain (a group of devices), what you
>>> really have is each device having an independent power switch, so as Ulf
>>> suggested, what you really need is for all the devices to share the same
>>> set of runtime PM callbacks that call SCI.  The only difference is the
>>> unique ID.
>>>
>>> Rather than using all of genpd, you could also just use a pm_domain
>>> which is what genpd is built on top of (and also omap_device, which
>>> you're probably familiar with also.)
>>
>> Even if this would work as well, the downside would be that you need
>> to re-invent the parts related to the DT parsing, the probing/removal
>> and attaching/detaching of the device to the PM domain.
>>
>> You probably don't want to go there... :-)
>
> All you'd need to read from DT would be the device-specific ID for
> TI-SCI, and that could be done at bind time with a notifier.  The, in
> that same notifier, if a TI-SCI ID exists, it would get added to the
> pm_domain.
>
> Anyways, your original proposal is much preferred if it can work.  I'm
> just throwing out another option because I really don't like one genpd
> per device.
>
> Kevin
>

I am first trying to leverage the dev_attach/detach and start/stop 
callbacks that Ulf suggested without creating a single genpd per device 
and it looks like it will work for us. I appreciate the alternative 
suggestions but I agree we'd like to leverage as much of the existing 
genpd framework as we can and avoid going down the omap_device style 
implementation path.

Regards,
Dave

[toc] | [prev] | [next] | [standalone]


#1479750

FromUlf Hansson <ulf.hansson@linaro.org>
Date2016-09-09 10:40 +0200
Message-ID<sfpvQ-wL-31@gated-at.bofh.it>
In reply to#1479397
On 8 September 2016 at 19:38, Kevin Hilman <khilman@baylibre.com> wrote:
> Ulf Hansson <ulf.hansson@linaro.org> writes:
>
>> [...]
>>
>>>
>>> One more idea...
>>>
>>> Since you don't really have a domain (a group of devices), what you
>>> really have is each device having an independent power switch, so as Ulf
>>> suggested, what you really need is for all the devices to share the same
>>> set of runtime PM callbacks that call SCI.  The only difference is the
>>> unique ID.
>>>
>>> Rather than using all of genpd, you could also just use a pm_domain
>>> which is what genpd is built on top of (and also omap_device, which
>>> you're probably familiar with also.)
>>
>> Even if this would work as well, the downside would be that you need
>> to re-invent the parts related to the DT parsing, the probing/removal
>> and attaching/detaching of the device to the PM domain.
>>
>> You probably don't want to go there... :-)
>
> All you'd need to read from DT would be the device-specific ID for
> TI-SCI, and that could be done at bind time with a notifier.  The, in
> that same notifier, if a TI-SCI ID exists, it would get added to the
> pm_domain.
>
> Anyways, your original proposal is much preferred if it can work.  I'm
> just throwing out another option because I really don't like one genpd
> per device.

Okay, then we are in full agreement!

BTW, I have just been trying to convince other people working on
Rockchip SoCs, to also avoid using one genpd per device. Feel free to
join those discussions [1] as well. :-)

Kind regards
Uffe

[1]
https://lkml.org/lkml/2016/9/1/377

[toc] | [prev] | [next] | [standalone]


#1478953

FromUlf Hansson <ulf.hansson@linaro.org>
Date2016-09-08 11:20 +0200
Message-ID<sf3F0-3UY-33@gated-at.bofh.it>
In reply to#1477807
>
>> Here are some ideas which could be used to solve the problem differently.
>>
>> *)
>> Assuming each platform device has a driver for it!?
>> Then why don't you implement the ->runtime_suspend|resume() callbacks
>> on the driver level and call the SCI interface to power on/off the
>> device from there? This ought to be the most straight forward
>> solution.
>
>
> Straightforward yes but not a realistic option as we are using shared
> drivers from other platforms so sticking in platform specific code won't
> work.

Agree, but...

Historically, I think this was *one* of the reasons to why omap's
hw_mod PM domain was invented.
At that point we did not have the common clk framework, the pinctrl
framework, the phy framework, syscon, etc. These device resources can
now be handled by the drivers themselves via generic interfaces and
thus they remains to be portable.

My point is, let's be sure you don't drop this approach unless it's
really SoC specific code needed to deal with the device.

>
>>
>>
>> **)
>> You may also use genpd's (struct generic_pm_domain)
>> ->attach|detach_dev() callbacks to create the device specific data
>> (the SCI device ID). The ->attach_dev() callback are invoked when a
>> device gets attached to its PM domain (genpd) at probe time.
>>
>> Currently these callbacks are already being used by SoCs that uses the
>> PM clk API from a genpd client. That is needed to create the device
>> specific PM clock list. We would have to do something similar here for
>> the SCI device IDs.
>>
>> Then, you must also assign/implement the ->start() and ->stop()
>> callbacks of the struct gpd_dev_ops, which is a part of the genpd
>> struct. These callbacks can then easily invoke SoC specific code/APIs
>> and perhaps that is the issue with my first suggested approach!?
>
>
> I've taken a look at what you have suggested here and I think it could work
> for us, thanks for the suggestion, I will give it a shot, I think that this
> will work just as well from a functional perspective.

Okay, great!

>
>>
>>>
>>> Based on the ID set provided in patch 2 of this series I see 12 gaps, so
>>> we'd be wasting space the size of 12 genpds. The ID mapping will change
>>> on
>>> future SoCs, so this number could be larger. Do you think this is an
>>> acceptable solution? It allows us to play nice with the new genpd
>>> framework
>>> changes at the cost of wasting some space allocated to filler genpds.
>>
>>
>> There are other issues as well, which mostly has do to with a
>> unnecessary long execution path, involving taking mutexes etc in
>> genpd.
>>
>> All you actually need, is to be able to power on/off a device from a
>> driver's ->runtime_suspend|resume() callback. Don't you think?
>
>
> Yes, but I thought the point of these frameworks was that they let us avoid
> doing it manually with platform specific code inside the drivers. I'll look
> at the callbacks in the genpd framework instead, that seems like a good
> place to do it.

BTW, as you would need to store your device specific data somewhere,
we probably need to extend the struct pm_subsys_data or the "struct
pm_domain_data", to hold a "void *data".

Kind regards
Uffe

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web