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

Commit b75c34b4 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mmc: Porting minor fixes for mmc and sdcard"

parents 826e825e 7ba53b8e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -461,6 +461,7 @@ CONFIG_QPNP_USB_PDPHY=y
CONFIG_MMC=y
CONFIG_MMC_BLOCK_MINORS=32
CONFIG_MMC_TEST=y
CONFIG_MMC_IPC_LOGGING=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_PLTFM=y
CONFIG_MMC_SDHCI_MSM_ICE=y
+4 −3
Original line number Diff line number Diff line
@@ -459,7 +459,8 @@ static int ioctl_do_sanitize(struct mmc_card *card)
{
	int err;

	if (!mmc_can_sanitize(card)) {
	if (!mmc_can_sanitize(card) &&
			(card->host->caps2 & MMC_CAP2_SANITIZE)) {
		pr_warn("%s: %s - SANITIZE is not supported\n",
			mmc_hostname(card->host), __func__);
		err = -EOPNOTSUPP;
@@ -653,13 +654,13 @@ static int mmc_blk_ioctl_cmd(struct mmc_blk_data *md,
	struct request *req;

	idata = mmc_blk_ioctl_copy_from_user(ic_ptr);
	if (IS_ERR(idata))
	if (IS_ERR_OR_NULL(idata))
		return PTR_ERR(idata);
	/* This will be NULL on non-RPMB ioctl():s */
	idata->rpmb = rpmb;

	card = md->queue.card;
	if (IS_ERR(card)) {
	if (IS_ERR_OR_NULL(card)) {
		err = PTR_ERR(card);
		goto cmd_done;
	}
+13 −0
Original line number Diff line number Diff line
@@ -134,6 +134,16 @@ static void mmc_bus_shutdown(struct device *dev)
	struct mmc_host *host = card->host;
	int ret;

	if (!drv) {
		pr_debug("%s: %s: drv is NULL\n", dev_name(dev), __func__);
		return;
	}

	if (!card) {
		pr_debug("%s: %s: card is NULL\n", dev_name(dev), __func__);
		return;
	}

	if (dev->driver && drv->shutdown)
		drv->shutdown(card);

@@ -250,12 +260,15 @@ EXPORT_SYMBOL(mmc_unregister_driver);
static void mmc_release_card(struct device *dev)
{
	struct mmc_card *card = mmc_dev_to_card(dev);
	struct mmc_host *host = card->host;

	sdio_free_common_cis(card);

	kfree(card->info);

	kfree(card);
	if (host)
		host->card = NULL;
}

/*
+13 −12
Original line number Diff line number Diff line
@@ -1277,7 +1277,7 @@ void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq)
	struct mmc_command *cmd;

	while (1) {
		wait_for_completion(&mrq->completion);
		wait_for_completion_io(&mrq->completion);

		cmd = mrq->cmd;

@@ -1544,6 +1544,10 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
{
	unsigned int mult;

	if (!card) {
		WARN_ON(1);
		return;
	}
	/*
	 * SDIO cards only define an upper 1 s limit on access.
	 */
@@ -3262,6 +3266,10 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
	struct mmc_host *host = card->host;
	unsigned int max_discard, max_trim;

	if (!host->max_busy_timeout ||
			(host->caps2 & MMC_CAP2_MAX_DISCARD_SIZE))
		return UINT_MAX;

	/*
	 * Without erase_group_def set, MMC erase timeout depends on clock
	 * frequence which can change.  In that case, the best choice is
@@ -3506,7 +3514,6 @@ void mmc_rescan(struct work_struct *work)
{
	struct mmc_host *host =
		container_of(work, struct mmc_host, detect.work);
	int i;

	if (host->rescan_disable)
		return;
@@ -3561,12 +3568,7 @@ void mmc_rescan(struct work_struct *work)
		goto out;
	}

	for (i = 0; i < ARRAY_SIZE(freqs); i++) {
		if (!mmc_rescan_try_freq(host, max(freqs[i], host->f_min)))
			break;
		if (freqs[i] <= host->f_min)
			break;
	}
	mmc_rescan_try_freq(host, host->f_min);
	host->err_stats[MMC_ERR_CMD_TIMEOUT] = 0;
	mmc_release_host(host);

@@ -3577,17 +3579,16 @@ void mmc_rescan(struct work_struct *work)

void mmc_start_host(struct mmc_host *host)
{
	mmc_claim_host(host);
	host->f_init = max(freqs[0], host->f_min);
	host->rescan_disable = 0;
	host->ios.power_mode = MMC_POWER_UNDEFINED;

	if (!(host->caps2 & MMC_CAP2_NO_PRESCAN_POWERUP)) {
		mmc_claim_host(host);
	if (!(host->caps2 & MMC_CAP2_NO_PRESCAN_POWERUP))
		mmc_power_up(host, host->ocr_avail);
		mmc_release_host(host);
	}

	mmc_gpiod_request_cd_irq(host);
	mmc_release_host(host);
	mmc_register_extcon(host);
	_mmc_detect_change(host, 0, false);
}
+34 −8
Original line number Diff line number Diff line
@@ -986,11 +986,11 @@ static void mmc_set_bus_speed(struct mmc_card *card)
 */
static int mmc_select_bus_width(struct mmc_card *card)
{
	static unsigned int ext_csd_bits[] = {
	static const unsigned int ext_csd_bits[] = {
		EXT_CSD_BUS_WIDTH_8,
		EXT_CSD_BUS_WIDTH_4,
	};
	static unsigned int bus_widths[] = {
	static const unsigned int bus_widths[] = {
		MMC_BUS_WIDTH_8,
		MMC_BUS_WIDTH_4,
	};
@@ -1275,10 +1275,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card)
	int err;
	u8 val;

	/* Reduce frequency to HS */
	max_dtr = card->ext_csd.hs_max_dtr;
	mmc_set_clock(host, max_dtr);

	/* Switch HS400 to HS DDR */
	val = EXT_CSD_TIMING_HS;
	err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING,
@@ -1289,6 +1285,10 @@ int mmc_hs400_to_hs200(struct mmc_card *card)

	mmc_set_timing(host, MMC_TIMING_MMC_DDR52);

	/* Reduce frequency to HS */
	max_dtr = card->ext_csd.hs_max_dtr;
	mmc_set_clock(host, max_dtr);

	err = mmc_switch_status(card);
	if (err)
		goto out_err;
@@ -2252,6 +2252,27 @@ static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type)
	return err;
}

int mmc_send_pon(struct mmc_card *card)
{
	int err = 0;
	struct mmc_host *host = card->host;

	if (!mmc_can_poweroff_notify(card))
		goto out;

	mmc_get_card(card, NULL);
	if (card->pon_type & MMC_LONG_PON)
		err = mmc_poweroff_notify(host->card, EXT_CSD_POWER_OFF_LONG);
	else if (card->pon_type & MMC_SHRT_PON)
		err = mmc_poweroff_notify(host->card, EXT_CSD_POWER_OFF_SHORT);
	if (err)
		pr_warn("%s: error %d sending PON type %u\n",
			mmc_hostname(host), err, card->pon_type);
	mmc_put_card(card, NULL);
out:
	return err;
}

/*
 * Host is being removed. Free up the current card.
 */
@@ -2259,7 +2280,9 @@ static void mmc_remove(struct mmc_host *host)
{
	mmc_exit_clk_scaling(host);
	mmc_remove_card(host->card);
	mmc_claim_host(host);
	host->card = NULL;
	mmc_release_host(host);
}

/*
@@ -2404,6 +2427,7 @@ static int _mmc_resume(struct mmc_host *host)
static int mmc_shutdown(struct mmc_host *host)
{
	int err = 0;
	struct mmc_card *card = host->card;

	/*
	 * In a specific case for poweroff notify, we need to resume the card
@@ -2420,8 +2444,10 @@ static int mmc_shutdown(struct mmc_host *host)
	if (host->caps2 & MMC_CAP2_CLK_SCALE)
		mmc_exit_clk_scaling(host);

	if (!err)
		err = _mmc_suspend(host, false);
	/* send power off notification */
	if (mmc_card_mmc(card))
		mmc_send_pon(card);

	mmc_log_string(host, "done err %d\n", err);
	return err;
}
Loading