From: Baolin Wang <baolin.wang@linaro.org>
To: Shawn Lin <shawn.lin@rock-chips.com>
Cc: "Ulf Hansson" <ulf.hansson@linaro.org>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Russell King" <rmk+kernel@arm.linux.org.uk>,
"Douglas Anderson" <dianders@chromium.org>,
"Heiko Stübner" <heiko@sntech.de>,
"David Jander" <david@protonic.nl>,
"Hans de Goede" <hdegoede@redhat.com>,
linux-mmc <linux-mmc@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Mark Brown" <broonie@kernel.org>,
"Linus Walleij" <linus.walleij@linaro.org>
Subject: Re: [PATCH v3] mmc: core: Optimize the mmc erase size alignment
Date: Mon, 5 Sep 2016 16:17:19 +0800 [thread overview]
Message-ID: <CAMz4kuLXVS9z2oUT2Sn-+hNJkaa0LMJZHCTCYscBCLZNUgYSPA@mail.gmail.com> (raw)
In-Reply-To: <363fc241-8220-2706-778c-706aec076d49@rock-chips.com>
Hi Shawn,
On 2 September 2016 at 16:34, Shawn Lin <shawn.lin@rock-chips.com> wrote:
> Hi Baolin,
>
> On 2016/8/31 17:32, Baolin Wang wrote:
>>
>> Before issuing mmc_erase() function, users always have checked if it can
>> erase with mmc_can_erase/trim/discard() function, thus remove the
>> redundant
>> erase checking in mmc_erase() function.
>>
>> This patch also optimizes the erase start/end sector alignment with
>
>
> It implies you could split this patch into two for dealing with diff
> things. :) Otherwise, you could add my test tag,
Yes, I will split it into two separate patches and thanks for your testing.
>
> Tested-by: Shawn Lin <shawn.lin@rock-chips.com>
>
>
>> round_up()/round_down() function, when erase command is MMC_ERASE_ARG.
>>
>> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
>> ---
>> Changes since v2:
>> - Add nr checking and other optimization in mmc_erase() function.
>>
>> Changes since v1:
>> - Add the alignment if card->erase_size is not power of 2.
>> ---
>> drivers/mmc/core/core.c | 82
>> ++++++++++++++++++++++++++++++-----------------
>> 1 file changed, 53 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>> index e55cde6..52156d4 100644
>> --- a/drivers/mmc/core/core.c
>> +++ b/drivers/mmc/core/core.c
>> @@ -2202,6 +2202,51 @@ out:
>> return err;
>> }
>>
>> +static unsigned int mmc_align_erase_size(struct mmc_card *card,
>> + unsigned int *from,
>> + unsigned int *to,
>> + unsigned int nr)
>> +{
>> + unsigned int from_new = *from, nr_new = nr, rem;
>> +
>> + if (is_power_of_2(card->erase_size)) {
>> + unsigned int temp = from_new;
>> +
>> + from_new = round_up(temp, card->erase_size);
>> + rem = from_new - temp;
>> +
>> + if (nr_new > rem)
>> + nr_new -= rem;
>> + else
>> + return 0;
>> +
>> + nr_new = round_down(nr_new, card->erase_size);
>> + } else {
>> + rem = from_new % card->erase_size;
>> + if (rem) {
>> + rem = card->erase_size - rem;
>> + from_new += rem;
>> + if (nr_new > rem)
>> + nr_new -= rem;
>> + else
>> + return 0;
>> + }
>> +
>> + rem = nr_new % card->erase_size;
>> + if (rem)
>> + nr_new -= rem;
>> + }
>> +
>> + if (nr_new == 0)
>> + return 0;
>> +
>> + /* 'from' and 'to' are inclusive */
>> + *to = from_new + nr_new - 1;
>> + *from = from_new;
>> +
>> + return nr_new;
>> +}
>> +
>> /**
>> * mmc_erase - erase sectors.
>> * @card: card to erase
>> @@ -2217,13 +2262,6 @@ int mmc_erase(struct mmc_card *card, unsigned int
>> from, unsigned int nr,
>> unsigned int rem, to = from + nr;
>> int err;
>>
>> - if (!(card->host->caps & MMC_CAP_ERASE) ||
>> - !(card->csd.cmdclass & CCC_ERASE))
>> - return -EOPNOTSUPP;
>> -
>> - if (!card->erase_size)
>> - return -EOPNOTSUPP;
>> -
>> if (mmc_card_sd(card) && arg != MMC_ERASE_ARG)
>> return -EOPNOTSUPP;
>>
>> @@ -2240,31 +2278,17 @@ int mmc_erase(struct mmc_card *card, unsigned int
>> from, unsigned int nr,
>> return -EINVAL;
>> }
>>
>> - if (arg == MMC_ERASE_ARG) {
>> - rem = from % card->erase_size;
>> - if (rem) {
>> - rem = card->erase_size - rem;
>> - from += rem;
>> - if (nr > rem)
>> - nr -= rem;
>> - else
>> - return 0;
>> - }
>> - rem = nr % card->erase_size;
>> - if (rem)
>> - nr -= rem;
>> - }
>> -
>> if (nr == 0)
>> return 0;
>>
>> - to = from + nr;
>> -
>> - if (to <= from)
>> - return -EINVAL;
>> -
>> - /* 'from' and 'to' are inclusive */
>> - to -= 1;
>> + if (arg == MMC_ERASE_ARG) {
>> + nr = mmc_align_erase_size(card, &from, &to, nr);
>> + if (nr == 0)
>> + return 0;
>> + } else {
>> + /* 'from' and 'to' are inclusive */
>> + to -= 1;
>> + }
>>
>> /*
>> * Special case where only one erase-group fits in the timeout
>> budget:
>>
>
>
> --
> Best Regards
> Shawn Lin
>
--
Baolin.wang
Best Regards
next prev parent reply other threads:[~2016-09-05 8:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-31 9:32 [PATCH v3] mmc: core: Optimize the mmc erase size alignment Baolin Wang
2016-09-02 8:34 ` Shawn Lin
2016-09-05 8:17 ` Baolin Wang [this message]
2016-09-02 9:43 ` Ulf Hansson
2016-09-05 8:27 ` Baolin Wang
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=CAMz4kuLXVS9z2oUT2Sn-+hNJkaa0LMJZHCTCYscBCLZNUgYSPA@mail.gmail.com \
--to=baolin.wang@linaro.org \
--cc=adrian.hunter@intel.com \
--cc=broonie@kernel.org \
--cc=david@protonic.nl \
--cc=dianders@chromium.org \
--cc=hdegoede@redhat.com \
--cc=heiko@sntech.de \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=shawn.lin@rock-chips.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).