From: Greg KH <gregkh@linuxfoundation.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Mathias Nyman <mathias.nyman@linux.intel.com>,
Dave Hansen <dave.hansen@intel.com>,
Lu Baolu <baolu.lu@linux.intel.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org,
Chunfeng Yun <chunfeng.yun@mediatek.com>
Subject: Re: earlyprintk=xdbc seems broken
Date: Mon, 20 Dec 2021 16:06:50 +0100 [thread overview]
Message-ID: <YcCcCjYcXw6T8LjG@kroah.com> (raw)
In-Reply-To: <YcCV0TECWE31fYV7@hirez.programming.kicks-ass.net>
On Mon, Dec 20, 2021 at 03:40:17PM +0100, Peter Zijlstra wrote:
> 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@linux.intel.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradaed.org>
> ---
> 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)
Please see c4d936efa46d ("Revert "usb: early: convert to
readl_poll_timeout_atomic()"") in Linus's tree. I already added a
comment much like yours. If that's not sufficient, I'll be glad to
re-word it.
thanks,
greg k-h
next prev parent reply other threads:[~2021-12-20 15:08 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-02 15:22 Peter Zijlstra
2021-12-03 0:52 ` Lu Baolu
2021-12-03 14:31 ` Mathias Nyman
2021-12-03 15:22 ` Dave Hansen
2021-12-03 15:29 ` Greg KH
2021-12-17 11:01 ` Mathias Nyman
2021-12-17 13:55 ` Peter Zijlstra
2021-12-17 15:19 ` Greg KH
2021-12-20 14:40 ` Peter Zijlstra
2021-12-20 15:06 ` Greg KH [this message]
2021-12-20 17:01 ` Peter Zijlstra
2021-12-20 14:34 ` Mathias Nyman
2021-12-20 15:51 ` Peter Zijlstra
2021-12-21 9:40 ` Peter Zijlstra
2021-12-21 9:41 ` Peter Zijlstra
2022-01-14 8:47 ` Peter Zijlstra
2022-01-14 19:31 ` Mathias Nyman
2022-01-15 16:06 ` Peter Zijlstra
2022-01-24 14:55 ` Mathias Nyman
2022-01-24 16:39 ` Peter Zijlstra
2022-01-24 16:46 ` Peter Zijlstra
2022-01-25 8:51 ` Mathias Nyman
2022-01-25 10:47 ` Peter Zijlstra
2022-01-25 10:54 ` Peter Zijlstra
2022-01-25 12:45 ` Peter Zijlstra
2022-01-25 13:09 ` Sven Schnelle
2022-01-25 13:54 ` Peter Zijlstra
2022-01-25 14:01 ` Sven Schnelle
2022-01-25 17:13 ` Mathias Nyman
2022-01-25 16:24 ` Dave Hansen
2022-02-17 3:44 ` Randy Dunlap
2022-01-25 19:39 ` Rajaram R
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=YcCcCjYcXw6T8LjG@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=baolu.lu@linux.intel.com \
--cc=chunfeng.yun@mediatek.com \
--cc=dave.hansen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@linux.intel.com \
--cc=peterz@infradead.org \
--cc=x86@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
Powered by JetHome