public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: "Kornel Dulęba" <korneld@chromium.org>
To: Sven van Ashbrook <svenva@chromium.org>
Cc: "Ulf Hansson" <ulf.hansson@linaro.org>,
	"Adrian Hunter" <adrian.hunter@intel.com>,
	"Jason Lai" <jasonlai.genesyslogic@gmail.com>,
	"Victor Shih" <victor.shih@genesyslogic.com.tw>,
	"Ben Chuang" <ben.chuang@genesyslogic.com.tw>,
	"Stanisław Kardach" <skardach@google.com>,
	linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] mmc: sdhci-pci-gli: Disable LPM during initialization
Date: Fri, 10 Nov 2023 08:26:53 +0000	[thread overview]
Message-ID: <ZU3pTY0qbA6cDB7f@google.com> (raw)
In-Reply-To: <CAG-rBijqw2VO8AQbwBh5Cu47gBbDsOGwPgw-8hSXMWCHXi6GLw@mail.gmail.com>

Hi Sven,

>Hi Kornel, see below.
>
>On Thu, Nov 9, 2023 at 6:20 AM Kornel Dulęba <korneld@chromium.org> wrote:
>>
>> To address IO performance commit f9e5b33934ce
>> ("mmc: host: Improve I/O read/write performance for GL9763E")
>> limited LPM negotiation to runtime suspend state.
>> The problem is that it only flips the switch in the runtime PM
>> resume/suspend logic.
>>
>> Disable LPM negotiation in gl9763e_add_host.
>> This helps in two ways:
>> 1. It was found that the LPM switch stays in the same position after
>>    warm reboot. Having it set in init helps with consistency.
>> 2. Disabling LPM during the first runtime resume leaves us susceptible
>>    to the performance issue in the time window between boot and the
>>    first runtime suspend.
>>
>> Fixes: f9e5b33934ce ("mmc: host: Improve I/O read/write performance for GL9763E")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Kornel Dulęba <korneld@chromium.org>
>> ---
>>  drivers/mmc/host/sdhci-pci-gli.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-pci-gli.c b/drivers/mmc/host/sdhci-pci-gli.c
>> index d83261e857a5..ce91d1e63a8e 100644
>> --- a/drivers/mmc/host/sdhci-pci-gli.c
>> +++ b/drivers/mmc/host/sdhci-pci-gli.c
>> @@ -220,6 +220,9 @@
>>
>>  #define GLI_MAX_TUNING_LOOP 40
>>
>> +static void gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot,
>> +                                             bool enable);
>> +
>>  /* Genesys Logic chipset */
>>  static inline void gl9750_wt_on(struct sdhci_host *host)
>>  {
>> @@ -1281,6 +1284,9 @@ static int gl9763e_add_host(struct sdhci_pci_slot *slot)
>>         if (ret)
>>                 goto cleanup;
>>
>> +       /* Disable LPM negotiation to avoid entering L1 state. */
>> +       gl9763e_set_low_power_negotiation(slot, false);
>> +
>>         return 0;
>
>What happens if the bridge is not driving the system rootfs? Imagine
>the case where
>the bridge is used to drive an auxiliary eMMC, unused until a few hours
>after boot. After this patch, the bridge may remain active (not-L1)
>for the entire time,
>although it's not being used...

That's already addressed by runtime PM. LPM negotiation will be
re-enabled duing the first runtime suspend. The default autosuspend
delay for all PCI MMC controllers is 50ms, so I think that's fine.
The only scenario where LPM will never be entered is if the user
explicitly disabled runtime PM for the controller. In that case however,
it's arguably better to have the LPM negotiation disabled for the sake 
of performance.

>
>I suspect we want the following:
>1. consistency - LPM register setting and runtime_pm state must agree
>2. power-efficient initial state - bridge must come out of probe
>runtime-suspended
>and LPM must be enabled
>
>I suspect the above will be fulfilled if we do
>
>+ /* Bring to consistent runtime suspended state with LPM negotiation enabled */
>+ gl9763e_set_low_power_negotiation(slot, false);
>+ pm_runtime_set_suspended(dev);
>
>WDYT?

I don't think this is something that we want do to. Apart from my
argument above there is one more thing to consider.
During runtime PM initialization in sdhci_pci_runtime_pm_allow
the usage counter is dropped using pm_runtime_put_noidle,
which doesn't trigger the machinery to suspend the device.
According to the comment that's because the mmc core logic will shortly
talk to the device, probably to initialize the eMMC card itself.

>
>>
>>  cleanup:
>> @@ -1323,7 +1329,6 @@ static void gli_set_gl9763e(struct sdhci_pci_slot *slot)
>>         pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
>>  }
>>
>> -#ifdef CONFIG_PM
>>  static void gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot, bool enable)
>>  {
>>         struct pci_dev *pdev = slot->chip->pdev;
>> @@ -1349,6 +1354,7 @@ static void gl9763e_set_low_power_negotiation(struct sdhci_pci_slot *slot, bool
>>         pci_write_config_dword(pdev, PCIE_GLI_9763E_VHS, value);
>>  }
>>
>> +#ifdef CONFIG_PM
>>  static int gl9763e_runtime_suspend(struct sdhci_pci_chip *chip)
>>  {
>>         struct sdhci_pci_slot *slot = chip->slots[0];
>> --
>> 2.42.0.869.gea05f2083d-goog
>>

  reply	other threads:[~2023-11-10 19:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-09 11:19 [PATCH] mmc: sdhci-pci-gli: Disable LPM during initialization Kornel Dulęba
2023-11-09 19:19 ` Sven van Ashbrook
2023-11-10  8:26   ` Kornel Dulęba [this message]
2023-11-10 16:58     ` Sven van Ashbrook
2023-11-14 10:26       ` Adrian Hunter
2023-11-09 19:23 ` Sven van Ashbrook
2023-11-14 10:46 ` Adrian Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZU3pTY0qbA6cDB7f@google.com \
    --to=korneld@chromium.org \
    --cc=adrian.hunter@intel.com \
    --cc=ben.chuang@genesyslogic.com.tw \
    --cc=jasonlai.genesyslogic@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=skardach@google.com \
    --cc=stable@vger.kernel.org \
    --cc=svenva@chromium.org \
    --cc=ulf.hansson@linaro.org \
    --cc=victor.shih@genesyslogic.com.tw \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox