OSDN Git Service

powerpc/papr_scm: Fix DIMM device registration race
authorOliver O'Halloran <oohall@gmail.com>
Thu, 6 Dec 2018 15:17:12 +0000 (02:17 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 9 Dec 2018 10:32:30 +0000 (21:32 +1100)
commitb0d65a8cbcb097d2110885c3660add97b0125867
tree56c682d7ee0c254fa6b668e2758eaefcb05691e1
parent409dd7dc83eb54c4bc156aea890cc95bc21dc6f0
powerpc/papr_scm: Fix DIMM device registration race

When a new nvdimm device is registered with libnvdimm via
nvdimm_create() it is added as a device on the nvdimm bus. The probe
function for the DIMM driver is potentially quite slow so actually
registering and probing the device is done in an async domain rather
than immediately after device creation. This can result in a race where
the region device (created 2nd) is probed first and fails to activate at
boot.

To fix this we use the same approach as the ACPI/NFIT driver which is to
check that all the DIMM devices registered successfully. LibNVDIMM
provides the nvdimm_bus_count_dimms() function which synchronises with
the async domain and verifies that the dimm was successfully registered
with the bus.

If either of these does not occur then we bail.

Fixes: b5beae5e224f ("powerpc/pseries: Add driver for PAPR SCM regions")
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/pseries/papr_scm.c