Re: [PATCH] mmc: Throttle calls to MMC_SEND_STATUS during mmc_do_erase()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2018/5/18 23:27, Martin Hicks wrote:
On Fri, May 18, 2018 at 08:36:00AM +0800, Shawn Lin wrote:

On 2018/5/18 1:53, Martin Hicks wrote:


This drastically reduces the rate at which the MMC_SEND_STATUS cmd polls
for completion of the MMC Erase operation.  On my embedded ARM platform
the interrupt rates drop from ~45000/s to ~1000/s, which prevents the
system from being very sluggish to respond during Erase operations.


Could you detail the relationship between status polling and why the
interrupt rates drop(probably with what does the interrupt rate mean)?
Which host drivers are you using and is that a single core platform?


Hi Shawn,

Yes, this is a single core NXP I.MX6UL with the sdhci-esdhc-imx driver.

You are not alone playing games in mmc subsystem with a single core
platform. :)

It seems that the loop is just sending MMC_SEND_STATUS commands as fast
as it can, and the host gets an interrupt for every command completion.

For our eMMC each call to mmc_do_erase during an invocation of
`blkdiscard -s /dev/sda` erases 2GB and takes 25-30 seconds to complete.

I now have second thoughts about this change since the same path is
used for discarding smaller blocks, like if you have "discard" enabled
on ext4.  These discard requests can complete very quickly and we wouldn't
want to add latency to these commands.  It looks like the "quick" discards
can complete in as little as 50 loops (~1ms), but that would be dependent
on the speed of the MMC bus, as well as how much work the eMMC drive has
to do.


I have bunch of patches working around various problems in single core
platform for linux-mmc, but never tought of sending upstream as all of
them are things just like what you do now, especially some host drivers
do lots work during softirq with spinlock hold, etc. So my advice is to
keep it out of tree, and you could do various hack if you want.

mh


Signed-off-by: Martin Hicks <mort@xxxxxxxx>
---
  drivers/mmc/core/core.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index db1bf63..5e37276 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2284,8 +2284,14 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from,
  			goto out;
  		}
-	} while (!(cmd.resp[0] & R1_READY_FOR_DATA) ||
-		 (R1_CURRENT_STATE(cmd.resp[0]) == R1_STATE_PRG));
+		if ((cmd.resp[0] & R1_READY_FOR_DATA) &&
+		    R1_CURRENT_STATE(cmd.resp[0]) != R1_STATE_PRG)
+			break;
+
+		/* Throttle the calls to MMC_SEND_STATUS */
+		usleep_range(1000, 2000);
+	} while (1);
+
  out:
  	mmc_retune_release(card->host);
  	return err;





--
Best Regards
Shawn Lin

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux