From c8762b5ad95b6553915329caa6c95cd15d11a8e1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 22 Jan 2024 12:25:07 -0800 Subject: [PATCH] 5.4-stable patches added patches: hid-wacom-correct-behavior-when-processing-some-confidence-false-touches.patch serial-sc16is7xx-add-check-for-unsupported-spi-modes-during-probe.patch serial-sc16is7xx-set-safe-default-spi-clock-frequency.patch wifi-mwifiex-configure-bssid-consistently-when-starting-ap.patch wifi-rtlwifi-convert-lnkctl-change-to-pcie-cap-rmw-accessors.patch wifi-rtlwifi-remove-bogus-and-dangerous-aspm-disable-enable-code.patch x86-kvm-do-not-try-to-disable-kvmclock-if-it-was-not-enabled.patch --- ...essing-some-confidence-false-touches.patch | 103 ++++++++++ ...r-unsupported-spi-modes-during-probe.patch | 49 +++++ ...set-safe-default-spi-clock-frequency.patch | 44 +++++ queue-5.4/series | 7 + ...-bssid-consistently-when-starting-ap.patch | 90 +++++++++ ...ctl-change-to-pcie-cap-rmw-accessors.patch | 78 ++++++++ ...d-dangerous-aspm-disable-enable-code.patch | 183 ++++++++++++++++++ ...sable-kvmclock-if-it-was-not-enabled.patch | 70 +++++++ 8 files changed, 624 insertions(+) create mode 100644 queue-5.4/hid-wacom-correct-behavior-when-processing-some-confidence-false-touches.patch create mode 100644 queue-5.4/serial-sc16is7xx-add-check-for-unsupported-spi-modes-during-probe.patch create mode 100644 queue-5.4/serial-sc16is7xx-set-safe-default-spi-clock-frequency.patch create mode 100644 queue-5.4/wifi-mwifiex-configure-bssid-consistently-when-starting-ap.patch create mode 100644 queue-5.4/wifi-rtlwifi-convert-lnkctl-change-to-pcie-cap-rmw-accessors.patch create mode 100644 queue-5.4/wifi-rtlwifi-remove-bogus-and-dangerous-aspm-disable-enable-code.patch create mode 100644 queue-5.4/x86-kvm-do-not-try-to-disable-kvmclock-if-it-was-not-enabled.patch diff --git a/queue-5.4/hid-wacom-correct-behavior-when-processing-some-confidence-false-touches.patch b/queue-5.4/hid-wacom-correct-behavior-when-processing-some-confidence-false-touches.patch new file mode 100644 index 00000000000..fb89e9bece1 --- /dev/null +++ b/queue-5.4/hid-wacom-correct-behavior-when-processing-some-confidence-false-touches.patch @@ -0,0 +1,103 @@ +From 502296030ec6b0329e00f9fb15018e170cc63037 Mon Sep 17 00:00:00 2001 +From: Jason Gerecke +Date: Tue, 19 Dec 2023 13:33:43 -0800 +Subject: HID: wacom: Correct behavior when processing some confidence == false touches + +From: Jason Gerecke + +commit 502296030ec6b0329e00f9fb15018e170cc63037 upstream. + +There appear to be a few different ways that Wacom devices can deal with +confidence: + + 1. If the device looses confidence in a touch, it will first clear + the tipswitch flag in one report, and then clear the confidence + flag in a second report. This behavior is used by e.g. DTH-2452. + + 2. If the device looses confidence in a touch, it will clear both + the tipswitch and confidence flags within the same report. This + behavior is used by some AES devices. + + 3. If the device looses confidence in a touch, it will clear *only* + the confidence bit. The tipswitch bit will remain set so long as + the touch is tracked. This behavior may be used in future devices. + +The driver does not currently handle situation 3 properly. Touches that +loose confidence will remain "in prox" and essentially frozen in place +until the tipswitch bit is finally cleared. Not only does this result +in userspace seeing a stuck touch, but it also prevents pen arbitration +from working properly (the pen won't send events until all touches are +up, but we don't currently process events from non-confident touches). + +This commit centralizes the checking of the confidence bit in the +wacom_wac_finger_slot() function and has 'prox' depend on it. In the +case where situation 3 is encountered, the treat the touch as though +it was removed, allowing both userspace and the pen arbitration to +act normally. + +Signed-off-by: Tatsunosuke Tobita +Signed-off-by: Ping Cheng +Signed-off-by: Jason Gerecke +Fixes: 7fb0413baa7f ("HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts") +Cc: stable@vger.kernel.org +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman +--- + drivers/hid/wacom_wac.c | 32 ++++---------------------------- + 1 file changed, 4 insertions(+), 28 deletions(-) + +--- a/drivers/hid/wacom_wac.c ++++ b/drivers/hid/wacom_wac.c +@@ -2612,8 +2612,8 @@ static void wacom_wac_finger_slot(struct + { + struct hid_data *hid_data = &wacom_wac->hid_data; + bool mt = wacom_wac->features.touch_max > 1; +- bool prox = hid_data->tipswitch && +- report_touch_events(wacom_wac); ++ bool touch_down = hid_data->tipswitch && hid_data->confidence; ++ bool prox = touch_down && report_touch_events(wacom_wac); + + if (wacom_wac->shared->has_mute_touch_switch && + !wacom_wac->shared->is_touch_on) { +@@ -2652,24 +2652,6 @@ static void wacom_wac_finger_slot(struct + } + } + +-static bool wacom_wac_slot_is_active(struct input_dev *dev, int key) +-{ +- struct input_mt *mt = dev->mt; +- struct input_mt_slot *s; +- +- if (!mt) +- return false; +- +- for (s = mt->slots; s != mt->slots + mt->num_slots; s++) { +- if (s->key == key && +- input_mt_get_value(s, ABS_MT_TRACKING_ID) >= 0) { +- return true; +- } +- } +- +- return false; +-} +- + static void wacom_wac_finger_event(struct hid_device *hdev, + struct hid_field *field, struct hid_usage *usage, __s32 value) + { +@@ -2717,14 +2699,8 @@ static void wacom_wac_finger_event(struc + } + + if (usage->usage_index + 1 == field->report_count) { +- if (equivalent_usage == wacom_wac->hid_data.last_slot_field) { +- bool touch_removed = wacom_wac_slot_is_active(wacom_wac->touch_input, +- wacom_wac->hid_data.id) && !wacom_wac->hid_data.tipswitch; +- +- if (wacom_wac->hid_data.confidence || touch_removed) { +- wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input); +- } +- } ++ if (equivalent_usage == wacom_wac->hid_data.last_slot_field) ++ wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input); + } + } + diff --git a/queue-5.4/serial-sc16is7xx-add-check-for-unsupported-spi-modes-during-probe.patch b/queue-5.4/serial-sc16is7xx-add-check-for-unsupported-spi-modes-during-probe.patch new file mode 100644 index 00000000000..0bd40f059e5 --- /dev/null +++ b/queue-5.4/serial-sc16is7xx-add-check-for-unsupported-spi-modes-during-probe.patch @@ -0,0 +1,49 @@ +From 6d710b769c1f5f0d55c9ad9bb49b7dce009ec103 Mon Sep 17 00:00:00 2001 +From: Hugo Villeneuve +Date: Thu, 21 Dec 2023 18:18:09 -0500 +Subject: serial: sc16is7xx: add check for unsupported SPI modes during probe + +From: Hugo Villeneuve + +commit 6d710b769c1f5f0d55c9ad9bb49b7dce009ec103 upstream. + +The original comment is confusing because it implies that variants other +than the SC16IS762 supports other SPI modes beside SPI_MODE_0. + +Extract from datasheet: + The SC16IS762 differs from the SC16IS752 in that it supports SPI clock + speeds up to 15 Mbit/s instead of the 4 Mbit/s supported by the + SC16IS752... In all other aspects, the SC16IS762 is functionally and + electrically the same as the SC16IS752. + +The same is also true of the SC16IS760 variant versus the SC16IS740 and +SC16IS750 variants. + +For all variants, only SPI mode 0 is supported. + +Change comment and abort probing if the specified SPI mode is not +SPI_MODE_0. + +Fixes: 2c837a8a8f9f ("sc16is7xx: spi interface is added") +Cc: +Signed-off-by: Hugo Villeneuve +Link: https://lore.kernel.org/r/20231221231823.2327894-3-hugo@hugovil.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/sc16is7xx.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/tty/serial/sc16is7xx.c ++++ b/drivers/tty/serial/sc16is7xx.c +@@ -1412,7 +1412,10 @@ static int sc16is7xx_spi_probe(struct sp + + /* Setup SPI bus */ + spi->bits_per_word = 8; +- /* only supports mode 0 on SC16IS762 */ ++ /* For all variants, only mode 0 is supported */ ++ if ((spi->mode & SPI_MODE_X_MASK) != SPI_MODE_0) ++ return dev_err_probe(&spi->dev, -EINVAL, "Unsupported SPI mode\n"); ++ + spi->mode = spi->mode ? : SPI_MODE_0; + spi->max_speed_hz = spi->max_speed_hz ? : 15000000; + ret = spi_setup(spi); diff --git a/queue-5.4/serial-sc16is7xx-set-safe-default-spi-clock-frequency.patch b/queue-5.4/serial-sc16is7xx-set-safe-default-spi-clock-frequency.patch new file mode 100644 index 00000000000..ccfd63dd85f --- /dev/null +++ b/queue-5.4/serial-sc16is7xx-set-safe-default-spi-clock-frequency.patch @@ -0,0 +1,44 @@ +From 3ef79cd1412236d884ab0c46b4d1921380807b48 Mon Sep 17 00:00:00 2001 +From: Hugo Villeneuve +Date: Thu, 21 Dec 2023 18:18:10 -0500 +Subject: serial: sc16is7xx: set safe default SPI clock frequency + +From: Hugo Villeneuve + +commit 3ef79cd1412236d884ab0c46b4d1921380807b48 upstream. + +15 MHz is supported only by 76x variants. + +If the SPI clock frequency is not specified, use a safe default clock value +of 4 MHz that is supported by all variants. + +Also use HZ_PER_MHZ macro to improve readability. + +Fixes: 2c837a8a8f9f ("sc16is7xx: spi interface is added") +Cc: +Signed-off-by: Hugo Villeneuve +Link: https://lore.kernel.org/r/20231221231823.2327894-4-hugo@hugovil.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/tty/serial/sc16is7xx.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/tty/serial/sc16is7xx.c ++++ b/drivers/tty/serial/sc16is7xx.c +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include + #include + + #define SC16IS7XX_NAME "sc16is7xx" +@@ -1417,7 +1418,7 @@ static int sc16is7xx_spi_probe(struct sp + return dev_err_probe(&spi->dev, -EINVAL, "Unsupported SPI mode\n"); + + spi->mode = spi->mode ? : SPI_MODE_0; +- spi->max_speed_hz = spi->max_speed_hz ? : 15000000; ++ spi->max_speed_hz = spi->max_speed_hz ? : 4 * HZ_PER_MHZ; + ret = spi_setup(spi); + if (ret) + return ret; diff --git a/queue-5.4/series b/queue-5.4/series index 20ac2922b49..af8d36f6453 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -155,3 +155,10 @@ usb-mon-fix-atomicity-violation-in-mon_bin_vma_fault.patch alsa-oxygen-fix-right-channel-of-capture-volume-mixer.patch fbdev-flush-deferred-work-in-fb_deferred_io_fsync.patch rootfs-fix-support-for-rootfstype-when-root-is-given.patch +wifi-rtlwifi-remove-bogus-and-dangerous-aspm-disable-enable-code.patch +wifi-rtlwifi-convert-lnkctl-change-to-pcie-cap-rmw-accessors.patch +wifi-mwifiex-configure-bssid-consistently-when-starting-ap.patch +x86-kvm-do-not-try-to-disable-kvmclock-if-it-was-not-enabled.patch +hid-wacom-correct-behavior-when-processing-some-confidence-false-touches.patch +serial-sc16is7xx-add-check-for-unsupported-spi-modes-during-probe.patch +serial-sc16is7xx-set-safe-default-spi-clock-frequency.patch diff --git a/queue-5.4/wifi-mwifiex-configure-bssid-consistently-when-starting-ap.patch b/queue-5.4/wifi-mwifiex-configure-bssid-consistently-when-starting-ap.patch new file mode 100644 index 00000000000..9232be846a2 --- /dev/null +++ b/queue-5.4/wifi-mwifiex-configure-bssid-consistently-when-starting-ap.patch @@ -0,0 +1,90 @@ +From f0dd488e11e71ac095df7638d892209c629d9af2 Mon Sep 17 00:00:00 2001 +From: David Lin +Date: Fri, 15 Dec 2023 08:51:18 +0800 +Subject: wifi: mwifiex: configure BSSID consistently when starting AP + +From: David Lin + +commit f0dd488e11e71ac095df7638d892209c629d9af2 upstream. + +AP BSSID configuration is missing at AP start. Without this fix, FW returns +STA interface MAC address after first init. When hostapd restarts, it gets MAC +address from netdev before driver sets STA MAC to netdev again. Now MAC address +between hostapd and net interface are different causes STA cannot connect to +AP. After that MAC address of uap0 mlan0 become the same. And issue disappears +after following hostapd restart (another issue is AP/STA MAC address become the +same). + +This patch fixes the issue cleanly. + +Signed-off-by: David Lin +Fixes: 12190c5d80bd ("mwifiex: add cfg80211 start_ap and stop_ap handlers") +Cc: stable@vger.kernel.org +Reviewed-by: Francesco Dolcini +Tested-by: Rafael Beims # Verdin iMX8MP/SD8997 SD +Acked-by: Brian Norris +Signed-off-by: Kalle Valo +Link: https://msgid.link/20231215005118.17031-1-yu-hao.lin@nxp.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/wireless/marvell/mwifiex/cfg80211.c | 2 ++ + drivers/net/wireless/marvell/mwifiex/fw.h | 1 + + drivers/net/wireless/marvell/mwifiex/ioctl.h | 1 + + drivers/net/wireless/marvell/mwifiex/uap_cmd.c | 8 ++++++++ + 4 files changed, 12 insertions(+) + +--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c ++++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c +@@ -1984,6 +1984,8 @@ static int mwifiex_cfg80211_start_ap(str + + mwifiex_set_sys_config_invalid_data(bss_cfg); + ++ memcpy(bss_cfg->mac_addr, priv->curr_addr, ETH_ALEN); ++ + if (params->beacon_interval) + bss_cfg->beacon_period = params->beacon_interval; + if (params->dtim_period) +--- a/drivers/net/wireless/marvell/mwifiex/fw.h ++++ b/drivers/net/wireless/marvell/mwifiex/fw.h +@@ -177,6 +177,7 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { + #define TLV_TYPE_STA_MAC_ADDR (PROPRIETARY_TLV_BASE_ID + 32) + #define TLV_TYPE_BSSID (PROPRIETARY_TLV_BASE_ID + 35) + #define TLV_TYPE_CHANNELBANDLIST (PROPRIETARY_TLV_BASE_ID + 42) ++#define TLV_TYPE_UAP_MAC_ADDRESS (PROPRIETARY_TLV_BASE_ID + 43) + #define TLV_TYPE_UAP_BEACON_PERIOD (PROPRIETARY_TLV_BASE_ID + 44) + #define TLV_TYPE_UAP_DTIM_PERIOD (PROPRIETARY_TLV_BASE_ID + 45) + #define TLV_TYPE_UAP_BCAST_SSID (PROPRIETARY_TLV_BASE_ID + 48) +--- a/drivers/net/wireless/marvell/mwifiex/ioctl.h ++++ b/drivers/net/wireless/marvell/mwifiex/ioctl.h +@@ -119,6 +119,7 @@ struct mwifiex_uap_bss_param { + u8 qos_info; + u8 power_constraint; + struct mwifiex_types_wmm_info wmm_info; ++ u8 mac_addr[ETH_ALEN]; + }; + + enum { +--- a/drivers/net/wireless/marvell/mwifiex/uap_cmd.c ++++ b/drivers/net/wireless/marvell/mwifiex/uap_cmd.c +@@ -479,6 +479,7 @@ void mwifiex_config_uap_11d(struct mwifi + static int + mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size) + { ++ struct host_cmd_tlv_mac_addr *mac_tlv; + struct host_cmd_tlv_dtim_period *dtim_period; + struct host_cmd_tlv_beacon_period *beacon_period; + struct host_cmd_tlv_ssid *ssid; +@@ -498,6 +499,13 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, v + int i; + u16 cmd_size = *param_size; + ++ mac_tlv = (struct host_cmd_tlv_mac_addr *)tlv; ++ mac_tlv->header.type = cpu_to_le16(TLV_TYPE_UAP_MAC_ADDRESS); ++ mac_tlv->header.len = cpu_to_le16(ETH_ALEN); ++ memcpy(mac_tlv->mac_addr, bss_cfg->mac_addr, ETH_ALEN); ++ cmd_size += sizeof(struct host_cmd_tlv_mac_addr); ++ tlv += sizeof(struct host_cmd_tlv_mac_addr); ++ + if (bss_cfg->ssid.ssid_len) { + ssid = (struct host_cmd_tlv_ssid *)tlv; + ssid->header.type = cpu_to_le16(TLV_TYPE_UAP_SSID); diff --git a/queue-5.4/wifi-rtlwifi-convert-lnkctl-change-to-pcie-cap-rmw-accessors.patch b/queue-5.4/wifi-rtlwifi-convert-lnkctl-change-to-pcie-cap-rmw-accessors.patch new file mode 100644 index 00000000000..b450d6e6088 --- /dev/null +++ b/queue-5.4/wifi-rtlwifi-convert-lnkctl-change-to-pcie-cap-rmw-accessors.patch @@ -0,0 +1,78 @@ +From 5894d0089cbc146063dcc0239a78ede0a8142efb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= +Date: Fri, 24 Nov 2023 10:47:17 +0200 +Subject: wifi: rtlwifi: Convert LNKCTL change to PCIe cap RMW accessors +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilpo Järvinen + +commit 5894d0089cbc146063dcc0239a78ede0a8142efb upstream. + +The rtlwifi driver comes with custom code to write into PCIe Link +Control register. RMW access for the Link Control register requires +locking that is already provided by the standard PCIe capability +accessors. + +Convert the custom RMW code writing into LNKCTL register to standard +RMW capability accessors. The accesses are changed to cover the full +LNKCTL register instead of touching just a single byte of the register. + +Fixes: 0c8173385e54 ("rtl8192ce: Add new driver") +Cc: stable@vger.kernel.org +Signed-off-by: Ilpo Järvinen +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20231124084725.12738-3-ilpo.jarvinen@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/wireless/realtek/rtlwifi/pci.c | 21 +++++++++++++++------ + 1 file changed, 15 insertions(+), 6 deletions(-) + +--- a/drivers/net/wireless/realtek/rtlwifi/pci.c ++++ b/drivers/net/wireless/realtek/rtlwifi/pci.c +@@ -164,21 +164,29 @@ static bool _rtl_pci_platform_switch_dev + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + ++ value &= PCI_EXP_LNKCTL_ASPMC; ++ + if (rtlhal->hw_type != HARDWARE_TYPE_RTL8192SE) +- value |= 0x40; ++ value |= PCI_EXP_LNKCTL_CCC; + +- pci_write_config_byte(rtlpci->pdev, 0x80, value); ++ pcie_capability_clear_and_set_word(rtlpci->pdev, PCI_EXP_LNKCTL, ++ PCI_EXP_LNKCTL_ASPMC | value, ++ value); + + return false; + } + +-/*When we set 0x01 to enable clk request. Set 0x0 to disable clk req.*/ +-static void _rtl_pci_switch_clk_req(struct ieee80211_hw *hw, u8 value) ++/* @value is PCI_EXP_LNKCTL_CLKREQ_EN or 0 to enable/disable clk request. */ ++static void _rtl_pci_switch_clk_req(struct ieee80211_hw *hw, u16 value) + { + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + +- pci_write_config_byte(rtlpci->pdev, 0x81, value); ++ value &= PCI_EXP_LNKCTL_CLKREQ_EN; ++ ++ pcie_capability_clear_and_set_word(rtlpci->pdev, PCI_EXP_LNKCTL, ++ PCI_EXP_LNKCTL_CLKREQ_EN, ++ value); + + if (rtlhal->hw_type == HARDWARE_TYPE_RTL8192SE) + udelay(100); +@@ -259,7 +267,8 @@ static void rtl_pci_enable_aspm(struct i + + if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_CLK_REQ) { + _rtl_pci_switch_clk_req(hw, (ppsc->reg_rfps_level & +- RT_RF_OFF_LEVL_CLK_REQ) ? 1 : 0); ++ RT_RF_OFF_LEVL_CLK_REQ) ? ++ PCI_EXP_LNKCTL_CLKREQ_EN : 0); + RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_CLK_REQ); + } + udelay(100); diff --git a/queue-5.4/wifi-rtlwifi-remove-bogus-and-dangerous-aspm-disable-enable-code.patch b/queue-5.4/wifi-rtlwifi-remove-bogus-and-dangerous-aspm-disable-enable-code.patch new file mode 100644 index 00000000000..25112083b6e --- /dev/null +++ b/queue-5.4/wifi-rtlwifi-remove-bogus-and-dangerous-aspm-disable-enable-code.patch @@ -0,0 +1,183 @@ +From b3943b3c2971444364e03224cfc828c5789deada Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= +Date: Fri, 24 Nov 2023 10:47:16 +0200 +Subject: wifi: rtlwifi: Remove bogus and dangerous ASPM disable/enable code +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ilpo Järvinen + +commit b3943b3c2971444364e03224cfc828c5789deada upstream. + +Ever since introduction in the commit 0c8173385e54 ("rtl8192ce: Add new +driver") the rtlwifi code has, according to comments, attempted to +disable/enable ASPM of the upstream bridge by writing into its LNKCTL +register. However, the code has never been correct because it performs +the writes to the device instead of the upstream bridge. + +Worse yet, the offset where the PCIe capabilities reside is derived +from the offset of the upstream bridge. As a result, the write will use +an offset on the device that does not relate to the LNKCTL register +making the ASPM disable/enable code outright dangerous. + +Because of those problems, there is no indication that the driver needs +disable/enable ASPM on the upstream bridge. As the Capabilities offset +is not correctly calculated for the write to target device's LNKCTL +register, the code is not disabling/enabling device's ASPM either. +Therefore, just remove the upstream bridge related ASPM disable/enable +code entirely. + +The upstream bridge related ASPM code was the only user of the struct +mp_adapter members num4bytes, pcibridge_pciehdr_offset, and +pcibridge_linkctrlreg so those are removed as well. + +Note: This change does not remove the code related to changing the +device's ASPM on purpose (which is independent of this flawed code +related to upstream bridge's ASPM). + +Suggested-by: Bjorn Helgaas +Fixes: 0c8173385e54 ("rtl8192ce: Add new driver") +Fixes: 886e14b65a8f ("rtlwifi: Eliminate raw reads and writes from PCIe portion") +Cc: stable@vger.kernel.org +Signed-off-by: Ilpo Järvinen +Signed-off-by: Kalle Valo +Link: https://lore.kernel.org/r/20231124084725.12738-2-ilpo.jarvinen@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/wireless/realtek/rtlwifi/pci.c | 58 ----------------------------- + drivers/net/wireless/realtek/rtlwifi/pci.h | 5 -- + 2 files changed, 1 insertion(+), 62 deletions(-) + +--- a/drivers/net/wireless/realtek/rtlwifi/pci.c ++++ b/drivers/net/wireless/realtek/rtlwifi/pci.c +@@ -192,11 +192,8 @@ static void rtl_pci_disable_aspm(struct + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor; +- u8 num4bytes = pcipriv->ndis_adapter.num4bytes; + /*Retrieve original configuration settings. */ + u8 linkctrl_reg = pcipriv->ndis_adapter.linkctrl_reg; +- u16 pcibridge_linkctrlreg = pcipriv->ndis_adapter. +- pcibridge_linkctrlreg; + u16 aspmlevel = 0; + u8 tmp_u1b = 0; + +@@ -221,16 +218,8 @@ static void rtl_pci_disable_aspm(struct + /*Set corresponding value. */ + aspmlevel |= BIT(0) | BIT(1); + linkctrl_reg &= ~aspmlevel; +- pcibridge_linkctrlreg &= ~(BIT(0) | BIT(1)); + + _rtl_pci_platform_switch_device_pci_aspm(hw, linkctrl_reg); +- udelay(50); +- +- /*4 Disable Pci Bridge ASPM */ +- pci_write_config_byte(rtlpci->pdev, (num4bytes << 2), +- pcibridge_linkctrlreg); +- +- udelay(50); + } + + /*Enable RTL8192SE ASPM & Enable Pci Bridge ASPM for +@@ -245,9 +234,7 @@ static void rtl_pci_enable_aspm(struct i + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); + struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); + u8 pcibridge_vendor = pcipriv->ndis_adapter.pcibridge_vendor; +- u8 num4bytes = pcipriv->ndis_adapter.num4bytes; + u16 aspmlevel; +- u8 u_pcibridge_aspmsetting; + u8 u_device_aspmsetting; + + if (!ppsc->support_aspm) +@@ -259,25 +246,6 @@ static void rtl_pci_enable_aspm(struct i + return; + } + +- /*4 Enable Pci Bridge ASPM */ +- +- u_pcibridge_aspmsetting = +- pcipriv->ndis_adapter.pcibridge_linkctrlreg | +- rtlpci->const_hostpci_aspm_setting; +- +- if (pcibridge_vendor == PCI_BRIDGE_VENDOR_INTEL) +- u_pcibridge_aspmsetting &= ~BIT(0); +- +- pci_write_config_byte(rtlpci->pdev, (num4bytes << 2), +- u_pcibridge_aspmsetting); +- +- rtl_dbg(rtlpriv, COMP_INIT, DBG_LOUD, +- "PlatformEnableASPM(): Write reg[%x] = %x\n", +- (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10), +- u_pcibridge_aspmsetting); +- +- udelay(50); +- + /*Get ASPM level (with/without Clock Req) */ + aspmlevel = rtlpci->const_devicepci_aspm_setting; + u_device_aspmsetting = pcipriv->ndis_adapter.linkctrl_reg; +@@ -359,22 +327,6 @@ static bool rtl_pci_check_buddy_priv(str + return find_buddy_priv; + } + +-static void rtl_pci_get_linkcontrol_field(struct ieee80211_hw *hw) +-{ +- struct rtl_pci_priv *pcipriv = rtl_pcipriv(hw); +- struct rtl_pci *rtlpci = rtl_pcidev(pcipriv); +- u8 capabilityoffset = pcipriv->ndis_adapter.pcibridge_pciehdr_offset; +- u8 linkctrl_reg; +- u8 num4bbytes; +- +- num4bbytes = (capabilityoffset + 0x10) / 4; +- +- /*Read Link Control Register */ +- pci_read_config_byte(rtlpci->pdev, (num4bbytes << 2), &linkctrl_reg); +- +- pcipriv->ndis_adapter.pcibridge_linkctrlreg = linkctrl_reg; +-} +- + static void rtl_pci_parse_configuration(struct pci_dev *pdev, + struct ieee80211_hw *hw) + { +@@ -2042,12 +1994,6 @@ static bool _rtl_pci_find_adapter(struct + PCI_SLOT(bridge_pdev->devfn); + pcipriv->ndis_adapter.pcibridge_funcnum = + PCI_FUNC(bridge_pdev->devfn); +- pcipriv->ndis_adapter.pcibridge_pciehdr_offset = +- pci_pcie_cap(bridge_pdev); +- pcipriv->ndis_adapter.num4bytes = +- (pcipriv->ndis_adapter.pcibridge_pciehdr_offset + 0x10) / 4; +- +- rtl_pci_get_linkcontrol_field(hw); + + if (pcipriv->ndis_adapter.pcibridge_vendor == + PCI_BRIDGE_VENDOR_AMD) { +@@ -2064,13 +2010,11 @@ static bool _rtl_pci_find_adapter(struct + pdev->vendor, pcipriv->ndis_adapter.linkctrl_reg); + + rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG, +- "pci_bridge busnumber:devnumber:funcnumber:vendor:pcie_cap:link_ctl_reg:amd %d:%d:%d:%x:%x:%x:%x\n", ++ "pci_bridge busnumber:devnumber:funcnumber:vendor:amd %d:%d:%d:%x:%x\n", + pcipriv->ndis_adapter.pcibridge_busnum, + pcipriv->ndis_adapter.pcibridge_devnum, + pcipriv->ndis_adapter.pcibridge_funcnum, + pcibridge_vendors[pcipriv->ndis_adapter.pcibridge_vendor], +- pcipriv->ndis_adapter.pcibridge_pciehdr_offset, +- pcipriv->ndis_adapter.pcibridge_linkctrlreg, + pcipriv->ndis_adapter.amd_l1_patch); + + rtl_pci_parse_configuration(pdev, hw); +--- a/drivers/net/wireless/realtek/rtlwifi/pci.h ++++ b/drivers/net/wireless/realtek/rtlwifi/pci.h +@@ -236,11 +236,6 @@ struct mp_adapter { + u16 pcibridge_vendorid; + u16 pcibridge_deviceid; + +- u8 num4bytes; +- +- u8 pcibridge_pciehdr_offset; +- u8 pcibridge_linkctrlreg; +- + bool amd_l1_patch; + }; + diff --git a/queue-5.4/x86-kvm-do-not-try-to-disable-kvmclock-if-it-was-not-enabled.patch b/queue-5.4/x86-kvm-do-not-try-to-disable-kvmclock-if-it-was-not-enabled.patch new file mode 100644 index 00000000000..7e61e61aa09 --- /dev/null +++ b/queue-5.4/x86-kvm-do-not-try-to-disable-kvmclock-if-it-was-not-enabled.patch @@ -0,0 +1,70 @@ +From 1c6d984f523f67ecfad1083bb04c55d91977bb15 Mon Sep 17 00:00:00 2001 +From: "Kirill A. Shutemov" +Date: Tue, 5 Dec 2023 03:45:01 +0300 +Subject: x86/kvm: Do not try to disable kvmclock if it was not enabled + +From: Kirill A. Shutemov + +commit 1c6d984f523f67ecfad1083bb04c55d91977bb15 upstream. + +kvm_guest_cpu_offline() tries to disable kvmclock regardless if it is +present in the VM. It leads to write to a MSR that doesn't exist on some +configurations, namely in TDX guest: + + unchecked MSR access error: WRMSR to 0x12 (tried to write 0x0000000000000000) + at rIP: 0xffffffff8110687c (kvmclock_disable+0x1c/0x30) + +kvmclock enabling is gated by CLOCKSOURCE and CLOCKSOURCE2 KVM paravirt +features. + +Do not disable kvmclock if it was not enabled. + +Signed-off-by: Kirill A. Shutemov +Fixes: c02027b5742b ("x86/kvm: Disable kvmclock on all CPUs on shutdown") +Reviewed-by: Sean Christopherson +Reviewed-by: Vitaly Kuznetsov +Cc: Paolo Bonzini +Cc: Wanpeng Li +Cc: stable@vger.kernel.org +Message-Id: <20231205004510.27164-6-kirill.shutemov@linux.intel.com> +Signed-off-by: Paolo Bonzini +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/kernel/kvmclock.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +--- a/arch/x86/kernel/kvmclock.c ++++ b/arch/x86/kernel/kvmclock.c +@@ -24,8 +24,8 @@ + + static int kvmclock __initdata = 1; + static int kvmclock_vsyscall __initdata = 1; +-static int msr_kvm_system_time __ro_after_init = MSR_KVM_SYSTEM_TIME; +-static int msr_kvm_wall_clock __ro_after_init = MSR_KVM_WALL_CLOCK; ++static int msr_kvm_system_time __ro_after_init; ++static int msr_kvm_wall_clock __ro_after_init; + static u64 kvm_sched_clock_offset __ro_after_init; + + static int __init parse_no_kvmclock(char *arg) +@@ -189,7 +189,8 @@ static void kvm_setup_secondary_clock(vo + + void kvmclock_disable(void) + { +- native_write_msr(msr_kvm_system_time, 0, 0); ++ if (msr_kvm_system_time) ++ native_write_msr(msr_kvm_system_time, 0, 0); + } + + static void __init kvmclock_init_mem(void) +@@ -286,7 +287,10 @@ void __init kvmclock_init(void) + if (kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE2)) { + msr_kvm_system_time = MSR_KVM_SYSTEM_TIME_NEW; + msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK_NEW; +- } else if (!kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE)) { ++ } else if (kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE)) { ++ msr_kvm_system_time = MSR_KVM_SYSTEM_TIME; ++ msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK; ++ } else { + return; + } + -- 2.47.3