From patchwork Tue Aug 9 09:33:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 73530 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp391143qga; Tue, 9 Aug 2016 02:34:32 -0700 (PDT) X-Received: by 10.66.76.9 with SMTP id g9mr168555037paw.51.1470735272917; Tue, 09 Aug 2016 02:34:32 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d5si41897259pfb.98.2016.08.09.02.34.32; Tue, 09 Aug 2016 02:34:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932166AbcHIJea (ORCPT + 4 others); Tue, 9 Aug 2016 05:34:30 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:34565 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752185AbcHIJe3 (ORCPT ); Tue, 9 Aug 2016 05:34:29 -0400 Received: by mail-pa0-f50.google.com with SMTP id fi15so3906381pac.1 for ; Tue, 09 Aug 2016 02:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=b9qA02m2sASIOyKmaJpoSwT/Uk7Tl4JNiynG/eBl5QM=; b=ALKgmsWTtuI47xJLYPwyISNzItOLWgHxASeaRMTVg0IhWZ6OBIsvu3WK08RaMnPz0L lM9qLDEMh79R8rF5FUDVnuici961VRngrqMPGlBckwJSVV5y4Cx+y8yftsjSsRBeM8Ig FC/UuzbX2qG9nj1c/8aDiLBGZe70Nkq+yrIY4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=b9qA02m2sASIOyKmaJpoSwT/Uk7Tl4JNiynG/eBl5QM=; b=Obj9obBK81y5kNrD8RhxgJkF4RxvPRVmTvSZOmmzXapZFxYT7D3QpCCH59G4Ewtvx8 ouMhyi8Q3no3bjqzxyJPrOmu8KDw3Spfwl/lP4slNrmBOHyNzA8zmu3eb01Wly7KyuzF zT1n++0vapYkmF5KxW7wtUqjDe7g/bTDJ2A/Kb3yDzeJub8CotHU3FyhIjEcHrnvRS3T cXYWqiELntY7vCO4pYCMHNjgB722+9N0LMotkIkUg4gWuTWQB7DoxrLKfEcdW/pUJoTI hb8KXP3YAkqnU76qU1KeRMeM5ruiNPQcEgCbtp1ry5UA+XYoG9IuVFL0dKFPMMuSTiJu 1vPA== X-Gm-Message-State: AEkoout+D0I6cIl87QrXC+OtbUfWqLXwBiPAqyP+ukOr+AFwkSVm3qULesVTciVEPSd2JkeQ X-Received: by 10.67.13.196 with SMTP id fa4mr173426946pad.115.1470735268668; Tue, 09 Aug 2016 02:34:28 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id n13sm54325063pfj.16.2016.08.09.02.34.25 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Aug 2016 02:34:28 -0700 (PDT) From: Baolin Wang To: gregkh@linuxfoundation.org, stefan.koch10@gmail.com, stern@rowland.harvard.edu Cc: oneukum@suse.com, falakreyaz@gmail.com, broonie@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [PATCH] usb: core: Add runtime resume checking Date: Tue, 9 Aug 2016 17:33:33 +0800 Message-Id: <653c8e893d4de1ab4dcade2ca2da9f2cfe369c2c.1470735102.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When the usb device has entered suspend state by runtime suspend method, and the sustem also try to enter suspend state by issuing usb_dev_suspend(), it will issue pm_runtime_resume() function to deal with wrong wakeup setting in choose_wakeup() function. But if usb device resumes failed due to xhci has been into suspend state and hardware is not accessible, which will set runtime errors. Thus when there is slave attached, usb device will resume failed by runtime resume method due to previous runtime errors. Then we should check if it resumes successfully in choose_wakeup() function, if it failed we should clear the runtime errors by pm_runtime_set_suspended() function to avoid runtime resume failure. Signed-off-by: Baolin Wang --- drivers/usb/core/driver.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index dadd1e8d..a1a0f5f 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -1412,6 +1412,7 @@ static int usb_resume_both(struct usb_device *udev, pm_message_t msg) static void choose_wakeup(struct usb_device *udev, pm_message_t msg) { int w; + int ret; /* Remote wakeup is needed only when we actually go to sleep. * For things like FREEZE and QUIESCE, if the device is already @@ -1431,8 +1432,12 @@ static void choose_wakeup(struct usb_device *udev, pm_message_t msg) /* If the device is autosuspended with the wrong wakeup setting, * autoresume now so the setting can be changed. */ - if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup) - pm_runtime_resume(&udev->dev); + if (udev->state == USB_STATE_SUSPENDED && w != udev->do_remote_wakeup) { + ret = pm_runtime_resume(&udev->dev); + if (ret == -ESHUTDOWN) + pm_runtime_set_suspended(&udev->dev); + } + udev->do_remote_wakeup = w; }