Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp612364pxu; Thu, 26 Nov 2020 07:07:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVhdbCtWARD4rpLAa340opkBqobzBARgzgk9LipioYvJtA4NZMU8BYXl1XxHX2IPRttG0O X-Received: by 2002:a50:c19a:: with SMTP id m26mr2939053edf.302.1606403275066; Thu, 26 Nov 2020 07:07:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606403275; cv=none; d=google.com; s=arc-20160816; b=w1OAXxz7SF6eyN3j1oUGuyXm/R41uIXYL7tEigUuGCNie69fIRUrYn6jyJ5s5Wnvpe A/06b6TiGXhkE4pLYxwc7fKLI9BQmGo5auH/QyidauHNLhIq7FiAJ/f5uKKXV8CbCX1y 2My1KXUOKZyUD5xuG1pYXtRiMUkdrTydxoDWslNNwJgvi3EtWMU/H1IxRJSPK7FBefFk 1Rcz8xXIFc3xJ1yylOXuN6Jf9psb2zGxZbXeXMqaE/x2fq5QQi3y0/RhM7vkgEmWN3pn oNaRDT9+iWPD4djujZxGarbyCvPICuBUiStLHe+/iYhgL62+P87pybZjvcyLyH5ukqGo FZiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=OqkXUBQ1i4Vmor4ADqr8LW41OTo4FFyxr1N6+Z/rA5s=; b=S972q9olNavgoh43BB3kTPZsqKKHoNRK4bKYX83z9AMW14w2bZKYhc/VfWam9LjWOw uRGEP1yltEVLD9xksdcpYLjGgiWTDG9eKRqMfu454G0PhNWyvZ9OwlO5XNsFW2NJtIt8 vVVWkzT0bj34WasHJi1i2V4cl0C3SXLTTsEQ+tYRvXPdTfDIfH2Gmv12zPJLnurih7bj jTHvCKRcRaVOyx3RuxWxV+dgYfvbHavcNSkzZxOb4dHLHVU98fTwqCU7wZv+MyAMj6fj uPSUQn42Ebb3OBFdYeH6X317V+BVx1Y7USJanTFUGaZQNm27w0RSLRZ0GXoHFq7lBfne KEYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gh8XjXmY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si3245139ejd.151.2020.11.26.07.07.31; Thu, 26 Nov 2020 07:07:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gh8XjXmY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390011AbgKZPCn (ORCPT + 99 others); Thu, 26 Nov 2020 10:02:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389568AbgKZPCn (ORCPT ); Thu, 26 Nov 2020 10:02:43 -0500 Received: from mail-vs1-xe43.google.com (mail-vs1-xe43.google.com [IPv6:2607:f8b0:4864:20::e43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E82FC061A04 for ; Thu, 26 Nov 2020 07:02:43 -0800 (PST) Received: by mail-vs1-xe43.google.com with SMTP id 128so801365vsw.10 for ; Thu, 26 Nov 2020 07:02:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=OqkXUBQ1i4Vmor4ADqr8LW41OTo4FFyxr1N6+Z/rA5s=; b=Gh8XjXmYgT4LldSMXq+eDAAJJpw9+ajrtOclQFMjho93UopgOYSwWmMfZN88qbnn26 Nik7LSQ7REuIyVQ7fxRGiuZcBaqes3wRK2JQ10kCOh23GLRDycvOlg97xnzmhkugYdPV KmzeHc9Pt2T9xYCjwUEWtsuN2ccRc+NKG5V7Z3uxlUSnjE7ewPM9NNJKEHuQlzJHY2Tz YIE8FRx/qOeXbU4NC3VafWqKHfPkZ+VhUMmfvWJwMhwpO3QG1vPdOr2Dj2FPC0tzg36Y 1ztZHIegTsaPgVDT0IOSNor/yjpsbO5wPNXCpOZg6iEJbSpcplcxlVxrHP4ppCkH3FAi xRxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=OqkXUBQ1i4Vmor4ADqr8LW41OTo4FFyxr1N6+Z/rA5s=; b=Q+W20Ajlu2OqDbrHLbV49qvIdttTB2PrjnuIYPIlizWCoxLGd/hM+7zKNHumdRtO7/ nb2eKZa7O3jE15UO0OiJKj+7QOUN57sTXngYtJVJfIUEUN62RIgzLWqxhXIoCWOBgEuo 4XXYYLbArKnoYd68k4sBlE4ZON1Hmoj4nTpbSbpcq1/cl6jTKKKcQHqLv8Mb45bmtTwQ sluXrh1E1VOqghbuymLlI55ah+pgPLDkhLc+cVvjh8joF8kiEE4AwNgcT7IyH+d1hDcu tkG/QrqYphX5qlxkKGBdjZrXvEQnupl5TCo4It0TTklzD1En7+j2ddneNL5JILG7WSW0 TdLw== X-Gm-Message-State: AOAM531VEEjtaCO7Y/y73wCmEy72BUtUojXDkUogisUv0hOInQ28OXxh +Sw3RCTy2n6hEmdK8qbqkyJsu9rfHjKGikjeSkIRAA== X-Received: by 2002:a67:8c44:: with SMTP id o65mr1942819vsd.55.1606402962450; Thu, 26 Nov 2020 07:02:42 -0800 (PST) MIME-Version: 1.0 References: <20201124060202.776-1-ricky_wu@realtek.com> <20201124204915.GA585306@bjorn-Precision-5520> <6f721ea4d5a84f45b0249b932d742367@realtek.com> In-Reply-To: From: Ulf Hansson Date: Thu, 26 Nov 2020 16:02:05 +0100 Message-ID: Subject: Re: [PATCH] misc: rtsx: rts5249 support runtime PM To: "Rafael J. Wysocki" , =?UTF-8?B?5ZCz5piK5r6EIFJpY2t5?= Cc: Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , Bjorn Helgaas , "vaibhavgupta40@gmail.com" , "kdlnx@doth.eu" , Doug Anderson , "rmfrfs@gmail.com" , Lee Jones , Linux Kernel Mailing List , linux-mmc , "Rafael J. Wysocki" , Linux PM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Nov 2020 at 15:19, Rafael J. Wysocki wrote: > > On Thu, Nov 26, 2020 at 4:07 AM =E5=90=B3=E6=98=8A=E6=BE=84 Ricky wrote: > > > > > -----Original Message----- > > > From: Rafael J. Wysocki [mailto:rafael@kernel.org] > > > Sent: Wednesday, November 25, 2020 10:04 PM > > > To: Bjorn Helgaas; =E5=90=B3=E6=98=8A=E6=BE=84 Ricky > > [cut] > > > > > > +static void rtsx_pci_rtd3_work(struct work_struct *work) > > > > > +{ > > > > > + struct delayed_work *dwork =3D to_delayed_work(work); > > > > > + struct rtsx_pcr *pcr =3D container_of(dwork, struct rtsx_pc= r, > > > rtd3_work); > > > > > + > > > > > + pcr_dbg(pcr, "--> %s\n", __func__); > > > > > + > > > > > + while (pcr->pci->dev.power.usage_count.counter > 0) { > > > > > + if (pm_runtime_active(&(pcr->pci->dev))) > > > > > + pm_runtime_put(&(pcr->pci->dev)); > > > > > > > > I'm not a runtime PM expert, but this looks fishy. AFAICT this is = the > > > > only driver in the tree that uses usage_count.counter this way, whi= ch > > > > is a pretty big hint that this needs a closer look. Cc'd Rafael. > > > > > > You are right, this is not correct from the PM-runtime POV. > > > > > > It looks like this attempts to force the PM-runtime usage counter dow= n > > > to 0 and it's kind of hard to say why this is done (and it shouldn't > > > be done in the first place, because it destroys the usage counter > > > balance). > > > > > > Ricky, is this an attempt to work around an issue of some sort? > > > > > > > Thanks Bjorn and Rafael > > I found when we boot up, our dev pcr->pci->dev.power.usage_count.counte= r always is 2, > > Don=E2=80=99t know how to make it to 0 because we need to support D3 an= d run runtime_suspended callback function > > Is there something wrong with us to enable runtime PM? > > That is possible. > > If you want it to be enabled by default, you need to call > pm_runtime_allow() from the driver at probe time, in addition to > pm_runtime_enable(), in the first place, but that only drops one > reference, so question is where the other one comes from. Yes, good point. Moreover, I am wondering whether you also need to deploy support for runtime PM for the child device (managed by drivers/mmc/host/rtsx_pci_sdmmc.c driver), as to make the support complete. > > Are the pm_runtime_get*() and pm_runtime_put*() calls balanced? Perhaps have a look at how the drivers/misc/cardreader/rtsx_usb.c and drivers/mmc/host/rtsx_usb_sdmmc.c have implemented this could help. I know it's USB, but it should work quite similar in regards to runtime PM, I think. Kind regards Uffe