From: Greg Kroah-Hartman Date: Fri, 13 May 2022 08:28:02 +0000 (+0200) Subject: 4.9-stable patches X-Git-Tag: v4.9.314~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=815205588f00830f5577627af3b05edf9aabe500;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: bluetooth-fix-the-creation-of-hdev-name.patch mmc-rtsx-add-74-clocks-in-power-on-flow.patch --- diff --git a/queue-4.9/bluetooth-fix-the-creation-of-hdev-name.patch b/queue-4.9/bluetooth-fix-the-creation-of-hdev-name.patch new file mode 100644 index 00000000000..ea8f4284bad --- /dev/null +++ b/queue-4.9/bluetooth-fix-the-creation-of-hdev-name.patch @@ -0,0 +1,65 @@ +From 103a2f3255a95991252f8f13375c3a96a75011cd Mon Sep 17 00:00:00 2001 +From: Itay Iellin +Date: Sat, 7 May 2022 08:32:48 -0400 +Subject: Bluetooth: Fix the creation of hdev->name + +From: Itay Iellin + +commit 103a2f3255a95991252f8f13375c3a96a75011cd upstream. + +Set a size limit of 8 bytes of the written buffer to "hdev->name" +including the terminating null byte, as the size of "hdev->name" is 8 +bytes. If an id value which is greater than 9999 is allocated, +then the "snprintf(hdev->name, sizeof(hdev->name), "hci%d", id)" +function call would lead to a truncation of the id value in decimal +notation. + +Set an explicit maximum id parameter in the id allocation function call. +The id allocation function defines the maximum allocated id value as the +maximum id parameter value minus one. Therefore, HCI_MAX_ID is defined +as 10000. + +Signed-off-by: Itay Iellin +Signed-off-by: Luiz Augusto von Dentz +Signed-off-by: Greg Kroah-Hartman +--- + include/net/bluetooth/hci_core.h | 3 +++ + net/bluetooth/hci_core.c | 6 +++--- + 2 files changed, 6 insertions(+), 3 deletions(-) + +--- a/include/net/bluetooth/hci_core.h ++++ b/include/net/bluetooth/hci_core.h +@@ -32,6 +32,9 @@ + /* HCI priority */ + #define HCI_PRIO_MAX 7 + ++/* HCI maximum id value */ ++#define HCI_MAX_ID 10000 ++ + /* HCI Core structures */ + struct inquiry_data { + bdaddr_t bdaddr; +--- a/net/bluetooth/hci_core.c ++++ b/net/bluetooth/hci_core.c +@@ -3064,10 +3064,10 @@ int hci_register_dev(struct hci_dev *hde + */ + switch (hdev->dev_type) { + case HCI_PRIMARY: +- id = ida_simple_get(&hci_index_ida, 0, 0, GFP_KERNEL); ++ id = ida_simple_get(&hci_index_ida, 0, HCI_MAX_ID, GFP_KERNEL); + break; + case HCI_AMP: +- id = ida_simple_get(&hci_index_ida, 1, 0, GFP_KERNEL); ++ id = ida_simple_get(&hci_index_ida, 1, HCI_MAX_ID, GFP_KERNEL); + break; + default: + return -EINVAL; +@@ -3076,7 +3076,7 @@ int hci_register_dev(struct hci_dev *hde + if (id < 0) + return id; + +- sprintf(hdev->name, "hci%d", id); ++ snprintf(hdev->name, sizeof(hdev->name), "hci%d", id); + hdev->id = id; + + BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); diff --git a/queue-4.9/mmc-rtsx-add-74-clocks-in-power-on-flow.patch b/queue-4.9/mmc-rtsx-add-74-clocks-in-power-on-flow.patch new file mode 100644 index 00000000000..734b9486cf1 --- /dev/null +++ b/queue-4.9/mmc-rtsx-add-74-clocks-in-power-on-flow.patch @@ -0,0 +1,112 @@ +From 1f311c94aabdb419c28e3147bcc8ab89269f1a7e Mon Sep 17 00:00:00 2001 +From: Ricky WU +Date: Wed, 2 Mar 2022 09:43:01 +0000 +Subject: mmc: rtsx: add 74 Clocks in power on flow + +From: Ricky WU + +commit 1f311c94aabdb419c28e3147bcc8ab89269f1a7e upstream. + +SD spec definition: +"Host provides at least 74 Clocks before issuing first command" +After 1ms for the voltage stable then start issuing the Clock signals + +if POWER STATE is +MMC_POWER_OFF to MMC_POWER_UP to issue Clock signal to card +MMC_POWER_UP to MMC_POWER_ON to stop issuing signal to card + +Signed-off-by: Ricky Wu +Link: https://lore.kernel.org/r/1badf10aba764191a1a752edcbf90389@realtek.com +Signed-off-by: Ulf Hansson +Signed-off-by: Ricky Wu +Signed-off-by: Ulf Hansson +Signed-off-by: Christian Loehle +Signed-off-by: Greg Kroah-Hartman +--- + drivers/mmc/host/rtsx_pci_sdmmc.c | 30 ++++++++++++++++++++---------- + 1 file changed, 20 insertions(+), 10 deletions(-) + +--- a/drivers/mmc/host/rtsx_pci_sdmmc.c ++++ b/drivers/mmc/host/rtsx_pci_sdmmc.c +@@ -49,10 +49,7 @@ struct realtek_pci_sdmmc { + bool double_clk; + bool eject; + bool initial_mode; +- int power_state; +-#define SDMMC_POWER_ON 1 +-#define SDMMC_POWER_OFF 0 +- ++ int prev_power_state; + int sg_count; + s32 cookie; + int cookie_sg_count; +@@ -914,14 +911,21 @@ static int sd_set_bus_width(struct realt + return err; + } + +-static int sd_power_on(struct realtek_pci_sdmmc *host) ++static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power_mode) + { + struct rtsx_pcr *pcr = host->pcr; + int err; + +- if (host->power_state == SDMMC_POWER_ON) ++ if (host->prev_power_state == MMC_POWER_ON) + return 0; + ++ if (host->prev_power_state == MMC_POWER_UP) { ++ rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0); ++ goto finish; ++ } ++ ++ msleep(100); ++ + rtsx_pci_init_cmd(pcr); + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_SELECT, 0x07, SD_MOD_SEL); + rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_SHARE_MODE, +@@ -940,11 +944,17 @@ static int sd_power_on(struct realtek_pc + if (err < 0) + return err; + ++ mdelay(1); ++ + err = rtsx_pci_write_register(pcr, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN); + if (err < 0) + return err; + +- host->power_state = SDMMC_POWER_ON; ++ /* send at least 74 clocks */ ++ rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, SD_CLK_TOGGLE_EN); ++ ++finish: ++ host->prev_power_state = power_mode; + return 0; + } + +@@ -953,7 +963,7 @@ static int sd_power_off(struct realtek_p + struct rtsx_pcr *pcr = host->pcr; + int err; + +- host->power_state = SDMMC_POWER_OFF; ++ host->prev_power_state = MMC_POWER_OFF; + + rtsx_pci_init_cmd(pcr); + +@@ -979,7 +989,7 @@ static int sd_set_power_mode(struct real + if (power_mode == MMC_POWER_OFF) + err = sd_power_off(host); + else +- err = sd_power_on(host); ++ err = sd_power_on(host, power_mode); + + return err; + } +@@ -1417,7 +1427,7 @@ static int rtsx_pci_sdmmc_drv_probe(stru + host->mmc = mmc; + host->pdev = pdev; + host->cookie = -1; +- host->power_state = SDMMC_POWER_OFF; ++ host->prev_power_state = MMC_POWER_OFF; + INIT_WORK(&host->work, sd_request); + platform_set_drvdata(pdev, host); + pcr->slots[RTSX_SD_CARD].p_dev = pdev; diff --git a/queue-4.9/series b/queue-4.9/series index 6b0f684d671..299b200b5aa 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -2,3 +2,5 @@ mips-use-address-of-operator-on-section-symbols.patch block-drbd-drbd_nl-make-conversion-to-enum-drbd_ret_code-explicit.patch can-grcan-grcan_probe-fix-broken-system-id-check-for-errata-workaround-needs.patch can-grcan-only-use-the-napi-poll-budget-for-rx.patch +bluetooth-fix-the-creation-of-hdev-name.patch +mmc-rtsx-add-74-clocks-in-power-on-flow.patch