* RE: [PATCH] mmc: core: sd: Remove unused buffer allocation in sd_enable_cache()
2026-06-02 9:40 ` [PATCH] mmc: core: sd: Remove unused buffer allocation in sd_enable_cache() Chanwoo Lee
@ 2026-06-02 9:59 ` Avri Altman
2026-06-03 9:28 ` Shawn Lin
2026-07-06 15:46 ` Ulf Hansson
2 siblings, 0 replies; 4+ messages in thread
From: Avri Altman @ 2026-06-02 9:59 UTC (permalink / raw)
To: Chanwoo Lee, Ulf Hansson, Pedro Demarchi Gomes, Sarthak Garg,
Linus Walleij,
open list:MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND...,
open list
> sd_enable_cache() allocates a 512-byte buffer that is never used.
> sd_write_ext_reg() allocates its own internal buffer, and no read-back verification
> is done in this function. Remove the unnecessary allocation.
>
> Fixes: 130206a615a9 ("mmc: core: Add support for cache ctrl for SD cards")
> Signed-off-by: Chanwoo Lee <cw9316.lee@samsung.com>
Reviewed-by: Avri Altman <avri.altman@sandisk.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] mmc: core: sd: Remove unused buffer allocation in sd_enable_cache()
2026-06-02 9:40 ` [PATCH] mmc: core: sd: Remove unused buffer allocation in sd_enable_cache() Chanwoo Lee
2026-06-02 9:59 ` Avri Altman
@ 2026-06-03 9:28 ` Shawn Lin
2026-07-06 15:46 ` Ulf Hansson
2 siblings, 0 replies; 4+ messages in thread
From: Shawn Lin @ 2026-06-03 9:28 UTC (permalink / raw)
To: Chanwoo Lee
Cc: shawn.lin, Ulf Hansson,
open list:MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND...,
Avri Altman, Sarthak Garg, open list, Linus Walleij,
Pedro Demarchi Gomes
在 2026/06/02 星期二 17:40, Chanwoo Lee 写道:
> sd_enable_cache() allocates a 512-byte buffer that is never used.
> sd_write_ext_reg() allocates its own internal buffer, and no read-back
> verification is done in this function. Remove the unnecessary allocation.
>
> Fixes: 130206a615a9 ("mmc: core: Add support for cache ctrl for SD cards")
This cleanup doesn't deserve a fixes tag, otherwise
Reviewed-by: Shawn Lin <shawn.lin@linux.dev>
> Signed-off-by: Chanwoo Lee <cw9316.lee@samsung.com>
> ---
> drivers/mmc/core/sd.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 948948ca9b4a..c763efb10f64 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -1379,15 +1379,10 @@ static int sd_flush_cache(struct mmc_host *host)
>
> static int sd_enable_cache(struct mmc_card *card)
> {
> - u8 *reg_buf;
> int err;
>
> card->ext_perf.feature_enabled &= ~SD_EXT_PERF_CACHE;
>
> - reg_buf = kzalloc(512, GFP_KERNEL);
> - if (!reg_buf)
> - return -ENOMEM;
> -
> /*
> * Set Cache Enable at bit 0 in the performance enhancement register at
> * 260 bytes offset.
> @@ -1397,7 +1392,7 @@ static int sd_enable_cache(struct mmc_card *card)
> if (err) {
> pr_warn("%s: error %d writing Cache Enable bit\n",
> mmc_hostname(card->host), err);
> - goto out;
> + return err;
> }
>
> err = mmc_poll_for_busy(card, SD_WRITE_EXTR_SINGLE_TIMEOUT_MS, false,
> @@ -1405,8 +1400,6 @@ static int sd_enable_cache(struct mmc_card *card)
> if (!err)
> card->ext_perf.feature_enabled |= SD_EXT_PERF_CACHE;
>
> -out:
> - kfree(reg_buf);
> return err;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] mmc: core: sd: Remove unused buffer allocation in sd_enable_cache()
2026-06-02 9:40 ` [PATCH] mmc: core: sd: Remove unused buffer allocation in sd_enable_cache() Chanwoo Lee
2026-06-02 9:59 ` Avri Altman
2026-06-03 9:28 ` Shawn Lin
@ 2026-07-06 15:46 ` Ulf Hansson
2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2026-07-06 15:46 UTC (permalink / raw)
To: Chanwoo Lee
Cc: Ulf Hansson, Pedro Demarchi Gomes, Avri Altman, Sarthak Garg,
Linus Walleij,
open list:MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND...,
open list
On Tue, Jun 2, 2026 at 11:41 AM Chanwoo Lee <cw9316.lee@samsung.com> wrote:
>
> sd_enable_cache() allocates a 512-byte buffer that is never used.
> sd_write_ext_reg() allocates its own internal buffer, and no read-back
> verification is done in this function. Remove the unnecessary allocation.
>
> Fixes: 130206a615a9 ("mmc: core: Add support for cache ctrl for SD cards")
> Signed-off-by: Chanwoo Lee <cw9316.lee@samsung.com>
Applied for next, thanks!
Kind regards
Uffe
> ---
> drivers/mmc/core/sd.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> index 948948ca9b4a..c763efb10f64 100644
> --- a/drivers/mmc/core/sd.c
> +++ b/drivers/mmc/core/sd.c
> @@ -1379,15 +1379,10 @@ static int sd_flush_cache(struct mmc_host *host)
>
> static int sd_enable_cache(struct mmc_card *card)
> {
> - u8 *reg_buf;
> int err;
>
> card->ext_perf.feature_enabled &= ~SD_EXT_PERF_CACHE;
>
> - reg_buf = kzalloc(512, GFP_KERNEL);
> - if (!reg_buf)
> - return -ENOMEM;
> -
> /*
> * Set Cache Enable at bit 0 in the performance enhancement register at
> * 260 bytes offset.
> @@ -1397,7 +1392,7 @@ static int sd_enable_cache(struct mmc_card *card)
> if (err) {
> pr_warn("%s: error %d writing Cache Enable bit\n",
> mmc_hostname(card->host), err);
> - goto out;
> + return err;
> }
>
> err = mmc_poll_for_busy(card, SD_WRITE_EXTR_SINGLE_TIMEOUT_MS, false,
> @@ -1405,8 +1400,6 @@ static int sd_enable_cache(struct mmc_card *card)
> if (!err)
> card->ext_perf.feature_enabled |= SD_EXT_PERF_CACHE;
>
> -out:
> - kfree(reg_buf);
> return err;
> }
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread