aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / omega / platform / pcie-cooling-proposal.patch
| 1 | --- a/drivers/thermal/pcie_cooling.c |
| 2 | +++ b/drivers/thermal/pcie_cooling.c |
| 3 | @@ -20,9 +20,13 @@ |
| 4 | static int pcie_cooling_get_max_level(struct thermal_cooling_device *cdev, unsigned long *state) |
| 5 | { |
| 6 | struct pci_dev *port = cdev->devdata; |
| 7 | + enum pci_bus_speed speed = READ_ONCE(port->subordinate->max_bus_speed); |
| 8 | + |
| 9 | + if (speed < PCIE_SPEED_2_5GT || speed > PCIE_SPEED_64_0GT) |
| 10 | + return -EINVAL; |
| 11 | |
| 12 | /* cooling state 0 is same as the maximum PCIe speed */ |
| 13 | - *state = port->subordinate->max_bus_speed - PCIE_SPEED_2_5GT; |
| 14 | + *state = speed - PCIE_SPEED_2_5GT; |
| 15 | |
| 16 | return 0; |
| 17 | } |
| 18 | @@ -31,8 +35,15 @@ |
| 19 | { |
| 20 | struct pci_dev *port = cdev->devdata; |
| 21 | |
| 22 | + enum pci_bus_speed speed = READ_ONCE(port->subordinate->cur_bus_speed); |
| 23 | + |
| 24 | + /* Unknown, non-PCIe or stale speeds are not cooling states. */ |
| 25 | + if (speed < PCIE_SPEED_2_5GT || speed > PCIE_SPEED_64_0GT || |
| 26 | + speed - PCIE_SPEED_2_5GT > cdev->max_state) |
| 27 | + return -EAGAIN; |
| 28 | + |
| 29 | /* cooling state 0 is same as the maximum PCIe speed */ |
| 30 | - *state = cdev->max_state - (port->subordinate->cur_bus_speed - PCIE_SPEED_2_5GT); |
| 31 | + *state = cdev->max_state - (speed - PCIE_SPEED_2_5GT); |
| 32 | |
| 33 | return 0; |
| 34 | } |