2023-01-16 15:36:14

by Christian Loehle

[permalink] [raw]
Subject: [PATCH] mmc: block: workaround long ioctl busy timeout

The ioctl interface allowed to set cmd_timeout_ms when polling for
busy on R1B commands. This was often limited by the max hw timeout
so work around it like for the sanitize command.

Signed-off-by: Christian Loehle <[email protected]>
---
drivers/mmc/core/block.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 20da7ed43e6d..ba3bc9014179 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -472,6 +472,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
struct scatterlist sg;
int err;
unsigned int target_part;
+ unsigned int busy_timeout = MMC_BLK_TIMEOUT_MS;
+ int poll_prog = false;

if (!card || !md || !idata)
return -EINVAL;
@@ -493,6 +495,12 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
cmd.opcode = idata->ic.opcode;
cmd.arg = idata->ic.arg;
cmd.flags = idata->ic.flags;
+ /* R1B flag might be removed here to work around hw, so save it */
+ poll_prog = (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B);
+ busy_timeout = idata->ic.cmd_timeout_ms ? :
+ MMC_BLK_TIMEOUT_MS;
+ if (poll_prog)
+ mmc_prepare_busy_cmd(card->host, &cmd, busy_timeout);

if (idata->buf_bytes) {
data.sg = &sg;
@@ -596,7 +604,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
if (idata->ic.postsleep_min_us)
usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);

