Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3355609pxj; Sun, 20 Jun 2021 18:40:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfs5Wg6pkBgKhk4p3FkMlMmRmm1pbT66QMoYEez7Kv9b64uvC/ZjlQ4FmKUwUswoc6PFZf X-Received: by 2002:a02:cebc:: with SMTP id z28mr15056550jaq.127.1624239601568; Sun, 20 Jun 2021 18:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624239601; cv=none; d=google.com; s=arc-20160816; b=S5ZUIh41ZswxmoQkFd6e1fgs/UUXnHGa+Dfe73t+EdNIF2Vv1BbwLDtX2olHq+N9dT 41EIQxlRWWpBU0DqmUHPg9ZCHSrzTXuvrgFXkZaePdWkPmHPyQNKZYIuZOsuN8a4SnEr WHfaF4UmGdSuIFNCoKkW4v23TRnUg7F+XnFdRO4qhuTZEFwYQVmrifV+zGDcOr85moAv 73lmLY/nxvSFKsbhj8vts1PFMk34f0BUn6Haf+pP9BrSAYMxzxOZPJNB/5MQndsmACqr /cyezkywj/IdPSgJUfp7M6O1L9WyyLbu/VVvvaqlKHb1U7ekGjsUNVq8BFHAhKhljZ3Z tuuA== 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:reply-to:in-reply-to:references:mime-version :dkim-signature; bh=Ucm3wibUKjyDXQlWvsaDkSdXqDbxxo3t9VSQN89L9Co=; b=uEXRSOeCWOWO+aLCjFvkr7SCH8L5fubOGVhgnzzfl/yd0xSU0U64AT4fYTk3ku+kGt mAA7ifQdG/lP+HKBqNPPhj7DhLlvwuEK9fkyKF8DblM8bv476O82rqDWLH54DlHqnHpM CgZPPos6jqYpSA+euT9fl4mx4Ghk676OvRAthbUOq4FoBza/FQEz8YwG4JHMBKMrrD5x WhfvzjpUz8Dq7RLS5/LU6nURHJ1E2rPGwgPp+EvPBPimkapI+4ibDJUMGkU9To4zvpBm +mHpsQ4ypQPQH/AW7NTPrtILn9lhNBD0CgFe0uENM3rhSfFjmLYlL7wkAbY5NEvxHkK3 4x6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BTlxdwbu; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f13si11495286ila.126.2021.06.20.18.39.38; Sun, 20 Jun 2021 18:40:01 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=BTlxdwbu; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbhFUBlC (ORCPT + 99 others); Sun, 20 Jun 2021 21:41:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbhFUBlB (ORCPT ); Sun, 20 Jun 2021 21:41:01 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07E66C061574; Sun, 20 Jun 2021 18:38:47 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id s22so22788970ljg.5; Sun, 20 Jun 2021 18:38:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=Ucm3wibUKjyDXQlWvsaDkSdXqDbxxo3t9VSQN89L9Co=; b=BTlxdwbuRpgVcK978ahZti3mOppExd/U6mwBAaLVrjhA5uQaZGlR3lBoODkFn0HOqk 62jBeVq9CY95Yu1xfBJlML0yHnMuCIP/9U+Ab1rxcGbgNG9ZBxEY2ag+aPPzUGR5otjs aqSBMT8ME6WaVxbcKal9RcHhIHfn45KBkAUTPbEnnqR3InZkcSxrCjBbGq5KDNR+ffI4 le0n5y2SK01XdEdJ8n+8QazVPH7zorDXFaK3i5reARh0KcGNht2hlOLs2i0PB5aqs5eF xuEZdk8zGXAz4FjopjVehUYszCezbBEMafTDgs4vVmk/UCRcCMFJiMa+kOo2BTRrB645 Al3A== 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:reply-to :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=Ucm3wibUKjyDXQlWvsaDkSdXqDbxxo3t9VSQN89L9Co=; b=WG3EEpcRlvcCbG2oWS4mEhEb/P/P8IoBOtiwtFPJJlCxl0lmqFjx6HyzJY8nQoBevQ a2/5F50c5pCJiKe2mla5kBwzIHfsFUA/sPGko3Hw2gbQKHpoEkepFkBXTksCusDw1zxD y+Iua/MVdMJsN4XCmLPvXBvxDysmIpuPJgzFF5sVq6M4mmwy3jGg0iqanp8BU9uW3Is8 oiWOuznOx7Tngc4msmDdLPmnU3y01EjooBTIqnVwjJVo2HkOH8n+MfWr1GAq131CTedA SgRYHjrcpTh54YK4G5efX3rDLSAoYOEaB8SCSZ5diZ+vyjqyCmKSf3KbAe3SEJItAdJL vdDA== X-Gm-Message-State: AOAM5302RsQ+EDj2Zp0Qbk7n1TqYipk94LRSgN3AKQRTuU5j6EZ8S6ka Nx5tz+Q4cDIKDFQ/9WClmrFTiuLyjoLJ5cPML/o= X-Received: by 2002:a2e:8190:: with SMTP id e16mr19511865ljg.81.1624239525427; Sun, 20 Jun 2021 18:38:45 -0700 (PDT) MIME-Version: 1.0 References: <20210320045720.11872-1-chgokhl@gmail.com> In-Reply-To: Reply-To: chgokhl@163.com From: hieagle Date: Mon, 21 Jun 2021 09:38:34 +0800 Message-ID: Subject: Re: [PATCH] mmc: core: Mark mmc_host device with pm_runtime_no_callbacks To: Ulf Hansson Cc: linux-mmc , Linux Kernel Mailing List , kehuanlin@fishsemi.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry, I don't receive the reply email in my gmail. Normally the mmc_host's power.disable_depth is large than zero, the rpm_resume(mmc:0001) will not be called recursively for parent. This is the most case. Although the mmc class device never calls pm_runtime_enable() directly, there are still some cases as below to call pm_runtime_enable(), which may cause it's power.disable_depth decremented to zero. case1: device_resume_early->pm_runtime_enable case2: device_resume->pm_runtime_enable Anything that can go wrong will go wrong. Unfortunately we meet the case. If you trigger to set the mmc_host's power.disable_depth value to zero after mmc suspended, you can find the issue. In our platform the mmc device's parent list is as below: mmc0:0001->mmc_host mmc0->fa630000.mmc->soc. The rpm_resume call trace is as below in our scenario: rpm_resume(mmc0:0001) | if (!parent && dev->parent) //true if (!parent->power.disable_depth && !parent->power.ignore_children) //true rpm_resume(parent, 0) ---> rpm_resume(mmc_host, 0) | | | callback =3D RPM_GET_CALLBACK(mmc_host, ...) = =3D NULL | retval =3D rpm_callback(callback, mmc_host) =3D= -ENOSYS | | | return retval =3D -ENOSYS if (retval) goto out; //skip rpm_callback() return retval =3D -ENOSYS The scenario is rare, but anything that can go wrong will go wrong. The patch can enhance the code to avoid this scenario. Ulf Hansson =E4=BA=8E2021=E5=B9=B43=E6=9C=8822=E6= =97=A5=E5=91=A8=E4=B8=80 =E4=B8=8B=E5=8D=886:26=E5=86=99=E9=81=93=EF=BC=9A > > On Sat, 20 Mar 2021 at 05:57, kehuanlin wrote: > > > > The rpm_resume() will call parent's resume callback recursively. > > Since mmc_host has no its own pm_runtime callbacks, the mmc devices > > may fail to resume (-ENOSYS in rpm_callback) sometimes. Mark mmc_host > > device with pm_runtime_no_callbacks can fix the issue. > > Can you please elaborate more on this? What do you mean by "sometimes"? > > More precisely, how do you trigger the rpm_callback() for mmc class > device to return -ENOSYS? > > Don't get me wrong, the patch is fine, but I want to understand if it > actually solves a problem for you - or that it's better considered as > an optimization? > > Kind regards > Uffe > > > > > Signed-off-by: kehuanlin > > --- > > drivers/mmc/core/host.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c > > index 9b89a91b6b47..177bebd9a6c4 100644 > > --- a/drivers/mmc/core/host.c > > +++ b/drivers/mmc/core/host.c > > @@ -15,6 +15,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -480,6 +481,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct d= evice *dev) > > host->class_dev.class =3D &mmc_host_class; > > device_initialize(&host->class_dev); > > device_enable_async_suspend(&host->class_dev); > > + pm_runtime_no_callbacks(&host->class_dev); > > > > if (mmc_gpio_alloc(host)) { > > put_device(&host->class_dev); > > -- > > 2.30.0 > >