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

Commit 9d33aac4 authored by Yaniv Gardi's avatar Yaniv Gardi Committed by Gerrit - the friendly Code Review server
Browse files

scsi: ufs: save and print current power info in the driver



There is no way to know the current working power info of the
driver, so in this patch, we save the power parameters, and we
print them to console.
This printing is necessary, since in case of crash, we can use those
logs to debug and investigate.

Change-Id: If0dc7a695c9b14a369e033e4c31787dcc2254ac3
Signed-off-by: default avatarYaniv Gardi <ygardi@codeaurora.org>
parent e345015b
Loading
Loading
Loading
Loading
+57 −0
Original line number Diff line number Diff line
@@ -2151,6 +2151,48 @@ static int ufshcd_uic_hibern8_exit(struct ufs_hba *hba)
	return ufshcd_uic_pwr_ctrl(hba, &uic_cmd);
}

 /**
 * ufshcd_print_pwr_info - print power params as saved in hba
 * power info
 * @hba: per-adapter instance
 */
static void ufshcd_print_pwr_info(struct ufs_hba *hba)
{
	char *names[] = {
		"INVALID MODE",
		"FAST MODE",
		"SLOW_MODE",
		"INVALID MODE",
		"FASTAUTO_MODE",
		"SLOWAUTO_MODE",
		"INVALID MODE",
	};

	dev_info(hba->dev, "%s:[RX, TX]: gear=[%d, %d], lane[%d, %d], pwr[%s, %s], rate = %d\n",
		 __func__,
		 hba->pwr_info.gear_rx, hba->pwr_info.gear_tx,
		 hba->pwr_info.lane_rx, hba->pwr_info.lane_tx,
		 names[hba->pwr_info.pwr_rx],
		 names[hba->pwr_info.pwr_tx],
		 hba->pwr_info.hs_rate);
}

 /**
 * ufshcd_init_pwr_info - setting the POR (power on reset)
 * values in hba power info
 * @hba: per-adapter instance
 */
static void ufshcd_init_pwr_info(struct ufs_hba *hba)
{
	hba->pwr_info.gear_rx = UFS_PWM_G1;
	hba->pwr_info.gear_tx = UFS_PWM_G1;
	hba->pwr_info.lane_rx = 1;
	hba->pwr_info.lane_tx = 1;
	hba->pwr_info.pwr_rx = SLOWAUTO_MODE;
	hba->pwr_info.pwr_tx = SLOWAUTO_MODE;
	hba->pwr_info.hs_rate = 0;
}

/**
 * ufshcd_config_max_pwr_mode - Set & Change power mode with
 *	maximum capability attribute information.
@@ -2264,8 +2306,18 @@ static int ufshcd_config_max_pwr_mode(struct ufs_hba *hba)
		if (hba->vops->pwr_change_notify)
			hba->vops->pwr_change_notify(hba,
				POST_CHANGE, NULL, &dev_required_params);

		hba->pwr_info.gear_rx = gear[RX];
		hba->pwr_info.gear_tx = gear[TX];
		hba->pwr_info.lane_rx = lanes[RX];
		hba->pwr_info.lane_tx = lanes[TX];
		hba->pwr_info.pwr_rx = pwr[RX];
		hba->pwr_info.pwr_tx = pwr[TX];
		hba->pwr_info.hs_rate = hs_rate;
	}

	ufshcd_print_pwr_info(hba);

	if (hba->quirks & UFSHCD_QUIRK_BROKEN_PWR_MODE_CHANGE)
		msleep(1000);

@@ -3381,6 +3433,7 @@ static void ufshcd_check_errors(struct ufs_hba *hba)
						SYSTEM_BUS_FATAL_ERROR);

				ufshcd_print_host_regs(hba);
				ufshcd_print_pwr_info(hba);
				ufshcd_print_tmrs(hba, hba->outstanding_tasks);
				ufshcd_print_trs(hba, hba->outstanding_reqs,
							pr_prdt);
@@ -3656,6 +3709,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)
	dev_err(hba->dev, "%s: Device abort task at tag %d", __func__, tag);
	scsi_print_command(cmd);
	ufshcd_print_host_regs(hba);
	ufshcd_print_pwr_info(hba);
	ufshcd_print_trs(hba, 1 << tag, true);

	lrbp = &hba->lrb[tag];
@@ -3997,6 +4051,9 @@ static int ufshcd_probe_hba(struct ufs_hba *hba)
	if (ret)
		goto out;

	ufshcd_init_pwr_info(hba);
	ufshcd_print_pwr_info(hba);

	/* UniPro link is active now */
	ufshcd_set_link_active(hba);

+2 −0
Original line number Diff line number Diff line
@@ -444,6 +444,8 @@ struct ufs_hba {
	struct ufs_vreg_info vreg_info;
	struct list_head clk_list_head;

	struct ufs_pa_layer_attr pwr_info;

#ifdef CONFIG_DEBUG_FS
	struct ufs_stats ufs_stats;
	struct debugfs_files debugfs_files;