The cpu_grp->mons_lock is acquired in the memlat hotplug notifier
callbacks to prevent races within the driver. The cpus_read_lock is
inherently acquired as well since it is in the middle of a hotplug
event. In parallel, stop_hwmon() could unregister from the hotplug
notifier (i.e. when last memlat mon in system is removed). However,
unregistering the hotplug notifier also requires the cpus_read_lock
and is done with the cpu_grp->mons_lock held as well which would lead
to a deadlock if a hotplug is currently in progress with the memlat
notifier callback waiting for the cpu_grp->mons_lock.
To fix this, release the cpu_grp->mons_lock in stop_hwmon() before
unregistering with the hotplug notifier. Also, make sure the memlat
hotplug notifier callbacks check cpu_grp->num_active_mons before
restarting events since that work won't be necessary if there are no
active memlat mons in the system.
Change-Id: I401639a6e28a472a64a96456d2c06f57b35dbc0d
Signed-off-by: Amir Vajid <avajid@codeaurora.org>