Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp454615pxj; Fri, 11 Jun 2021 03:26:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2Xi9KWx1Fxi0jPdFzGP+f/3oy/jG7OTNDDSklSdkReYPTcFK4Zscb3wJ8RZjMnLSvKuR1 X-Received: by 2002:a05:6402:8d4:: with SMTP id d20mr2890473edz.117.1623407209923; Fri, 11 Jun 2021 03:26:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623407209; cv=none; d=google.com; s=arc-20160816; b=jot1t280S1kDauQXuCho+OQ6FhQKpLGWGpIWUKdrMSLkTgTZ76BJ/0xwV/IDc4ccfU rDBSVaKzMs1w9GBAg+3puIROw/40k0kKzXr0U1l8LWxXElyufdD1AFgNmmFxRPSF6k5D DM8o/lfEmGA1iJ4hCbgvmaoQlm27yRyxL7rXJo4MW4nzwSNGfWqNB7yskWAE2d56WM0N KxGFnHvZysx5QQFiQfJfP4UUg09fjWZD6DdYUkDZ1JjdL2/Yp7gVWkqQ2L/o/F02CYhZ 0hd812iRaAVwZ2NLpm0S3mxMZOG/i/+Y+V3mjEmr1EHim2NXy/nQSqXDvqdzVCgIflzV JfHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=BK5FSPAIVY7BHkqa7m1EZ7jj7bUTkuHalv8GCJ5Ni4s=; b=SahFL8pwc205GfYdWjjETPRKtq+tbQLXlQSPceo/g2FTEq8HgRR7KanccMuonv7wcj rGvvKSc9HG/d+1s424Cp0CFosT3bj7BoGmOJgeP3w2+Q0ZNUGsIzQjO1zoBzfImZTg3b uVPPk/4TkUYaSbe5rLVizSBUnV6HocvgOvq25465mqJZNnTy+RTLzMz3XuCdgXkaKPO6 pVW0kkiDNq2XI7xv6lhianOm79J7nyusfUqV7IMOUuBaXN7awyaJ/uV/euZMZEO2qcXp cPtQCh7Afrz9VWjjNKvoETGT3tMdIPceG6DnQXArDqowhQovpHqxxVjgM8ijaCKTuIYx xB+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JmCUI9Lx; 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 dd11si4428353edb.528.2021.06.11.03.26.26; Fri, 11 Jun 2021 03:26:49 -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=@linaro.org header.s=google header.b=JmCUI9Lx; 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 S230365AbhFKK1D (ORCPT + 99 others); Fri, 11 Jun 2021 06:27:03 -0400 Received: from mail-vs1-f42.google.com ([209.85.217.42]:42615 "EHLO mail-vs1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbhFKK1C (ORCPT ); Fri, 11 Jun 2021 06:27:02 -0400 Received: by mail-vs1-f42.google.com with SMTP id l25so3466590vsb.9 for ; Fri, 11 Jun 2021 03:24:51 -0700 (PDT) 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; bh=BK5FSPAIVY7BHkqa7m1EZ7jj7bUTkuHalv8GCJ5Ni4s=; b=JmCUI9LxHn1plyMQFyPsw0EPm98tNnjsR+0gzYK0zeVAitU0BQSDb2gb+Liv5AusmV /i+75NEJbsybJrbJ6PnJwJ6s3qfk7huCB/m1TO17P43lekpDK0Eo7Ap8RwRMQHxnLfcL a0e24WAD0YqlHvTrR9NuQ3oC9KO38MZI/OSfXgweAmumesRVtYn72vEUeAsC6JSebNz4 o3lUTv5C84pgLHPTdNtZPnZN8a8iDEnTdQyLJQnkAJXsxe2vRd7KVWeJhbphwa/SfWCE 47HcBsj7QCrgP+YT0wggIQEWCgiwd9GH+ou1Uwi0We/CMxlXJ7IJOIL+j2va1rtNfiUb acFQ== 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; bh=BK5FSPAIVY7BHkqa7m1EZ7jj7bUTkuHalv8GCJ5Ni4s=; b=dueXhxhiLXYCdrNOICrKqSVH9Jbzt1McdvcL6Q1CZz3wXmZVz/Q1IgU3ZXsQGsoDoJ N7UFMyvMqi3+hMhc9skx4DrGokS51HY5NNJlXwD5gWf1CgNjZapNg0nGwYZQWBoCaKVz hFGuODCPp96BwDmJvMnQRGG5JXc5eEB2MozhaXFLAPxwYVOJNsWoR7v9JQtq5Q9V+4sN 0rPmFXrWgTIrfUMjWTVcHK1Xu8quQr5Xa954bocj5zuxj5MdLq+ws8Xg/YgfBOqDYsuA ofDbL6jswBE3EJyieviPDVf7YR4grSxd1K5wL2sl9+mJx7PqNkGei2pxHGyMc6qOSDHx +J8w== X-Gm-Message-State: AOAM5332tYDi9C4RWagYwZ5/JKKihV/8lKgttAMC7UpfWmm+3V9Vtq/L /HHCjR0hpC64eGzByha9JnaIznNCANe3QzYdDFfDsg== X-Received: by 2002:a05:6102:386:: with SMTP id m6mr5780364vsq.48.1623407031441; Fri, 11 Jun 2021 03:23:51 -0700 (PDT) MIME-Version: 1.0 References: <20210602192758.38735-1-alcooperx@gmail.com> <20210602192758.38735-2-alcooperx@gmail.com> <6acd480a-8928-89bb-0f40-d278294973a1@gmail.com> In-Reply-To: From: Ulf Hansson Date: Fri, 11 Jun 2021 12:23:14 +0200 Message-ID: Subject: Re: [PATCH 2/2] mmc: sdhci-iproc: Add support for the legacy sdhci controller on the BCM7211 To: Florian Fainelli Cc: "Rafael J. Wysocki" , Linux PM , Al Cooper , Linux Kernel Mailing List , Adrian Hunter , BCM Kernel Feedback , DTML , Linux ARM , linux-mmc , Nicolas Saenz Julienne , Ray Jui , Rob Herring , Scott Branden Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 10 Jun 2021 at 17:59, Florian Fainelli wrote: > > > > On 6/10/2021 1:49 AM, Ulf Hansson wrote: > > On Thu, 10 Jun 2021 at 01:59, Florian Fainelli wrote: > >> > >> > >> > >> On 6/9/2021 2:22 AM, Ulf Hansson wrote: > >>> On Wed, 9 Jun 2021 at 05:07, Florian Fainelli wrote: > >>>> > >>>> > >>>> > >>>> On 6/8/2021 5:40 AM, Ulf Hansson wrote: > >>>>> On Wed, 2 Jun 2021 at 21:28, Al Cooper wrote: > >>>>>> > >>>>>> Add support for the legacy Arasan sdhci controller on the BCM7211 and > >>>>>> related SoC's. This includes adding a .shutdown callback to increase > >>>>>> the power savings during S5. > >>>>> > >>>>> Please split this into two separate changes. > >>>>> > >>>>> May I also ask about the ->shutdown() callback and in relation to S5. > >>>>> What makes the ->shutdown callback only being invoked for S5? > >>>> > >>>> It is not only called for S5 (entered via poweroff on a prompt) but also > >>>> during kexec or reboot. The poweroff path is via: > >>>> > >>>> kernel_power_off() -> kernel_shutdown_prepare() -> device_shutdown() -> > >>>> .shutdown() > >>>> > >>>> For kexec or reboot we do not really care about power savings since we > >>>> are about to load a new image anyway, however for S5/poweroff we do care > >>>> about quiescing the eMMC controller in a way that its clocks and the > >>>> eMMC device can be put into low power mode since we will stay in that > >>>> mode for seconds/hours/days until someone presses a button on their > >>>> remote (or other wake-up sources). > >>> > >>> Hmm, I am not sure I understand correctly. At shutdown we don't care > >>> about wake-up sources from the kernel point of view, instead we treat > >>> everything as if it will be powered off. > >> > >> The same .shutdown() path is used whether you kexec, reboot or poweroff, > >> but for poweroff we do care about allowing specific wake-up sources > >> configured as such to wake-up the system at a later time, like GPIOs, > >> RTC, etc. > > > > That's true, but using the ->shutdown() callbacks in this way would > > certainly be a new use case. > > > > Most subsystems/drivers don't care about power management in those > > callbacks, but rather just about managing a graceful shutdown. > > > > It sounds to me like you should have a look at the hibernation > > path/callbacks instead - or perhaps even the system suspend > > path/callback. Normally, that's where we care about power management. > > The platforms we use do not support hibernation, keep in mind that these > are embedded SoCs that support the S2 (standby), S3 (mem) and poweroff > suspend states, hibernation is not something that we can support. > > > > > I have looped in Rafael, to allow him to share his opinion on this. > > > >> > >>> > >>> We put devices into low power state at system suspend and potentially > >>> also during some of the hibernation phases. > >>> > >>> Graceful shutdown of the eMMC is also managed by the mmc core. > >> > >> AFAICT that calls mmc_blk_shutdown() but that is pretty much it, the > >> SDHCI platform_driver still needs to do something in order to conserve > >> power including disabling host->clk, otherwise we would not have done > >> that for sdhci-brcmstb.c. > > > > That's not entirely correct. When mmc_bus_shutdown() is called for the > > struct device* that belongs to an eMMC card, two actions are taken. > > > > *) We call mmc_blk_shutdown(), to suspend the block device queue from > > receiving new I/O requests. > > **) We call host->bus_ops->shutdown(), which is an eMMC specific > > callback set to mmc_shutdown(). In this step, we do a graceful > > shutdown/power-off of the eMMC card. > > > > When it comes to controller specific resources, like clocks and PM > > domains, for example, those may very well stay turned on. Do deal with > > these, then yes, you would need to implement the ->shutdown() > > callback. But as I said above, I am not sure it's the right thing to > > do. > > As explained before, we can enter S5 for an indefinite amount of time > until a wake-up source wakes us up so we must conserve power, even if we > happen to wake up the next second, we don't know that ahead of time. The > point of calling sdhci_pltfm_suspend() here is to ensure that host->clk > is turned off which cuts the eMMC controller digital clock, I forgot how > much power we save by doing so, but every 10s of mW counts for us. I fully understand that you want to avoid draining energy, every single uA certainly counts in cases like these. What puzzles me, is that your platform seems to keep some resources powered on (like device clocks) when entering the system wide low power state, S5. In principle, I am wondering if it would be possible to use S5 as the system-wide low power state for the system suspend path, rather than S3, for example? In this way, we would be able to re-use already implemented ->suspend|resume callbacks from most subsystems/drivers, I believe. Or is there a problem with that? I think we need an opinion from Rafel to move forward. Kind regards Uffe