Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6f48d42 authored by Sahitya Tummala's avatar Sahitya Tummala Committed by Xiaonian Wang
Browse files

mmc: sdhci: Vote for PM QOS



Vote for PM QOS by specifying the acceptable CPU to DMA latency
so that system can enter into the possible power states without
affecting the SDHC performance.

Change-Id: I5fcf9aa93da690c6e64ab70ea5b039ca663c80ad
Signed-off-by: default avatarSahitya Tummala <stummala@codeaurora.org>
Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
[xiaonian@codeaurora.org: fix trivial merge conflict]
Signed-off-by: default avatarXiaonian Wang <xiaonian@codeaurora.org>
parent 7c1b4489
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@ struct sdhci_msm_pltfm_data {
	struct sdhci_msm_slot_reg_data *vreg_data;
	bool nonremovable;
	struct sdhci_msm_pin_data *pin_data;
	u32 cpu_dma_latency_us;
};

struct sdhci_msm_host {
@@ -767,6 +768,7 @@ static struct sdhci_msm_pltfm_data *sdhci_msm_populate_pdata(struct device *dev)
	struct sdhci_msm_pltfm_data *pdata = NULL;
	struct device_node *np = dev->of_node;
	u32 bus_width = 0;
	u32 cpu_dma_latency;
	int len, i;

	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
@@ -785,6 +787,10 @@ static struct sdhci_msm_pltfm_data *sdhci_msm_populate_pdata(struct device *dev)
		pdata->mmc_bus_width = 0;
	}

	if (!of_property_read_u32(np, "qcom,cpu-dma-latency-us",
				&cpu_dma_latency))
		pdata->cpu_dma_latency_us = cpu_dma_latency;

	pdata->vreg_data = devm_kzalloc(dev, sizeof(struct
						    sdhci_msm_slot_reg_data),
					GFP_KERNEL);
@@ -1461,6 +1467,8 @@ static int sdhci_msm_probe(struct platform_device *pdev)
	if (msm_host->pdata->nonremovable)
		msm_host->mmc->caps |= MMC_CAP_NONREMOVABLE;

	host->cpu_dma_latency_us = msm_host->pdata->cpu_dma_latency_us;

	ret = sdhci_add_host(host);
	if (ret) {
		dev_err(&pdev->dev, "Add host failed (%d)\n", ret);
+29 −1
Original line number Diff line number Diff line
@@ -1490,6 +1490,26 @@ EXPORT_SYMBOL_GPL(sdhci_set_power);
 *                                                                           *
\*****************************************************************************/

static int sdhci_enable(struct mmc_host *mmc)
{
	struct sdhci_host *host = mmc_priv(mmc);

	if (host->cpu_dma_latency_us)
		pm_qos_update_request(&host->pm_qos_req_dma,
					host->cpu_dma_latency_us);
	return 0;
}

static int sdhci_disable(struct mmc_host *mmc)
{
	struct sdhci_host *host = mmc_priv(mmc);

	if (host->cpu_dma_latency_us)
		pm_qos_update_request(&host->pm_qos_req_dma,
					PM_QOS_DEFAULT_VALUE);
	return 0;
}

static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
{
	struct sdhci_host *host;
@@ -2306,6 +2326,8 @@ static const struct mmc_host_ops sdhci_ops = {
	.select_drive_strength		= sdhci_select_drive_strength,
	.card_event			= sdhci_card_event,
	.card_busy	= sdhci_card_busy,
	.enable		= sdhci_enable,
	.disable	= sdhci_disable,
};

/*****************************************************************************\
@@ -3622,6 +3644,10 @@ int __sdhci_add_host(struct sdhci_host *host)

	mmiowb();

	if (host->cpu_dma_latency_us)
		pm_qos_add_request(&host->pm_qos_req_dma,
				PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE);

	ret = mmc_add_host(mmc);
	if (ret)
		goto unled;
@@ -3693,7 +3719,9 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)

	sdhci_disable_card_detection(host);

	mmc_remove_host(mmc);
	if (host->cpu_dma_latency_us)
		pm_qos_remove_request(&host->pm_qos_req_dma);
	mmc_remove_host(host->mmc);

	sdhci_led_unregister(host);

+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <linux/compiler.h>
#include <linux/types.h>
#include <linux/io.h>
#include <linux/pm_qos.h>

#include <linux/mmc/host.h>

@@ -536,6 +537,9 @@ struct sdhci_host {
#define SDHCI_TUNING_MODE_2	1
#define SDHCI_TUNING_MODE_3	2

	unsigned int		cpu_dma_latency_us;
	struct pm_qos_request	pm_qos_req_dma;

	unsigned long private[0] ____cacheline_aligned;
};