- if (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B) {
+ if (poll_prog) {
/*
* Ensure RPMB/R1B command has completed by polling CMD13 "Send Status". Here we
* allow to override the default timeout value if a custom timeout is specified.
--
2.37.3


Hyperstone GmbH | Reichenaustr. 39a | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


2023-01-16 15:45:38

by Avri Altman

[permalink] [raw]
Subject: RE: [PATCH] mmc: block: workaround long ioctl busy timeout

>
> The ioctl interface allowed to set cmd_timeout_ms when polling for busy on
> R1B commands. This was often limited by the max hw timeout so work around
> it like for the sanitize command.
>
> Signed-off-by: Christian Loehle <[email protected]>
> ---
> drivers/mmc/core/block.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index
> 20da7ed43e6d..ba3bc9014179 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -472,6 +472,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card
> *card, struct mmc_blk_data *md,
> struct scatterlist sg;
> int err;
> unsigned int target_part;
> + unsigned int busy_timeout = MMC_BLK_TIMEOUT_MS;
> + int poll_prog = false;
>
> if (!card || !md || !idata)
> return -EINVAL;
> @@ -493,6 +495,12 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card
> *card, struct mmc_blk_data *md,
> cmd.opcode = idata->ic.opcode;
> cmd.arg = idata->ic.arg;
> cmd.flags = idata->ic.flags;
> + /* R1B flag might be removed here to work around hw, so save it */
> + poll_prog = (idata->rpmb || (cmd.flags & MMC_RSP_R1B) ==
> MMC_RSP_R1B);
> + busy_timeout = idata->ic.cmd_timeout_ms ? :
> + MMC_BLK_TIMEOUT_MS;
Isn't commit 23e09be254f9 already introduced the very same thing?
Meaning mmc_poll_for_busy() is already called with the appropriate timeout?

Thanks,
Avri

> + if (poll_prog)
> + mmc_prepare_busy_cmd(card->host, &cmd, busy_timeout);
>
> if (idata->buf_bytes) {
> data.sg = &sg;
> @@ -596,7 +604,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card
> *card, struct mmc_blk_data *md,
> if (idata->ic.postsleep_min_us)
> usleep_range(idata->ic.postsleep_min_us, idata-
> >ic.postsleep_max_us);
>
> - if (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B) {
> + if (poll_prog) {
> /*
> * Ensure RPMB/R1B command has completed by polling CMD13
> "Send Status". Here we
> * allow to override the default timeout value if a custom timeout is
> specified.
> --
> 2.37.3
>
>
> Hyperstone GmbH | Reichenaustr. 39a | 78467 Konstanz Managing Director:
> Dr. Jan Peter Berns.
> Commercial register of local courts: Freiburg HRB381782

2023-02-13 10:34:54

by Christian Loehle

[permalink] [raw]
Subject: RE: [PATCH] mmc: block: workaround long ioctl busy timeout

Any more comments regarding this patch?

-----Original Message-----
From: Christian L?hle
Sent: Montag, 16. Januar 2023 15:38
To: [email protected]; 'Avri Altman' <[email protected]>; [email protected]; [email protected]
Cc: [email protected]
Subject: [PATCH] mmc: block: workaround long ioctl busy timeout

The ioctl interface allowed to set cmd_timeout_ms when polling for busy on R1B commands. This was often limited by the max hw timeout so work around it like for the sanitize command.

Signed-off-by: Christian Loehle <[email protected]>
---
drivers/mmc/core/block.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 20da7ed43e6d..ba3bc9014179 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -472,6 +472,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
struct scatterlist sg;
int err;
unsigned int target_part;
+ unsigned int busy_timeout = MMC_BLK_TIMEOUT_MS;
+ int poll_prog = false;

if (!card || !md || !idata)
return -EINVAL;
@@ -493,6 +495,12 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
cmd.opcode = idata->ic.opcode;
cmd.arg = idata->ic.arg;
cmd.flags = idata->ic.flags;
+ /* R1B flag might be removed here to work around hw, so save it */
+ poll_prog = (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B);
+ busy_timeout = idata->ic.cmd_timeout_ms ? :
+ MMC_BLK_TIMEOUT_MS;
+ if (poll_prog)
+ mmc_prepare_busy_cmd(card->host, &cmd, busy_timeout);

if (idata->buf_bytes) {
data.sg = &sg;
@@ -596,7 +604,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
if (idata->ic.postsleep_min_us)
usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);

- if (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B) {
+ if (poll_prog) {
/*
* Ensure RPMB/R1B command has completed by polling CMD13 "Send Status". Here we
* allow to override the default timeout value if a custom timeout is specified.
--
2.37.3


Hyperstone GmbH | Reichenaustr. 39a | 78467 Konstanz
Managing Director: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


2023-02-13 13:38:49

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH] mmc: block: workaround long ioctl busy timeout

On Mon, 16 Jan 2023 at 15:38, Christian Löhle <[email protected]> wrote:
>
> The ioctl interface allowed to set cmd_timeout_ms when polling for
> busy on R1B commands. This was often limited by the max hw timeout
> so work around it like for the sanitize command.
>
> Signed-off-by: Christian Loehle <[email protected]>
> ---
> drivers/mmc/core/block.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 20da7ed43e6d..ba3bc9014179 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -472,6 +472,8 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
> struct scatterlist sg;
> int err;
> unsigned int target_part;
> + unsigned int busy_timeout = MMC_BLK_TIMEOUT_MS;
> + int poll_prog = false;
>
> if (!card || !md || !idata)
> return -EINVAL;
> @@ -493,6 +495,12 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
> cmd.opcode = idata->ic.opcode;
> cmd.arg = idata->ic.arg;
> cmd.flags = idata->ic.flags;
> + /* R1B flag might be removed here to work around hw, so save it */
> + poll_prog = (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B);
> + busy_timeout = idata->ic.cmd_timeout_ms ? :
> + MMC_BLK_TIMEOUT_MS;
> + if (poll_prog)
> + mmc_prepare_busy_cmd(card->host, &cmd, busy_timeout);

This may end up using R1B for rpmb commands, we don't want that.

>
> if (idata->buf_bytes) {
> data.sg = &sg;
> @@ -596,7 +604,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md,
> if (idata->ic.postsleep_min_us)
> usleep_range(idata->ic.postsleep_min_us, idata->ic.postsleep_max_us);
>
> - if (idata->rpmb || (cmd.flags & MMC_RSP_R1B) == MMC_RSP_R1B) {
> + if (poll_prog) {

If we end up using R1B and the host supports HW busy detection, we
should skip polling.

> /*
> * Ensure RPMB/R1B command has completed by polling CMD13 "Send Status". Here we
> * allow to override the default timeout value if a custom timeout is specified.

I believe I understand the problem you are trying to address in the
$subject patch. Let me try to help out, by sending a re-worked patch
to try to cover the things I pointed out above in a more consistent
way.

Kind regards
Uffe

2023-02-13 19:26:55

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] mmc: block: workaround long ioctl busy timeout

Hi Christian,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.2-rc8 next-20230213]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Christian-L-hle/mmc-block-workaround-long-ioctl-busy-timeout/20230213-183603
patch link: https://lore.kernel.org/r/8f4a0fc6f2e64ef091784c5cd704c113%40hyperstone.com
patch subject: [PATCH] mmc: block: workaround long ioctl busy timeout
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20230214/[email protected]/config)
compiler: powerpc-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/94406ad8626aa2d7761fb7eb20a918a4805ea667
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Christian-L-hle/mmc-block-workaround-long-ioctl-busy-timeout/20230213-183603
git checkout 94406ad8626aa2d7761fb7eb20a918a4805ea667
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "mmc_prepare_busy_cmd" [drivers/mmc/core/mmc_block.ko] undefined!

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

2023-02-14 01:52:06

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] mmc: block: workaround long ioctl busy timeout

Hi Christian,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.2-rc8 next-20230213]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Christian-L-hle/mmc-block-workaround-long-ioctl-busy-timeout/20230213-183603
patch link: https://lore.kernel.org/r/8f4a0fc6f2e64ef091784c5cd704c113%40hyperstone.com
patch subject: [PATCH] mmc: block: workaround long ioctl busy timeout
config: x86_64-randconfig-a003-20230213 (https://download.01.org/0day-ci/archive/20230214/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/94406ad8626aa2d7761fb7eb20a918a4805ea667
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Christian-L-hle/mmc-block-workaround-long-ioctl-busy-timeout/20230213-183603
git checkout 94406ad8626aa2d7761fb7eb20a918a4805ea667
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "mmc_prepare_busy_cmd" [drivers/mmc/core/mmc_block.ko] undefined!

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests