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

Commit 0196fe42 authored by Siba Prasad's avatar Siba Prasad
Browse files

mmc: host: Capture error states in Trace logs.



Upon encountering any error, few important registers are being captured
in trace logs in sdhci_dumpregs(). But without capturing exact error,
it would be tough to determine from which point in driver this dumpregs
has called. So capture the error state as well in Trace logs before
calling sdhci_dumpregs(). Also capture power irq related registers in
Trace logs upon any power irq related errors.

Change-Id: Ide172cdfb88a988cd4220bed03d05b8c6c4f15cb
Signed-off-by: default avatarSiba Prasad <sibap@codeaurora.org>
parent 70be28c9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2944,6 +2944,7 @@ static int mmc_runtime_suspend(struct mmc_host *host)
		return -EBUSY;
	}

	MMC_TRACE(host, "%s\n", __func__);
	err = _mmc_suspend(host, true);
	if (err)
		pr_err("%s: error %d doing aggressive suspend\n",
@@ -2962,6 +2963,7 @@ static int mmc_runtime_resume(struct mmc_host *host)
	int err;
	ktime_t start = ktime_get();

	MMC_TRACE(host, "%s\n", __func__);
	err = _mmc_resume(host);
	if (err && err != -ENOMEDIUM)
		pr_err("%s: error %d doing runtime resume\n",
+24 −4
Original line number Diff line number Diff line
@@ -2492,15 +2492,31 @@ void sdhci_msm_dump_pwr_ctrl_regs(struct sdhci_host *host)
	struct sdhci_msm_host *msm_host = pltfm_host->priv;
	const struct sdhci_msm_offset *msm_host_offset =
					msm_host->offset;
	unsigned int irq_flags = 0;
	struct irq_desc *pwr_irq_desc = irq_to_desc(msm_host->pwr_irq);

	pr_err("%s: PWRCTL_STATUS: 0x%08x | PWRCTL_MASK: 0x%08x | PWRCTL_CTL: 0x%08x\n",
	if (pwr_irq_desc)
		irq_flags = ACCESS_PRIVATE(pwr_irq_desc->irq_data.common,
				state_use_accessors);

	pr_err("%s: PWRCTL_STATUS: 0x%08x | PWRCTL_MASK: 0x%08x | PWRCTL_CTL: 0x%08x, pwr isr state=0x%x\n",
		mmc_hostname(host->mmc),
		sdhci_msm_readl_relaxed(host,
			msm_host_offset->CORE_PWRCTL_STATUS),
		sdhci_msm_readl_relaxed(host,
			msm_host_offset->CORE_PWRCTL_MASK),
		sdhci_msm_readl_relaxed(host,
			msm_host_offset->CORE_PWRCTL_CTL));
			msm_host_offset->CORE_PWRCTL_CTL), irq_flags);

	MMC_TRACE(host->mmc,
		"%s: Sts: 0x%08x | Mask: 0x%08x | Ctrl: 0x%08x, pwr isr state=0x%x\n",
		__func__,
		sdhci_msm_readb_relaxed(host,
			msm_host_offset->CORE_PWRCTL_STATUS),
		sdhci_msm_readb_relaxed(host,
			msm_host_offset->CORE_PWRCTL_MASK),
		sdhci_msm_readb_relaxed(host,
			msm_host_offset->CORE_PWRCTL_CTL), irq_flags);
}

static irqreturn_t sdhci_msm_pwr_irq(int irq, void *data)
@@ -2772,10 +2788,14 @@ static void sdhci_msm_check_power_status(struct sdhci_host *host, u32 req_type)
	if (done)
		init_completion(&msm_host->pwr_irq_completion);
	else if (!wait_for_completion_timeout(&msm_host->pwr_irq_completion,
				msecs_to_jiffies(MSM_PWR_IRQ_TIMEOUT_MS)))
				msecs_to_jiffies(MSM_PWR_IRQ_TIMEOUT_MS))) {
		__WARN_printf("%s: request(%d) timed out waiting for pwr_irq\n",
					mmc_hostname(host->mmc), req_type);

		MMC_TRACE(host->mmc,
			"%s: request(%d) timed out waiting for pwr_irq\n",
			__func__, req_type);
		sdhci_msm_dump_pwr_ctrl_regs(host);
	}
	pr_debug("%s: %s: request %d done\n", mmc_hostname(host->mmc),
			__func__, req_type);
}
+22 −1
Original line number Diff line number Diff line
@@ -245,6 +245,8 @@ void sdhci_reset(struct sdhci_host *host, u8 mask)
		if (timeout == 0) {
			pr_err("%s: Reset 0x%x never completed.\n",
				mmc_hostname(host->mmc), (int)mask);
			MMC_TRACE(host->mmc, "%s: Reset 0x%x never completed\n",
					__func__, (int)mask);
			if ((host->quirks2 & SDHCI_QUIRK2_USE_RESET_WORKAROUND)
				&& host->ops->reset_workaround) {
				if (!host->reset_wa_applied) {
@@ -1244,6 +1246,9 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
		if (timeout == 0) {
			pr_err("%s: Controller never released inhibit bit(s).\n",
			       mmc_hostname(host->mmc));
			MMC_TRACE(host->mmc,
			"%s :Controller never released inhibit bit(s)\n",
			__func__);
			sdhci_dumpregs(host);
			cmd->error = -EIO;
			sdhci_finish_mrq(host, cmd->mrq);
@@ -1302,12 +1307,12 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
	if (cmd->data)
		host->data_start_time = ktime_get();
	trace_mmc_cmd_rw_start(cmd->opcode, cmd->arg, cmd->flags);
	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
	MMC_TRACE(host->mmc,
		"%s: updated 0x8=0x%08x 0xC=0x%08x 0xE=0x%08x\n", __func__,
		sdhci_readl(host, SDHCI_ARGUMENT),
		sdhci_readw(host, SDHCI_TRANSFER_MODE),
		sdhci_readw(host, SDHCI_COMMAND));
	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
}
EXPORT_SYMBOL_GPL(sdhci_send_command);

@@ -1533,6 +1538,8 @@ void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
		if (timeout == 0) {
			pr_err("%s: Internal clock never stabilised.\n",
			       mmc_hostname(host->mmc));
			MMC_TRACE(host->mmc,
			"%s: Internal clock never stabilised.\n", __func__);
			sdhci_dumpregs(host);
			return;
		}
@@ -2917,6 +2924,7 @@ static void sdhci_timeout_data_timer(unsigned long data)
	    (host->cmd && sdhci_data_line_cmd(host->cmd))) {
		pr_err("%s: Timeout waiting for hardware interrupt.\n",
		       mmc_hostname(host->mmc));
		MMC_TRACE(host->mmc, "Timeout waiting for h/w interrupt\n");
		sdhci_dumpregs(host);

		if (host->data) {
@@ -2959,6 +2967,9 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
			return;
		pr_err("%s: Got command interrupt 0x%08x even though no command operation was in progress.\n",
		       mmc_hostname(host->mmc), (unsigned)intmask);
		MMC_TRACE(host->mmc,
		"Got command interrupt 0x%08x even though no command operation was in progress.\n",
		(unsigned int)intmask);
		sdhci_dumpregs(host);
		return;
	}
@@ -3111,6 +3122,9 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)

		pr_err("%s: Got data interrupt 0x%08x even though no data operation was in progress.\n",
		       mmc_hostname(host->mmc), (unsigned)intmask);
		MMC_TRACE(host->mmc,
		"Got data interrupt 0x%08x even though no data operation was in progress.\n",
		(unsigned int)intmask);
		sdhci_dumpregs(host);

		return;
@@ -3146,6 +3160,11 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
			       mmc_hostname(host->mmc), intmask,
			       host->data->error, ktime_to_ms(ktime_sub(
			       ktime_get(), host->data_start_time)));
			MMC_TRACE(host->mmc,
				"data txfr (0x%08x) error: %d after %lld ms\n",
				intmask, host->data->error,
				ktime_to_ms(ktime_sub(ktime_get(),
				host->data_start_time)));

			if (!host->mmc->sdr104_wa ||
			    (host->mmc->ios.timing != MMC_TIMING_UHS_SDR104))
@@ -3399,6 +3418,8 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
	if (unexpected) {
		pr_err("%s: Unexpected interrupt 0x%08x.\n",
			   mmc_hostname(host->mmc), unexpected);
		MMC_TRACE(host->mmc, "Unexpected interrupt 0x%08x.\n",
				unexpected);
		sdhci_dumpregs(host);
	}