* [PATCH v3 0/4] PCI: Add pci_power_t helper functions
@ 2026-11-21 12:59 Habil Eren Türker
2026-11-21 12:59 ` [PATCH v3 1/4] " Habil Eren Türker
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Habil Eren Türker @ 2026-11-21 12:59 UTC (permalink / raw)
To: Bjorn Helgaas, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
Dave Hansen, x86@kernel.org
Cc: H . Peter Anvin, andriy.shevchenko@intel.com,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Habil Eren Türker
This series introduces helper functions for accessing PCI power
states in the Power Management Control/Status register and
converts existing PMCSR accesses to use these helpers.
The helpers provide typed access to the PCI power state field,
including extraction, setting, and comparison operations.
The series also updates the Apple Airport reset quirk to use
the new comparison helper.
This follows the discussion with Andy Shevchenko and
Bjorn Helgaas in response to "x86/quirks: Cast PCI_D0
to u16 in apple_airport_reset()" [1].
Changes in v2:
- Add helpers for comparing PCI power states.
- Convert PCI core and quirk code to use the new helpers.
- Address review feedback.
Changes in v3:
- Move helpers' positions to upper lines of the pci.h with
header include.
- Fix indentation in pci.c.
- Rename function `pci_power_eq()` to `pci_power_t_eq()` for
API name consistency.
- Rewrite pci_power_t_eq() parameters for comparison of
two `pci_power_t` type variables.
- Modify `pci_power_t_set` to use `u16 *csr` instead of
u32.
- Use `FIELD_MODIFY()` in `pci_power_t_set()`.
- Remove `pci_power_gt` and `pci_power_lt`.
- Add resolved Sparse warnings to commit messages.
- Link to v2: https://lore.kernel.org/lkml/cover.1795097970.git.habilerenturker@hotmail.com/
Link: https://lore.kernel.org/lkml/20261118161559.63617-1-habilerenturker@hotmail.com/ [1]
Note: LLM assistance was used for editing the cover letter and
commit descriptions. ALl changes were reviewed by the submitter.
Habil Eren Türker (4):
PCI: Add pci_power_t helper functions
PCI: Convert pci.c to pci_power_t helpers
PCI: Convert quirks.c to pci_power_t helpers
x86/quirks: Use pci_power_t_eq() in apple_airport_reset()
arch/x86/kernel/early-quirks.c | 6 +++---
drivers/pci/pci.c | 28 ++++++++++++----------------
drivers/pci/quirks.c | 2 +-
include/linux/pci.h | 17 +++++++++++++++++
4 files changed, 33 insertions(+), 20 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v3 1/4] PCI: Add pci_power_t helper functions 2026-11-21 12:59 [PATCH v3 0/4] PCI: Add pci_power_t helper functions Habil Eren Türker @ 2026-11-21 12:59 ` Habil Eren Türker 2026-11-21 12:59 ` [PATCH] PCI: Convert pci.c to pci_power_t helpers Habil Eren Türker ` (2 subsequent siblings) 3 siblings, 0 replies; 6+ messages in thread From: Habil Eren Türker @ 2026-11-21 12:59 UTC (permalink / raw) To: Bjorn Helgaas, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86@kernel.org Cc: H . Peter Anvin, andriy.shevchenko@intel.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Habil Eren Türker Add helper functions to extract, set and compare PCI power states in the Power Management Control/Status register. Functions added: - pci_power_t_get() - pci_power_t_set() - pci_power_t_eq() Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com> --- include/linux/pci.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/pci.h b/include/linux/pci.h index aa3765a20a96..bfaff0ea6c2d 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -40,6 +40,7 @@ #include <linux/io.h> #include <linux/resource_ext.h> #include <linux/msi_api.h> +#include <linux/bitfield.h> #include <uapi/linux/pci.h> #include <linux/pci_ids.h> @@ -200,6 +201,22 @@ static inline const char *pci_power_name(pci_power_t state) return pci_power_names[1 + (__force int) state]; } +/* Helper functions for PCI power management */ +static inline pci_power_t pci_power_t_get(u16 csr) +{ + return (pci_power_t __force)FIELD_GET(PCI_PM_CTRL_STATE_MASK, csr); +} + +static inline void pci_power_t_set(u16 *csr, pci_power_t state) +{ + FIELD_MODIFY(PCI_PM_CTRL_STATE_MASK, csr, (__force u16)state); +} + +static inline bool pci_power_t_eq(pci_power_t state_a, pci_power_t state_b) +{ + return state_a == state_b; +} + /** * typedef pci_channel_state_t * -- 2.47.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] PCI: Convert pci.c to pci_power_t helpers 2026-11-21 12:59 [PATCH v3 0/4] PCI: Add pci_power_t helper functions Habil Eren Türker 2026-11-21 12:59 ` [PATCH v3 1/4] " Habil Eren Türker @ 2026-11-21 12:59 ` Habil Eren Türker 2026-11-21 17:56 ` kernel test robot 2026-11-21 12:59 ` [PATCH v3 3/4] PCI: Convert quirks.c " Habil Eren Türker 2026-11-21 12:59 ` [PATCH v3 4/4] x86/quirks: Use pci_power_t_eq() in apple_airport_reset() Habil Eren Türker 3 siblings, 1 reply; 6+ messages in thread From: Habil Eren Türker @ 2026-11-21 12:59 UTC (permalink / raw) To: Bjorn Helgaas, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86@kernel.org Cc: H . Peter Anvin, andriy.shevchenko@intel.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Habil Eren Türker Convert PCI core code to use the pci_power_t helper functions when accessing the Power Management Control/Status register. Keep comparisons between values already typed as pci_power_t as direct typed comparisons. Resolved Sparse warnings: - drivers/pci/pci.c : warning: incorrect type in assignment (different base types) (4 warnings) - drivers/pci/pci.c : warning: invalid assignment: |= (3 warnings) Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com> --- drivers/pci/pci.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7c6f2aba8144..d39c897f7735 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1171,7 +1171,7 @@ void pci_update_current_state(struct pci_dev *dev, pci_power_t state) dev->current_state = PCI_D3cold; return; } - dev->current_state = pmcsr & PCI_PM_CTRL_STATE_MASK; + dev->current_state = pci_power_t_get(pmcsr); } else { dev->current_state = state; } @@ -1368,12 +1368,11 @@ int pci_power_up(struct pci_dev *dev) return -EIO; } - state = pmcsr & PCI_PM_CTRL_STATE_MASK; + need_restore = !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET) && + (pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D3hot) || + dev->current_state >= PCI_D3hot); - need_restore = (state == PCI_D3hot || dev->current_state >= PCI_D3hot) && - !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET); - - if (state == PCI_D0) + if (pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D0)) goto end; /* @@ -1383,7 +1382,7 @@ int pci_power_up(struct pci_dev *dev) pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, 0); /* Mandatory transition delays; see PCI PM 1.2. */ - if (state == PCI_D3hot) { + if (pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D3hot)) { pci_dev_d3_sleep(dev); if (!(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET)) { ret = pci_dev_wait(dev, "power up D3hot->D0uninitialized", @@ -1393,7 +1392,7 @@ int pci_power_up(struct pci_dev *dev) return -EIO; } } - } else if (state == PCI_D2) { + } else if (pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D2)) { udelay(PCI_PM_D2_DELAY); } @@ -1432,7 +1431,7 @@ static int pci_set_full_power_state(struct pci_dev *dev, bool locked) } pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); - dev->current_state = pmcsr & PCI_PM_CTRL_STATE_MASK; + dev->current_state = pci_power_t_get(pmcsr); if (dev->current_state != PCI_D0) { pci_info_ratelimited(dev, "Refused to change power state from %s to D0\n", pci_power_name(dev->current_state)); @@ -1546,8 +1545,7 @@ static int pci_set_low_power_state(struct pci_dev *dev, pci_power_t state, bool return -EIO; } - pmcsr &= ~PCI_PM_CTRL_STATE_MASK; - pmcsr |= state; + pci_power_t_set(&pmcsr, state); /* Enter specified state */ pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, pmcsr); @@ -1559,7 +1557,7 @@ static int pci_set_low_power_state(struct pci_dev *dev, pci_power_t state, bool udelay(PCI_PM_D2_DELAY); pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); - dev->current_state = pmcsr & PCI_PM_CTRL_STATE_MASK; + dev->current_state = pci_power_t_get(pmcsr); if (dev->current_state != state) pci_info_ratelimited(dev, "Refused to change power state from %s to %s\n", pci_power_name(dev->current_state), @@ -4590,13 +4588,11 @@ static int pci_pm_reset(struct pci_dev *dev, bool probe) return ret; } - csr &= ~PCI_PM_CTRL_STATE_MASK; - csr |= PCI_D3hot; + pci_power_t_set(&csr, PCI_D3hot); pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, csr); pci_dev_d3_sleep(dev); - csr &= ~PCI_PM_CTRL_STATE_MASK; - csr |= PCI_D0; + pci_power_t_set(&csr, PCI_D0); pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, csr); pci_dev_d3_sleep(dev); -- 2.47.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] PCI: Convert pci.c to pci_power_t helpers 2026-11-21 12:59 ` [PATCH] PCI: Convert pci.c to pci_power_t helpers Habil Eren Türker @ 2026-11-21 17:56 ` kernel test robot 0 siblings, 0 replies; 6+ messages in thread From: kernel test robot @ 2026-11-21 17:56 UTC (permalink / raw) To: Habil Eren Türker, Bjorn Helgaas, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86@kernel.org Cc: llvm, oe-kbuild-all, H . Peter Anvin, andriy.shevchenko@intel.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Habil Eren Türker Hi Habil, kernel test robot noticed the following build errors: [auto build test ERROR on pci/next] [also build test ERROR on pci/for-linus linus/master v7.4-rc3 next-20261119] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Habil-Eren-T-rker/PCI-Convert-pci-c-to-pci_power_t-helpers/20261121-125915 base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next patch link: https://lore.kernel.org/r/20261121125811.50315-3-habilerenturker%40hotmail.com patch subject: [PATCH] PCI: Convert pci.c to pci_power_t helpers config: loongarch-allnoconfig (https://download.01.org/0day-ci/archive/20261122/202611220152.DcrSGe3C-lkp@intel.com/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261122/202611220152.DcrSGe3C-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202611220152.DcrSGe3C-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/pci/pci.c:1174:24: error: call to undeclared function 'pci_power_t_get'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 1174 | dev->current_state = pci_power_t_get(pmcsr); | ^ drivers/pci/pci.c:1174:24: note: did you mean 'pci_power_name'? include/linux/pci.h:198:27: note: 'pci_power_name' declared here 198 | static inline const char *pci_power_name(pci_power_t state) | ^ >> drivers/pci/pci.c:1372:5: error: call to undeclared function 'pci_power_t_eq'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 1372 | (pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D3hot) || | ^ drivers/pci/pci.c:1372:20: error: call to undeclared function 'pci_power_t_get'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 1372 | (pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D3hot) || | ^ drivers/pci/pci.c:1434:23: error: call to undeclared function 'pci_power_t_get'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 1434 | dev->current_state = pci_power_t_get(pmcsr); | ^ >> drivers/pci/pci.c:1548:2: error: call to undeclared function 'pci_power_t_set'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 1548 | pci_power_t_set(&pmcsr, state); | ^ drivers/pci/pci.c:1548:2: note: did you mean 'pci_power_name'? include/linux/pci.h:198:27: note: 'pci_power_name' declared here 198 | static inline const char *pci_power_name(pci_power_t state) | ^ drivers/pci/pci.c:1560:23: error: call to undeclared function 'pci_power_t_get'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 1560 | dev->current_state = pci_power_t_get(pmcsr); | ^ drivers/pci/pci.c:4595:2: error: call to undeclared function 'pci_power_t_set'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 4595 | pci_power_t_set(&csr, PCI_D3hot); | ^ 7 errors generated. vim +/pci_power_t_get +1174 drivers/pci/pci.c 1149 1150 /** 1151 * pci_update_current_state - Read power state of given device and cache it 1152 * @dev: PCI device to handle. 1153 * @state: State to cache in case the device doesn't have the PM capability 1154 * 1155 * The power state is read from the PMCSR register, which however is 1156 * inaccessible in D3cold. The platform firmware is therefore queried first 1157 * to detect accessibility of the register. In case the platform firmware 1158 * reports an incorrect state or the device isn't power manageable by the 1159 * platform at all, we try to detect D3cold by testing accessibility of the 1160 * vendor ID in config space. 1161 */ 1162 void pci_update_current_state(struct pci_dev *dev, pci_power_t state) 1163 { 1164 if (platform_pci_get_power_state(dev) == PCI_D3cold) { 1165 dev->current_state = PCI_D3cold; 1166 } else if (dev->pm_cap) { 1167 u16 pmcsr; 1168 1169 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); 1170 if (PCI_POSSIBLE_ERROR(pmcsr)) { 1171 dev->current_state = PCI_D3cold; 1172 return; 1173 } > 1174 dev->current_state = pci_power_t_get(pmcsr); 1175 } else { 1176 dev->current_state = state; 1177 } 1178 } 1179 1180 /** 1181 * pci_refresh_power_state - Refresh the given device's power state data 1182 * @dev: Target PCI device. 1183 * 1184 * Ask the platform to refresh the devices power state information and invoke 1185 * pci_update_current_state() to update its current PCI power state. 1186 */ 1187 void pci_refresh_power_state(struct pci_dev *dev) 1188 { 1189 platform_pci_refresh_power_state(dev); 1190 pci_update_current_state(dev, dev->current_state); 1191 } 1192 1193 /** 1194 * pci_platform_power_transition - Use platform to change device power state 1195 * @dev: PCI device to handle. 1196 * @state: State to put the device into. 1197 */ 1198 int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state) 1199 { 1200 int error; 1201 1202 error = platform_pci_set_power_state(dev, state); 1203 if (!error) 1204 pci_update_current_state(dev, state); 1205 else if (!dev->pm_cap) /* Fall back to PCI_D0 */ 1206 dev->current_state = PCI_D0; 1207 1208 return error; 1209 } 1210 EXPORT_SYMBOL_GPL(pci_platform_power_transition); 1211 1212 static int pci_resume_one(struct pci_dev *pci_dev, void *ign) 1213 { 1214 pm_request_resume(&pci_dev->dev); 1215 return 0; 1216 } 1217 1218 /** 1219 * pci_resume_bus - Walk given bus and runtime resume devices on it 1220 * @bus: Top bus of the subtree to walk. 1221 */ 1222 void pci_resume_bus(struct pci_bus *bus) 1223 { 1224 if (bus) 1225 pci_walk_bus(bus, pci_resume_one, NULL); 1226 } 1227 1228 static int pci_dev_wait(struct pci_dev *dev, char *reset_type, int timeout) 1229 { 1230 int delay = 1; 1231 bool retrain = false; 1232 struct pci_dev *root, *bridge; 1233 1234 root = pcie_find_root_port(dev); 1235 1236 if (pci_is_pcie(dev)) { 1237 bridge = pci_upstream_bridge(dev); 1238 if (bridge) 1239 retrain = true; 1240 } 1241 1242 /* 1243 * The caller has already waited long enough after a reset that the 1244 * device should respond to config requests, but it may respond 1245 * with Request Retry Status (RRS) if it needs more time to 1246 * initialize. 1247 * 1248 * If the device is below a Root Port with Configuration RRS 1249 * Software Visibility enabled, reading the Vendor ID may return a 1250 * special data value if the device responded with RRS. Read the 1251 * Vendor ID until we get non-RRS status and something other than 1252 * ~0. The Vendor ID of VFs reads ~0, so check their Command 1253 * register instead. 1254 * 1255 * If there's no Root Port or Configuration RRS Software Visibility 1256 * is not enabled, the device may still respond with RRS, but 1257 * hardware may retry the config request. If no retries receive 1258 * Successful Completion, hardware generally synthesizes ~0 1259 * (PCI_ERROR_RESPONSE) data to complete the read. Reading Vendor 1260 * ID for VFs and non-existent devices also returns ~0, so read the 1261 * Command register until it returns something other than ~0. 1262 */ 1263 for (;;) { 1264 u32 id; 1265 1266 if (pci_dev_is_disconnected(dev)) { 1267 pci_dbg(dev, "disconnected; not waiting\n"); 1268 return -ENOTTY; 1269 } 1270 1271 if (root && root->config_rrs_sv) { 1272 pci_read_config_dword(dev, PCI_VENDOR_ID, &id); 1273 if (!pci_bus_rrs_vendor_id(id)) { 1274 if (PCI_POSSIBLE_ERROR(id) && dev->is_virtfn) 1275 pci_read_config_dword(dev, PCI_COMMAND, 1276 &id); 1277 if (!PCI_POSSIBLE_ERROR(id)) 1278 break; 1279 } 1280 } else { 1281 pci_read_config_dword(dev, PCI_COMMAND, &id); 1282 if (!PCI_POSSIBLE_ERROR(id)) 1283 break; 1284 } 1285 1286 if (delay > timeout) { 1287 pci_err(dev, "not ready %dms after %s; giving up\n", 1288 delay - 1, reset_type); 1289 return -ENOTTY; 1290 } 1291 1292 if (delay > PCI_RESET_WAIT) { 1293 if (retrain) { 1294 retrain = false; 1295 if (pcie_failed_link_retrain(bridge) == 0) { 1296 delay = 1; 1297 continue; 1298 } 1299 } 1300 pci_info(dev, "not ready %dms after %s; waiting\n", 1301 delay - 1, reset_type); 1302 } 1303 1304 msleep(delay); 1305 delay *= 2; 1306 } 1307 1308 if (delay > PCI_RESET_WAIT) 1309 pci_info(dev, "ready %dms after %s\n", delay - 1, 1310 reset_type); 1311 else 1312 pci_dbg(dev, "ready %dms after %s\n", delay - 1, 1313 reset_type); 1314 1315 return 0; 1316 } 1317 1318 /** 1319 * pci_power_up - Put the given device into D0 1320 * @dev: PCI device to power up 1321 * 1322 * On success, return 0 or 1, depending on whether or not it is necessary to 1323 * restore the device's BARs subsequently (1 is returned in that case). 1324 * 1325 * On failure, return a negative error code. Always return failure if @dev 1326 * lacks a Power Management Capability, even if the platform was able to 1327 * put the device in D0 via non-PCI means. 1328 */ 1329 int pci_power_up(struct pci_dev *dev) 1330 { 1331 bool need_restore; 1332 pci_power_t state; 1333 u16 pmcsr; 1334 int ret; 1335 1336 /* 1337 * When setting power state to D0, platform_pci_set_power_state() 1338 * ensures main power is on. If it puts the device in D0, it also 1339 * completes any required delays after the transition; if it leaves 1340 * the device in D1, D2, or D3hot, we use the PM Capability to 1341 * transition to D0. 1342 * 1343 * In all cases, the device is either Configuration-Ready or 1344 * inaccessible upon return. 1345 */ 1346 platform_pci_set_power_state(dev, PCI_D0); 1347 1348 if (!dev->pm_cap) { 1349 state = platform_pci_get_power_state(dev); 1350 if (state == PCI_UNKNOWN) 1351 dev->current_state = PCI_D0; 1352 else 1353 dev->current_state = state; 1354 1355 return -EIO; 1356 } 1357 1358 if (pci_dev_is_disconnected(dev)) { 1359 dev->current_state = PCI_D3cold; 1360 return -EIO; 1361 } 1362 1363 pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); 1364 if (PCI_POSSIBLE_ERROR(pmcsr)) { 1365 pci_err(dev, "Unable to change power state from %s to D0, device inaccessible\n", 1366 pci_power_name(dev->current_state)); 1367 dev->current_state = PCI_D3cold; 1368 return -EIO; 1369 } 1370 1371 need_restore = !(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET) && > 1372 (pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D3hot) || 1373 dev->current_state >= PCI_D3hot); 1374 1375 if (pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D0)) 1376 goto end; 1377 1378 /* 1379 * Force the entire word to 0. This doesn't affect PME_Status, disables 1380 * PME_En, and sets PowerState to 0. 1381 */ 1382 pci_write_config_word(dev, dev->pm_cap + PCI_PM_CTRL, 0); 1383 1384 /* Mandatory transition delays; see PCI PM 1.2. */ 1385 if (pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D3hot)) { 1386 pci_dev_d3_sleep(dev); 1387 if (!(pmcsr & PCI_PM_CTRL_NO_SOFT_RESET)) { 1388 ret = pci_dev_wait(dev, "power up D3hot->D0uninitialized", 1389 PCIE_RESET_READY_POLL_MS); 1390 if (ret) { 1391 dev->current_state = PCI_D3cold; 1392 return -EIO; 1393 } 1394 } 1395 } else if (pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D2)) { 1396 udelay(PCI_PM_D2_DELAY); 1397 } 1398 1399 end: 1400 dev->current_state = PCI_D0; 1401 if (need_restore) 1402 return 1; 1403 1404 return 0; 1405 } 1406 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 3/4] PCI: Convert quirks.c to pci_power_t helpers 2026-11-21 12:59 [PATCH v3 0/4] PCI: Add pci_power_t helper functions Habil Eren Türker 2026-11-21 12:59 ` [PATCH v3 1/4] " Habil Eren Türker 2026-11-21 12:59 ` [PATCH] PCI: Convert pci.c to pci_power_t helpers Habil Eren Türker @ 2026-11-21 12:59 ` Habil Eren Türker 2026-11-21 12:59 ` [PATCH v3 4/4] x86/quirks: Use pci_power_t_eq() in apple_airport_reset() Habil Eren Türker 3 siblings, 0 replies; 6+ messages in thread From: Habil Eren Türker @ 2026-11-21 12:59 UTC (permalink / raw) To: Bjorn Helgaas, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86@kernel.org Cc: H . Peter Anvin, andriy.shevchenko@intel.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Habil Eren Türker Use pci_power_t helper functions when accessing PCI power states in PCI quirks. Resolved Sparse warning: - drivers/pci/quirks.c : warning: restricted pci_power_t degrades to integer Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com> --- drivers/pci/quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 7f1f47ea2ee4..4417ed6422a9 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -2487,7 +2487,7 @@ static void quirk_e100_interrupt(struct pci_dev *dev) */ if (dev->pm_cap) { pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); - if ((pmcsr & PCI_PM_CTRL_STATE_MASK) != PCI_D0) + if (!pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D0)) return; } -- 2.47.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 4/4] x86/quirks: Use pci_power_t_eq() in apple_airport_reset() 2026-11-21 12:59 [PATCH v3 0/4] PCI: Add pci_power_t helper functions Habil Eren Türker ` (2 preceding siblings ...) 2026-11-21 12:59 ` [PATCH v3 3/4] PCI: Convert quirks.c " Habil Eren Türker @ 2026-11-21 12:59 ` Habil Eren Türker 3 siblings, 0 replies; 6+ messages in thread From: Habil Eren Türker @ 2026-11-21 12:59 UTC (permalink / raw) To: Bjorn Helgaas, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86@kernel.org Cc: H . Peter Anvin, andriy.shevchenko@intel.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Habil Eren Türker Use pci_power_t_eq() to check the PCI power state in the Apple Airport reset quirk. Resolved Sparse warnings: - arch/x86/kernel/early-quirks.c : warning: restricted pci_power_t degrades to integer (2 warnings) Signed-off-by: Habil Eren Türker <habilerenturker@hotmail.com> --- arch/x86/kernel/early-quirks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c index 7459a073c74d..b10a73fb4bcd 100644 --- a/arch/x86/kernel/early-quirks.c +++ b/arch/x86/kernel/early-quirks.c @@ -644,13 +644,13 @@ static void __init apple_airport_reset(int bus, int slot, int func) /* Card may have been put into PCI_D3hot by grub quirk */ pmcsr = read_pci_config_16(bus, slot, func, BCM4331_PM_CAP + PCI_PM_CTRL); - if ((pmcsr & PCI_PM_CTRL_STATE_MASK) != (__force u16)PCI_D0) { - pmcsr &= ~PCI_PM_CTRL_STATE_MASK; + if (!pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D0)) { + pci_power_t_set(&pmcsr, PCI_D0); write_pci_config_16(bus, slot, func, BCM4331_PM_CAP + PCI_PM_CTRL, pmcsr); mdelay(10); pmcsr = read_pci_config_16(bus, slot, func, BCM4331_PM_CAP + PCI_PM_CTRL); - if ((pmcsr & PCI_PM_CTRL_STATE_MASK) != (__force u16)PCI_D0) { + if (!pci_power_t_eq(pci_power_t_get(pmcsr), PCI_D0)) { pr_err("pci 0000:%02x:%02x.%d: Cannot power up Apple AirPort card\n", bus, slot, func); return; -- 2.47.3 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-21 17:57 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-21 12:59 [PATCH v3 0/4] PCI: Add pci_power_t helper functions Habil Eren Türker 2026-11-21 12:59 ` [PATCH v3 1/4] " Habil Eren Türker 2026-11-21 12:59 ` [PATCH] PCI: Convert pci.c to pci_power_t helpers Habil Eren Türker 2026-11-21 17:56 ` kernel test robot 2026-11-21 12:59 ` [PATCH v3 3/4] PCI: Convert quirks.c " Habil Eren Türker 2026-11-21 12:59 ` [PATCH v3 4/4] x86/quirks: Use pci_power_t_eq() in apple_airport_reset() Habil Eren Türker
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox