linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Michael Ellerman <mpe@ellerman.id.au>
Subject: [PATCH 4.14 79/91] rtc: opal: Fix OPAL RTC driver OPAL_BUSY loops
Date: Mon, 30 Apr 2018 12:25:01 -0700	[thread overview]
Message-ID: <20180430184008.416390019@linuxfoundation.org> (raw)
In-Reply-To: <20180430184004.216234025@linuxfoundation.org>

4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Nicholas Piggin <npiggin@gmail.com>

commit 682e6b4da5cbe8e9a53f979a58c2a9d7dc997175 upstream.

The OPAL RTC driver does not sleep in case it gets OPAL_BUSY or
OPAL_BUSY_EVENT from firmware, which causes large scheduling
latencies, up to 50 seconds have been observed here when RTC stops
responding (BMC reboot can do it).

Fix this by converting it to the standard form OPAL_BUSY loop that
sleeps.

Fixes: 628daa8d5abf ("powerpc/powernv: Add RTC and NVRAM support plus RTAS fallbacks")
Cc: stable@vger.kernel.org # v3.2+
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/powerpc/platforms/powernv/opal-rtc.c |    8 ++++--
 drivers/rtc/rtc-opal.c                    |   37 ++++++++++++++++++------------
 2 files changed, 28 insertions(+), 17 deletions(-)

--- a/arch/powerpc/platforms/powernv/opal-rtc.c
+++ b/arch/powerpc/platforms/powernv/opal-rtc.c
@@ -48,10 +48,12 @@ unsigned long __init opal_get_boot_time(
 
 	while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
 		rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
-		if (rc == OPAL_BUSY_EVENT)
+		if (rc == OPAL_BUSY_EVENT) {
+			mdelay(OPAL_BUSY_DELAY_MS);
 			opal_poll_events(NULL);
-		else if (rc == OPAL_BUSY)
-			mdelay(10);
+		} else if (rc == OPAL_BUSY) {
+			mdelay(OPAL_BUSY_DELAY_MS);
+		}
 	}
 	if (rc != OPAL_SUCCESS)
 		return 0;
--- a/drivers/rtc/rtc-opal.c
+++ b/drivers/rtc/rtc-opal.c
@@ -57,7 +57,7 @@ static void tm_to_opal(struct rtc_time *
 
 static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
 {
-	long rc = OPAL_BUSY;
+	s64 rc = OPAL_BUSY;
 	int retries = 10;
 	u32 y_m_d;
 	u64 h_m_s_ms;
@@ -66,13 +66,17 @@ static int opal_get_rtc_time(struct devi
 
 	while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
 		rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
-		if (rc == OPAL_BUSY_EVENT)
+		if (rc == OPAL_BUSY_EVENT) {
+			msleep(OPAL_BUSY_DELAY_MS);
 			opal_poll_events(NULL);
-		else if (retries-- && (rc == OPAL_HARDWARE
-				       || rc == OPAL_INTERNAL_ERROR))
-			msleep(10);
-		else if (rc != OPAL_BUSY && rc != OPAL_BUSY_EVENT)
-			break;
+		} else if (rc == OPAL_BUSY) {
+			msleep(OPAL_BUSY_DELAY_MS);
+		} else if (rc == OPAL_HARDWARE || rc == OPAL_INTERNAL_ERROR) {
+			if (retries--) {
+				msleep(10); /* Wait 10ms before retry */
+				rc = OPAL_BUSY; /* go around again */
+			}
+		}
 	}
 
 	if (rc != OPAL_SUCCESS)
@@ -87,21 +91,26 @@ static int opal_get_rtc_time(struct devi
 
 static int opal_set_rtc_time(struct device *dev, struct rtc_time *tm)
 {
-	long rc = OPAL_BUSY;
+	s64 rc = OPAL_BUSY;
 	int retries = 10;
 	u32 y_m_d = 0;
 	u64 h_m_s_ms = 0;
 
 	tm_to_opal(tm, &y_m_d, &h_m_s_ms);
+
 	while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
 		rc = opal_rtc_write(y_m_d, h_m_s_ms);
-		if (rc == OPAL_BUSY_EVENT)
+		if (rc == OPAL_BUSY_EVENT) {
+			msleep(OPAL_BUSY_DELAY_MS);
 			opal_poll_events(NULL);
-		else if (retries-- && (rc == OPAL_HARDWARE
-				       || rc == OPAL_INTERNAL_ERROR))
-			msleep(10);
-		else if (rc != OPAL_BUSY && rc != OPAL_BUSY_EVENT)
-			break;
+		} else if (rc == OPAL_BUSY) {
+			msleep(OPAL_BUSY_DELAY_MS);
+		} else if (rc == OPAL_HARDWARE || rc == OPAL_INTERNAL_ERROR) {
+			if (retries--) {
+				msleep(10); /* Wait 10ms before retry */
+				rc = OPAL_BUSY; /* go around again */
+			}
+		}
 	}
 
 	return rc == OPAL_SUCCESS ? 0 : -EIO;

  parent reply	other threads:[~2018-04-30 19:27 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-30 19:23 [PATCH 4.14 00/91] 4.14.39-stable review Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 01/91] ext4: prevent right-shifting extents beyond EXT_MAX_BLOCKS Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 02/91] ext4: set h_journal if there is a failure starting a reserved handle Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 03/91] ext4: add MODULE_SOFTDEP to ensure crc32c is included in the initramfs Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 04/91] ext4: add validity checks for bitmap block numbers Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 05/91] ext4: fix bitmap position validation Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 06/91] random: set up the NUMA crng instances after the CRNG is fully initialized Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 07/91] random: fix possible sleeping allocation from irq context Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 08/91] random: rate limit unseeded randomness warnings Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 09/91] usbip: usbip_event: fix to not print kernel pointer address Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 10/91] usbip: usbip_host: fix to hold parent lock for device_attach() calls Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 11/91] usbip: vhci_hcd: Fix usb device and sockfd leaks Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 12/91] usbip: vhci_hcd: check rhport before using in vhci_hub_control() Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 13/91] Revert "xhci: plat: Register shutdown for xhci_plat" Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 14/91] xhci: Fix USB ports for Dell Inspiron 5775 Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 15/91] USB: serial: simple: add libtransistor console Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 16/91] USB: serial: ftdi_sio: use jtag quirk for Arrow USB Blaster Greg Kroah-Hartman
2018-04-30 19:23 ` [PATCH 4.14 17/91] USB: serial: cp210x: add ID for NI USB serial console Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 18/91] usb: typec: ucsi: Increase command completion timeout value Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 19/91] usb: core: Add quirk for HP v222w 16GB Mini Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 20/91] USB: Increment wakeup count on remote wakeup Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 21/91] ALSA: usb-audio: Skip broken EU on Dell dock USB-audio Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 22/91] virtio: add ability to iterate over vqs Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 23/91] virtio_console: dont tie bufs to a vq Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 24/91] virtio_console: free buffers after reset Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 25/91] virtio_console: drop custom control queue cleanup Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 26/91] virtio_console: move removal code Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 27/91] virtio_console: reset on out of memory Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 28/91] drm/virtio: fix vq wait_event condition Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 29/91] tty: Dont call panic() at tty_ldisc_init() Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 30/91] tty: n_gsm: Fix long delays with control frame timeouts in ADM mode Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 31/91] tty: n_gsm: Fix DLCI handling for ADM mode if debug & 2 is not set Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 32/91] tty: Avoid possible error pointer dereference at tty_ldisc_restore() Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 33/91] tty: Use __GFP_NOFAIL for tty_ldisc_get() Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 34/91] ALSA: dice: fix OUI for TC group Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 35/91] ALSA: dice: fix error path to destroy initialized stream data Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 36/91] ALSA: hda - Skip jack and others for non-existing PCM streams Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 37/91] ALSA: opl3: Hardening for potential Spectre v1 Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 38/91] ALSA: asihpi: " Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 39/91] ALSA: hdspm: " Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 40/91] ALSA: rme9652: " Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 41/91] ALSA: control: " Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 42/91] ALSA: pcm: Return negative delays from SNDRV_PCM_IOCTL_DELAY Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 43/91] ALSA: core: Report audio_tstamp in snd_pcm_sync_ptr Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 44/91] ALSA: seq: oss: Fix unbalanced use lock for synth MIDI device Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 45/91] ALSA: seq: oss: Hardening for potential Spectre v1 Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 46/91] ALSA: hda: " Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 47/91] ALSA: hda/realtek - Add some fixes for ALC233 Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 48/91] ALSA: hda/realtek - Update ALC255 depop optimize Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 49/91] ALSA: hda/realtek - change the location for one of two front mics Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 50/91] mtd: spi-nor: cadence-quadspi: Fix page fault kernel panic Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 51/91] mtd: cfi: cmdset_0001: Do not allow read/write to suspend erase block Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 52/91] mtd: cfi: cmdset_0001: Workaround Micron Erase suspend bug Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 53/91] mtd: cfi: cmdset_0002: Do not allow read/write to suspend erase block Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 54/91] mtd: rawnand: tango: Fix struct clk memory leak Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 55/91] kobject: dont use WARN for registration failures Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 56/91] scsi: sd: Defer spinning up drive while SANITIZE is in progress Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 57/91] bfq-iosched: ensure to clear bic/bfqq pointers when preparing request Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 58/91] vfio: ccw: process ssch with interrupts disabled Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 59/91] ANDROID: binder: prevent transactions into own process Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 60/91] PCI: aardvark: Fix logic in advk_pcie_{rd,wr}_conf() Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 61/91] PCI: aardvark: Set PIO_ADDR_LS correctly in advk_pcie_rd_conf() Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 62/91] PCI: aardvark: Use ISR1 instead of ISR0 interrupt in legacy irq mode Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 63/91] PCI: aardvark: Fix PCIe Max Read Request Size setting Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 64/91] ARM: amba: Make driver_override output consistent with other buses Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 65/91] ARM: amba: Fix race condition with driver_override Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 66/91] ARM: amba: Dont read past the end of sysfs "driver_override" buffer Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 67/91] ARM: socfpga_defconfig: Remove QSPI Sector 4K size force Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 68/91] KVM: arm/arm64: Close VMID generation race Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 69/91] powerpc/mm: Flush cache on memory hot(un)plug Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 70/91] powerpc/powernv/npu: Do a PID GPU TLB flush when invalidating a large address range Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 71/91] crypto: drbg - set freed buffers to NULL Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 72/91] ASoC: fsl_esai: Fix divisor calculation failure at lower ratio Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 73/91] libceph: un-backoff on tick when we have a authenticated session Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 74/91] libceph: reschedule a tick in finish_hunting() Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 75/91] libceph: validate con->state at the top of try_write() Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 76/91] fpga-manager: altera-ps-spi: preserve nCONFIG state Greg Kroah-Hartman
2018-04-30 19:24 ` [PATCH 4.14 77/91] earlycon: Use a pointer table to fix __earlycon_table stride Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 78/91] cpufreq: powernv: Fix hardlockup due to synchronous smp_call in timer interrupt Greg Kroah-Hartman
2018-04-30 19:25 ` Greg Kroah-Hartman [this message]
2018-04-30 19:25 ` [PATCH 4.14 80/91] drm/amdgpu: set COMPUTE_PGM_RSRC1 for SGPR/VGPR clearing shaders Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 81/91] drm/i915: Enable display WA#1183 from its correct spot Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 82/91] objtool, perf: Fix GCC 8 -Wrestrict error Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 83/91] tools/lib/subcmd/pager.c: do not alias select() params Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 84/91] x86/ipc: Fix x32 version of shmid64_ds and msqid64_ds Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 85/91] x86/smpboot: Dont use mwait_play_dead() on AMD systems Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 86/91] x86/microcode/intel: Save microcode patch unconditionally Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 87/91] x86/microcode: Do not exit early from __reload_late() Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 88/91] tick/sched: Do not mess with an enqueued hrtimer Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 89/91] arm/arm64: KVM: Add PSCI version selection API Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 90/91] powerpc/eeh: Fix race with driver un/bind Greg Kroah-Hartman
2018-04-30 19:25 ` [PATCH 4.14 91/91] net: dont call update_pmtu unconditionally Greg Kroah-Hartman
2018-05-01  0:54 ` [PATCH 4.14 00/91] 4.14.39-stable review Nathan Chancellor
2018-05-01  1:24 ` kernelci.org bot
2018-05-01 13:21 ` Guenter Roeck
2018-05-01 14:04 ` Dan Rue
2018-05-01 19:06 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180430184008.416390019@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).