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

Commit e57b7d5a authored by Ram Prakash Gupta's avatar Ram Prakash Gupta
Browse files

mmc: cqhci: Enable pm qos and add voting



Enable pm qos and adding bus voting by mmc driver during
data transfer.

Change-Id: If31c8c246e277440705a29f15e533831f2091418
Signed-off-by: default avatarRam Prakash Gupta <rampraka@codeaurora.org>
parent 9df64c18
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -374,6 +374,9 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
	if (host->inlinecrypt_support)
		queue_flag_set_unlocked(QUEUE_FLAG_INLINECRYPT, mq->queue);

	if (host->ops->init)
		host->ops->init(host);

	INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler);
	INIT_WORK(&mq->complete_work, mmc_blk_mq_complete_work);

+28 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2015, 2019, The Linux Foundation.
 * All rights reserved.
/*
 * Copyright (c) 2015,2019  The Linux Foundation. All rights reserved.
 */

#include <linux/delay.h>
@@ -18,6 +18,7 @@
#include <linux/mmc/card.h>

#include "cqhci.h"
#include "sdhci-msm.h"

#define DCMD_SLOT 31
#define NUM_SLOTS 32
@@ -551,14 +552,35 @@ static void cqhci_prep_dcmd_desc(struct mmc_host *mmc,

}

static void cqhci_pm_qos_vote(struct sdhci_host *host, struct mmc_request *mrq)
{
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
	struct sdhci_msm_host *msm_host = pltfm_host->priv;

	sdhci_msm_pm_qos_cpu_vote(host,
		msm_host->pdata->pm_qos_data.cmdq_latency, mrq->req->cpu);
}

static void cqhci_pm_qos_unvote(struct sdhci_host *host,
						struct mmc_request *mrq)
{
	/* use async as we're inside an atomic context (soft-irq) */
	sdhci_msm_pm_qos_cpu_unvote(host, mrq->req->cpu, true);
}

static void cqhci_post_req(struct mmc_host *host, struct mmc_request *mrq)
{
	struct mmc_data *data = mrq->data;
	struct sdhci_host *sdhci_host = mmc_priv(host);

	if (data) {
		dma_unmap_sg(mmc_dev(host), data->sg, data->sg_len,
			     (data->flags & MMC_DATA_READ) ?
			     DMA_FROM_DEVICE : DMA_TO_DEVICE);

		/* we're in atomic context (soft-irq) so unvote async. */
		sdhci_msm_pm_qos_irq_unvote(sdhci_host, true);
		cqhci_pm_qos_unvote(sdhci_host, mrq);
	}
}

@@ -599,6 +621,7 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
	int tag = cqhci_tag(mrq);
	struct cqhci_host *cq_host = mmc->cqe_private;
	unsigned long flags;
	struct sdhci_host *host = mmc_priv(mmc);
	u64 ice_ctx = 0;

	if (!cq_host->enabled) {
@@ -642,6 +665,9 @@ static int cqhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
			       mmc_hostname(mmc), err);
			return err;
		}
		/* PM QoS */
		sdhci_msm_pm_qos_irq_vote(host);
		cqhci_pm_qos_vote(host, mrq);
	} else {
		cqhci_prep_dcmd_desc(mmc, mrq);
	}
+2 −0
Original line number Diff line number Diff line
@@ -4134,6 +4134,8 @@ void sdhci_msm_pm_qos_irq_vote(struct sdhci_host *host)

	if (!msm_host->pm_qos_irq.enabled)
		return;
	if (host->power_policy > SDHCI_POWER_SAVE_MODE)
		return;

	counter = atomic_inc_return(&msm_host->pm_qos_irq.counter);
	/* Make sure to update the voting in case power policy has changed */