mbox series

[0/4] thermal: Introduce Qualcomm Thermal Mitigation Device support

Message ID 20230905-caleb-qmi_cooling-v1-0-5aa39d4164a7@linaro.org
Headers show
Series thermal: Introduce Qualcomm Thermal Mitigation Device support | expand

Message

Caleb Connolly Sept. 29, 2023, 4:16 p.m. UTC
The Thermal Mitigation Device (TMD) Service is a QMI service that runs
on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
It exposes various mitigations including passive thermal controls and
rail voltage restrictions.

This series introduces support for exposing TMDs as cooling devices
in the kernel through the thermal framework, using the QMI interface.

Each TMD client is described as a child of the remoteproc node in
devicetree. With subnodes for each control.

This series is based on previous work by Bhupesh Sharma which can be
found at [1]. I'm sending this as a fresh series as it has been a
year since the original version and I have rewritten most of the driver.

[1]: https://lore.kernel.org/linux-arm-msm/20220912085049.3517140-1-bhupesh.sharma@linaro.org/

---
Caleb Connolly (4):
      remoteproc: qcom: probe all child devices
      dt-bindings: thermal: Add qcom,qmi-cooling yaml bindings
      thermal: qcom: add qmi-cooling driver
      MAINTAINERS: Add entry for Qualcomm Cooling Driver

 .../bindings/remoteproc/qcom,msm8996-mss-pil.yaml  |  13 +
 .../bindings/remoteproc/qcom,pas-common.yaml       |   6 +
 .../bindings/thermal/qcom,qmi-cooling.yaml         | 168 +++++++
 MAINTAINERS                                        |   8 +
 drivers/remoteproc/qcom_q6v5.c                     |   4 +
 drivers/remoteproc/qcom_q6v5_mss.c                 |   8 -
 drivers/thermal/qcom/Kconfig                       |  13 +
 drivers/thermal/qcom/Makefile                      |   1 +
 drivers/thermal/qcom/qmi-cooling.c                 | 520 +++++++++++++++++++++
 drivers/thermal/qcom/qmi-cooling.h                 | 428 +++++++++++++++++
 10 files changed, 1161 insertions(+), 8 deletions(-)
---
base-commit: 9067f80db58bbce81d5f0703aa2fd261e88bc812

// Caleb (they/them)

Comments

Manivannan Sadhasivam Oct. 2, 2023, 2:52 p.m. UTC | #1
On Sun, Oct 01, 2023 at 06:26:14PM +0100, Caleb Connolly wrote:
> 
> 
> On 01/10/2023 16:57, Manivannan Sadhasivam wrote:
> > On Fri, Sep 29, 2023 at 05:16:16PM +0100, Caleb Connolly wrote:
> > > The Thermal Mitigation Device (TMD) Service is a QMI service that runs
> > > on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
> > > It exposes various mitigations including passive thermal controls and
> > > rail voltage restrictions.
> > > 
> > > This series introduces support for exposing TMDs as cooling devices
> > > in the kernel through the thermal framework, using the QMI interface.
> > > 
> > > Each TMD client is described as a child of the remoteproc node in
> > > devicetree. With subnodes for each control.
> > > 
> > 
> > Daniel expressed concerns in the past aganist representing TMD driver as a
> > cooling device since it is not tied to thermal zones and the governors cannot
> > use it. Instead he suggested to represent it as a powercap device with thermal
> > constraints.
> 
> Hi Mani,
> 
> Forgive me as I'm not yet super familiar with the thermal subsystem.
> 
> As I understand it, the DT layout here enables each control to be referenced
> under the thermal zones, at least this is the approach taken in CAF 4.9.
> 
> Maybe I don't quite understand what you mean, are you saying that using
> thermal zones is the wrong approach?

Thermal framework expects each thermal zone represented in DT to have atleast
one corresponding thermal sensor defined using "thermal-sensors" property. But
with TMD, there is no thermal sensor AFAIK.

> > 
> > So please look into that approach.
> 
> Any recommended reading? Or drivers I can use as a reference?
> 

drivers/powercap/arm_scmi_powercap.c seems to be a good reference.

- Mani

