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

Commit efe302c7 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mmc: core: cmdq helper for reset and claim host context"

parents b715bdef 4457076d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3111,7 +3111,7 @@ void mmc_blk_cmdq_complete_rq(struct request *rq)
		BUG_ON(!test_and_clear_bit(cmdq_req->tag,
			 &ctx_info->data_active_reqs));

	mmc_cmdq_post_req(host, mrq, err);
	mmc_cmdq_post_req(host, cmdq_req->tag, err);
	if (err) {
		pr_err("%s: %s: txfr error: %d\n", mmc_hostname(mrq->host),
		       __func__, err);
+25 −3
Original line number Diff line number Diff line
@@ -1442,13 +1442,13 @@ EXPORT_SYMBOL(mmc_cmdq_discard_queue);
/**
 *	mmc_cmdq_post_req - post process of a completed request
 *	@host: host instance
 *	@mrq: the request to be processed
 *	@tag: the request tag.
 *	@err: non-zero is error, success otherwise
 */
void mmc_cmdq_post_req(struct mmc_host *host, struct mmc_request *mrq, int err)
void mmc_cmdq_post_req(struct mmc_host *host, int tag, int err)
{
	if (likely(host->cmdq_ops->post_req))
		host->cmdq_ops->post_req(host, mrq, err);
		host->cmdq_ops->post_req(host, tag, err);
}
EXPORT_SYMBOL(mmc_cmdq_post_req);

@@ -3530,6 +3530,7 @@ EXPORT_SYMBOL(mmc_can_reset);
static int mmc_do_hw_reset(struct mmc_host *host, int check)
{
	struct mmc_card *card = host->card;
	int ret;

	if (!host->bus_ops->power_restore)
		return -EOPNOTSUPP;
@@ -3576,9 +3577,28 @@ static int mmc_do_hw_reset(struct mmc_host *host, int check)
	mmc_set_ios(host);

	mmc_host_clk_release(host);
	mmc_claim_host(host);
	ret = host->bus_ops->power_restore(host);
	mmc_release_host(host);
	return ret;
}

/*
 * mmc_cmdq_hw_reset: Helper API for doing
 * reset_all of host and reinitializing card.
 * This must be called with mmc_claim_host
 * acquired by the caller.
 */
int mmc_cmdq_hw_reset(struct mmc_host *host)
{
	if (!host->bus_ops->power_restore)
		return -EOPNOTSUPP;

	mmc_power_cycle(host, host->ocr_avail);
	mmc_select_voltage(host, host->card->ocr);
	return host->bus_ops->power_restore(host);
}
EXPORT_SYMBOL(mmc_cmdq_hw_reset);

int mmc_hw_reset(struct mmc_host *host)
{
@@ -3856,7 +3876,9 @@ int mmc_power_restore_host(struct mmc_host *host)
	}

	mmc_power_up(host, host->card->ocr);
	mmc_claim_host(host);
	ret = host->bus_ops->power_restore(host);
	mmc_release_host(host);

	mmc_bus_put(host);

+4 −2
Original line number Diff line number Diff line
@@ -2625,6 +2625,10 @@ static int mmc_runtime_resume(struct mmc_host *host)
	return err;
}

/*
 * mmc_power_restore: Must be called with claim_host
 * acquired by the caller.
 */
static int mmc_power_restore(struct mmc_host *host)
{
	int ret;
@@ -2638,9 +2642,7 @@ static int mmc_power_restore(struct mmc_host *host)
		return ret;
	}

	mmc_claim_host(host);
	ret = mmc_init_card(host, host->card->ocr, host->card);
	mmc_release_host(host);

	ret = mmc_resume_clk_scaling(host);
	if (ret)
+13 −5
Original line number Diff line number Diff line
@@ -992,15 +992,23 @@ static int cmdq_halt(struct mmc_host *mmc, bool halt)
	return ret;
}

static void cmdq_post_req(struct mmc_host *host, struct mmc_request *mrq,
			  int err)
static void cmdq_post_req(struct mmc_host *mmc, int tag, int err)
{
	struct mmc_data *data = mrq->data;
	struct sdhci_host *sdhci_host = mmc_priv(host);
	struct cmdq_host *cq_host;
	struct mmc_request *mrq;
	struct mmc_data *data;
	struct sdhci_host *sdhci_host = mmc_priv(mmc);

	if (WARN_ON(!mmc))
		return;

	cq_host = (struct cmdq_host *)mmc_cmdq_private(mmc);
	mrq = get_req_by_tag(cq_host, tag);
	data = mrq->data;

	if (data) {
		data->error = err;
		dma_unmap_sg(mmc_dev(host), data->sg, data->sg_len,
		dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len,
			     (data->flags & MMC_DATA_READ) ?
			     DMA_FROM_DEVICE : DMA_TO_DEVICE);
		if (err)
+2 −2
Original line number Diff line number Diff line
@@ -134,8 +134,7 @@ struct mmc_cmdq_req;
extern int mmc_cmdq_discard_queue(struct mmc_host *host, u32 tasks);
extern int mmc_cmdq_halt(struct mmc_host *host, bool enable);
extern int mmc_cmdq_halt_on_empty_queue(struct mmc_host *host);
extern void mmc_cmdq_post_req(struct mmc_host *host, struct mmc_request *mrq,
			      int err);
extern void mmc_cmdq_post_req(struct mmc_host *host, int tag, int err);
extern int mmc_cmdq_start_req(struct mmc_host *host,
			      struct mmc_cmdq_req *cmdq_req);
extern int mmc_cmdq_prepare_flush(struct mmc_command *cmd);
@@ -191,6 +190,7 @@ extern int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen);
extern int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount,
			      bool is_rel_write);
extern int mmc_hw_reset(struct mmc_host *host);
extern int mmc_cmdq_hw_reset(struct mmc_host *host);
extern int mmc_hw_reset_check(struct mmc_host *host);
extern int mmc_can_reset(struct mmc_card *card);

Loading