On Mon, Dec 16, 2024 at 10:51:18AM +0530, Manivannan Sadhasivam wrote: > On Sun, Dec 15, 2024 at 06:32:02PM +0100, Lukas Wunner wrote: > > On Wed, Dec 11, 2024 at 05:55:48PM +0800, Qiang Yu wrote: > > > PCIe3 is able to link up after applying your patch. Slot power is turned on > > > correctly. > > > But see "NULL pointer dereference" when I try to remove device. > > > > There's a WARN splat occurring before the NULL pointer deref. > > Was this happening before or is it new? Probably makes sense > > to debug that first before looking into the NULL pointer deref, > > which could be a result of it. > > > > Precisely. > > > > > > [ 38.757726] WARNING: CPU: 1 PID: 816 at drivers/regulator/core.c:5857 > > > regulator_unregister+0x13c/0x160 > > > [ 38.767288] Modules linked in: phy_qcom_qmp_combo aux_bridge > > > drm_kms_helper drm nvme backlight pinctrl_sm8550_lpass_lpi pci_pwrctl_slot > > > pci_pwrctrl_core nvme_core phy_qcom_edp phy_qcom_eusb2_repeater > > > dispcc_x1e80100 pinctrl_lpass_lpi phy_qcom_snps_eusb2 lpasscc_sc8280xp typec > > > gpucc_x1e80100 phy_qcom_qmp_pcie > > > [ 38.795279] CPU: 1 UID: 0 PID: 816 Comm: bash Not tainted > > > 6.12.0-next-20241128-00005-g6178bf6ce3c2-dirty #50 > > > [ 38.805359] Hardware name: Qualcomm IDP, BIOS > > > 6.0.240607.BOOT.MXF.2.4-00348.1-HAMOA-1.67705.7 06/ 7/2024 > > > [ 38.815088] pstate: 61400005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS > > > BTYPE=--) > > > [ 38.822239] pc : regulator_unregister+0x13c/0x160 > > > [ 38.827081] lr : regulator_unregister+0xc0/0x160 > > > > The WARN splat seems to be caused by: > > > > WARN_ON(rdev->open_count); > > > > So the regulator is unregistered although it's still in use. > > Is there maybe a multifunction PCIe device in your system > > so that multiple devices are using the same regulator? > > > > Maybe the regulator is shared with other peripherals (not just PCIe) in the > system. > > @Qiang: I referred your patch [1] that added the slot regulators, but they were > not used by any peripherals other than PCIe. Could you please post the list of > consumers of the 3 slot regulators? > Just looked briefly into regulator_unregister() and I can see that it will get called only when the regulator driver is unbound from the regulator device. Your previous DT reference suggests that you were probably using fixed regulator for all 3 slot regulators. In that case, this splat can occur when the regulator driver is unbound (module unload?) with still one of the consumers holding reference. So somehow regulator_put() is never called for that consumer but the regulator is removed. This looks like a bug somewhere. - Mani -- மணிவண்ணன் சதாசிவம்