Linux USB
 help / color / mirror / Atom feed
From: Sergey Shtylyov <s.shtylyov@omp.ru>
To: Mathias Nyman <mathias.nyman@linux.intel.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-usb@vger.kernel.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH v4] usb: host: xhci-plat: fix possible kernel oops while resuming
Date: Tue, 19 Sep 2023 23:53:31 +0300	[thread overview]
Message-ID: <003fb120-893f-de64-919b-a7f1f66532be@omp.ru> (raw)
In-Reply-To: <0957c21d-144b-1d84-2f79-f4cc6ba2a493@linux.intel.com>

On 9/11/23 3:53 PM, Mathias Nyman wrote:
[...]

>> If this driver enables the xHC clocks while resuming from sleep, it calls
>> clk_prepare_enable() without checking for errors and blithely goes on to
>> read/write the xHC's registers -- which, with the xHC not being clocked,
>> at least on ARM32 usually causes an imprecise external abort exceptions
>> which cause kernel oops.  Currently, the chips for which the driver does
>> the clock dance on suspend/resume seem to be the Broadcom STB SoCs, based
>> on ARM32 CPUs, as it seems...
>>
>> In order to fix this issue, add the result checks for clk_prepare_enable()
>> calls in xhci_plat_resume(), add conditional clk_disable_unprepare() calls
>> on the error path of xhci_plat_resume(); then factor out the common clock
>> disabling code from the suspend() and resume() driver PM methods into a
>> separate function to avoid code duplication.

> Minor nitpick, but not sure a separate function is helpful here.
> It's two lines of code called twice.

   Tried to save on the object code size...

>> Found by Linux Verification Center (linuxtesting.org) with the Svace static
>> analysis tool.
>>
>> Fixes: 8bd954c56197 ("usb: host: xhci-plat: suspend and resume clocks")
>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> If I understood correctly this issue hasn't been seen in real life,

   Not yet?

> and this patch only changes how we fail?

   Yes, failing gracefully instead of a kernel oops...

> So I guess this would be more suitable for usb-next than usb-linus.

   Maybe. I'll recast and rebase...

[...]

> Thanks
> Mathias

MBR, Sergey

      reply	other threads:[~2023-09-19 20:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 19:18 [PATCH v4] usb: host: xhci-plat: fix possible kernel oops while resuming Sergey Shtylyov
2023-09-08 18:58 ` Sergey Shtylyov
2023-09-11 12:53 ` Mathias Nyman
2023-09-19 20:53   ` Sergey Shtylyov [this message]

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=003fb120-893f-de64-919b-a7f1f66532be@omp.ru \
    --to=s.shtylyov@omp.ru \
    --cc=f.fainelli@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=mathias.nyman@linux.intel.com \
    /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