mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: Peter Chen <peter.chen@nxp.com>,
	Jia-Ju Bai <baijiaju1990@gmail.com>,
	"mathias.nyman@intel.com" <mathias.nyman@intel.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] usb: xhci: Two possible sleep-in-atomic-context bugs
Date: Wed, 20 Jun 2018 12:15:00 +0300	[thread overview]
Message-ID: <8410b5bf-097c-2b53-84ff-221fb4ab03fa@linux.intel.com> (raw)
In-Reply-To: <HE1PR04MB14501B0EC65D993623D96A168B770@HE1PR04MB1450.eurprd04.prod.outlook.com>

On 20.06.2018 06:28, Peter Chen wrote:
>   
>>
>> The driver may sleep with holding a spinlock.
>> The function call paths (from bottom to top) in Linux-4.16.7 are:
>>
>> [FUNC] schedule
>> drivers/base/power/runtime.c, 741: schedule in rpm_resume
>> drivers/base/power/runtime.c, 1322: rpm_resume in pm_runtime_forbid
>> drivers/usb/host/xhci-hub.c, 647: pm_runtime_forbid in xhci_enter_test_mode
>> drivers/usb/host/xhci-hub.c, 632: _raw_spin_lock_irqsave in xhci_enter_test_mode
>>
>> [FUNC] schedule
>> drivers/base/power/runtime.c, 570: schedule in rpm_suspend
>> drivers/base/power/runtime.c, 434: rpm_suspend in rpm_idle
>> drivers/base/power/runtime.c, 1343: rpm_idle in pm_runtime_allow
>> drivers/usb/host/xhci-hub.c, 670: pm_runtime_allow in xhci_exit_test_mode
>> drivers/usb/host/xhci-hub.c, 1387: xhci_exit_test_mode in xhci_hub_control
>> drivers/usb/host/xhci-hub.c, 1038: _raw_spin_lock_irqsave in xhci_hub_control
>>
>> These bugs are found by my static analysis tool (DSAC-2) and checked by my code
>> review.
>>
> 
> I don't think runtime PM API is needed at xhci_hub_control since the controller should
> be always active, Mathias, do you agree I delete pm_runtime_forbid and pm_runtime_allow
> to fix this issue?
> 

The USB2 test mode is a bit special, it will disable all connected devices, and halt the host.
Port should stay in test mode until feature is cleared or host reset.
There is a risk runtime suspend will try to suspend the host as no devices seem preset.

But I think pm_runtime_get_noresume() and pm_runtime_put_noidle() could be used instad,
those should be safe.

-Mathias


      reply	other threads:[~2018-06-20  9:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-20  3:12 Jia-Ju Bai
2018-06-20  3:28 ` Peter Chen
2018-06-20  9:15   ` Mathias Nyman [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=8410b5bf-097c-2b53-84ff-221fb4ab03fa@linux.intel.com \
    --to=mathias.nyman@linux.intel.com \
    --cc=baijiaju1990@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=peter.chen@nxp.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

Powered by JetHome