> Thanks
> > 
> > - Mani
> > 
> > > This series is based on previous work by Bhupesh Sharma which can be
> > > found at [1]. I'm sending this as a fresh series as it has been a
> > > year since the original version and I have rewritten most of the driver.
> > > 
> > > [1]: https://lore.kernel.org/linux-arm-msm/20220912085049.3517140-1-bhupesh.sharma@linaro.org/
> > > 
> > > ---
> > > Caleb Connolly (4):
> > >        remoteproc: qcom: probe all child devices
> > >        dt-bindings: thermal: Add qcom,qmi-cooling yaml bindings
> > >        thermal: qcom: add qmi-cooling driver
> > >        MAINTAINERS: Add entry for Qualcomm Cooling Driver
> > > 
> > >   .../bindings/remoteproc/qcom,msm8996-mss-pil.yaml  |  13 +
> > >   .../bindings/remoteproc/qcom,pas-common.yaml       |   6 +
> > >   .../bindings/thermal/qcom,qmi-cooling.yaml         | 168 +++++++
> > >   MAINTAINERS                                        |   8 +
> > >   drivers/remoteproc/qcom_q6v5.c                     |   4 +
> > >   drivers/remoteproc/qcom_q6v5_mss.c                 |   8 -
> > >   drivers/thermal/qcom/Kconfig                       |  13 +
> > >   drivers/thermal/qcom/Makefile                      |   1 +
> > >   drivers/thermal/qcom/qmi-cooling.c                 | 520 +++++++++++++++++++++
> > >   drivers/thermal/qcom/qmi-cooling.h                 | 428 +++++++++++++++++
> > >   10 files changed, 1161 insertions(+), 8 deletions(-)
> > > ---
> > > base-commit: 9067f80db58bbce81d5f0703aa2fd261e88bc812
> > > 
> > > // Caleb (they/them)
> > > 
> > 
> 
> -- 
> // Caleb (they/them)
Dmitry Baryshkov Oct. 2, 2023, 3 p.m. UTC | #2
On Mon, 2 Oct 2023 at 17:52, Manivannan Sadhasivam <mani@kernel.org> wrote:
>
> On Sun, Oct 01, 2023 at 06:26:14PM +0100, Caleb Connolly wrote:
> >
> >
> > On 01/10/2023 16:57, Manivannan Sadhasivam wrote:
> > > On Fri, Sep 29, 2023 at 05:16:16PM +0100, Caleb Connolly wrote:
> > > > The Thermal Mitigation Device (TMD) Service is a QMI service that runs
> > > > on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
> > > > It exposes various mitigations including passive thermal controls and
> > > > rail voltage restrictions.
> > > >
> > > > This series introduces support for exposing TMDs as cooling devices
> > > > in the kernel through the thermal framework, using the QMI interface.
> > > >
> > > > Each TMD client is described as a child of the remoteproc node in
> > > > devicetree. With subnodes for each control.
> > > >
> > >
> > > Daniel expressed concerns in the past aganist representing TMD driver as a
> > > cooling device since it is not tied to thermal zones and the governors cannot
> > > use it. Instead he suggested to represent it as a powercap device with thermal
> > > constraints.
> >
> > Hi Mani,
> >
> > Forgive me as I'm not yet super familiar with the thermal subsystem.
> >
> > As I understand it, the DT layout here enables each control to be referenced
> > under the thermal zones, at least this is the approach taken in CAF 4.9.
> >
> > Maybe I don't quite understand what you mean, are you saying that using
> > thermal zones is the wrong approach?
>
> Thermal framework expects each thermal zone represented in DT to have atleast
> one corresponding thermal sensor defined using "thermal-sensors" property. But
> with TMD, there is no thermal sensor AFAIK.

As far as I understand, no. It is perfectly fine to have 'cooling'
devices, which react to external thermal monitoring events. I might be
mistaken, but I think that is the case here, isn't it?

>
> > >
> > > So please look into that approach.
> >
> > Any recommended reading? Or drivers I can use as a reference?
> >
>
> drivers/powercap/arm_scmi_powercap.c seems to be a good reference.
>
> - Mani
>
> > Thanks
> > >
> > > - Mani
> > >
> > > > This series is based on previous work by Bhupesh Sharma which can be
> > > > found at [1]. I'm sending this as a fresh series as it has been a
> > > > year since the original version and I have rewritten most of the driver.
> > > >
> > > > [1]: https://lore.kernel.org/linux-arm-msm/20220912085049.3517140-1-bhupesh.sharma@linaro.org/
> > > >
> > > > ---
> > > > Caleb Connolly (4):
> > > >        remoteproc: qcom: probe all child devices
> > > >        dt-bindings: thermal: Add qcom,qmi-cooling yaml bindings
> > > >        thermal: qcom: add qmi-cooling driver
> > > >        MAINTAINERS: Add entry for Qualcomm Cooling Driver
> > > >
> > > >   .../bindings/remoteproc/qcom,msm8996-mss-pil.yaml  |  13 +
> > > >   .../bindings/remoteproc/qcom,pas-common.yaml       |   6 +
> > > >   .../bindings/thermal/qcom,qmi-cooling.yaml         | 168 +++++++
> > > >   MAINTAINERS                                        |   8 +
> > > >   drivers/remoteproc/qcom_q6v5.c                     |   4 +
> > > >   drivers/remoteproc/qcom_q6v5_mss.c                 |   8 -
> > > >   drivers/thermal/qcom/Kconfig                       |  13 +
> > > >   drivers/thermal/qcom/Makefile                      |   1 +
> > > >   drivers/thermal/qcom/qmi-cooling.c                 | 520 +++++++++++++++++++++
> > > >   drivers/thermal/qcom/qmi-cooling.h                 | 428 +++++++++++++++++
> > > >   10 files changed, 1161 insertions(+), 8 deletions(-)
> > > > ---
> > > > base-commit: 9067f80db58bbce81d5f0703aa2fd261e88bc812
> > > >
> > > > // Caleb (they/them)
> > > >
> > >
> >
> > --
> > // Caleb (they/them)
>
> --
> மணிவண்ணன் சதாசிவம்
Caleb Connolly Oct. 2, 2023, 3:14 p.m. UTC | #3
On 02/10/2023 16:00, Dmitry Baryshkov wrote:
> On Mon, 2 Oct 2023 at 17:52, Manivannan Sadhasivam <mani@kernel.org> wrote:
>>
>> On Sun, Oct 01, 2023 at 06:26:14PM +0100, Caleb Connolly wrote:
>>>
>>>
>>> On 01/10/2023 16:57, Manivannan Sadhasivam wrote:
>>>> On Fri, Sep 29, 2023 at 05:16:16PM +0100, Caleb Connolly wrote:
>>>>> The Thermal Mitigation Device (TMD) Service is a QMI service that runs
>>>>> on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
>>>>> It exposes various mitigations including passive thermal controls and
>>>>> rail voltage restrictions.
>>>>>
>>>>> This series introduces support for exposing TMDs as cooling devices
>>>>> in the kernel through the thermal framework, using the QMI interface.
>>>>>
>>>>> Each TMD client is described as a child of the remoteproc node in
>>>>> devicetree. With subnodes for each control.
>>>>>
>>>>
>>>> Daniel expressed concerns in the past aganist representing TMD driver as a
>>>> cooling device since it is not tied to thermal zones and the governors cannot
>>>> use it. Instead he suggested to represent it as a powercap device with thermal
>>>> constraints.

I think so, see for example in CAF 4.9 [1]

As far as I can tell, the QMI TMD service was written specifically *for*
the cooling_device API, so it's a bit of a chicken and egg problem
trying to coerce it to some other form...

That all being said, I can definitely see the potential value in using
the powercap framework. Especially if it would let us tie the TMD
controls more directly with the remoteproc device and more easily
integrate it with DTPM.

For example, would it also make sense to adjust these values to preserve
battery life? Which API makes the most sense for that?

[1]:
https://github.com/android-linux-stable/msm-4.9/blob/384eee701481c3dd08822819cf4d5f1da5729db1/arch/arm64/boot/dts/qcom/sdm670-thermal.dtsi#L661
>>>
>>> Hi Mani,
>>>
>>> Forgive me as I'm not yet super familiar with the thermal subsystem.
>>>
>>> As I understand it, the DT layout here enables each control to be referenced
>>> under the thermal zones, at least this is the approach taken in CAF 4.9.
>>>
>>> Maybe I don't quite understand what you mean, are you saying that using
>>> thermal zones is the wrong approach?
>>
>> Thermal framework expects each thermal zone represented in DT to have atleast
>> one corresponding thermal sensor defined using "thermal-sensors" property. But
>> with TMD, there is no thermal sensor AFAIK.
> 
> As far as I understand, no. It is perfectly fine to have 'cooling'
> devices, which react to external thermal monitoring events. I might be
> mistaken, but I think that is the case here, isn't it?
> 
>>
>>>>
>>>> So please look into that approach.
>>>
>>> Any recommended reading? Or drivers I can use as a reference?
>>>
>>
>> drivers/powercap/arm_scmi_powercap.c seems to be a good reference.
>>
>> - Mani
>>
>>> Thanks
>>>>
>>>> - Mani
>>>>
>>>>> This series is based on previous work by Bhupesh Sharma which can be
>>>>> found at [1]. I'm sending this as a fresh series as it has been a
>>>>> year since the original version and I have rewritten most of the driver.
>>>>>
>>>>> [1]: https://lore.kernel.org/linux-arm-msm/20220912085049.3517140-1-bhupesh.sharma@linaro.org/
>>>>>
>>>>> ---
>>>>> Caleb Connolly (4):
>>>>>        remoteproc: qcom: probe all child devices
>>>>>        dt-bindings: thermal: Add qcom,qmi-cooling yaml bindings
>>>>>        thermal: qcom: add qmi-cooling driver
>>>>>        MAINTAINERS: Add entry for Qualcomm Cooling Driver
>>>>>
>>>>>   .../bindings/remoteproc/qcom,msm8996-mss-pil.yaml  |  13 +
>>>>>   .../bindings/remoteproc/qcom,pas-common.yaml       |   6 +
>>>>>   .../bindings/thermal/qcom,qmi-cooling.yaml         | 168 +++++++
>>>>>   MAINTAINERS                                        |   8 +
>>>>>   drivers/remoteproc/qcom_q6v5.c                     |   4 +
>>>>>   drivers/remoteproc/qcom_q6v5_mss.c                 |   8 -
>>>>>   drivers/thermal/qcom/Kconfig                       |  13 +
>>>>>   drivers/thermal/qcom/Makefile                      |   1 +
>>>>>   drivers/thermal/qcom/qmi-cooling.c                 | 520 +++++++++++++++++++++
>>>>>   drivers/thermal/qcom/qmi-cooling.h                 | 428 +++++++++++++++++
>>>>>   10 files changed, 1161 insertions(+), 8 deletions(-)
>>>>> ---
>>>>> base-commit: 9067f80db58bbce81d5f0703aa2fd261e88bc812
>>>>>
>>>>> // Caleb (they/them)
>>>>>
>>>>
>>>
>>> --
>>> // Caleb (they/them)
>>
>> --
>> மணிவண்ணன் சதாசிவம்
> 
> 
>
Manivannan Sadhasivam Oct. 2, 2023, 3:58 p.m. UTC | #4
On Mon, Oct 02, 2023 at 06:00:37PM +0300, Dmitry Baryshkov wrote:
> On Mon, 2 Oct 2023 at 17:52, Manivannan Sadhasivam <mani@kernel.org> wrote:
> >
> > On Sun, Oct 01, 2023 at 06:26:14PM +0100, Caleb Connolly wrote:
> > >
> > >
> > > On 01/10/2023 16:57, Manivannan Sadhasivam wrote:
> > > > On Fri, Sep 29, 2023 at 05:16:16PM +0100, Caleb Connolly wrote:
> > > > > The Thermal Mitigation Device (TMD) Service is a QMI service that runs
> > > > > on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
> > > > > It exposes various mitigations including passive thermal controls and
> > > > > rail voltage restrictions.
> > > > >
> > > > > This series introduces support for exposing TMDs as cooling devices
> > > > > in the kernel through the thermal framework, using the QMI interface.
> > > > >
> > > > > Each TMD client is described as a child of the remoteproc node in
> > > > > devicetree. With subnodes for each control.
> > > > >
> > > >
> > > > Daniel expressed concerns in the past aganist representing TMD driver as a
> > > > cooling device since it is not tied to thermal zones and the governors cannot
> > > > use it. Instead he suggested to represent it as a powercap device with thermal
> > > > constraints.
> > >
> > > Hi Mani,
> > >
> > > Forgive me as I'm not yet super familiar with the thermal subsystem.
> > >
> > > As I understand it, the DT layout here enables each control to be referenced
> > > under the thermal zones, at least this is the approach taken in CAF 4.9.
> > >
> > > Maybe I don't quite understand what you mean, are you saying that using
> > > thermal zones is the wrong approach?
> >
> > Thermal framework expects each thermal zone represented in DT to have atleast
> > one corresponding thermal sensor defined using "thermal-sensors" property. But
> > with TMD, there is no thermal sensor AFAIK.
> 
> As far as I understand, no. It is perfectly fine to have 'cooling'
> devices, which react to external thermal monitoring events. I might be
> mistaken, but I think that is the case here, isn't it?
> 

Yes it is represented as cooling device(s). But I do not see any cognizant way
to plug it with thermal zones i.e., unless TMD itself reports temperature of the
modem, using it as a cooling device for external temperature events doesn't
sound good to me.

- Mani

> >
> > > >
> > > > So please look into that approach.
> > >
> > > Any recommended reading? Or drivers I can use as a reference?
> > >
> >
> > drivers/powercap/arm_scmi_powercap.c seems to be a good reference.
> >
> > - Mani
> >
> > > Thanks
> > > >
> > > > - Mani
> > > >
> > > > > This series is based on previous work by Bhupesh Sharma which can be
> > > > > found at [1]. I'm sending this as a fresh series as it has been a
> > > > > year since the original version and I have rewritten most of the driver.
> > > > >
> > > > > [1]: https://lore.kernel.org/linux-arm-msm/20220912085049.3517140-1-bhupesh.sharma@linaro.org/
> > > > >
> > > > > ---
> > > > > Caleb Connolly (4):
> > > > >        remoteproc: qcom: probe all child devices
> > > > >        dt-bindings: thermal: Add qcom,qmi-cooling yaml bindings
> > > > >        thermal: qcom: add qmi-cooling driver
> > > > >        MAINTAINERS: Add entry for Qualcomm Cooling Driver
> > > > >
> > > > >   .../bindings/remoteproc/qcom,msm8996-mss-pil.yaml  |  13 +
> > > > >   .../bindings/remoteproc/qcom,pas-common.yaml       |   6 +
> > > > >   .../bindings/thermal/qcom,qmi-cooling.yaml         | 168 +++++++
> > > > >   MAINTAINERS                                        |   8 +
> > > > >   drivers/remoteproc/qcom_q6v5.c                     |   4 +
> > > > >   drivers/remoteproc/qcom_q6v5_mss.c                 |   8 -
> > > > >   drivers/thermal/qcom/Kconfig                       |  13 +
> > > > >   drivers/thermal/qcom/Makefile                      |   1 +
> > > > >   drivers/thermal/qcom/qmi-cooling.c                 | 520 +++++++++++++++++++++
> > > > >   drivers/thermal/qcom/qmi-cooling.h                 | 428 +++++++++++++++++
> > > > >   10 files changed, 1161 insertions(+), 8 deletions(-)
> > > > > ---
> > > > > base-commit: 9067f80db58bbce81d5f0703aa2fd261e88bc812
> > > > >
> > > > > // Caleb (they/them)
> > > > >
> > > >
> > >
> > > --
> > > // Caleb (they/them)
> >
> > --
> > மணிவண்ணன் சதாசிவம்
> 
> 
> 
> -- 
> With best wishes
> Dmitry
Dmitry Baryshkov Oct. 2, 2023, 4 p.m. UTC | #5
On Mon, 2 Oct 2023 at 18:58, Manivannan Sadhasivam <mani@kernel.org> wrote:
>
> On Mon, Oct 02, 2023 at 06:00:37PM +0300, Dmitry Baryshkov wrote:
> > On Mon, 2 Oct 2023 at 17:52, Manivannan Sadhasivam <mani@kernel.org> wrote:
> > >
> > > On Sun, Oct 01, 2023 at 06:26:14PM +0100, Caleb Connolly wrote:
> > > >
> > > >
> > > > On 01/10/2023 16:57, Manivannan Sadhasivam wrote:
> > > > > On Fri, Sep 29, 2023 at 05:16:16PM +0100, Caleb Connolly wrote:
> > > > > > The Thermal Mitigation Device (TMD) Service is a QMI service that runs
> > > > > > on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
> > > > > > It exposes various mitigations including passive thermal controls and
> > > > > > rail voltage restrictions.
> > > > > >
> > > > > > This series introduces support for exposing TMDs as cooling devices
> > > > > > in the kernel through the thermal framework, using the QMI interface.
> > > > > >
> > > > > > Each TMD client is described as a child of the remoteproc node in
> > > > > > devicetree. With subnodes for each control.
> > > > > >
> > > > >
> > > > > Daniel expressed concerns in the past aganist representing TMD driver as a
> > > > > cooling device since it is not tied to thermal zones and the governors cannot
> > > > > use it. Instead he suggested to represent it as a powercap device with thermal
> > > > > constraints.
> > > >
> > > > Hi Mani,
> > > >
> > > > Forgive me as I'm not yet super familiar with the thermal subsystem.
> > > >
> > > > As I understand it, the DT layout here enables each control to be referenced
> > > > under the thermal zones, at least this is the approach taken in CAF 4.9.
> > > >
> > > > Maybe I don't quite understand what you mean, are you saying that using
> > > > thermal zones is the wrong approach?
> > >
> > > Thermal framework expects each thermal zone represented in DT to have atleast
> > > one corresponding thermal sensor defined using "thermal-sensors" property. But
> > > with TMD, there is no thermal sensor AFAIK.
> >
> > As far as I understand, no. It is perfectly fine to have 'cooling'
> > devices, which react to external thermal monitoring events. I might be
> > mistaken, but I think that is the case here, isn't it?
> >
>
> Yes it is represented as cooling device(s). But I do not see any cognizant way
> to plug it with thermal zones i.e., unless TMD itself reports temperature of the
> modem, using it as a cooling device for external temperature events doesn't
> sound good to me.

Why? We have compute, q6, wlan tsens sensors. So it seems natural to
tell CDSP to slow down if compute sensor reports overheating.

>
> - Mani
>
> > >
> > > > >
> > > > > So please look into that approach.
> > > >
> > > > Any recommended reading? Or drivers I can use as a reference?
> > > >
> > >
> > > drivers/powercap/arm_scmi_powercap.c seems to be a good reference.
> > >
> > > - Mani
> > >
> > > > Thanks
> > > > >
> > > > > - Mani
> > > > >
> > > > > > This series is based on previous work by Bhupesh Sharma which can be
> > > > > > found at [1]. I'm sending this as a fresh series as it has been a
> > > > > > year since the original version and I have rewritten most of the driver.
> > > > > >
> > > > > > [1]: https://lore.kernel.org/linux-arm-msm/20220912085049.3517140-1-bhupesh.sharma@linaro.org/
> > > > > >
> > > > > > ---
> > > > > > Caleb Connolly (4):
> > > > > >        remoteproc: qcom: probe all child devices
> > > > > >        dt-bindings: thermal: Add qcom,qmi-cooling yaml bindings
> > > > > >        thermal: qcom: add qmi-cooling driver
> > > > > >        MAINTAINERS: Add entry for Qualcomm Cooling Driver
> > > > > >
> > > > > >   .../bindings/remoteproc/qcom,msm8996-mss-pil.yaml  |  13 +
> > > > > >   .../bindings/remoteproc/qcom,pas-common.yaml       |   6 +
> > > > > >   .../bindings/thermal/qcom,qmi-cooling.yaml         | 168 +++++++
> > > > > >   MAINTAINERS                                        |   8 +
> > > > > >   drivers/remoteproc/qcom_q6v5.c                     |   4 +
> > > > > >   drivers/remoteproc/qcom_q6v5_mss.c                 |   8 -
> > > > > >   drivers/thermal/qcom/Kconfig                       |  13 +
> > > > > >   drivers/thermal/qcom/Makefile                      |   1 +
> > > > > >   drivers/thermal/qcom/qmi-cooling.c                 | 520 +++++++++++++++++++++
> > > > > >   drivers/thermal/qcom/qmi-cooling.h                 | 428 +++++++++++++++++
> > > > > >   10 files changed, 1161 insertions(+), 8 deletions(-)
> > > > > > ---
> > > > > > base-commit: 9067f80db58bbce81d5f0703aa2fd261e88bc812
> > > > > >
> > > > > > // Caleb (they/them)
> > > > > >
> > > > >
> > > >
> > > > --
> > > > // Caleb (they/them)
> > >
> > > --
> > > மணிவண்ணன் சதாசிவம்
> >
> >
> >
> > --
> > With best wishes
> > Dmitry
>
> --
> மணிவண்ணன் சதாசிவம்
Manivannan Sadhasivam Oct. 2, 2023, 4:13 p.m. UTC | #6
On Mon, Oct 02, 2023 at 07:00:27PM +0300, Dmitry Baryshkov wrote:
> On Mon, 2 Oct 2023 at 18:58, Manivannan Sadhasivam <mani@kernel.org> wrote:
> >
> > On Mon, Oct 02, 2023 at 06:00:37PM +0300, Dmitry Baryshkov wrote:
> > > On Mon, 2 Oct 2023 at 17:52, Manivannan Sadhasivam <mani@kernel.org> wrote:
> > > >
> > > > On Sun, Oct 01, 2023 at 06:26:14PM +0100, Caleb Connolly wrote:
> > > > >
> > > > >
> > > > > On 01/10/2023 16:57, Manivannan Sadhasivam wrote:
> > > > > > On Fri, Sep 29, 2023 at 05:16:16PM +0100, Caleb Connolly wrote:
> > > > > > > The Thermal Mitigation Device (TMD) Service is a QMI service that runs
> > > > > > > on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
> > > > > > > It exposes various mitigations including passive thermal controls and
> > > > > > > rail voltage restrictions.
> > > > > > >
> > > > > > > This series introduces support for exposing TMDs as cooling devices
> > > > > > > in the kernel through the thermal framework, using the QMI interface.
> > > > > > >
> > > > > > > Each TMD client is described as a child of the remoteproc node in
> > > > > > > devicetree. With subnodes for each control.
> > > > > > >
> > > > > >
> > > > > > Daniel expressed concerns in the past aganist representing TMD driver as a
> > > > > > cooling device since it is not tied to thermal zones and the governors cannot
> > > > > > use it. Instead he suggested to represent it as a powercap device with thermal
> > > > > > constraints.
> > > > >
> > > > > Hi Mani,
> > > > >
> > > > > Forgive me as I'm not yet super familiar with the thermal subsystem.
> > > > >
> > > > > As I understand it, the DT layout here enables each control to be referenced
> > > > > under the thermal zones, at least this is the approach taken in CAF 4.9.
> > > > >
> > > > > Maybe I don't quite understand what you mean, are you saying that using
> > > > > thermal zones is the wrong approach?
> > > >
> > > > Thermal framework expects each thermal zone represented in DT to have atleast
> > > > one corresponding thermal sensor defined using "thermal-sensors" property. But
> > > > with TMD, there is no thermal sensor AFAIK.
> > >
> > > As far as I understand, no. It is perfectly fine to have 'cooling'
> > > devices, which react to external thermal monitoring events. I might be
> > > mistaken, but I think that is the case here, isn't it?
> > >
> >
> > Yes it is represented as cooling device(s). But I do not see any cognizant way
> > to plug it with thermal zones i.e., unless TMD itself reports temperature of the
> > modem, using it as a cooling device for external temperature events doesn't
> > sound good to me.
> 
> Why? We have compute, q6, wlan tsens sensors. So it seems natural to
> tell CDSP to slow down if compute sensor reports overheating.
> 

TMD is for external devices such as PCIe modems as well. Is there a temperature
sensor for that?

- Mani

> >
> > - Mani
> >
> > > >
> > > > > >
> > > > > > So please look into that approach.
> > > > >
> > > > > Any recommended reading? Or drivers I can use as a reference?
> > > > >
> > > >
> > > > drivers/powercap/arm_scmi_powercap.c seems to be a good reference.
> > > >
> > > > - Mani
> > > >
> > > > > Thanks
> > > > > >
> > > > > > - Mani
> > > > > >
> > > > > > > This series is based on previous work by Bhupesh Sharma which can be
> > > > > > > found at [1]. I'm sending this as a fresh series as it has been a
> > > > > > > year since the original version and I have rewritten most of the driver.
> > > > > > >
> > > > > > > [1]: https://lore.kernel.org/linux-arm-msm/20220912085049.3517140-1-bhupesh.sharma@linaro.org/
> > > > > > >
> > > > > > > ---
> > > > > > > Caleb Connolly (4):
> > > > > > >        remoteproc: qcom: probe all child devices
> > > > > > >        dt-bindings: thermal: Add qcom,qmi-cooling yaml bindings
> > > > > > >        thermal: qcom: add qmi-cooling driver
> > > > > > >        MAINTAINERS: Add entry for Qualcomm Cooling Driver
> > > > > > >
> > > > > > >   .../bindings/remoteproc/qcom,msm8996-mss-pil.yaml  |  13 +
> > > > > > >   .../bindings/remoteproc/qcom,pas-common.yaml       |   6 +
> > > > > > >   .../bindings/thermal/qcom,qmi-cooling.yaml         | 168 +++++++
> > > > > > >   MAINTAINERS                                        |   8 +
> > > > > > >   drivers/remoteproc/qcom_q6v5.c                     |   4 +
> > > > > > >   drivers/remoteproc/qcom_q6v5_mss.c                 |   8 -
> > > > > > >   drivers/thermal/qcom/Kconfig                       |  13 +
> > > > > > >   drivers/thermal/qcom/Makefile                      |   1 +
> > > > > > >   drivers/thermal/qcom/qmi-cooling.c                 | 520 +++++++++++++++++++++
> > > > > > >   drivers/thermal/qcom/qmi-cooling.h                 | 428 +++++++++++++++++
> > > > > > >   10 files changed, 1161 insertions(+), 8 deletions(-)
> > > > > > > ---
> > > > > > > base-commit: 9067f80db58bbce81d5f0703aa2fd261e88bc812
> > > > > > >
> > > > > > > // Caleb (they/them)
> > > > > > >
> > > > > >
> > > > >
> > > > > --
> > > > > // Caleb (they/them)
> > > >
> > > > --
> > > > மணிவண்ணன் சதாசிவம்
> > >
> > >
> > >
> > > --
> > > With best wishes
> > > Dmitry
> >
> > --
> > மணிவண்ணன் சதாசிவம்
> 
> 
> 
> -- 
> With best wishes
> Dmitry
Neil Armstrong Oct. 2, 2023, 4:28 p.m. UTC | #7
On 02/10/2023 18:13, Manivannan Sadhasivam wrote:
> On Mon, Oct 02, 2023 at 07:00:27PM +0300, Dmitry Baryshkov wrote:
>> On Mon, 2 Oct 2023 at 18:58, Manivannan Sadhasivam <mani@kernel.org> wrote:
>>>
>>> On Mon, Oct 02, 2023 at 06:00:37PM +0300, Dmitry Baryshkov wrote:
>>>> On Mon, 2 Oct 2023 at 17:52, Manivannan Sadhasivam <mani@kernel.org> wrote:
>>>>>
>>>>> On Sun, Oct 01, 2023 at 06:26:14PM +0100, Caleb Connolly wrote:
>>>>>>
>>>>>>
>>>>>> On 01/10/2023 16:57, Manivannan Sadhasivam wrote:
>>>>>>> On Fri, Sep 29, 2023 at 05:16:16PM +0100, Caleb Connolly wrote:
>>>>>>>> The Thermal Mitigation Device (TMD) Service is a QMI service that runs
>>>>>>>> on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
>>>>>>>> It exposes various mitigations including passive thermal controls and
>>>>>>>> rail voltage restrictions.
>>>>>>>>
>>>>>>>> This series introduces support for exposing TMDs as cooling devices
>>>>>>>> in the kernel through the thermal framework, using the QMI interface.
>>>>>>>>
>>>>>>>> Each TMD client is described as a child of the remoteproc node in
>>>>>>>> devicetree. With subnodes for each control.
>>>>>>>>
>>>>>>>
>>>>>>> Daniel expressed concerns in the past aganist representing TMD driver as a
>>>>>>> cooling device since it is not tied to thermal zones and the governors cannot
>>>>>>> use it. Instead he suggested to represent it as a powercap device with thermal
>>>>>>> constraints.
>>>>>>
>>>>>> Hi Mani,
>>>>>>
>>>>>> Forgive me as I'm not yet super familiar with the thermal subsystem.
>>>>>>
>>>>>> As I understand it, the DT layout here enables each control to be referenced
>>>>>> under the thermal zones, at least this is the approach taken in CAF 4.9.
>>>>>>
>>>>>> Maybe I don't quite understand what you mean, are you saying that using
>>>>>> thermal zones is the wrong approach?
>>>>>
>>>>> Thermal framework expects each thermal zone represented in DT to have atleast
>>>>> one corresponding thermal sensor defined using "thermal-sensors" property. But
>>>>> with TMD, there is no thermal sensor AFAIK.
>>>>
>>>> As far as I understand, no. It is perfectly fine to have 'cooling'
>>>> devices, which react to external thermal monitoring events. I might be
>>>> mistaken, but I think that is the case here, isn't it?
>>>>
>>>
>>> Yes it is represented as cooling device(s). But I do not see any cognizant way
>>> to plug it with thermal zones i.e., unless TMD itself reports temperature of the
>>> modem, using it as a cooling device for external temperature events doesn't
>>> sound good to me.
>>
>> Why? We have compute, q6, wlan tsens sensors. So it seems natural to
>> tell CDSP to slow down if compute sensor reports overheating.
>>
> 
> TMD is for external devices such as PCIe modems as well. Is there a temperature
> sensor for that?

Is could, for example NVMe does.

But here Caleb only exposes the internal DSP over the TMD as cooling devices, so
it matches the tsens input we have.

Neil

> 
> - Mani
> 
>>>
>>> - Mani
>>>
>>>>>
>>>>>>>
>>>>>>> So please look into that approach.
>>>>>>
>>>>>> Any recommended reading? Or drivers I can use as a reference?
>>>>>>
>>>>>
>>>>> drivers/powercap/arm_scmi_powercap.c seems to be a good reference.
>>>>>
>>>>> - Mani
>>>>>
>>>>>> Thanks
>>>>>>>
>>>>>>> - Mani
>>>>>>>
>>>>>>>> This series is based on previous work by Bhupesh Sharma which can be
>>>>>>>> found at [1]. I'm sending this as a fresh series as it has been a
>>>>>>>> year since the original version and I have rewritten most of the driver.
>>>>>>>>
>>>>>>>> [1]: https://lore.kernel.org/linux-arm-msm/20220912085049.3517140-1-bhupesh.sharma@linaro.org/
>>>>>>>>
>>>>>>>> ---
>>>>>>>> Caleb Connolly (4):
>>>>>>>>         remoteproc: qcom: probe all child devices
>>>>>>>>         dt-bindings: thermal: Add qcom,qmi-cooling yaml bindings
>>>>>>>>         thermal: qcom: add qmi-cooling driver
>>>>>>>>         MAINTAINERS: Add entry for Qualcomm Cooling Driver
>>>>>>>>
>>>>>>>>    .../bindings/remoteproc/qcom,msm8996-mss-pil.yaml  |  13 +
>>>>>>>>    .../bindings/remoteproc/qcom,pas-common.yaml       |   6 +
>>>>>>>>    .../bindings/thermal/qcom,qmi-cooling.yaml         | 168 +++++++
>>>>>>>>    MAINTAINERS                                        |   8 +
>>>>>>>>    drivers/remoteproc/qcom_q6v5.c                     |   4 +
>>>>>>>>    drivers/remoteproc/qcom_q6v5_mss.c                 |   8 -
>>>>>>>>    drivers/thermal/qcom/Kconfig                       |  13 +
>>>>>>>>    drivers/thermal/qcom/Makefile                      |   1 +
>>>>>>>>    drivers/thermal/qcom/qmi-cooling.c                 | 520 +++++++++++++++++++++
>>>>>>>>    drivers/thermal/qcom/qmi-cooling.h                 | 428 +++++++++++++++++
>>>>>>>>    10 files changed, 1161 insertions(+), 8 deletions(-)
>>>>>>>> ---
>>>>>>>> base-commit: 9067f80db58bbce81d5f0703aa2fd261e88bc812
>>>>>>>>
>>>>>>>> // Caleb (they/them)
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> // Caleb (they/them)
>>>>>
>>>>> --
>>>>> மணிவண்ணன் சதாசிவம்
>>>>
>>>>
>>>>
>>>> --
>>>> With best wishes
>>>> Dmitry
>>>
>>> --
>>> மணிவண்ணன் சதாசிவம்
>>
>>
>>
>> -- 
>> With best wishes
>> Dmitry
>
Bjorn Andersson Oct. 5, 2023, 2:36 a.m. UTC | #8
On Mon, Oct 02, 2023 at 09:43:08PM +0530, Manivannan Sadhasivam wrote:
> On Mon, Oct 02, 2023 at 07:00:27PM +0300, Dmitry Baryshkov wrote:
> > On Mon, 2 Oct 2023 at 18:58, Manivannan Sadhasivam <mani@kernel.org> wrote:
> > >
> > > On Mon, Oct 02, 2023 at 06:00:37PM +0300, Dmitry Baryshkov wrote:
> > > > On Mon, 2 Oct 2023 at 17:52, Manivannan Sadhasivam <mani@kernel.org> wrote:
> > > > >
> > > > > On Sun, Oct 01, 2023 at 06:26:14PM +0100, Caleb Connolly wrote:
> > > > > >
> > > > > >
> > > > > > On 01/10/2023 16:57, Manivannan Sadhasivam wrote:
> > > > > > > On Fri, Sep 29, 2023 at 05:16:16PM +0100, Caleb Connolly wrote:
> > > > > > > > The Thermal Mitigation Device (TMD) Service is a QMI service that runs
> > > > > > > > on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
> > > > > > > > It exposes various mitigations including passive thermal controls and
> > > > > > > > rail voltage restrictions.
> > > > > > > >
> > > > > > > > This series introduces support for exposing TMDs as cooling devices
> > > > > > > > in the kernel through the thermal framework, using the QMI interface.
> > > > > > > >
> > > > > > > > Each TMD client is described as a child of the remoteproc node in
> > > > > > > > devicetree. With subnodes for each control.
> > > > > > > >
> > > > > > >
> > > > > > > Daniel expressed concerns in the past aganist representing TMD driver as a
> > > > > > > cooling device since it is not tied to thermal zones and the governors cannot
> > > > > > > use it. Instead he suggested to represent it as a powercap device with thermal
> > > > > > > constraints.
> > > > > >
> > > > > > Hi Mani,
> > > > > >
> > > > > > Forgive me as I'm not yet super familiar with the thermal subsystem.
> > > > > >
> > > > > > As I understand it, the DT layout here enables each control to be referenced
> > > > > > under the thermal zones, at least this is the approach taken in CAF 4.9.
> > > > > >
> > > > > > Maybe I don't quite understand what you mean, are you saying that using
> > > > > > thermal zones is the wrong approach?
> > > > >
> > > > > Thermal framework expects each thermal zone represented in DT to have atleast
> > > > > one corresponding thermal sensor defined using "thermal-sensors" property. But
> > > > > with TMD, there is no thermal sensor AFAIK.
> > > >
> > > > As far as I understand, no. It is perfectly fine to have 'cooling'
> > > > devices, which react to external thermal monitoring events. I might be
> > > > mistaken, but I think that is the case here, isn't it?
> > > >
> > >
> > > Yes it is represented as cooling device(s). But I do not see any cognizant way
> > > to plug it with thermal zones i.e., unless TMD itself reports temperature of the
> > > modem, using it as a cooling device for external temperature events doesn't
> > > sound good to me.
> > 
> > Why? We have compute, q6, wlan tsens sensors. So it seems natural to
> > tell CDSP to slow down if compute sensor reports overheating.
> > 
> 
> TMD is for external devices such as PCIe modems as well. Is there a temperature
> sensor for that?
> 

According to the schematics for the SC8280XP CRD sys_therm5 would be the
sensor you're looking for.

Regards,
Bjorn
Bjorn Andersson Oct. 5, 2023, 2:52 a.m. UTC | #9
On Sun, Oct 01, 2023 at 09:27:01PM +0530, Manivannan Sadhasivam wrote:
> On Fri, Sep 29, 2023 at 05:16:16PM +0100, Caleb Connolly wrote:
> > The Thermal Mitigation Device (TMD) Service is a QMI service that runs
> > on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
> > It exposes various mitigations including passive thermal controls and
> > rail voltage restrictions.
> > 
> > This series introduces support for exposing TMDs as cooling devices
> > in the kernel through the thermal framework, using the QMI interface.
> > 
> > Each TMD client is described as a child of the remoteproc node in
> > devicetree. With subnodes for each control.
> > 
> 
> Daniel expressed concerns in the past aganist representing TMD driver as a
> cooling device since it is not tied to thermal zones and the governors cannot
> use it. Instead he suggested to represent it as a powercap device with thermal
> constraints.
> 
> So please look into that approach.
> 

The powercap framework revolves around the idea that we have some amount
of power (micro-watt) being available to the system, which can be split
across a range of devices.

Say that we implement this as a powercap thing, what current consumption
would you attribute these entires? How would you map a given uW value to
the mitigation levels provided by the qmi-cooling instances?


Beyond that, I'm still not sure how we would plug this in. We don't have
a picture of the power consumption/flow through the system at any point
in time - as the control of the power grid is distributed across the
various subsystems.

Regards,
Bjorn
Manivannan Sadhasivam Oct. 10, 2023, 12:24 p.m. UTC | #10
On Wed, Oct 04, 2023 at 07:36:58PM -0700, Bjorn Andersson wrote:
> On Mon, Oct 02, 2023 at 09:43:08PM +0530, Manivannan Sadhasivam wrote:
> > On Mon, Oct 02, 2023 at 07:00:27PM +0300, Dmitry Baryshkov wrote:
> > > On Mon, 2 Oct 2023 at 18:58, Manivannan Sadhasivam <mani@kernel.org> wrote:
> > > >
> > > > On Mon, Oct 02, 2023 at 06:00:37PM +0300, Dmitry Baryshkov wrote:
> > > > > On Mon, 2 Oct 2023 at 17:52, Manivannan Sadhasivam <mani@kernel.org> wrote:
> > > > > >
> > > > > > On Sun, Oct 01, 2023 at 06:26:14PM +0100, Caleb Connolly wrote:
> > > > > > >
> > > > > > >
> > > > > > > On 01/10/2023 16:57, Manivannan Sadhasivam wrote:
> > > > > > > > On Fri, Sep 29, 2023 at 05:16:16PM +0100, Caleb Connolly wrote:
> > > > > > > > > The Thermal Mitigation Device (TMD) Service is a QMI service that runs
> > > > > > > > > on remote subsystems (the modem and DSPs) on Qualcomm SoCs.
> > > > > > > > > It exposes various mitigations including passive thermal controls and
> > > > > > > > > rail voltage restrictions.
> > > > > > > > >
> > > > > > > > > This series introduces support for exposing TMDs as cooling devices
> > > > > > > > > in the kernel through the thermal framework, using the QMI interface.
> > > > > > > > >
> > > > > > > > > Each TMD client is described as a child of the remoteproc node in
> > > > > > > > > devicetree. With subnodes for each control.
> > > > > > > > >
> > > > > > > >
> > > > > > > > Daniel expressed concerns in the past aganist representing TMD driver as a
> > > > > > > > cooling device since it is not tied to thermal zones and the governors cannot
> > > > > > > > use it. Instead he suggested to represent it as a powercap device with thermal
> > > > > > > > constraints.
> > > > > > >
> > > > > > > Hi Mani,
> > > > > > >
> > > > > > > Forgive me as I'm not yet super familiar with the thermal subsystem.
> > > > > > >
> > > > > > > As I understand it, the DT layout here enables each control to be referenced
> > > > > > > under the thermal zones, at least this is the approach taken in CAF 4.9.
> > > > > > >
> > > > > > > Maybe I don't quite understand what you mean, are you saying that using
> > > > > > > thermal zones is the wrong approach?
> > > > > >
> > > > > > Thermal framework expects each thermal zone represented in DT to have atleast
> > > > > > one corresponding thermal sensor defined using "thermal-sensors" property. But
> > > > > > with TMD, there is no thermal sensor AFAIK.
> > > > >
> > > > > As far as I understand, no. It is perfectly fine to have 'cooling'
> > > > > devices, which react to external thermal monitoring events. I might be
> > > > > mistaken, but I think that is the case here, isn't it?
> > > > >
> > > >
> > > > Yes it is represented as cooling device(s). But I do not see any cognizant way
> > > > to plug it with thermal zones i.e., unless TMD itself reports temperature of the
> > > > modem, using it as a cooling device for external temperature events doesn't
> > > > sound good to me.
> > > 
> > > Why? We have compute, q6, wlan tsens sensors. So it seems natural to
> > > tell CDSP to slow down if compute sensor reports overheating.
> > > 
> > 
> > TMD is for external devices such as PCIe modems as well. Is there a temperature
> > sensor for that?
> > 
> 
> According to the schematics for the SC8280XP CRD sys_therm5 would be the
> sensor you're looking for.
> 

Hmm, then it seems fine from my end as long we have the correct sensor data to
hook up these cooling devices.

- Mani

> Regards,
> Bjorn