On Tue, Jul 15, 2025 at 02:21:47PM GMT, Brian Norris wrote: > Hi Manivannan, > > Thanks for reviewing. > > On Sat, Jul 12, 2025 at 10:56:38PM +0530, Manivannan Sadhasivam wrote: > > If you take a look at commit f1536585588b ("PCI: Don't rely on > > of_platform_depopulate() for reused OF-nodes"), you can realize that the PCI > > core clears OF_POPULATED flag while removing the PCI device. So > > of_platform_device_destroy() will do nothing. > > I've looked through that commit several times, and while I think I > understand its claim, I really haven't been able to validate it. I've > inspected the code for anything like of_node_clear_flag(nc, > OF_POPULATED), and the closest I see for any PCI-relevant code is in > drivers/of/platform.c -- mostly in error paths (undoing device creation) > or of_platform_device_destroy() or of_platform_depopulate(). > > I've also tried quite a bit of tracing / printk'ing, and I can't find > the OF_POPULATED getting cleared either. > > Is there any chance there's a mistake in the claims in commit > f1536585588b? e.g., maybe Bartosz was looking at OF_POPULATED_BUS (which > is different, but also relevant to his change)? Or am I missing > something obvious in here? > Now, I did look into the OF code and I also couldn't see where exactly the OF_POPULATED flag is getting cleared by the PCI core :/ So I'll defer the question to Bartosz. > OTOH, I also see that part of my change is not really doing quite what I > thought it was -- so far, I think there may be some kind of resource > leak (kobj ref), since I'm not seeing pci_release_host_bridge_dev() > called when I think it should be. If I perform cleanup in > pci_free_host_bridge() instead, then I do indeed see > of_platform_device_destroy() tear things down the way I expect. > Oh, that's bad! Which controller it is? I played with making the pcie-qcom driver modular and I unloaded/loaded multiple times, but never saw any refcount warning (I really hope if there was any leak, it would've tripped over during insmod). - Mani -- மணிவண்ணன் சதாசிவம்