Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1037708ybb; Wed, 25 Mar 2020 14:28:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvdBb0z+PbTVhoVL1tifG4sstbovEQ6WW9HqG7F0Q/NPhPeZGdJTQfB9BIMnbWsnqU7PsU/ X-Received: by 2002:aca:edcf:: with SMTP id l198mr3909367oih.97.1585171739757; Wed, 25 Mar 2020 14:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585171739; cv=none; d=google.com; s=arc-20160816; b=LQoWTHsng1rNHUvViojrJAxnGtsynNgu3zN0G6vwY5BLgeNhLdRtbAh6wc3pPXo2z9 09TXI6FrP7yH9hri/LneBJUWUnwTcTi/p1n3FnAAWLvJvc+EFyQ72Ch7ET+pBs9z9KY8 kXGQ7WrNCuIwwkSmWTZxEPC8g+9sRFlB2WrcWvcTnml1MPB/4qWw7U0t2/5HFcaUhfnH WWmV+NCfgyRqWptV+83ZbVN34NdfhxqkMyI2NmV8jMwJwrCYd6tpifJG++vz21F15Hbp hiIQM8wyKWq7NTVM2ikwu0IgXklj5QV6JSp6VLNsE008tSk6X2A/R/FJ1utAjInuFwMN Rnag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=kMnQUhHsMUqkwZSy38drjBgyagt4hVHMEAtOg07ZQq8=; b=qaBto0vfwm2vHMqhJg7XXlNZ1Edv4NEM0QuoO9u8Yt+7P6ZVSgcg2xuK+gOaWII6IG 8ma+zW+/35RMGlbvx41P6QsR0nEiU4abnCPNy+jurFV47xSpch602xuvv1sppWek094o VcWxQokF7WF6ni8MUmD3UuVFgGWGcN7jzUwg1vaGmnDSdP0P0IDgj1T62dvrUb39hzpj 8+BnRrakiKmvJPDNSBeP7cIjyaY/qYT6Xg57KTwYvwT2KAGalTYVVXnCRhQpGd2/XTVN EtOW+qQ4GVSREPqZ93YuJZ+sm/Y+NLLYi8pmkihY+o1hdpjaxkF2t6WVBWa3HmSjtzzN JvBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si160524ote.164.2020.03.25.14.28.46; Wed, 25 Mar 2020 14:28:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727406AbgCYV2T (ORCPT + 99 others); Wed, 25 Mar 2020 17:28:19 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:44175 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727351AbgCYV2T (ORCPT ); Wed, 25 Mar 2020 17:28:19 -0400 Received: by mail-oi1-f196.google.com with SMTP id v134so3548502oie.11; Wed, 25 Mar 2020 14:28:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kMnQUhHsMUqkwZSy38drjBgyagt4hVHMEAtOg07ZQq8=; b=X3OOwSWwF9exeyEaukuWVnthtnuCWkdj/NhnzgeqrAmzkzlpU2fT/VytfClj4jEFGJ G5o4gBQdeEgLIC78xTNGk+ErRE3NP+lWB3eKoLn+VkXHURccNbfl2IDQooDC0N2FqxpP 1rSlrh4Lfm6leOlBEFzcsfCAw1tbbHxp731gtzTNtDy02Owu+V9KHo1qO7+HnfTeIrb+ jF8ouIms+DFnG0IazntOwmamZ+brj1YNWbwLkf1X6oRBRU0OMbDQ5r25hjyWp/LbPxQk K1D7JZg1/HWdNehhcl35Poa+DQfvSFhSXkg3mqICk3/nxMCSvt6eki071DUhP8sx2BYE kAfQ== X-Gm-Message-State: ANhLgQ1pUVY2M0FtB2Yw1Dhc97q49m1Z29krYAT8gHNAYsSASS5uAPUW Sl3yUdcc7Ae7hb0le3d1rzRpVC7rBVQSt94Tcds= X-Received: by 2002:aca:f07:: with SMTP id 7mr2269427oip.68.1585171698442; Wed, 25 Mar 2020 14:28:18 -0700 (PDT) MIME-Version: 1.0 References: <20200325150017.xhabucfo3v6i234o@e107158-lin> In-Reply-To: From: "Rafael J. Wysocki" Date: Wed, 25 Mar 2020 22:28:06 +0100 Message-ID: Subject: Re: lockdep warning in urb.c:363 usb_submit_urb To: Alan Stern Cc: Qais Yousef , "Rafael J. Wysocki" , Oliver Neukum , Greg Kroah-Hartman , USB list , Linux-pm mailing list , Kernel development list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 25, 2020 at 9:49 PM Alan Stern wrote: > > On Wed, 25 Mar 2020, Qais Yousef wrote: > > > Thanks for all the hints Alan. > > > > I think I figured it out, the below patch seems to fix it for me. Looking > > at other drivers resume functions it seems we're missing the > > pm_runtime_disable()->set_active()->enable() dance. Doing that fixes the > > warning and the dev_err() in driver/base/power. > > Ah, yes. This should have been added years ago; guess I forgot. :-( > > > I don't see xhci-plat.c doing that, I wonder if it needs it too. > > > > I'm not well versed about the details and the rules here. So my fix could be > > a hack, though it does seem the right thing to do. > > > > I wonder why the power core doesn't handle this transparently.. > > Initially, we didn't want the PM core to do this automatically because > we thought some devices might want to remain runtime-suspended > following a system resume, and only the device driver would know what > to do. > > Raphael, now that we have the direct_complete mechanism, can we revisit > this? Should the PM core automatically call pm_runtime_set_active() if > dev->power.direct_complete isn't set? Perhaps in device_resume_early() > prior to the pm_runtime_enable() call? > > It's possible we discussed this and decided against it at the time when > direct_complete was added, but if so I don't remember what was said. Me neither. :-) That said complexity has grown since then and there are the DPM_FLAG_SMART_SUSPEND and DPM_FLAG_LEAVE_SUSPENDED flags that can be used to control that behavior to some extent. Setting DPM_FLAG_SMART_SUSPEND alone, in particular, causes pm_runtime_set_active() to be called at the noirq stage of device resume either by the core or by bus types (e.g. PCI) etc. It looks like ohci-platform might use DPM_FLAG_SMART_SUSPEND, but I need to take a closer look at that (possibly later this week). Cheers! > > > diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c > > index 7addfc2cbadc..eb92c8092fae 100644 > > --- a/drivers/usb/host/ohci-platform.c > > +++ b/drivers/usb/host/ohci-platform.c > > @@ -299,6 +299,10 @@ static int ohci_platform_resume(struct device *dev) > > } > > > > ohci_resume(hcd, false); > > + > > + pm_runtime_disable(dev); > > + pm_runtime_set_active(dev); > > + pm_runtime_enable(dev); > > return 0; > > } > > #endif /* CONFIG_PM_SLEEP */ > > > > > > Thanks > > > > -- > > Qais Yousef > >