Skip to contentSkip to conversation

Minor MMC fixes

PATCH In review Adrian Hunter 3 participants 7 messages Jun 23, 2011 – Jun 25, 2011 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

cover Minor MMC fixes

Hi

Here are 4 minor fixes:

Adrian Hunter (4):
mmc: block: switch card to User Data Area when removing the block driver
mmc: core: make erase timeout calculation allow for gated clock
mmc: queue: append partition subname to queue thread name
mmc: queue: bring discard_granularity/alignment into line with SCSI definitions

 drivers/mmc/card/block.c |    5 ++++-
 drivers/mmc/card/queue.c |   15 ++++++---------
 drivers/mmc/card/queue.h |    3 ++-
 drivers/mmc/core/core.c  |    2 +-
 4 files changed, 13 insertions(+), 12 deletions(-)

Regards
Adrian Hunter

#1 lore raw

PATCH 1/4 mmc: block: switch card to User Data Area when removing the block driver

The MMC block driver and other drivers (e.g. mmc-test) will expect the card to be switched to the User Data Area eMMC partition when they start. Hence the MMC block driver should ensure it is that way when it is removed.

Cc Andrei Warkentin <[email protected]>
---
 drivers/mmc/card/block.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/mmc/card/block.c +3 -0
index e5d1c8a..d36b7ea 100644
@@ -1440,6 +1440,9 @@ static void mmc_blk_remove(struct mmc_card *card)
 	struct mmc_blk_data *md = mmc_get_drvdata(card);
 
 	mmc_blk_remove_parts(card, md);
+	mmc_claim_host(card->host);
+	mmc_blk_part_switch(card, md);
+	mmc_release_host(card->host);
 	mmc_blk_remove_req(md);
 	mmc_set_drvdata(card, NULL);
 }
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 2/4 mmc: core: make erase timeout calculation allow for gated clock

In reply to Adrian Hunter

The erase timeout calculation may depend on clock rate which is zero if the clock is gated, so use mmc_host_clk_rate() which allows for that case.

---
 drivers/mmc/core/core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mmc/core/core.c +1 -1
index 68091dd..7843efe 100644
@@ -1245,7 +1245,7 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
 		 */
 		timeout_clks <<= 1;
 		timeout_us += (timeout_clks * 1000) /
-			      (card->host->ios.clock / 1000);
+			      (mmc_host_clk_rate(card->host) / 1000);
 
 		erase_timeout = timeout_us / 1000;
 
Signature · 1 line
1.7.4.4
#3 lore raw

PATCH 3/4 mmc: queue: append partition subname to queue thread name

In reply to Adrian Hunter

For example, an eMMC with 2 boot partitions will have 3 threads. The names change from:

   40 ?        00:00:00 mmcqd/0
   41 ?        00:00:00 mmcqd/0
   42 ?        00:00:00 mmcqd/0

to:

   40 ?        00:00:00 mmcqd/0
   41 ?        00:00:00 mmcqd/0boot0
   42 ?        00:00:00 mmcqd/0boot1
Cc Andrei Warkentin <[email protected]>
---
 drivers/mmc/card/block.c |    2 +-
 drivers/mmc/card/queue.c |    8 +++++---
 drivers/mmc/card/queue.h |    3 ++-
 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/mmc/card/block.c +1 -1
index d36b7ea..bee2106 100644
@@ -1167,7 +1167,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
 	INIT_LIST_HEAD(&md->part);
 	md->usage = 1;
 
-	ret = mmc_init_queue(&md->queue, card, &md->lock);
+	ret = mmc_init_queue(&md->queue, card, &md->lock, subname);
 	if (ret)
 		goto err_putdisk;
 
drivers/mmc/card/queue.c +5 -3
index c07322c..3e2db1c 100644
@@ -106,10 +106,12 @@ static void mmc_request(struct request_queue *q)
  * @mq: mmc queue
  * @card: mmc card to attach this queue
  * @lock: queue lock
+ * @subname: partition subname
  *
  * Initialise a MMC card request queue.
  */
-int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock)
+int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
+		   spinlock_t *lock, const char *subname)
 {
 	struct mmc_host *host = card->host;
 	u64 limit = BLK_BOUNCE_HIGH;
@@ -209,8 +211,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
 
 	sema_init(&mq->thread_sem, 1);
 
-	mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd/%d",
-		host->index);
+	mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd/%d%s",
+		host->index, subname ? subname : "");
 
 	if (IS_ERR(mq->thread)) {
 		ret = PTR_ERR(mq->thread);
drivers/mmc/card/queue.h +2 -1
index 64e66e0..6223ef8 100644
@@ -19,7 +19,8 @@ struct mmc_queue {
 	unsigned int		bounce_sg_len;
 };
 
-extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *);
+extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
+			  const char *);
 extern void mmc_cleanup_queue(struct mmc_queue *);
 extern void mmc_queue_suspend(struct mmc_queue *);
 extern void mmc_queue_resume(struct mmc_queue *);
Signature · 1 line
1.7.4.4
#4 lore raw

Re: [PATCH 3/4] mmc: queue: append partition subname to queue thread name

Hi Adrian..

I also found this problem..
So i confused the same mmcdq name.

Thanks for fixed the mmcqd name.

Regards,
Jaehoon Chung

Quoted 77 lines · Adrian Hunter

For example, an eMMC with 2 boot partitions will have 3 threads. The names change from:

   40 ?        00:00:00 mmcqd/0
   41 ?        00:00:00 mmcqd/0
   42 ?        00:00:00 mmcqd/0

to:

   40 ?        00:00:00 mmcqd/0
   41 ?        00:00:00 mmcqd/0boot0
   42 ?        00:00:00 mmcqd/0boot1
Cc Andrei Warkentin <[email protected]>
---
 drivers/mmc/card/block.c |    2 +-
 drivers/mmc/card/queue.c |    8 +++++---
 drivers/mmc/card/queue.h |    3 ++-
 3 files changed, 8 insertions(+), 5 deletions(-)
drivers/mmc/card/block.c +1 -1
index d36b7ea..bee2106 100644
@@ -1167,7 +1167,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
 	INIT_LIST_HEAD(&md->part);
 	md->usage = 1;
 
-	ret = mmc_init_queue(&md->queue, card, &md->lock);
+	ret = mmc_init_queue(&md->queue, card, &md->lock, subname);
 	if (ret)
 		goto err_putdisk;
 
drivers/mmc/card/queue.c +5 -3
index c07322c..3e2db1c 100644
@@ -106,10 +106,12 @@ static void mmc_request(struct request_queue *q)
  * @mq: mmc queue
  * @card: mmc card to attach this queue
  * @lock: queue lock
+ * @subname: partition subname
  *
  * Initialise a MMC card request queue.
  */
-int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock)
+int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
+		   spinlock_t *lock, const char *subname)
 {
 	struct mmc_host *host = card->host;
 	u64 limit = BLK_BOUNCE_HIGH;
@@ -209,8 +211,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock
 
 	sema_init(&mq->thread_sem, 1);
 
-	mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd/%d",
-		host->index);
+	mq->thread = kthread_run(mmc_queue_thread, mq, "mmcqd/%d%s",
+		host->index, subname ? subname : "");
 
 	if (IS_ERR(mq->thread)) {
 		ret = PTR_ERR(mq->thread);
drivers/mmc/card/queue.h +2 -1
index 64e66e0..6223ef8 100644
@@ -19,7 +19,8 @@ struct mmc_queue {
 	unsigned int		bounce_sg_len;
 };
 
-extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *);
+extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
+			  const char *);
 extern void mmc_cleanup_queue(struct mmc_queue *);
 extern void mmc_queue_suspend(struct mmc_queue *);
 extern void mmc_queue_resume(struct mmc_queue *);
#5 lore raw

PATCH 4/4 mmc: queue: bring discard_granularity/alignment into line with SCSI definitions

In reply to Adrian Hunter

SCSI defines discard alignment as the offset to the first optimal discard. In the case of SD/MMC, that is always zero which is the default.

SCSI defines discard granularity as a hint of a optimal discard size. That is much better expressed by the MMC "preferred erase size" (pref_erase) field.

---
 drivers/mmc/card/queue.c |    7 +------
 1 files changed, 1 insertions(+), 6 deletions(-)
drivers/mmc/card/queue.c +1 -6
index 3e2db1c..6413afa 100644
@@ -135,12 +135,7 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,
 		mq->queue->limits.max_discard_sectors = UINT_MAX;
 		if (card->erased_byte == 0)
 			mq->queue->limits.discard_zeroes_data = 1;
-		if (!mmc_can_trim(card) && is_power_of_2(card->erase_size)) {
-			mq->queue->limits.discard_granularity =
-							card->erase_size << 9;
-			mq->queue->limits.discard_alignment =
-							card->erase_size << 9;
-		}
+		mq->queue->limits.discard_granularity = card->pref_erase << 9;
 		if (mmc_can_secure_erase_trim(card))
 			queue_flag_set_unlocked(QUEUE_FLAG_SECDISCARD,
 						mq->queue);
Signature · 1 line
1.7.4.4
#6 lore raw
In reply to Adrian Hunter

Hi Adrian,

Quoted 7 lines · Adrian Hunter

Here are 4 minor fixes:

Adrian Hunter (4):
mmc: block: switch card to User Data Area when removing the block driver
mmc: core: make erase timeout calculation allow for gated clock
mmc: queue: append partition subname to queue thread name
mmc: queue: bring discard_granularity/alignment into line with SCSI definitions

Thanks, will push these for 3.0.

- Chris.

Signature · 2 lines
Chris Ball   <[email protected]>   <http://printf.net/>
One Laptop Per Child