Re: [PATCHv2 1/5] pci: make pci_stop_dev concurrent safe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 02, 2024 at 04:39:37PM -0700, Davidlohr Bueso wrote:
> > +	set_bit(PCI_DEV_ADDED, &dev->priv_flags);
> > +}
> 
> So set_bit does not imply any barriers. 

Huh. Hannes told me the same thing just last weak, and I was thinking
"nah, it's an atomic operation." But I'm mistaken thinking that provides
a memory barrier.

> Does this matter in the future when breaking up
> pci_rescan_remove_lock? For example, what prevents things like:

We're still far from being able to remove the big pci rescan/remove
lock, but yes, that's the idea. This should be safe as-is since it is
still using that lock, I can add smp barriers to make the memroy
dependencies explicit.
 
> pci_bus_add_device()			pci_stop_dev()
>     pci_dev_assign_added()
> 	dev->priv_flags [S]
> 					    pci_dev_test_and_clear_added() // true
> 						dev->priv_flags [L]
>     device_attach(&dev->dev)
> 					    device_release_driver(&dev->dev)
> 
> ... I guess that implied barrier from that device_lock() in device_attach().
> I am not familiar with this code, but overall I think any locking rework should
> explain more about the ordering implications in the changes if the end result

Oh, goot point. This sequence shouldn't be possible with either the
existing or proposed bus locking, and I can certainly add more detailed
explanations.




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux