From patchwork Tue Jul 31 06:17:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 10550111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3FF03139A for ; Tue, 31 Jul 2018 06:17:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5831C2965C for ; Tue, 31 Jul 2018 06:17:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4994C296B2; Tue, 31 Jul 2018 06:17:53 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 EB7952965C for ; Tue, 31 Jul 2018 06:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731993AbeGaH43 (ORCPT ); Tue, 31 Jul 2018 03:56:29 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:40423 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729284AbeGaH42 (ORCPT ); Tue, 31 Jul 2018 03:56:28 -0400 Received: from 1-161-146-33.dynamic-ip.hinet.net ([1.161.146.33] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fkNyd-0004XZ-T3; Tue, 31 Jul 2018 06:17:48 +0000 From: Kai-Heng Feng To: arnd@arndb.de, gregkh@linuxfoundation.org Cc: ulf.hansson@linaro.org, stern@rowland.harvard.edu, bauer.chen@realtek.com, ricky_wu@realtek.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Kai-Heng Feng Subject: [PATCH 5/5] misc: rtsx_usb: / memstick: rtsx_usb_ms: Avoid long delay before system suspend Date: Tue, 31 Jul 2018 14:17:21 +0800 Message-Id: <20180731061721.15831-6-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180731061721.15831-1-kai.heng.feng@canonical.com> References: <20180731061721.15831-1-kai.heng.feng@canonical.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's a long power-on delay at the end of rtsx_usb_ms_set_param(). This delay is noticeable right before system suspend. To prevent already suspended memstick host from getting powered on by PM core, use DPM_FLAG_SMART_SUSPEND to avoid the situation. Signed-off-by: Kai-Heng Feng --- drivers/memstick/host/rtsx_usb_ms.c | 4 ++++ drivers/misc/cardreader/rtsx_usb.c | 1 + 2 files changed, 5 insertions(+) diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c index 126eb310980a..e3b635d1220f 100644 --- a/drivers/memstick/host/rtsx_usb_ms.c +++ b/drivers/memstick/host/rtsx_usb_ms.c @@ -763,6 +763,10 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev) msh->set_param = rtsx_usb_ms_set_param; msh->caps = MEMSTICK_CAP_PAR4; + /* DPM_FLAG_LEAVE_SUSPENDED is not needed, the parent device will wake + * up memstick host. + */ + dev_pm_set_driver_flags(ms_dev(host), DPM_FLAG_SMART_SUSPEND); pm_runtime_set_active(ms_dev(host)); pm_runtime_enable(ms_dev(host)); diff --git a/drivers/misc/cardreader/rtsx_usb.c b/drivers/misc/cardreader/rtsx_usb.c index f7a66f614085..98bb878a6ade 100644 --- a/drivers/misc/cardreader/rtsx_usb.c +++ b/drivers/misc/cardreader/rtsx_usb.c @@ -671,6 +671,7 @@ static int rtsx_usb_probe(struct usb_interface *intf, goto out_init_fail; #ifdef CONFIG_PM + dev_pm_set_driver_flags(&intf->dev, DPM_FLAG_SMART_SUSPEND | DPM_FLAG_LEAVE_SUSPENDED); intf->needs_remote_wakeup = 1; usb_enable_autosuspend(usb_dev); #endif