It's not a problem if new children are registered before the parent's
->suspend() is called, the PM core can handle that. The problem is the
potential race between the suspending task and the threads registering new
children concurrently to the executing ->suspend(), because if those threads
lose the race, the resume ordering will be broken.
Since the PM core knows nothing about the drivers internals, the drivers'
->suspend() methods must be responsible for synchronizing with the other
threads used by the driver.
I think we just attempted to take device semaphores too early. We probably
can take the device semaphores _after_ suspending all devices without
much hassle. However, it's not actually a problem if a suspended device
gets unregistered - it's removed from the list on which it is at the moment
and won't be resumed. It also is not a problem if the device is registered
after it's master's ->resume() has run.
Besides, taking the semaphores for all _existing_ devices doesn't prevent
new devices from being added and that's we needed to take
pm_sleep_rwsem in device_add().
I'd rather not do that.
As I said above, I don't see a problem with registering new devices before
the parent's ->suspend() is run and after it's ->resume() has run. That
doesn't break any ordering rules and we can handle it.
Thanks,
Rafael
--