Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp148033imm; Thu, 26 Jul 2018 00:40:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfOs/wWgl9tVSSz8XJKWgxYLZoGNVvneU8c6p97nakMJEtlSIx2iNXA10Z+VTgr2B+ngPtW X-Received: by 2002:a62:6b44:: with SMTP id g65-v6mr984234pfc.226.1532590824231; Thu, 26 Jul 2018 00:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532590824; cv=none; d=google.com; s=arc-20160816; b=QLHBBdUT+Lq6/You2Nw/U6bqZJrnGc2+OkU3DxPJbXlePVIesJJ5o/ahpZH/3lCUze e4T//znU3Jpqc6KCr2maPqJQajS5rPssmfOsGvatHzJMB//FzPXmyY+9kLUfVSg5qJVQ CXUpR+oKkcLPdub+P5sgQ3m2RSXGQ+PPxPbqHmEJbU3mAHxgMmhjbkUytA28LKyys/bO 7fZfa2Bag+Xd2ykEqOFFB7Sb9WfrJ3w1n0RNezATMX1eh4Z6Qh+AQnKFFlnO8WHDoxYw 3VFr9lA/+U9Ga3naBfvnjmnCSWZITH7y6DviiZ2UYw72AQtUrHdaiYU0WmwRlCnHCJxI 3eyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:arc-authentication-results; bh=v/gQcoWXize2e0g8LJQaE9OZD2HgXAiwbKUoDDNIP5c=; b=U9WIxy3s1VHZcwQGlQMvapDroqmMV2cYOM3FzZIIv0CcmGRa5UZymL0QtE5B/TLkGE 7uY3jB+Zq6n8P+CaC1C2VmbH+GYWyiOwhuN7KfPI1OXBF+ZXIuHItpK4YM/UIwUurfqe EvKUhBDyz3aZmqSExmh7rQlWncRDV3iAJiawjgR0x4qTZkGH5YVeDj+kxw0HifZSlAEd kcXRKwwu2CsGgrTj1w1p+qzGZvLkdTvsruHaA3V9mVwK5PM2FuAHRqIw4WcLl16Emwlk u6uQttzGupK7wDm03quQYn9xzoO3VL16keMropm/NfU7ILzUxT5sREltOsGleqYYbrTn zP/g== 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=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8-v6si632671plh.492.2018.07.26.00.40.09; Thu, 26 Jul 2018 00:40:24 -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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729026AbeGZIyK convert rfc822-to-8bit (ORCPT + 99 others); Thu, 26 Jul 2018 04:54:10 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:42270 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728690AbeGZIyJ (ORCPT ); Thu, 26 Jul 2018 04:54:09 -0400 Received: from mail-pl0-f71.google.com ([209.85.160.71]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fiar4-0000t6-6C for linux-kernel@vger.kernel.org; Thu, 26 Jul 2018 07:38:34 +0000 Received: by mail-pl0-f71.google.com with SMTP id w1-v6so684541plq.8 for ; Thu, 26 Jul 2018 00:38:34 -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:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=B4wJZGAXMifKAgCH9OHsU241nyQ5w9g4nnrEmwQSeWQ=; b=Unmhhla5HsTO7+/L2IsS5hKtrImPaO0AM6DJry12gzbonYjxXgmL4Tfn/0ukevKJxq sibrQiAWFg7nYZwMDPMpW3wa6W2SiHs6mF3shvDQCgitl8wCaFELdThUq+wzIiXLE12E 3FGfEQsQsOU5zOFqShkY2VT8i7dmSqoVvnUfFJT6IM8hS4Ssf7NqaHplYKU3wQfok48q Mn34XahiLYaJDMsH+M2TE2J+gMCihDFgfZADvquApvPY2LY5ZoGolefyT+uEhpN2miuk sCXxlc/PU/G2HpwqR6xNrZw1GeWEcGzauSWwTb7325vtkSsfF+4Ddr0bFxFbZljqOLoi 4wJA== X-Gm-Message-State: AOUpUlEF35MqC0xr/5t4cPhJU13PlQWoddsry6hvFvaHAabtMWEDyP1i juPQfwwhaPBdcQWuL8xVbpOy0bFB2GCMByE6hKoKGW9l/R6shujvU5+e4G+il94OmyhIbKbhtV9 tpbBz3oj1BUkGIeMjyqa+Fx1EdOIpmCrWOBdirZv/qg== X-Received: by 2002:a62:d842:: with SMTP id e63-v6mr1006865pfg.88.1532590712898; Thu, 26 Jul 2018 00:38:32 -0700 (PDT) X-Received: by 2002:a62:d842:: with SMTP id e63-v6mr1006842pfg.88.1532590712603; Thu, 26 Jul 2018 00:38:32 -0700 (PDT) Received: from [192.168.20.35] (1-161-137-98.dynamic-ip.hinet.net. [1.161.137.98]) by smtp.gmail.com with ESMTPSA id w5-v6sm1091701pfn.44.2018.07.26.00.38.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 00:38:32 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: [PATCH 4/5] memstick: rtsx_usb_ms: Support runtime power management From: Kai-Heng Feng In-Reply-To: Date: Thu, 26 Jul 2018 15:38:27 +0800 Cc: arnd@arndb.de, gregkh@linuxfoundation.org, ulf.hansson@linaro.org, bauer.chen@realtek.com, ricky_wu@realtek.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: References: To: Alan Stern X-Mailer: Apple Mail (2.3445.9.1) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 2018Jul26, at 01:59, Alan Stern wrote: > > 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(). There are two different uses for pm_runtime helpers. The first use case is to prevent parent device, rtsx_usb, from suspending: pm_runtime_get_noresume() rtsx_usb_read_register() pm_runtime_put_noidle() The second use case, to manage memstick host itself. memstick_detect_change() powers the host on if there’s a card in slot, and it powers host off when there’s no card. Once memstick_detect_change() is done, we can check if the host can be suspended. So we are sure the timing when the power is on or off. Kai-Heng > > Alan Stern >