From patchwork Wed Aug 3 19:46:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9262153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CC5746048F for ; Wed, 3 Aug 2016 19:50:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE83827F8D for ; Wed, 3 Aug 2016 19:50:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B309528306; Wed, 3 Aug 2016 19:50:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DAED27F8D for ; Wed, 3 Aug 2016 19:50:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758204AbcHCTuo (ORCPT ); Wed, 3 Aug 2016 15:50:44 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33249 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752682AbcHCTuh (ORCPT ); Wed, 3 Aug 2016 15:50:37 -0400 Received: by mail-wm0-f68.google.com with SMTP id o80so37851264wme.0; Wed, 03 Aug 2016 12:49:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=KcVq8kuqEhpvXe7e2BlBuwXTH5n4i9XuKNBlq7J/Rsg=; b=nUEiJpTbL1njVujrQsYfd8z47VmYuqzP93Jl0hCbJxbf2h2tiVs8Oodku1ykkXm6wv fE+5bZr0Rpmkx49YAVesHEIrI8xT3Lwd8ByKtuuf5gMbznaDxU98iVOvtCVsXvDRPkwq LaftFjC+SxLn+OQhkki9dZTNi8xUOUxXRNzToS4JuqDlNvyH3tpLkbYgOqa7Uaw+JXeF Cp/YcxxVn6B/pe4+6Fh62vpjx9FB0fnxVGBnMLPchjw3skOeZRAH3yhnIS/fBr1aRd9X cMOCx8Q2zcUQLq2Qa/eobnTBtZAtnJKQ5CMla6LBBpTVH4un2eLUtaMMJp1cfKNfgUyo Vrzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=KcVq8kuqEhpvXe7e2BlBuwXTH5n4i9XuKNBlq7J/Rsg=; b=f0bX48kunwhSuU0uP1N6WnUZ45OPo0wwt1kqNrqE8CFQHrbClyifuSugaAAWdWBDCn PVIuSb7on/HoZEc/+gcj4kDnQykXopJuj7heQOcvVknTA0qsNejGN5KMgKsVg5mUfKqd j9EYxtCsirT7W8uyNXLxsQorjQmK54YNv067DbGhrkMmc5xFWioZN8qs3u+cemfQ7gfq cmoxn/blAiUxPnrHBmWRxF/UBsshuIQxSlm8p9ce8qTKnJ18+jR5lR7qNf7U6UK8k/+X xPgWpktkVHg/i+IwmgQ3aNaM5ZwX0nKaQogmbp/XBA8xW5aqwJAwrWAU8PbgyJymzY6j sOmw== X-Gm-Message-State: AEkoouv3whWL4d8RfKsidXR69cOMZYhgr3rNc0S1QC5UCFuE6Kx8bCnawYK+UqAAW1SMUQ== X-Received: by 10.28.193.202 with SMTP id r193mr27880349wmf.27.1470253756949; Wed, 03 Aug 2016 12:49:16 -0700 (PDT) Received: from ?IPv6:2003:62:5f01:4400:757e:4744:3a80:1de8? (p200300625F014400757E47443A801DE8.dip0.t-ipconnect.de. [2003:62:5f01:4400:757e:4744:3a80:1de8]) by smtp.googlemail.com with ESMTPSA id x203sm23801wmg.0.2016.08.03.12.49.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Aug 2016 12:49:16 -0700 (PDT) To: Greg Kroah-Hartman Cc: Linux USB Mailing List , linux-scsi@vger.kernel.org, "Martin K. Petersen" From: Heiner Kallweit Subject: [PATCH] usb: storage: fix runtime pm issue in usb_stor_probe2 Message-ID: <0c83d917-678d-d4fc-3225-f2e8355f6280@gmail.com> Date: Wed, 3 Aug 2016 21:46:47 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since commit 71723f95463d "PM / runtime: print error when activating a child to unactive parent" I see the following error message: scsi host2: usb-storage 1-3:1.0 scsi host2: runtime PM trying to activate child device host2 but parent (1-3:1.0) is not active Digging into it it seems to be related to the problem described in the commit message for cd998ded5c12 "i2c: designware: Prevent runtime suspend during adapter registration" as scsi_add_host also calls device_add and after the call to device_add the parent device is suspended. Fix this by using the approach from the mentioned commit and getting the runtime pm reference before calling scsi_add_host. Signed-off-by: Heiner Kallweit Acked-by: Alan Stern --- drivers/usb/storage/usb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index ef2d8cd..8c5f011 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -1070,17 +1070,17 @@ int usb_stor_probe2(struct us_data *us) result = usb_stor_acquire_resources(us); if (result) goto BadDevice; + usb_autopm_get_interface_no_resume(us->pusb_intf); snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s", dev_name(&us->pusb_intf->dev)); result = scsi_add_host(us_to_host(us), dev); if (result) { dev_warn(dev, "Unable to add the scsi host\n"); - goto BadDevice; + goto HostAddErr; } /* Submit the delayed_work for SCSI-device scanning */ - usb_autopm_get_interface_no_resume(us->pusb_intf); set_bit(US_FLIDX_SCAN_PENDING, &us->dflags); if (delay_use > 0) @@ -1090,6 +1090,8 @@ int usb_stor_probe2(struct us_data *us) return 0; /* We come here if there are any problems */ +HostAddErr: + usb_autopm_put_interface_no_suspend(us->pusb_intf); BadDevice: usb_stor_dbg(us, "storage_probe() failed\n"); release_everything(us);