Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/native/omega/platform/pcie-cooling-proposal.patch # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / native / omega / platform / pcie-cooling-proposal.patch` 34 lines ยท 1124 bytes Raw Blame History 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 }