opal/hmi: Fix a TOD HMI failure during a race condition.
opal/hmi: Fix a TOD HMI failure during a race condition.

There are chances where another interrupt can wake a CPU in 0x100
vector just when HMI for TOD error is also pending. In such a rare race
condition if CPU has woken up with tb_loss power saving mode, it will
invoke opal call to resync the TB. Since TOD is already in error state,
resync TB will timeout leaving TFMR bit 18 set to '1'. (TFMR[18]=1 means
TB is prepared to receive new value from TOD. Once the new value is
received this bit gets reset to '0', otherwise TB would stay in waiting
state). When HMI is delivered, it may find all TFMR errors are already
cleared but would fail to restore TB since TFMR bit 18 is already set.
This leads to HMI recovery failure causing a kernel crash.

This patch fixes this by clearing of TB errors if TFMR[18] is set to 1.
This makes sure that TB is in clean state before TB restore process starts.

Signed-off-by: Mahesh Salgaonkar <6a890e1065a1d4e8df9dcf1d9a2c9c740bbcf8aa@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.vnet.ibm.com>
(cherry picked from commit 026b9a13bf8d61a7e72721d59961b40cbc98b410)
Signed-off-by: Stewart Smith <ec31ab75ddf977353c8f660f92ea8b23f64aef25@linux.vnet.ibm.com>

open-power/skiboot,mikey/skiboot,legoater/skiboot,shenki/skiboot,legoater/skiboot,open-power/skiboot,open-power/skiboot,shenki/skiboot,shenki/skiboot,qemu/skiboot,open-power/skiboot,qemu/skiboot,mikey/skiboot,legoater/skiboot,open-power/skiboot,legoater/skiboot,qemu/skiboot,mikey/skiboot,qemu/skiboot,shenki/skiboot,stewart-ibm/skiboot,shenki/skiboot,qemu/skiboot,stewart-ibm/skiboot,stewart-ibm/skiboot,legoater/skiboot