Linux Power Management development
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Madhusudhan Sana <quic_msana@quicinc.com>,
	Ulf Hansson <ulf.hansson@linaro.org>
Cc: quic_cang@quicinc.com, quic_nguyenb@quicinc.com,
	quic_bhaskarv@quicinc.com, quic_mapa@quicinc.com,
	quic_narepall@quicinc.com, quic_nitirawa@quicinc.com,
	quic_rampraka@quicinc.com, quic_sachgupt@quicinc.com,
	quic_sartgarg@quicinc.com,
	Linux PM list <linux-pm@vger.kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH] mmc: sdhc: Add PM QoS support for mmc driver
Date: Fri, 8 Nov 2024 16:43:37 +0200	[thread overview]
Message-ID: <1e47ee3e-7439-4dc4-aef6-0ad2f82ee341@intel.com> (raw)
In-Reply-To: <20241101024421.26679-1-quic_msana@quicinc.com>

On 1/11/24 04:44, Madhusudhan Sana wrote:
> Register mmc driver to CPU latency PM QoS framework to improve
> mmc device io performance.

Not sure host controller drivers should really be manipulating
cpu_latency_qos in order to squeeze a bit more I/O performance.

> 
> Signed-off-by: Madhusudhan Sana <quic_msana@quicinc.com>
> ---
>  drivers/mmc/host/sdhci.c | 47 ++++++++++++++++++++++++++++++++++++++++
>  drivers/mmc/host/sdhci.h |  4 ++++
>  2 files changed, 51 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index f4a7733a8ad2..ffcc9544a3df 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -359,6 +359,46 @@ static void sdhci_config_dma(struct sdhci_host *host)
>  	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
>  }
>  
> +/*
> + * sdhci_pm_qos_init - initialize PM QoS request
> + */
> +void sdhci_pm_qos_init(struct sdhci_host *host)
> +{
> +	if (host->pm_qos_enable)
> +		return;
> +
> +	cpu_latency_qos_add_request(&host->pm_qos_req, PM_QOS_DEFAULT_VALUE);
> +
> +	if (cpu_latency_qos_request_active(&host->pm_qos_req))
> +		host->pm_qos_enable = true;
> +}
> +
> +/*
> + * sdhci_pm_qos_exit - remove request from PM QoS
> + */
> +void sdhci_pm_qos_exit(struct sdhci_host *host)
> +{
> +	if (!host->pm_qos_enable)
> +		return;
> +
> +	cpu_latency_qos_remove_request(&host->pm_qos_req);
> +	host->pm_qos_enable = false;
> +}
> +
> +/*
> + * sdhci_pm_qos_update - update PM QoS request
> + * @on - True, vote for perf PM QoS mode
> + *     - False, vote for power save mode.
> + */
> +static void sdhci_pm_qos_update(struct sdhci_host *host, bool on)
> +{
> +	if (!host->pm_qos_enable)
> +		return;
> +
> +	cpu_latency_qos_update_request(&host->pm_qos_req, on ?
> +						0 : PM_QOS_DEFAULT_VALUE);
> +}
> +
>  static void sdhci_init(struct sdhci_host *host, int soft)
>  {
>  	struct mmc_host *mmc = host->mmc;
> @@ -384,6 +424,9 @@ static void sdhci_init(struct sdhci_host *host, int soft)
>  		host->reinit_uhs = true;
>  		mmc->ops->set_ios(mmc, &mmc->ios);
>  	}
> +
> +	sdhci_pm_qos_init(host);
> +	sdhci_pm_qos_update(host, true);
>  }
>  
>  static void sdhci_reinit(struct sdhci_host *host)
> @@ -2072,6 +2115,7 @@ void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
>  
>  	clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock);
>  	sdhci_enable_clk(host, clk);
> +	sdhci_pm_qos_update(host, true);
>  }
>  EXPORT_SYMBOL_GPL(sdhci_set_clock);
>  
> @@ -3811,6 +3855,7 @@ int sdhci_suspend_host(struct sdhci_host *host)
>  		sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE);
>  		free_irq(host->irq, host);
>  	}
> +	sdhci_pm_qos_update(host, false);
>  
>  	return 0;
>  }
> @@ -3873,6 +3918,7 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host)
>  	spin_lock_irqsave(&host->lock, flags);
>  	host->runtime_suspended = true;
>  	spin_unlock_irqrestore(&host->lock, flags);
> +	sdhci_pm_qos_update(host, false);
>  
>  	return 0;
>  }
> @@ -4987,6 +5033,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
>  	if (host->use_external_dma)
>  		sdhci_external_dma_release(host);
>  
> +	sdhci_pm_qos_exit(host);
>  	host->adma_table = NULL;
>  	host->align_buffer = NULL;
>  }
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index cd0e35a80542..685036ed888b 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -16,6 +16,7 @@
>  #include <linux/io.h>
>  #include <linux/leds.h>
>  #include <linux/interrupt.h>
> +#include <linux/devfreq.h>
>  
>  #include <linux/mmc/host.h>
>  
> @@ -675,6 +676,9 @@ struct sdhci_host {
>  
>  	u64			data_timeout;
>  
> +	struct pm_qos_request pm_qos_req;	/* PM QoS request handle */
> +	bool pm_qos_enable;			/* flag to check PM QoS is enable */
> +
>  	unsigned long private[] ____cacheline_aligned;
>  };
>  


       reply	other threads:[~2024-11-08 14:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20241101024421.26679-1-quic_msana@quicinc.com>
2024-11-08 14:43 ` Adrian Hunter [this message]
2024-11-12 15:08   ` [PATCH] mmc: sdhc: Add PM QoS support for mmc driver Ulf Hansson
2025-05-14  3:00     ` Ram Prakash Gupta
2025-05-19 14:00       ` Ulf Hansson

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=1e47ee3e-7439-4dc4-aef6-0ad2f82ee341@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=quic_bhaskarv@quicinc.com \
    --cc=quic_cang@quicinc.com \
    --cc=quic_mapa@quicinc.com \
    --cc=quic_msana@quicinc.com \
    --cc=quic_narepall@quicinc.com \
    --cc=quic_nguyenb@quicinc.com \
    --cc=quic_nitirawa@quicinc.com \
    --cc=quic_rampraka@quicinc.com \
    --cc=quic_sachgupt@quicinc.com \
    --cc=quic_sartgarg@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=ulf.hansson@linaro.org \
    /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