diff mbox series

[v3] mmc: core: Use GFP_NOIO in ACMD22

Message ID 20241021153227.493970-1-avri.altman@wdc.com (mailing list archive)
State New
Headers show
Series [v3] mmc: core: Use GFP_NOIO in ACMD22 | expand

Commit Message

Avri Altman Oct. 21, 2024, 3:32 p.m. UTC
While reviewing the SDUC series, Adrian made a comment concerning the
memory allocation code in mmc_sd_num_wr_blocks() - see [1].
Prevent memory allocations from triggering I/O operations while ACMD22
is in progress.

[1] https://lore.kernel.org/linux-mmc/3016fd71-885b-4ef9-97ed-46b4b0cb0e35@intel.com/

Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Fixes: 051913dada04 ("mmc_block: do not DMA to stack")
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Cc: stable@vger.kernel.org

---
Changes since v2:
 - Fix checkpatch warnings (Adrian)

Changes since v1:
 - Move memalloc_noio_restore around (Adrian)
---
 drivers/mmc/core/block.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Ulf Hansson Oct. 25, 2024, 2:51 p.m. UTC | #1
On Mon, 21 Oct 2024 at 17:34, Avri Altman <avri.altman@wdc.com> wrote:
>
> While reviewing the SDUC series, Adrian made a comment concerning the
> memory allocation code in mmc_sd_num_wr_blocks() - see [1].
> Prevent memory allocations from triggering I/O operations while ACMD22
> is in progress.
>
> [1] https://lore.kernel.org/linux-mmc/3016fd71-885b-4ef9-97ed-46b4b0cb0e35@intel.com/
>
> Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
> Fixes: 051913dada04 ("mmc_block: do not DMA to stack")
> Signed-off-by: Avri Altman <avri.altman@wdc.com>
> Cc: stable@vger.kernel.org

Applied for next (as it doesn't apply on fixes), thanks!

Kind regards
Uffe



>
> ---
> Changes since v2:
>  - Fix checkpatch warnings (Adrian)
>
> Changes since v1:
>  - Move memalloc_noio_restore around (Adrian)
> ---
>  drivers/mmc/core/block.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 04f3165cf9ae..a813fd7f39cc 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -995,6 +995,8 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks)
>         u32 result;
>         __be32 *blocks;
>         u8 resp_sz = mmc_card_ult_capacity(card) ? 8 : 4;
> +       unsigned int noio_flag;
> +
>         struct mmc_request mrq = {};
>         struct mmc_command cmd = {};
>         struct mmc_data data = {};
> @@ -1018,7 +1020,9 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks)
>         mrq.cmd = &cmd;
>         mrq.data = &data;
>
> +       noio_flag = memalloc_noio_save();
>         blocks = kmalloc(resp_sz, GFP_KERNEL);
> +       memalloc_noio_restore(noio_flag);
>         if (!blocks)
>                 return -ENOMEM;
>
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index 04f3165cf9ae..a813fd7f39cc 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -995,6 +995,8 @@  static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks)
 	u32 result;
 	__be32 *blocks;
 	u8 resp_sz = mmc_card_ult_capacity(card) ? 8 : 4;
+	unsigned int noio_flag;
+
 	struct mmc_request mrq = {};
 	struct mmc_command cmd = {};
 	struct mmc_data data = {};
@@ -1018,7 +1020,9 @@  static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks)
 	mrq.cmd = &cmd;
 	mrq.data = &data;
 
+	noio_flag = memalloc_noio_save();
 	blocks = kmalloc(resp_sz, GFP_KERNEL);
+	memalloc_noio_restore(noio_flag);
 	if (!blocks)
 		return -ENOMEM;