mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-29 18:19:02 +00:00
01d8e41c16
Changelog: https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.6.51 Removed upstreamed: generic/backport-6.6/200-regmap-maple-work-around-false-positive-warning.patch generic/backport-6.6/822-v6.11-0012-nvmem-Fix-return-type-of-devm_nvmem_device_get-in-ke.patch bcm27xx/patches-6.6/950-1018-drivers-mmc-apply-SD-quirks-earlier-during-probe.patch Manually rebased: bcm27xx/patches-6.6/950-0993-drivers-mmc-cqhci-clear-CQHCI_CTL-if-halt-fails.patch ramips/patches-6.6/311-MIPS-use-set_mode-to-enable-disable-the-cevt-r4k-irq.patch[4] All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.6.51&id=e42ea96d6d36a16526cb82b8aa2e5422814c3250 2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.6.51&id=3d1baf322a3a69b38b6b2d511cfe0d611d1b5462 3. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.6.51&id=115a755bb38db5a1175be44e6a9a93a0a8233885 4. Adapted the changes from Hauke Mehrtens' modification in PR#16366 to 5.15.167 Build system: x86/64 Build-tested: x86/64/AMD Cezanne, flogic/xiaomi_redmi-router-ax6000-ubootmod, ramips/tplink_archer-a6-v3 Run-tested: x86/64/AMD Cezanne, flogic/xiaomi_redmi-router-ax6000-ubootmod, ramips/tplink_archer-a6-v3 Signed-off-by: John Audia <therealgraysky@proton.me> Link: https://github.com/openwrt/openwrt/pull/16370 Signed-off-by: Robert Marko <robimarko@gmail.com>
156 lines
4.1 KiB
Diff
156 lines
4.1 KiB
Diff
From d8748eda96b47efea833e2a6ea478bb370654f1d Mon Sep 17 00:00:00 2001
|
|
From: Jonathan Bell <jonathan@raspberrypi.com>
|
|
Date: Wed, 20 Mar 2024 13:00:30 +0000
|
|
Subject: [PATCH 0983/1085] drivers: mmc: preallocate a block for SD extension
|
|
register accesses
|
|
|
|
The Performance Extension register is regularly accessed in a hot path
|
|
to do write cache flushes. Don't invoke kmalloc/kfree for every access,
|
|
preallocate a 512B buffer for this purpose.
|
|
|
|
Also remove an unused alloc in sd_enable_cache().
|
|
|
|
Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
|
|
---
|
|
drivers/mmc/core/bus.c | 2 ++
|
|
drivers/mmc/core/sd.c | 34 +++++++++++-----------------------
|
|
include/linux/mmc/card.h | 1 +
|
|
3 files changed, 14 insertions(+), 23 deletions(-)
|
|
|
|
--- a/drivers/mmc/core/bus.c
|
|
+++ b/drivers/mmc/core/bus.c
|
|
@@ -264,6 +264,8 @@ static void mmc_release_card(struct devi
|
|
|
|
sdio_free_common_cis(card);
|
|
|
|
+ kfree(card->ext_reg_buf);
|
|
+
|
|
kfree(card->info);
|
|
|
|
kfree(card);
|
|
--- a/drivers/mmc/core/sd.c
|
|
+++ b/drivers/mmc/core/sd.c
|
|
@@ -1026,9 +1026,8 @@ int sd_write_ext_reg(struct mmc_card *ca
|
|
struct scatterlist sg;
|
|
u8 *reg_buf;
|
|
|
|
- reg_buf = kzalloc(512, GFP_KERNEL);
|
|
- if (!reg_buf)
|
|
- return -ENOMEM;
|
|
+ reg_buf = card->ext_reg_buf;
|
|
+ memset(reg_buf, 0, 512);
|
|
|
|
mrq.cmd = &cmd;
|
|
mrq.data = &data;
|
|
@@ -1060,8 +1059,6 @@ int sd_write_ext_reg(struct mmc_card *ca
|
|
mmc_set_data_timeout(&data, card);
|
|
mmc_wait_for_req(host, &mrq);
|
|
|
|
- kfree(reg_buf);
|
|
-
|
|
/*
|
|
* Note that, the SD card is allowed to signal busy on DAT0 up to 1s
|
|
* after the CMD49. Although, let's leave this to be managed by the
|
|
@@ -1102,9 +1099,7 @@ static int sd_parse_ext_reg_power(struct
|
|
int err;
|
|
u8 *reg_buf;
|
|
|
|
- reg_buf = kzalloc(512, GFP_KERNEL);
|
|
- if (!reg_buf)
|
|
- return -ENOMEM;
|
|
+ reg_buf = card->ext_reg_buf;
|
|
|
|
/* Read the extension register for power management function. */
|
|
err = sd_read_ext_reg(card, fno, page, offset, 512, reg_buf);
|
|
@@ -1134,7 +1129,6 @@ static int sd_parse_ext_reg_power(struct
|
|
card->ext_power.offset = offset;
|
|
|
|
out:
|
|
- kfree(reg_buf);
|
|
return err;
|
|
}
|
|
|
|
@@ -1144,9 +1138,7 @@ static int sd_parse_ext_reg_perf(struct
|
|
int err;
|
|
u8 *reg_buf;
|
|
|
|
- reg_buf = kzalloc(512, GFP_KERNEL);
|
|
- if (!reg_buf)
|
|
- return -ENOMEM;
|
|
+ reg_buf = card->ext_reg_buf;
|
|
|
|
err = sd_read_ext_reg(card, fno, page, offset, 512, reg_buf);
|
|
if (err) {
|
|
@@ -1189,7 +1181,6 @@ static int sd_parse_ext_reg_perf(struct
|
|
card->ext_perf.offset = offset;
|
|
|
|
out:
|
|
- kfree(reg_buf);
|
|
return err;
|
|
}
|
|
|
|
@@ -1260,6 +1251,12 @@ static int sd_read_ext_regs(struct mmc_c
|
|
if (!gen_info_buf)
|
|
return -ENOMEM;
|
|
|
|
+ card->ext_reg_buf = kzalloc(512, GFP_KERNEL);
|
|
+ if (!card->ext_reg_buf) {
|
|
+ err = -ENOMEM;
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
/*
|
|
* Read 512 bytes of general info, which is found at function number 0,
|
|
* at page 0 and with no offset.
|
|
@@ -1326,9 +1323,7 @@ static int sd_flush_cache(struct mmc_hos
|
|
if (!sd_cache_enabled(host))
|
|
return 0;
|
|
|
|
- reg_buf = kzalloc(512, GFP_KERNEL);
|
|
- if (!reg_buf)
|
|
- return -ENOMEM;
|
|
+ reg_buf = card->ext_reg_buf;
|
|
|
|
/*
|
|
* Set Flush Cache at bit 0 in the performance enhancement register at
|
|
@@ -1364,21 +1359,15 @@ static int sd_flush_cache(struct mmc_hos
|
|
if (reg_buf[0] & BIT(0))
|
|
err = -ETIMEDOUT;
|
|
out:
|
|
- kfree(reg_buf);
|
|
return err;
|
|
}
|
|
|
|
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 +1386,6 @@ static int sd_enable_cache(struct mmc_ca
|
|
card->ext_perf.feature_enabled |= SD_EXT_PERF_CACHE;
|
|
|
|
out:
|
|
- kfree(reg_buf);
|
|
return err;
|
|
}
|
|
|
|
--- a/include/linux/mmc/card.h
|
|
+++ b/include/linux/mmc/card.h
|
|
@@ -320,6 +320,7 @@ struct mmc_card {
|
|
struct sd_switch_caps sw_caps; /* switch (CMD6) caps */
|
|
struct sd_ext_reg ext_power; /* SD extension reg for PM */
|
|
struct sd_ext_reg ext_perf; /* SD extension reg for PERF */
|
|
+ u8 *ext_reg_buf; /* 512 byte block for extension register R/W */
|
|
|
|
unsigned int sdio_funcs; /* number of SDIO functions */
|
|
atomic_t sdio_funcs_probed; /* number of probed SDIO funcs */
|