linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Hook up a PCIe device into the thermal framework
@ 2021-01-14 17:04 Waldemar Rymarkiewicz
  2021-01-14 20:51 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Waldemar Rymarkiewicz @ 2021-01-14 17:04 UTC (permalink / raw)
  To: linux-kernel, linux-pci

Hi,

I've been looking for a nice way to hook up a PCIe device into the
thermal framework recently and I want to confront my findings with the
right people here.

I have a PCIe wireless adapter connected to PCI-to-PCI bridge which in
turns is connected to a PCI root complex (RC). I want to define a
thermal zone over the wireless adapter in my system and control it
over DT (thermal-zones{...})  instead of keeping thermal zone
definition statically in the PCI device driver (as it's done in the
iwlwifi wireless driver or the mlxsw ethernet driver for example)

The issue I have faced is that a PCI device has no DT node
(pci_dev.dev.of_node) which is reasonable as this is by design
discoverable device. This, however, prevents me to register the PCI
device as a thermal sensor (dev.of_node is required by thermal).

As far as we consider a fixed PCI topology eg. a SoC internal design I
could put something like this in DT (used by ath11k/ath10k btw).

pci@... {
   ...
   pci-bridge@... {
   ...
        wifi:wifi@0 {
              reg = <0x0 0 0 0 0>;
              #thermal-sensor-cells = <0>;
         };
   };
};

but in case we consider an arbitrary location of the device in PCI
topology that DT modification will not work and still I have no device
node.

Is there any preferred solution in the Linux kernel for this kind of use-case?

All the ideas appreciated.

Thanks,
/Waldek

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Hook up a PCIe device into the thermal framework
  2021-01-14 17:04 Hook up a PCIe device into the thermal framework Waldemar Rymarkiewicz
@ 2021-01-14 20:51 ` Bjorn Helgaas
  2021-01-15  8:49   ` Waldemar Rymarkiewicz
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2021-01-14 20:51 UTC (permalink / raw)
  To: Waldemar Rymarkiewicz
  Cc: linux-kernel, linux-pci, Zhang Rui, Daniel Lezcano,
	Amit Kucheria, Rob Herring, Frank Rowand, linux-pm

[+cc thermal and DT folks]

On Thu, Jan 14, 2021 at 06:04:18PM +0100, Waldemar Rymarkiewicz wrote:
> Hi,
> 
> I've been looking for a nice way to hook up a PCIe device into the
> thermal framework recently and I want to confront my findings with the
> right people here.
> 
> I have a PCIe wireless adapter connected to PCI-to-PCI bridge which in
> turns is connected to a PCI root complex (RC). I want to define a
> thermal zone over the wireless adapter in my system and control it
> over DT (thermal-zones{...})  instead of keeping thermal zone
> definition statically in the PCI device driver (as it's done in the
> iwlwifi wireless driver or the mlxsw ethernet driver for example)
> 
> The issue I have faced is that a PCI device has no DT node
> (pci_dev.dev.of_node) which is reasonable as this is by design
> discoverable device. This, however, prevents me to register the PCI
> device as a thermal sensor (dev.of_node is required by thermal).
> 
> As far as we consider a fixed PCI topology eg. a SoC internal design I
> could put something like this in DT (used by ath11k/ath10k btw).
> 
> pci@... {
>    ...
>    pci-bridge@... {
>    ...
>         wifi:wifi@0 {
>               reg = <0x0 0 0 0 0>;
>               #thermal-sensor-cells = <0>;
>          };
>    };
> };
> 
> but in case we consider an arbitrary location of the device in PCI
> topology that DT modification will not work and still I have no device
> node.

I'm absolutely not a DT expert, but I assume that a thermal zone would
be associated with some resource fixed by the platform, such as a fan,
so I would think a thermal zone would have to be described in terms of
the platform physical topology, not the PCI device type.

> Is there any preferred solution in the Linux kernel for this kind of use-case?
> 
> All the ideas appreciated.
> 
> Thanks,
> /Waldek

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Hook up a PCIe device into the thermal framework
  2021-01-14 20:51 ` Bjorn Helgaas
@ 2021-01-15  8:49   ` Waldemar Rymarkiewicz
  0 siblings, 0 replies; 3+ messages in thread
From: Waldemar Rymarkiewicz @ 2021-01-15  8:49 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: linux-kernel, linux-pci, Zhang Rui, Daniel Lezcano,
	Amit Kucheria, Rob Herring, Frank Rowand, linux-pm

Hi,

> > topology that DT modification will not work and still I have no device
> > node.
>
> I'm absolutely not a DT expert, but I assume that a thermal zone would
> be associated with some resource fixed by the platform, such as a fan,
> so I would think a thermal zone would have to be described in terms of
> the platform physical topology, not the PCI device type.

The thermal zone needs a temperature sensor device to read out
temperature and also some cooling devices which are mapped to specific
zone trips.
In a below scenario, when TZ hists the wifi_allert0 trip it will run
the fan but if the temp still rises it will try to dissipate the heat
by running some actions within wifi adapter eg. switch off some
antennas.

[...]
wifi_thermal: wifi-thermal {
    thermal-sensors = <&wifi_device>;
    trips {
        wifi_alert0: wifi-alert0 {
            temperature = <90000>;
            hysteresis = <5000>;
            type = "active";
        };

        wifi_alert1: wifi-alert1 {
            temperature = <110000>;
            hysteresis = <5000>;
            type = "passive";
        };

        cooling-maps {
            map0 {
                 trip = <&wifi_alert0>;
                 cooling-device = <&fan0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
            };
            map1 {
                 trip = <&wifi_alert1>;
                 cooling-device = <&wifi_device THERMAL_NO_LIMIT
THERMAL_NO_LIMIT>;
            };
        };
};
[...]

My problem is not a cooling method but the binding of the PCI device
(it has a thermal sensor) with the thermal zone

    thermal-sensors = <&wifi_device>;     // wifi_devcie does not
exist until I will statically define it under PCI controller

The point here is that defining wifi_device under the controller I
need to reflect the PCI topology. Which is fair as DT should reflect
the HW connection. Even if I define a wifi_device anywhere in DT and
assuming the PCI core will search whole DT and not only subnodes of
the controller/bridge/switch here likely comes another problem. What
should be the key to search for the device node? PCI addresses devices
by bus:device: function and this is known after PCI scan.

To me seems that so far no one found a good way to handle thermal
within PCI devices, so some drivers statically create TZ and handle it
within the driver. This way, unfortunately, we lose the flexibility of
thermal control from a system-wide perspective. WiFi adapter is not
aware of the fan for example.

/Waldek

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-15  8:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14 17:04 Hook up a PCIe device into the thermal framework Waldemar Rymarkiewicz
2021-01-14 20:51 ` Bjorn Helgaas
2021-01-15  8:49   ` Waldemar Rymarkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).