* [PATCH v2] mmc: core: Use GFP_NOIO in ACMD22
@ 2024-10-18 5:29 Avri Altman
2024-10-21 10:47 ` Adrian Hunter
0 siblings, 1 reply; 5+ messages in thread
From: Avri Altman @ 2024-10-18 5:29 UTC (permalink / raw)
To: Ulf Hansson, linux-mmc; +Cc: Adrian Hunter, Avri Altman, stable
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
---
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] mmc: core: Use GFP_NOIO in ACMD22
2024-10-18 5:29 [PATCH v2] mmc: core: Use GFP_NOIO in ACMD22 Avri Altman
@ 2024-10-21 10:47 ` Adrian Hunter
2024-10-21 12:24 ` Avri Altman
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Hunter @ 2024-10-21 10:47 UTC (permalink / raw)
To: Avri Altman, Ulf Hansson, linux-mmc; +Cc: stable
On 18/10/24 08:29, 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
Some checkpatch warnings:
WARNING: Use lore.kernel.org archive links when possible - see https://lore.kernel.org/lists.html
#12:
[1] https://www.spinics.net/lists/linux-mmc/msg82199.html
WARNING: The commit message has 'stable@', perhaps it also needs a 'Fixes:' tag?
total: 0 errors, 2 warnings, 17 lines checked
Otherwise:
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
>
> ---
> 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;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v2] mmc: core: Use GFP_NOIO in ACMD22
2024-10-21 10:47 ` Adrian Hunter
@ 2024-10-21 12:24 ` Avri Altman
2024-10-21 14:33 ` Adrian Hunter
0 siblings, 1 reply; 5+ messages in thread
From: Avri Altman @ 2024-10-21 12:24 UTC (permalink / raw)
To: Adrian Hunter, Ulf Hansson, linux-mmc@vger.kernel.org
Cc: stable@vger.kernel.org
>
> On 18/10/24 08:29, 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
>
> Some checkpatch warnings:
>
> WARNING: Use lore.kernel.org archive links when possible - see
> https://lore.kernel.org/lists.html
> #12:
> [1] https://www.spinics.net/lists/linux-mmc/msg82199.html
Done.
>
> WARNING: The commit message has 'stable@', perhaps it also needs a
> 'Fixes:' tag?
I tried to look for the patch that introduced mmc_sd_num_wr_blocks but couldn't find it in Ulf's tree.
Thanks,
Avri
>
> total: 0 errors, 2 warnings, 17 lines checked
>
> Otherwise:
>
> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
>
> >
> > ---
> > 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;
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] mmc: core: Use GFP_NOIO in ACMD22
2024-10-21 12:24 ` Avri Altman
@ 2024-10-21 14:33 ` Adrian Hunter
2024-10-21 15:26 ` Avri Altman
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Hunter @ 2024-10-21 14:33 UTC (permalink / raw)
To: Avri Altman, Ulf Hansson, linux-mmc@vger.kernel.org
Cc: stable@vger.kernel.org
On 21/10/24 15:24, Avri Altman wrote:
>>
>> On 18/10/24 08:29, 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
>>
>> Some checkpatch warnings:
>>
>> WARNING: Use lore.kernel.org archive links when possible - see
>> https://lore.kernel.org/lists.html
>> #12:
>> [1] https://www.spinics.net/lists/linux-mmc/msg82199.html
> Done.
>
>>
>> WARNING: The commit message has 'stable@', perhaps it also needs a
>> 'Fixes:' tag?
> I tried to look for the patch that introduced mmc_sd_num_wr_blocks but couldn't find it in Ulf's tree.
Seems like the following introduced the kmalloc()
commit 051913dada046ac948eb6f48c0717fc25de2a917
Author: Ben Dooks <ben@simtec.co.uk>
Date: Mon Jun 8 23:33:57 2009 +0100
mmc_block: do not DMA to stack
>
> Thanks,
> Avri
>>
>> total: 0 errors, 2 warnings, 17 lines checked
>>
>> Otherwise:
>>
>> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
>>
>>>
>>> ---
>>> 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;
>>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v2] mmc: core: Use GFP_NOIO in ACMD22
2024-10-21 14:33 ` Adrian Hunter
@ 2024-10-21 15:26 ` Avri Altman
0 siblings, 0 replies; 5+ messages in thread
From: Avri Altman @ 2024-10-21 15:26 UTC (permalink / raw)
To: Adrian Hunter, Ulf Hansson, linux-mmc@vger.kernel.org
Cc: stable@vger.kernel.org
> >> WARNING: The commit message has 'stable@', perhaps it also needs a
> >> 'Fixes:' tag?
> > I tried to look for the patch that introduced mmc_sd_num_wr_blocks but
> couldn't find it in Ulf's tree.
>
> Seems like the following introduced the kmalloc()
>
> commit 051913dada046ac948eb6f48c0717fc25de2a917
> Author: Ben Dooks <ben@simtec.co.uk>
> Date: Mon Jun 8 23:33:57 2009 +0100
>
> mmc_block: do not DMA to stack
Got it.
Thanks,
Avri
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-21 15:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-18 5:29 [PATCH v2] mmc: core: Use GFP_NOIO in ACMD22 Avri Altman
2024-10-21 10:47 ` Adrian Hunter
2024-10-21 12:24 ` Avri Altman
2024-10-21 14:33 ` Adrian Hunter
2024-10-21 15:26 ` Avri Altman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox