diff mbox

[RFC,V2,33/46] mmc: mmc_test: Disable Command Queue while mmc_test is used

Message ID 575A9A1E.7010906@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Adrian Hunter June 10, 2016, 10:44 a.m. UTC
Normal read and write commands may not be used while the command queue is
enabled. Disable the Command Queue when mmc_test is probed and re-enable it
when it is removed.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---


V2: Claim / release the host when enabling / disabling CMDQ


 drivers/mmc/card/mmc_test.c | 13 +++++++++++++
 drivers/mmc/core/mmc.c      |  7 +++++++
 include/linux/mmc/card.h    |  1 +
 3 files changed, 21 insertions(+)

Comments

Venu Byravarasu June 10, 2016, 10:59 a.m. UTC | #1
> -----Original Message-----
> From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
> owner@vger.kernel.org] On Behalf Of Adrian Hunter
> Sent: Friday, June 10, 2016 4:15 PM
> To: Ulf Hansson
> Cc: linux-mmc; Alex Lemberg; Mateusz Nowak; Yuliy Izrailov; Jaehoon Chung;
> Dong Aisheng; Das Asutosh; Zhangfei Gao; Sujit Reddy Thumma; Dorfman
> Konstantin; David Griego; Sahitya Tummala; Harjani Ritesh
> Subject: [PATCH RFC V2 33/46] mmc: mmc_test: Disable Command Queue
> while mmc_test is used
> 
> Normal read and write commands may not be used while the command
> queue is enabled.

CQ may not be efficient when single rd/wr commands get issued with variable delays in between.
In such situations, CQ preparation for individual rd/wr cmds would be an unnecessary overhead. 
Hence even when CQ is supported, prefer CQ only when more than 1 data cmds are to be issued to device.

> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> 
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Adrian Hunter June 10, 2016, 11:36 a.m. UTC | #2
On 10/06/16 13:59, Venu Byravarasu wrote:
>> -----Original Message-----
>> From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
>> owner@vger.kernel.org] On Behalf Of Adrian Hunter
>> Sent: Friday, June 10, 2016 4:15 PM
>> To: Ulf Hansson
>> Cc: linux-mmc; Alex Lemberg; Mateusz Nowak; Yuliy Izrailov; Jaehoon Chung;
>> Dong Aisheng; Das Asutosh; Zhangfei Gao; Sujit Reddy Thumma; Dorfman
>> Konstantin; David Griego; Sahitya Tummala; Harjani Ritesh
>> Subject: [PATCH RFC V2 33/46] mmc: mmc_test: Disable Command Queue
>> while mmc_test is used
>>
>> Normal read and write commands may not be used while the command
>> queue is enabled.
> 
> CQ may not be efficient when single rd/wr commands get issued with variable delays in between.
> In such situations, CQ preparation for individual rd/wr cmds would be an unnecessary overhead. 
> Hence even when CQ is supported, prefer CQ only when more than 1 data cmds are to be issued to device.

So you are suggesting toggling CQ on/off depending on whether there is more
than 1 data request?

Does that apply also to using hardware CQ i.e. a v5.1 host controller?

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Venu Byravarasu June 10, 2016, 12:03 p.m. UTC | #3
> -----Original Message-----
> From: Adrian Hunter [mailto:adrian.hunter@intel.com]
> Sent: Friday, June 10, 2016 5:07 PM
> To: Venu Byravarasu; Ulf Hansson
> Cc: linux-mmc; Alex Lemberg; Mateusz Nowak; Yuliy Izrailov; Jaehoon Chung;
> Dong Aisheng; Das Asutosh; Zhangfei Gao; Dorfman Konstantin; David
> Griego; Sahitya Tummala; Harjani Ritesh
> Subject: Re: [PATCH RFC V2 33/46] mmc: mmc_test: Disable Command
> Queue while mmc_test is used
> 
> On 10/06/16 13:59, Venu Byravarasu wrote:
> >> -----Original Message-----
> >> From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc-
> >> owner@vger.kernel.org] On Behalf Of Adrian Hunter
> >> Sent: Friday, June 10, 2016 4:15 PM
> >> To: Ulf Hansson
> >> Cc: linux-mmc; Alex Lemberg; Mateusz Nowak; Yuliy Izrailov; Jaehoon
> >> Chung; Dong Aisheng; Das Asutosh; Zhangfei Gao; Sujit Reddy Thumma;
> >> Dorfman Konstantin; David Griego; Sahitya Tummala; Harjani Ritesh
> >> Subject: [PATCH RFC V2 33/46] mmc: mmc_test: Disable Command Queue
> >> while mmc_test is used
> >>
> >> Normal read and write commands may not be used while the command
> >> queue is enabled.
> >
> > CQ may not be efficient when single rd/wr commands get issued with
> variable delays in between.
> > In such situations, CQ preparation for individual rd/wr cmds would be an
> unnecessary overhead.
> > Hence even when CQ is supported, prefer CQ only when more than 1 data
> cmds are to be issued to device.
> 
> So you are suggesting toggling CQ on/off depending on whether there is
> more than 1 data request?

I didn't go thro' your implementation part for CQ yet & my comment was generic.

If preparation of CQ is taking N more operations than non-CQ command, then by not opting for CQ, you might save those N operations.
-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
index 5a8dc5a76e0d..7dee9e5a8cfb 100644
--- a/drivers/mmc/card/mmc_test.c
+++ b/drivers/mmc/card/mmc_test.c
@@ -3240,6 +3240,14 @@  static int mmc_test_probe(struct mmc_card *card)
 	if (ret)
 		return ret;
 
+	if (card->ext_csd.cmdq_en) {
+		mmc_claim_host(card->host);
+		ret = mmc_cmdq_disable(card);
+		mmc_release_host(card->host);
+		if (ret)
+			return ret;
+	}
+
 	dev_info(&card->dev, "Card claimed for testing.\n");
 
 	return 0;
@@ -3247,6 +3255,11 @@  static int mmc_test_probe(struct mmc_card *card)
 
 static void mmc_test_remove(struct mmc_card *card)
 {
+	if (card->reenable_cmdq) {
+		mmc_claim_host(card->host);
+		mmc_cmdq_enable(card);
+		mmc_release_host(card->host);
+	}
 	mmc_test_free_result(card);
 	mmc_test_free_dbgfs_file(card);
 }
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index eb1781b066f3..2e54daa237f6 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1736,6 +1736,13 @@  static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	}
 
 	/*
+	 * In some cases (e.g. RPMB or mmc_test), the Command Queue must be
+	 * disabled for a time, so a flag is needed to indicate to re-enable the
+	 * Command Queue.
+	 */
+	card->reenable_cmdq = card->ext_csd.cmdq_en;
+
+	/*
 	 * The mandatory minimum values are defined for packed command.
 	 * read: 5, write: 3
 	 */
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 1c380271038f..2abcedc1e9e9 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -284,6 +284,7 @@  struct mmc_card {
 #define MMC_QUIRK_BROKEN_IRQ_POLLING	(1<<11)	/* Polling SDIO_CCCR_INTx could create a fake interrupt */
 #define MMC_QUIRK_TRIM_BROKEN	(1<<12)		/* Skip trim */
 
+	bool			reenable_cmdq;	/* Re-enable Command Queue */
 
 	unsigned int		erase_size;	/* erase size in sectors */
  	unsigned int		erase_shift;	/* if erase unit is power 2 */