Message ID | 20210504161222.101536-3-ulf.hansson@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Initital support for new power/perf features for SD cards | expand |
On Tue, May 4, 2021 at 6:12 PM Ulf Hansson <ulf.hansson@linaro.org> wrote: > In mmc_send_hpi_cmd() the host->max_busy_timeout is being validated towards > the timeout for the eMMC HPI command, as to decide whether an R1 or R1B > response should be used. > > Although, it has turned out the some host can't cope with that conversion, > but needs R1B, which means MMC_CAP_NEED_RSP_BUSY is set for them. Let's > take this into account, via using the common mmc_prepare_busy_cmd() when > doing the validation, which also avoids some open coding. > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij
On 2021/5/5 0:12, Ulf Hansson wrote: > In mmc_send_hpi_cmd() the host->max_busy_timeout is being validated towards > the timeout for the eMMC HPI command, as to decide whether an R1 or R1B > response should be used. > > Although, it has turned out the some host can't cope with that conversion, > but needs R1B, which means MMC_CAP_NEED_RSP_BUSY is set for them. Let's > take this into account, via using the common mmc_prepare_busy_cmd() when > doing the validation, which also avoids some open coding. Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> > > Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> > --- > drivers/mmc/core/mmc_ops.c | 21 +++++---------------- > 1 file changed, 5 insertions(+), 16 deletions(-) > > diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c > index 025a4134d5c7..66ae699a410f 100644 > --- a/drivers/mmc/core/mmc_ops.c > +++ b/drivers/mmc/core/mmc_ops.c > @@ -817,28 +817,17 @@ static int mmc_send_hpi_cmd(struct mmc_card *card) > { > unsigned int busy_timeout_ms = card->ext_csd.out_of_int_time; > struct mmc_host *host = card->host; > - bool use_r1b_resp = true; > + bool use_r1b_resp = false; > struct mmc_command cmd = {}; > int err; > > cmd.opcode = card->ext_csd.hpi_cmd; > cmd.arg = card->rca << 16 | 1; > + cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; > > - /* > - * Make sure the host's max_busy_timeout fit the needed timeout for HPI. > - * In case it doesn't, let's instruct the host to avoid HW busy > - * detection, by using a R1 response instead of R1B. > - */ > - if (host->max_busy_timeout && busy_timeout_ms > host->max_busy_timeout) > - use_r1b_resp = false; > - > - if (cmd.opcode == MMC_STOP_TRANSMISSION && use_r1b_resp) { > - cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; > - cmd.busy_timeout = busy_timeout_ms; > - } else { > - cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; > - use_r1b_resp = false; > - } > + if (cmd.opcode == MMC_STOP_TRANSMISSION) > + use_r1b_resp = mmc_prepare_busy_cmd(host, &cmd, > + busy_timeout_ms); > > err = mmc_wait_for_cmd(host, &cmd, 0); > if (err) { >
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 025a4134d5c7..66ae699a410f 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -817,28 +817,17 @@ static int mmc_send_hpi_cmd(struct mmc_card *card) { unsigned int busy_timeout_ms = card->ext_csd.out_of_int_time; struct mmc_host *host = card->host; - bool use_r1b_resp = true; + bool use_r1b_resp = false; struct mmc_command cmd = {}; int err; cmd.opcode = card->ext_csd.hpi_cmd; cmd.arg = card->rca << 16 | 1; + cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; - /* - * Make sure the host's max_busy_timeout fit the needed timeout for HPI. - * In case it doesn't, let's instruct the host to avoid HW busy - * detection, by using a R1 response instead of R1B. - */ - if (host->max_busy_timeout && busy_timeout_ms > host->max_busy_timeout) - use_r1b_resp = false; - - if (cmd.opcode == MMC_STOP_TRANSMISSION && use_r1b_resp) { - cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; - cmd.busy_timeout = busy_timeout_ms; - } else { - cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; - use_r1b_resp = false; - } + if (cmd.opcode == MMC_STOP_TRANSMISSION) + use_r1b_resp = mmc_prepare_busy_cmd(host, &cmd, + busy_timeout_ms); err = mmc_wait_for_cmd(host, &cmd, 0); if (err) {
In mmc_send_hpi_cmd() the host->max_busy_timeout is being validated towards the timeout for the eMMC HPI command, as to decide whether an R1 or R1B response should be used. Although, it has turned out the some host can't cope with that conversion, but needs R1B, which means MMC_CAP_NEED_RSP_BUSY is set for them. Let's take this into account, via using the common mmc_prepare_busy_cmd() when doing the validation, which also avoids some open coding. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> --- drivers/mmc/core/mmc_ops.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-)