From: Bhaskara Budiredla <bbudiredla@marvell.com>
To: <ulf.hansson@linaro.org>, <keescook@chromium.org>,
<ccross@android.com>, <tony.luck@intel.com>,
<sgoutham@marvell.com>
Cc: <linux-mmc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
outgoing2/0000-cover-letter.patch@mx0a-0016f401.pphosted.com,
Bhaskara Budiredla <bbudiredla@marvell.com>
Subject: [PATCH v2 2/2] mmc: cavium: Add MMC polling method to support kmsg panic/oops write
Date: Mon, 23 Nov 2020 16:49:25 +0530 [thread overview]
Message-ID: <20201123111925.28999-2-bbudiredla@marvell.com> (raw)
In-Reply-To: <20201123111925.28999-1-bbudiredla@marvell.com>
To enable the writing of panic and oops logs, a cavium specific MMC
polling method is defined and thereby ensure the functioning of mmcpstore.
Signed-off-by: Bhaskara Budiredla <bbudiredla@marvell.com>
---
drivers/mmc/host/cavium-thunderx.c | 10 +++++
drivers/mmc/host/cavium.c | 67 ++++++++++++++++++++++++++++++
drivers/mmc/host/cavium.h | 3 ++
3 files changed, 80 insertions(+)
diff --git a/drivers/mmc/host/cavium-thunderx.c b/drivers/mmc/host/cavium-thunderx.c
index 76013bbbcff3..83f25dd6820a 100644
--- a/drivers/mmc/host/cavium-thunderx.c
+++ b/drivers/mmc/host/cavium-thunderx.c
@@ -19,12 +19,22 @@
static void thunder_mmc_acquire_bus(struct cvm_mmc_host *host)
{
+#if IS_ENABLED(CONFIG_MMC_PSTORE)
+ if (!host->pstore)
+ down(&host->mmc_serializer);
+#else
down(&host->mmc_serializer);
+#endif
}
static void thunder_mmc_release_bus(struct cvm_mmc_host *host)
{
+#if IS_ENABLED(CONFIG_MMC_PSTORE)
+ if (!host->pstore)
+ up(&host->mmc_serializer);
+#else
up(&host->mmc_serializer);
+#endif
}
static void thunder_mmc_int_enable(struct cvm_mmc_host *host, u64 val)
diff --git a/drivers/mmc/host/cavium.c b/drivers/mmc/host/cavium.c
index c5da3aaee334..708bec9d0345 100644
--- a/drivers/mmc/host/cavium.c
+++ b/drivers/mmc/host/cavium.c
@@ -510,6 +510,66 @@ irqreturn_t cvm_mmc_interrupt(int irq, void *dev_id)
return IRQ_RETVAL(emm_int != 0);
}
+#if IS_ENABLED(CONFIG_MMC_PSTORE)
+static int cvm_req_completion_poll(struct mmc_host *host, unsigned long msecs)
+{
+ struct cvm_mmc_slot *slot = mmc_priv(host);
+ struct cvm_mmc_host *cvm_host = slot->host;
+ u64 emm_int;
+
+ while (msecs) {
+ emm_int = readq(cvm_host->base + MIO_EMM_INT(cvm_host));
+
+ if (emm_int & MIO_EMM_INT_DMA_DONE)
+ return 0;
+ else if (emm_int & MIO_EMM_INT_DMA_ERR)
+ return -EIO;
+ mdelay(1);
+ msecs--;
+ }
+
+ return -ETIMEDOUT;
+}
+
+static void cvm_req_cleanup_pending(struct mmc_host *host)
+{
+ struct cvm_mmc_slot *slot = mmc_priv(host);
+ struct cvm_mmc_host *cvm_host = slot->host;
+ u64 fifo_cfg;
+ u64 dma_cfg;
+ u64 emm_int;
+
+ cvm_host->pstore = 1;
+
+ /* Clear pending DMA FIFO queue */
+ fifo_cfg = readq(cvm_host->dma_base + MIO_EMM_DMA_FIFO_CFG(cvm_host));
+ if (FIELD_GET(MIO_EMM_DMA_FIFO_CFG_COUNT, fifo_cfg))
+ writeq(MIO_EMM_DMA_FIFO_CFG_CLR,
+ cvm_host->dma_base + MIO_EMM_DMA_FIFO_CFG(cvm_host));
+
+ /* Clear ongoing DMA, if there is any */
+ dma_cfg = readq(cvm_host->dma_base + MIO_EMM_DMA_CFG(cvm_host));
+ if (dma_cfg & MIO_EMM_DMA_CFG_EN) {
+ dma_cfg |= MIO_EMM_DMA_CFG_CLR;
+ writeq(dma_cfg, cvm_host->dma_base +
+ MIO_EMM_DMA_CFG(cvm_host));
+ do {
+ dma_cfg = readq(cvm_host->dma_base +
+ MIO_EMM_DMA_CFG(cvm_host));
+ } while (dma_cfg & MIO_EMM_DMA_CFG_EN);
+ }
+
+ /* Clear pending DMA interrupts */
+ emm_int = readq(cvm_host->base + MIO_EMM_INT(cvm_host));
+ if (emm_int)
+ writeq(emm_int, cvm_host->base + MIO_EMM_INT(cvm_host));
+
+ /* Clear prepared and yet to be fired DMA requests */
+ cvm_host->current_req = NULL;
+ cvm_host->dma_active = false;
+}
+#endif
+
/*
* Program DMA_CFG and if needed DMA_ADR.
* Returns 0 on error, DMA address otherwise.
@@ -901,6 +961,10 @@ static const struct mmc_host_ops cvm_mmc_ops = {
.set_ios = cvm_mmc_set_ios,
.get_ro = mmc_gpio_get_ro,
.get_cd = mmc_gpio_get_cd,
+#if IS_ENABLED(CONFIG_MMC_PSTORE)
+ .req_cleanup_pending = cvm_req_cleanup_pending,
+ .req_completion_poll = cvm_req_completion_poll,
+#endif
};
static void cvm_mmc_set_clock(struct cvm_mmc_slot *slot, unsigned int clock)
@@ -1058,6 +1122,9 @@ int cvm_mmc_of_slot_probe(struct device *dev, struct cvm_mmc_host *host)
slot->bus_id = id;
slot->cached_rca = 1;
+#if IS_ENABLED(CONFIG_MMC_PSTORE)
+ host->pstore = 0;
+#endif
host->acquire_bus(host);
host->slot[id] = slot;
cvm_mmc_switch_to(slot);
diff --git a/drivers/mmc/host/cavium.h b/drivers/mmc/host/cavium.h
index f3eea5eaa678..248a5a6e3522 100644
--- a/drivers/mmc/host/cavium.h
+++ b/drivers/mmc/host/cavium.h
@@ -75,6 +75,9 @@ struct cvm_mmc_host {
spinlock_t irq_handler_lock;
struct semaphore mmc_serializer;
+#if IS_ENABLED(CONFIG_MMC_PSTORE)
+ bool pstore;
+#endif
struct gpio_desc *global_pwr_gpiod;
atomic_t shared_power_users;
--
2.17.1
next prev parent reply other threads:[~2020-11-23 11:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-23 11:19 [PATCH v2 1/2] mmc: Support kmsg dumper based on pstore/blk Bhaskara Budiredla
2020-11-23 11:19 ` Bhaskara Budiredla [this message]
2020-11-24 11:37 ` Christoph Hellwig
2020-11-24 14:22 ` Ulf Hansson
2020-12-01 20:28 ` Kees Cook
2020-12-01 20:26 ` Kees Cook
2020-12-02 6:36 ` [EXT] " Bhaskara Budiredla
2020-12-02 19:32 ` Kees Cook
2020-12-03 5:41 ` Bhaskara Budiredla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201123111925.28999-2-bbudiredla@marvell.com \
--to=bbudiredla@marvell.com \
--cc=ccross@android.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=outgoing2/0000-cover-letter.patch@mx0a-0016f401.pphosted.com \
--cc=sgoutham@marvell.com \
--cc=tony.luck@intel.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).