From: Adrian Hunter <adrian.hunter@intel.com>
To: Avri Altman <avri.altman@wdc.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
linux-mmc@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH] mmc: core: Use GFP_NOIO in ACMD22
Date: Tue, 15 Oct 2024 12:44:37 +0300 [thread overview]
Message-ID: <18e66783-0fc7-4c55-8087-dc4212e851b4@intel.com> (raw)
In-Reply-To: <20241014114458.360538-1-avri.altman@wdc.com>
On 14/10/24 14:44, Avri Altman 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://www.spinics.net/lists/linux-mmc/msg82199.html
>
> Suggested-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Avri Altman <avri.altman@wdc.com>
> Cc: stable@vger.kernel.org
> ---
> 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 04f3165cf9ae..042b0147d47e 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,9 +1020,13 @@ 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);
Could have memalloc_noio_restore() here:
memalloc_noio_restore(noio_flag);
but I feel maybe adding something like:
u64 __aligned(8) tiny_io_buf;
to either struct mmc_card or struct mmc_host is better?
Ulf, any thoughts?
> - if (!blocks)
> + if (!blocks) {
> + memalloc_noio_restore(noio_flag);
> return -ENOMEM;
> + }
>
> sg_init_one(&sg, blocks, resp_sz);
>
> @@ -1041,6 +1047,8 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks)
> }
> kfree(blocks);
>
> + memalloc_noio_restore(noio_flag);
> +
> if (cmd.error || data.error)
> return -EIO;
>
next prev parent reply other threads:[~2024-10-15 9:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-14 11:44 [PATCH] mmc: core: Use GFP_NOIO in ACMD22 Avri Altman
2024-10-15 9:44 ` Adrian Hunter [this message]
2024-10-16 14:44 ` Ulf Hansson
2024-10-16 15:20 ` Avri Altman
2024-10-17 9:13 ` Ulf Hansson
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=18e66783-0fc7-4c55-8087-dc4212e851b4@intel.com \
--to=adrian.hunter@intel.com \
--cc=avri.altman@wdc.com \
--cc=linux-mmc@vger.kernel.org \
--cc=stable@vger.kernel.org \
--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