Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1072723imm; Wed, 25 Jul 2018 11:01:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeqY3kJe8s0AU+e7P30EQHcesRYEmmAovzwMCZnN1b07JAm117Sq64c7gHeBNtrBw4ZyQYU X-Received: by 2002:a62:f610:: with SMTP id x16-v6mr23364500pfh.169.1532541666722; Wed, 25 Jul 2018 11:01:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532541666; cv=none; d=google.com; s=arc-20160816; b=PAROITZQxp6d6diZlDZC2MMTfD03qodduHh6rjJ3LRldaBgJ/ZqJJv7POnEXACDROp 2JABhl2e2wLHMBEkNp9nVHv+hKjMfwqGtnJiYPMiWo9sQjeoOWY72eYOQtRDlfB1Xsqe urSDhU5My2h+rU3TdaH+u+NhqXSpAZ+kxBubJhE1hqvfbh2/c3sWi2mITP6PPigwqgjw XEYOofnxLepE3v2OOaOE9umfN/3cS5sAkYQUeHeVKMFpy5JyHV5NcjCCfGEqVHtXEObr DHffaP1jRcNUCxVNPu6H6qdOHsLtVJJyTUZBa6XZrMupCzovEEIkG22IgGs39CZiWTF0 kCKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=83NAWkdUQohV0pYo9WcnOCrLalxKo4kcxnDfEuNvtU0=; b=SkQhM4e0yR9dFaykE2vil8vjlCUiVirFKc9cmCH7ShJN/iXu2dIzUNHyfnVkWxW3je VRJFKJ3gzRZdVMdcdomA7WSKWKejjbBeF/jYEcpIb7w+49FBCDt144cqInho2GoPYsAd cO5K2+hc8P0SmJFVBb0Q07EC/fsEtYlgo/gjzk4ymPkyQGlrK1YjUg65ekSlTR5uwUo+ FH0L6DeYtwRQMn3vgEG5YdeDlxnN+DNZAb3xr2HoaBF5eh9MyBzAQjLiLER86ef8oZZY 8x8F9x5KChEyKK75VWPlspS4/zJtHAQuyqXs56fuaeuOqvpIynvQUi/8Yhlf14/znZ0S YNIA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 31-v6si13905878plg.260.2018.07.25.11.00.50; Wed, 25 Jul 2018 11:01:06 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729847AbeGYTMn (ORCPT + 99 others); Wed, 25 Jul 2018 15:12:43 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:37464 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729367AbeGYTMn (ORCPT ); Wed, 25 Jul 2018 15:12:43 -0400 Received: (qmail 4939 invoked by uid 2102); 25 Jul 2018 13:59:58 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 25 Jul 2018 13:59:58 -0400 Date: Wed, 25 Jul 2018 13:59:58 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Kai-Heng Feng cc: arnd@arndb.de, , , , , , Subject: Re: [PATCH 4/5] memstick: rtsx_usb_ms: Support runtime power management In-Reply-To: <20180725152515.1833-5-kai.heng.feng@canonical.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 25 Jul 2018, Kai-Heng Feng wrote: > In order to let host's parent device, rtsx_usb, to use USB remote wake > up signaling to do card detection, it needs to be suspended. Hence it's > necessary to add runtime PM support for the memstick host. > > To keep memstick host stays suspended when it's not in use, convert the > card detection function from kthread to delayed_work, which can be > scheduled when the host is resumed and can be canceled when the host is > suspended. > > Use an idle function check if there's no card and the power mode is > MEMSTICK_POWER_OFF. If both criteria are met, put the device to suspend. > > Signed-off-by: Kai-Heng Feng I'm not familiar enough with this driver to comment on specific instances, but you should carefully go through the code and make sure that you use pm_runtime_get_noresume() and pm_runtime_put_noidle() correctly. The basic idea is to use these when you know beforehand that the device is already at full power (for _get_noresume) and the usage count will not go to 0 (for _put_noidle). If you aren't certain of these requirements then you should call pm_runtime_get_sync() and pm_runtime_put(). Alan Stern