linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: cavium: Ensure proper mapping between request and interrupt
@ 2021-11-15 16:02 Wojciech Bartczak
  2021-11-22 18:12 ` kernel test robot
  2021-11-23 16:14 ` Ulf Hansson
  0 siblings, 2 replies; 3+ messages in thread
From: Wojciech Bartczak @ 2021-11-15 16:02 UTC (permalink / raw)
  To: linux-mmc; +Cc: rric, ulf.hansson, beanhuo, tanxiaofei, wbartczak, linux-kernel

The MMC block in octeontx2 uses architecture, where data lines are
shared between up to three supported cards. To keep the track of the
request hardware reports bus_id for the command complete interrupt.
At the same time the driver keeps information about the request on the
fly. This change combines these information to ensure proper mapping
between the request and the response.

Signed-off-by: Wojciech Bartczak <wbartczak@marvell.com>
---
 drivers/mmc/host/cavium.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/cavium.c b/drivers/mmc/host/cavium.c
index 95a41983c6c0..24ea03f5a7c0 100644
--- a/drivers/mmc/host/cavium.c
+++ b/drivers/mmc/host/cavium.c
@@ -438,6 +438,8 @@ irqreturn_t cvm_mmc_interrupt(int irq, void *dev_id)
 	struct mmc_request *req;
 	u64 emm_int, rsp_sts;
 	bool host_done;
+	struct cvm_mmc_slot *slot;
+	int bus_id;
 
 	if (host->need_irq_handler_lock)
 		spin_lock(&host->irq_handler_lock);
@@ -455,7 +457,19 @@ irqreturn_t cvm_mmc_interrupt(int irq, void *dev_id)
 	if (!req)
 		goto out;
 
+	slot = mmc_priv(req->host);
+
+	/* Get response */
 	rsp_sts = readq(host->base + MIO_EMM_RSP_STS(host));
+	/* Map request to cvm_mmc_slot */
+	bus_id = FIELD_GET(MIO_EMM_RSP_STS_BUS_ID, rsp_sts);
+	if (bus_id != slot->bus_id) {
+		dev_err(mmc_classdev(slot->mmc),
+			"Remapping, request for slot %d, interrupt for %d!\n",
+			slot->bus_id, bus_id);
+		slot = host->slot[bus_id];
+	}
+
 	/*
 	 * dma_val set means DMA is still in progress. Don't touch
 	 * the request and wait for the interrupt indicating that
@@ -493,8 +507,9 @@ irqreturn_t cvm_mmc_interrupt(int irq, void *dev_id)
 	    (rsp_sts & MIO_EMM_RSP_STS_DMA_PEND))
 		cleanup_dma(host, rsp_sts);
 
+	if (mrq->done)
+		mrq->done(mrq);
 	host->current_req = NULL;
-	req->done(req);
 
 no_req_done:
 	if (host->dmar_fixup_done)
@@ -669,6 +684,7 @@ static void cvm_mmc_dma_request(struct mmc_host *mmc,
 		set_wdog(slot, data->timeout_ns);
 
 	WARN_ON(host->current_req);
+	mrq->host = mmc;
 	host->current_req = mrq;
 
 	emm_dma = prepare_ext_dma(mmc, mrq);
@@ -776,6 +792,7 @@ static void cvm_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
 	mods = cvm_mmc_get_cr_mods(cmd);
 
 	WARN_ON(host->current_req);
+	mrq->host = mmc;
 	host->current_req = mrq;
 
 	if (cmd->data) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-23 16:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 16:02 [PATCH] mmc: cavium: Ensure proper mapping between request and interrupt Wojciech Bartczak
2021-11-22 18:12 ` kernel test robot
2021-11-23 16:14 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).