linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: core: Fix off-by-one error in mmc_do_calc_max_discard()
@ 2015-06-01  9:20 David Jander
  2015-06-01 10:36 ` Adrian Hunter
  0 siblings, 1 reply; 9+ messages in thread
From: David Jander @ 2015-06-01  9:20 UTC (permalink / raw)
  To: Pierre Ossman, Ulf Hansson, Sascha Hauer
  Cc: Johan Rudholm, Adrian Hunter, Javier Martinez Canillas, linux-mmc,
	linux-kernel, David Jander

qty is the maximum number of discard that _do_ fit in the timeout, not
the first amount that does _not_ fit anymore.
This seemingly harmless error has a very severe performance impact when
the timeout value is enough for only 1 erase group.

Signed-off-by: David Jander <david@protonic.nl>
---
 drivers/mmc/core/core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 92e7671..1f9573b 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2234,16 +2234,13 @@ static unsigned int mmc_do_calc_max_discard(struct mmc_card *card,
 	if (!qty)
 		return 0;
 
-	if (qty == 1)
-		return 1;
-
 	/* Convert qty to sectors */
 	if (card->erase_shift)
-		max_discard = --qty << card->erase_shift;
+		max_discard = qty << card->erase_shift;
 	else if (mmc_card_sd(card))
 		max_discard = qty;
 	else
-		max_discard = --qty * card->erase_size;
+		max_discard = qty * card->erase_size;
 
 	return max_discard;
 }
-- 
2.1.4


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

end of thread, other threads:[~2015-06-04  8:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-01  9:20 [PATCH] mmc: core: Fix off-by-one error in mmc_do_calc_max_discard() David Jander
2015-06-01 10:36 ` Adrian Hunter
2015-06-01 11:32   ` David Jander
2015-06-01 11:50     ` Adrian Hunter
2015-06-01 12:30       ` David Jander
2015-06-01 12:38         ` Adrian Hunter
2015-06-01 13:32           ` David Jander
2015-06-04  8:15             ` Ulf Hansson
2015-06-04  8:24               ` David Jander

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).