PCI: Add device-specific reset for Qualcomm devices
PATCH v11 1/1 PCI: Add device-specific reset for Qualcomm devices
Some Qualcomm PCIe devices (WCN6855/WCN7850 WiFi cards, SDX62/SDX65 modems) lack working reset methods for VFIO passthrough scenarios. These devices have no FLR capability, advertise NoSoftRst+ (blocking PM reset), and have broken bus reset.
The problem manifests in VFIO passthrough scenarios:
- WCN6855 (17cb:1103) and WCN7850 (17cb:1107) WiFi devices:
Normal VM operation works fine, including clean shutdown/reboot. However, when the VM terminates uncleanly (crash, force-off), VFIO attempts to reset the device before it can be assigned to another VM. Without a working reset method, the device remains in an undefined state, preventing reuse.
- SDX62/SDX65 (17cb:0308) 5G modems: Never successfully initialize even on first VM assignment without proper reset capability.
Add device-specific reset methods using BAR-space hardware reset registers that exist in these devices:
- WCN6855/WCN7850 WiFi devices use SoC global reset via BAR0 (sequence from ath11k/ath12k driver: ath11k_pci_soc_global_reset(), ath11k_pci_sw_reset(), ath11k_mhi_set_mhictrl_reset()):
- Write/clear reset bit at offset 0x3008
- Wait for PCIe link recovery (up to 5 seconds)
- Clear MHI controller SYSERR status at offset 0x38
- SDX62/SDX65 modem devices use MHI SoC reset via BAR0 (sequence from MHI
driver: mhi_soc_reset(), mhi_pci_reset_prepare()):
- Write reset request to offset 0xb0
- Wait 2 seconds for reset completion
These are true hardware reset mechanisms (not power management or firmware error recovery), providing proper device reset for VFIO scenarios.
Testing was performed on desktop platforms with M.2 WiFi and modem cards using M.2-to-PCIe adapters, including extensive force-reset cycling to verify stability.
---
v11: Address Manivannan Sadhasivam feedback:
- Remove unused QUALCOMM_WIFI_MHISTATUS define
- Use PCI_ERROR_RESPONSE instead of 0xffffffff
- Sort device IDs in ascending order (0x0308, 0x1103, 0x1107)
v10: https://lore.kernel.org/all/[email protected]/
drivers/pci/quirks.c | 117 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+)
drivers/pci/quirks.c +117 -0
@@ -4240,6 +4240,120 @@ static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe)return 0 ; } +#define QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET 0x3008 +#define QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V BIT(0) +#define QUALCOMM_WIFI_MHICTRL 0x38 +#define QUALCOMM_WIFI_MHICTRL_RESET_MASK 0x2 + +/* +* Qualcomm WiFi device-specific reset using SoC global reset via BAR0 +* registers. +*/ +static int reset_qualcomm_wifi (struct pci_dev *pdev,bool probe) +{ +bool link_recovered = false; +unsigned long timeout; +void __iomem *bar; +u32 val; +u16 cmd; + +if (probe) +return 0 ; + +if (pdev->current_state !=PCI_D0 ) +return -EINVAL ; + +pci_read_config_word (pdev,PCI_COMMAND , &cmd); +pci_write_config_word (pdev,PCI_COMMAND , cmd |PCI_COMMAND_MEMORY ); + + bar =pci_iomap (pdev,0 ,0 ); +if (!bar) { +pci_write_config_word (pdev,PCI_COMMAND , cmd); +return -ENODEV ; + } + + val =ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); + val |=QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V ; +iowrite32 (val, bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); +ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); + +msleep (10 ); + + val &= ~QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V ; +iowrite32 (val, bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); +ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); + +msleep (10 ); + + timeout = jiffies +msecs_to_jiffies (5000 ); +while (time_before (jiffies, timeout)) { + val =ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); +if (val !=PCI_ERROR_RESPONSE ) { + link_recovered = true; +break ; + } +msleep (20 ); + } + +if (!link_recovered) { +pci_err (pdev,"PCIe link failed to recover after reset\n" ); + goto out_restore; + } + +/* After SOC_GLOBAL_RESET, MHISTATUS may still have SYSERR bit set +* and thus need to set MHICTRL_RESET to clear SYSERR. +*/ +iowrite32 (QUALCOMM_WIFI_MHICTRL_RESET_MASK , bar +QUALCOMM_WIFI_MHICTRL ); +ioread32 (bar +QUALCOMM_WIFI_MHICTRL ); + +msleep (10 ); + +out_restore: +pci_iounmap (pdev, bar); +pci_write_config_word (pdev,PCI_COMMAND , cmd); + +return link_recovered ?0 : -ETIMEDOUT ; +} + +#define MHI_SOC_RESET_REQ_OFFSET 0xb0 +#define MHI_SOC_RESET_REQ BIT(0) + +/* +* Qualcomm modem device-specific reset using MHI SoC reset via BAR0 +* register. +*/ +static int reset_qualcomm_modem (struct pci_dev *pdev,bool probe) +{ +void __iomem *bar; +u16 cmd; + +if (probe) +return 0 ; + +if (pdev->current_state !=PCI_D0 ) +return -EINVAL ; + +pci_read_config_word (pdev,PCI_COMMAND , &cmd); +pci_write_config_word (pdev,PCI_COMMAND , cmd |PCI_COMMAND_MEMORY ); + + bar =pci_iomap (pdev,0 ,0 ); +if (!bar) { +pci_write_config_word (pdev,PCI_COMMAND , cmd); +return -ENODEV ; + } + +iowrite32 (MHI_SOC_RESET_REQ , bar +MHI_SOC_RESET_REQ_OFFSET ); +ioread32 (bar +MHI_SOC_RESET_REQ_OFFSET ); + +/* Be sure device reset has been executed */ +msleep (2000 ); + +pci_iounmap (pdev, bar); +pci_write_config_word (pdev,PCI_COMMAND , cmd); + +return 0 ; +} +static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82599_SFP_VF , reset_intel_82599_sfp_virtfn },
@@ -4255,6 +4369,9 @@ static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { reset_chelsio_generic_dev }, {PCI_VENDOR_ID_HUAWEI ,PCI_DEVICE_ID_HINIC_VF , reset_hinic_vf_dev }, + { PCI_VENDOR_ID_QCOM, 0x0308, reset_qualcomm_modem }, /* SDX62/SDX65 modems */ + { PCI_VENDOR_ID_QCOM, 0x1103, reset_qualcomm_wifi }, /* WCN6855 WiFi */ + { PCI_VENDOR_ID_QCOM, 0x1107, reset_qualcomm_wifi }, /* WCN7850 WiFi */ { 0 } };
Signature · 1 line
2.54.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] The condition checking for PCIe link recovery evaluates to always-true due to a type promotion…
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] The condition checking for PCIe link recovery evaluates to always-true due to a type promotion mismatch, completely bypassing the 5-second wait loop.
- [Medium] The reset_qualcomm_wifi function performs a read-modify-write on a hardware register without verifying if the initial read succeeded.
- [Medium] The polling loop for PCIe link recovery does not perform a final condition check after the timeout, potentially causing false failures if the thread is delayed by the scheduler.
- [Medium] The device-specific reset methods may trigger a SoC hardware reset that drops the PCIe physical link, which would cause the upstream port to generate unmasked hotplug events. --
commit 632c19d8e3a5ffaea7401f14cf4ba2e70f72cb54
Author: Jose Ignacio Tornos Martinez <[email protected]>
Subject: PCI: Add device-specific reset for Qualcomm devices
This commit adds device-specific reset methods for certain Qualcomm PCIe devices (WCN6855/WCN7850 WiFi cards, SDX62/SDX65 modems) that lack working reset methods for VFIO passthrough. It implements true hardware reset mechanisms using BAR-space hardware reset registers.
Quoted 3 lines
drivers/pci/quirks.c +0
-0@@ -4227,6 +4227,120 @@ static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe)
[ ... ]
Quoted 17 lines
drivers/pci/quirks.c +17
-0+static int reset_qualcomm_wifi (struct pci_dev *pdev,bool probe) +{ +bool link_recovered = false; +unsigned long timeout; +void __iomem *bar; +u32 val; +u16 cmd; + +if (probe) +return 0 ; + +if (pdev->current_state !=PCI_D0 ) +return -EINVAL ; + +pci_read_config_word (pdev,PCI_COMMAND , &cmd); +pci_write_config_word (pdev,PCI_COMMAND , cmd |PCI_COMMAND_MEMORY ); +
drivers/pci/quirks.c static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe) · line 4278
Quoted 10 lines
drivers/pci/quirks.c +10
-0+ bar =pci_iomap (pdev,0 ,0 ); +if (!bar) { +pci_write_config_word (pdev,PCI_COMMAND , cmd); +return -ENODEV ; + } + + val =ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); + val |=QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V ; +iowrite32 (val, bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); +ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET );
[Severity: Medium]
If the device is already hung and the initial ioread32() returns 0xFFFFFFFF due to a completion timeout, does this read-modify-write sequence blindly write 0xFFFFFFFF back to the hardware? Could writing all 1s to a global SoC reset register overwrite reserved bits or place the device in an undefined state?
drivers/pci/quirks.c static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe) · line 4288
Quoted 10 lines
drivers/pci/quirks.c +10
-0+ +msleep (10 ); + + val &= ~QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V ; +iowrite32 (val, bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); +ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); + +msleep (10 ); + + timeout = jiffies +msecs_to_jiffies (5000 );
[Severity: Medium]
If this SoC hardware reset physically drops the PCIe link, and this port is hotplug-capable, will the upstream Root Port generate unmasked Surprise Link Down events? Since pci_dev_specific_reset() runs without masking link change events, could pciehp asynchronously remove the device from the bus while this reset is polling, breaking the VFIO passthrough?
drivers/pci/quirks.c static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe) · line 4289
Quoted 1 line
drivers/pci/quirks.c +1
-0+while (time_before (jiffies, timeout)) {
[Severity: Medium]
If the executing thread is preempted or experiences a scheduling delay just before evaluating time_before(jiffies, timeout), and the delay pushes jiffies past the timeout, will the loop exit immediately without a final hardware check? Could this falsely report a timeout failure even if the device recovered during the delay window? Should this perform a final check after the loop, or perhaps use read_poll_timeout()?
drivers/pci/quirks.c
Quoted 2 lines
drivers/pci/quirks.c +2
-0+ val =ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); +if (val !=PCI_ERROR_RESPONSE ) {
[Severity: High]
Since val is a u32 and PCI_ERROR_RESPONSE is a 64-bit value (~0ULL), will C type promotion zero-extend val to 64 bits and cause this condition to always be true? When the device is unresponsive and returns 0xFFFFFFFF, does this bypass the 5-second wait loop and falsely report success? Would it be better to use the standard !PCI_POSSIBLE_ERROR(val) macro here?
Quoted 7 lines
drivers/pci/quirks.c +7
-0+ link_recovered = true; +break ; + } +msleep (20 ); + } + +if (!link_recovered) {
[ ... ]
Quoted 15 lines
drivers/pci/quirks.c +15
-0+static int reset_qualcomm_modem (struct pci_dev *pdev,bool probe) +{ +void __iomem *bar; +u16 cmd; + +if (probe) +return 0 ; + +if (pdev->current_state !=PCI_D0 ) +return -EINVAL ; + +pci_read_config_word (pdev,PCI_COMMAND , &cmd); +pci_write_config_word (pdev,PCI_COMMAND , cmd |PCI_COMMAND_MEMORY ); + + bar =pci_iomap (pdev,0 ,0 );
drivers/pci/quirks.c static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe) · line 4349
Quoted 10 lines
drivers/pci/quirks.c +10
-0+if (!bar) { +pci_write_config_word (pdev,PCI_COMMAND , cmd); +return -ENODEV ; + } + +iowrite32 (MHI_SOC_RESET_REQ , bar +MHI_SOC_RESET_REQ_OFFSET ); +ioread32 (bar +MHI_SOC_RESET_REQ_OFFSET ); + +/* Be sure device reset has been executed */ +msleep (2000 );
[Severity: Medium]
If this modem SoC reset also drops the PCIe physical link, does it suffer from the same unmasked hotplug event issue described above?
Quoted 6 lines
drivers/pci/quirks.c +6
-0+ +pci_iounmap (pdev, bar); +pci_write_config_word (pdev,PCI_COMMAND , cmd); + +return 0 ; +}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 32 lines · Jose Ignacio Tornos Martinez
Some Qualcomm PCIe devices (WCN6855/WCN7850 WiFi cards, SDX62/SDX65 modems) lack working reset methods for VFIO passthrough scenarios. These devices have no FLR capability, advertise NoSoftRst+ (blocking PM reset), and have broken bus reset.
The problem manifests in VFIO passthrough scenarios:
- WCN6855 (17cb:1103) and WCN7850 (17cb:1107) WiFi devices:
Normal VM operation works fine, including clean shutdown/reboot. However, when the VM terminates uncleanly (crash, force-off), VFIO attempts to reset the device before it can be assigned to another VM. Without a working reset method, the device remains in an undefined state, preventing reuse.- SDX62/SDX65 (17cb:0308) 5G modems: Never successfully initialize even on first VM assignment without proper reset capability.
Add device-specific reset methods using BAR-space hardware reset registers that exist in these devices:
- WCN6855/WCN7850 WiFi devices use SoC global reset via BAR0 (sequence from ath11k/ath12k driver:
ath11k_pci_soc_global_reset(),ath11k_pci_sw_reset(),ath11k_mhi_set_mhictrl_reset()):
- Write/clear reset bit at offset0x3008
- Wait for PCIe link recovery (up to 5 seconds)
- Clear MHI controller SYSERR status at offset0x38- SDX62/SDX65 modem devices use MHI SoC reset via BAR0 (sequence from MHI
driver:mhi_soc_reset(),mhi_pci_reset_prepare()):
- Write reset request to offset0xb0
- Wait 2 seconds for reset completion
Quoted 8 lines
These are true hardware reset mechanisms (not power management or firmware error recovery), providing proper device reset for VFIO scenarios.
Testing was performed on desktop platforms with M.2 WiFi and modem cards using M.2-to-PCIe adapters, including extensive force-reset cycling to verify stability.
Signed-off-by Jose Ignacio Tornos Martinez <[email protected]>
Couple of comments below, including one bug due to my previous suggestion. Once those are addressed, feel free to add:
Quoted 15 lines
---
v11: Address Manivannan Sadhasivam feedback:
- Remove unusedQUALCOMM_WIFI_MHISTATUSdefine
- UsePCI_ERROR_RESPONSEinstead of0xffffffff
- Sort device IDs in ascending order (0x0308,0x1103,0x1107)
v10: https://lore.kernel.org/all/[email protected]/drivers/pci/quirks.c | 117 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+)drivers/pci/quirks.c +0
-0
drivers/pci/quirks.c static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe) · line 4246
Quoted 7 lines
drivers/pci/quirks.c +4
-0@@ -4240,6 +4240,120 @@ static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe)return 0 ; } +#define QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET 0x3008 +#define QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V BIT(0) +#define QUALCOMM_WIFI_MHICTRL 0x38 +#define QUALCOMM_WIFI_MHICTRL_RESET_MASK 0x2
Qcom calls these WiFi devices as WLAN devices. So I'd prefer to use this term all around even for function names.
Quoted 35 lines
drivers/pci/quirks.c +35
-0+ +/* +* Qualcomm WiFi device-specific reset using SoC global reset via BAR0 +* registers. +*/ +static int reset_qualcomm_wifi (struct pci_dev *pdev,bool probe) +{ +bool link_recovered = false; +unsigned long timeout; +void __iomem *bar; +u32 val; +u16 cmd; + +if (probe) +return 0 ; + +if (pdev->current_state !=PCI_D0 ) +return -EINVAL ; + +pci_read_config_word (pdev,PCI_COMMAND , &cmd); +pci_write_config_word (pdev,PCI_COMMAND , cmd |PCI_COMMAND_MEMORY ); + + bar =pci_iomap (pdev,0 ,0 ); +if (!bar) { +pci_write_config_word (pdev,PCI_COMMAND , cmd); +return -ENODEV ; + } + + val =ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); + val |=QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V ; +iowrite32 (val, bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); +ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); + +msleep (10 ); +
drivers/pci/quirks.c static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe) · line 4291
Quoted 10 lines
drivers/pci/quirks.c +10
-0+ val &= ~QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V ; +iowrite32 (val, bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); +ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); + +msleep (10 ); + + timeout = jiffies +msecs_to_jiffies (5000 ); +while (time_before (jiffies, timeout)) { + val =ioread32 (bar +QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET ); +if (val !=PCI_ERROR_RESPONSE ) {
As Sashiko also pointed out, this will always evaluate to true due to PCI_ERROR_RESPONSE being ~0ULL. Please use:
if (!PCI_POSSIBLE_ERROR(val))
Sorry for the wrong suggestion earlier.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Hi Mani,
No worries! v12 with the fix and WLAN renaming is on the way. Thanks for catching it and your help
Best regards
Jose Ignacio
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Jose,
kernel test robot noticed the following build warnings:
[auto build test WARNING on pci/next]
[also build test WARNING on pci/for-linus linus/master v7.2-rc6 next-20260807]
[cannot apply to linux-review/Jose-Ignacio-Tornos-Martinez/Add-device-specific-reset-for-Qualcomm-devices/20260804-001013] [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/Jose-Ignacio-Tornos-Martinez/PCI-Add-device-specific-reset-for-Qualcomm-devices/20260810-131417 base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next patch link: https://lore.kernel.org/r/20260626055023.197470-1-jtornosm%40redhat.com patch subject: [PATCH v11] PCI: Add device-specific reset for Qualcomm devices config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20260810/[email protected]/config) compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 12df34b8469b8095359de8c249cb1b2753fadeea) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260810/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/pci/quirks.c:4278:11: warning: result of comparison of constant 18446744073709551615 with expression of type 'u32' (aka 'unsigned int') is always true [-Wtautological-constant-out-of-range-compare]
4278 | if (val != PCI_ERROR_RESPONSE) {
| ~~~ ^ ~~~~~~~~~~~~~~~~~~1 warning generated.
vim +4278 drivers/pci/quirks.c
4234
4235 /*
4236 * Qualcomm WiFi device-specific reset using SoC global reset via BAR0
4237 * registers.
4238 */
4239 static int reset_qualcomm_wifi(struct pci_dev *pdev, bool probe)
4240 {
4241 bool link_recovered = false;
4242 unsigned long timeout;
4243 void __iomem *bar;
4244 u32 val;
4245 u16 cmd;
4246
4247 if (probe)
4248 return 0;
4249
4250 if (pdev->current_state != PCI_D0)
4251 return -EINVAL;
4252
4253 pci_read_config_word(pdev, PCI_COMMAND, &cmd);
4254 pci_write_config_word(pdev, PCI_COMMAND, cmd | PCI_COMMAND_MEMORY);
4255
4256 bar = pci_iomap(pdev, 0, 0);
4257 if (!bar) {
4258 pci_write_config_word(pdev, PCI_COMMAND, cmd);
4259 return -ENODEV;
4260 }
4261
4262 val = ioread32(bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
4263 val |= QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V;
4264 iowrite32(val, bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
4265 ioread32(bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
4266
4267 msleep(10);
4268
4269 val &= ~QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V;
4270 iowrite32(val, bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
4271 ioread32(bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
4272
4273 msleep(10);
4274
4275 timeout = jiffies + msecs_to_jiffies(5000);
4276 while (time_before(jiffies, timeout)) {
4277 val = ioread32(bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
> 4278 if (val != PCI_ERROR_RESPONSE) { 4279 link_recovered = true;
4280 break;
4281 }
4282 msleep(20);
4283 }
4284
4285 if (!link_recovered) {
4286 pci_err(pdev, "PCIe link failed to recover after reset\n");
4287 goto out_restore;
4288 }
4289
4290 /* After SOC_GLOBAL_RESET, MHISTATUS may still have SYSERR bit set
4291 * and thus need to set MHICTRL_RESET to clear SYSERR.
4292 */
4293 iowrite32(QUALCOMM_WIFI_MHICTRL_RESET_MASK, bar + QUALCOMM_WIFI_MHICTRL);
4294 ioread32(bar + QUALCOMM_WIFI_MHICTRL);
4295
4296 msleep(10);
4297
4298 out_restore:
4299 pci_iounmap(pdev, bar);
4300 pci_write_config_word(pdev, PCI_COMMAND, cmd);
4301
4302 return link_recovered ? 0 : -ETIMEDOUT;
4303 }
4304
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Please, use the latest version (v13):
https://lore.kernel.org/all/[email protected]/
That and more things are fixed there.
Thanks
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Jose,
kernel test robot noticed the following build warnings:
[auto build test WARNING on pci/next]
[also build test WARNING on pci/for-linus linus/master v7.2-rc6 next-20260807]
[cannot apply to linux-review/Jose-Ignacio-Tornos-Martinez/Add-device-specific-reset-for-Qualcomm-devices/20260804-001013] [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/Jose-Ignacio-Tornos-Martinez/PCI-Add-device-specific-reset-for-Qualcomm-devices/20260810-131417 base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next patch link: https://lore.kernel.org/r/20260626055023.197470-1-jtornosm%40redhat.com patch subject: [PATCH v11] PCI: Add device-specific reset for Qualcomm devices config: um-randconfig-r073-20260810 (https://download.01.org/0day-ci/archive/20260811/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 smatch: v0.5.0-9187-g5189e3fb
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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
smatch warnings:drivers/pci/quirks.c:4278 reset_qualcomm_wifi() warn: always true condition '(val != (~0)) => (0-u32max != u64max)'
vim +4278 drivers/pci/quirks.c
4234
4235 /*
4236 * Qualcomm WiFi device-specific reset using SoC global reset via BAR0
4237 * registers.
4238 */
4239 static int reset_qualcomm_wifi(struct pci_dev *pdev, bool probe)
4240 {
4241 bool link_recovered = false;
4242 unsigned long timeout;
4243 void __iomem *bar;
4244 u32 val;
4245 u16 cmd;
4246
4247 if (probe)
4248 return 0;
4249
4250 if (pdev->current_state != PCI_D0)
4251 return -EINVAL;
4252
4253 pci_read_config_word(pdev, PCI_COMMAND, &cmd);
4254 pci_write_config_word(pdev, PCI_COMMAND, cmd | PCI_COMMAND_MEMORY);
4255
4256 bar = pci_iomap(pdev, 0, 0);
4257 if (!bar) {
4258 pci_write_config_word(pdev, PCI_COMMAND, cmd);
4259 return -ENODEV;
4260 }
4261
4262 val = ioread32(bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
4263 val |= QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V;
4264 iowrite32(val, bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
4265 ioread32(bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
4266
4267 msleep(10);
4268
4269 val &= ~QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET_V;
4270 iowrite32(val, bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
4271 ioread32(bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
4272
4273 msleep(10);
4274
4275 timeout = jiffies + msecs_to_jiffies(5000);
4276 while (time_before(jiffies, timeout)) {
4277 val = ioread32(bar + QUALCOMM_WIFI_PCIE_SOC_GLOBAL_RESET);
> 4278 if (val != PCI_ERROR_RESPONSE) { 4279 link_recovered = true;
4280 break;
4281 }
4282 msleep(20);
4283 }
4284
4285 if (!link_recovered) {
4286 pci_err(pdev, "PCIe link failed to recover after reset\n");
4287 goto out_restore;
4288 }
4289
4290 /* After SOC_GLOBAL_RESET, MHISTATUS may still have SYSERR bit set
4291 * and thus need to set MHICTRL_RESET to clear SYSERR.
4292 */
4293 iowrite32(QUALCOMM_WIFI_MHICTRL_RESET_MASK, bar + QUALCOMM_WIFI_MHICTRL);
4294 ioread32(bar + QUALCOMM_WIFI_MHICTRL);
4295
4296 msleep(10);
4297
4298 out_restore:
4299 pci_iounmap(pdev, bar);
4300 pci_write_config_word(pdev, PCI_COMMAND, cmd);
4301
4302 return link_recovered ? 0 : -ETIMEDOUT;
4303 }
4304
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Please, use the latest version (v13):
https://lore.kernel.org/all/[email protected]/
That and more things are fixed there.
Thanks