forked from mirrors/linux
		
	PCI: Make pci_destroy_dev() concurrent safe
Use an atomic flag instead of the racy check against the device's kobj parent. We shouldn't be poking into device implementation details at this level anyway. Link: https://lore.kernel.org/r/20241022224851.340648-3-kbusch@meta.com Signed-off-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
		
							parent
							
								
									93093ea1f0
								
							
						
					
					
						commit
						e3f30d563a
					
				
					 2 changed files with 7 additions and 1 deletions
				
			
		| 
						 | 
					@ -469,6 +469,7 @@ static inline int pci_dev_set_disconnected(struct pci_dev *dev, void *unused)
 | 
				
			||||||
#define PCI_DEV_ADDED 0
 | 
					#define PCI_DEV_ADDED 0
 | 
				
			||||||
#define PCI_DPC_RECOVERED 1
 | 
					#define PCI_DPC_RECOVERED 1
 | 
				
			||||||
#define PCI_DPC_RECOVERING 2
 | 
					#define PCI_DPC_RECOVERING 2
 | 
				
			||||||
 | 
					#define PCI_DEV_REMOVED 3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static inline void pci_dev_assign_added(struct pci_dev *dev)
 | 
					static inline void pci_dev_assign_added(struct pci_dev *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -487,6 +488,11 @@ static inline bool pci_dev_is_added(const struct pci_dev *dev)
 | 
				
			||||||
	return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
 | 
						return test_bit(PCI_DEV_ADDED, &dev->priv_flags);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static inline bool pci_dev_test_and_set_removed(struct pci_dev *dev)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return test_and_set_bit(PCI_DEV_REMOVED, &dev->priv_flags);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_PCIEAER
 | 
					#ifdef CONFIG_PCIEAER
 | 
				
			||||||
#include <linux/aer.h>
 | 
					#include <linux/aer.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,7 @@ static void pci_stop_dev(struct pci_dev *dev)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void pci_destroy_dev(struct pci_dev *dev)
 | 
					static void pci_destroy_dev(struct pci_dev *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (!dev->dev.kobj.parent)
 | 
						if (pci_dev_test_and_set_removed(dev))
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pci_npem_remove(dev);
 | 
						pci_npem_remove(dev);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue