Re: earlyprintk=xdbc seems broken

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 17, 2021 at 04:19:20PM +0100, Greg KH wrote:
> On Fri, Dec 17, 2021 at 02:55:07PM +0100, Peter Zijlstra wrote:
> > On Fri, Dec 17, 2021 at 01:01:43PM +0200, Mathias Nyman wrote:
> > > I can reproduce this.
> > > Looks like problems started when driver converted to readl_poll_timeout_atomic() in:
> > > 
> > > 796eed4b2342 usb: early: convert to readl_poll_timeout_atomic()
> > 
> > I can confirm, reverting that solves the boot hang, things aren't quite
> > working for me though.
> > 
> > > Seems to hang when read_poll_timeout_atomic() calls ktime_* functions.
> > > Maybe  it's too early for ktime.
> > 
> > It certainly is, using ktime for delay loops sounds daft to me anyhow.
> 
> It was a "find a pattern and replace it with a function call" type of
> cleanup series.  It's obviously wrong, I will go revert it now.

796eed4b2342 is definitely wrong, but instead of a straight up revert,
perhaps do something like this ?

---
Subject: usb: early: Revert from readl_poll_timeout_atomic()

Reverts commit 796eed4b2342 ("usb: early: convert to
readl_poll_timeout_atomic()") and puts in a comment to avoid the same
happening again.

Specifically that commit is wrong because readl_poll_timeout_atomic()
relies on ktime() working while this earlyprintk driver should be usable
long before that.

Fixes: 796eed4b2342 ("usb: early: convert to readl_poll_timeout_atomic()")
Debugged-by: Mathias Nyman <mathias.nyman@xxxxxxxxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
 drivers/usb/early/xhci-dbc.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 933d77ad0a64..ff279a830653 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -14,7 +14,6 @@
 #include <linux/pci_ids.h>
 #include <linux/memblock.h>
 #include <linux/io.h>
-#include <linux/iopoll.h>
 #include <asm/pci-direct.h>
 #include <asm/fixmap.h>
 #include <linux/bcd.h>
@@ -136,9 +135,20 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done, int wait, int delay)
 {
 	u32 result;
 
-	return readl_poll_timeout_atomic(ptr, result,
-					 ((result & mask) == done),
-					 delay, wait);
+	/*
+	 * This must not be readl_poll_timeout_atomic(), as this is used
+	 * *early*, before ktime lives.
+	 */
+	do {
+		result = readl(ptr);
+		result &= mask;
+		if (result == done)
+			return 0;
+		udelay(delay);
+		wait -= delay;
+	} while (wait > 0);
+
+	return -ETIMEDOUT;
 }
 
 static void __init xdbc_bios_handoff(void)



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux