RE: [PATCH] mmc: block: ioctl: No busywaiting of non-TRAN CMDs

From: Avri Altman
Date: Thu May 06 2021 - 02:15:22 EST


> Prevent busywaiting for TRAN state indication
> after issuing a command that will not transition
> to TRAN state.
>
> Signed-off-by: Christian Loehle <cloehle@xxxxxxxxxxxxxx>
> ---
> drivers/mmc/core/block.c | 3 ++-
> drivers/mmc/core/block.h | 5 +++++
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 689eb9afeeed..9baf95639688 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -593,7 +593,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card
> *card, struct mmc_blk_data *md,
>
> memcpy(&(idata->ic.response), cmd.resp, sizeof(cmd.resp));
>
> - if (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B) {
> + if ((idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B)
> + && TRAN_TRANSITION_CMD(cmd.opcode)) {
> /*
> * Ensure RPMB/R1B command has completed by polling CMD13
> * "Send Status".
> diff --git a/drivers/mmc/core/block.h b/drivers/mmc/core/block.h
> index 31153f656f41..51b806384ab0 100644
> --- a/drivers/mmc/core/block.h
> +++ b/drivers/mmc/core/block.h
> @@ -17,4 +17,9 @@ struct work_struct;
>
> void mmc_blk_mq_complete_work(struct work_struct *work);
>
> +#define TRAN_TRANSITION_CMD(cmd) !(cmd == MMC_SEND_STATUS \
> + || cmd == MMC_SEND_CID \
> + || cmd == MMC_ALL_SEND_CID \
> + || cmd == MMC_SEND_CSD)
> +
You might want to use a static inline here to allow type checking.
If you decide to leave it as a macro however, need to add () on each term.

Thanks,
Avri

> #endif
> --
> 2.31.1
>
> Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz
> Managing Directors: Dr. Jan Peter Berns.
> Commercial register of local courts: Freiburg HRB381782