]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jan 2024 20:24:34 +0000 (12:24 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jan 2024 20:24:34 +0000 (12:24 -0800)
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

queue-4.19/hid-wacom-correct-behavior-when-processing-some-confidence-false-touches.patch [new file with mode: 0644]
queue-4.19/serial-sc16is7xx-add-check-for-unsupported-spi-modes-during-probe.patch [new file with mode: 0644]
queue-4.19/serial-sc16is7xx-set-safe-default-spi-clock-frequency.patch [new file with mode: 0644]
queue-4.19/series
queue-4.19/wifi-mwifiex-configure-bssid-consistently-when-starting-ap.patch [new file with mode: 0644]
queue-4.19/wifi-rtlwifi-convert-lnkctl-change-to-pcie-cap-rmw-accessors.patch [new file with mode: 0644]
queue-4.19/wifi-rtlwifi-remove-bogus-and-dangerous-aspm-disable-enable-code.patch [new file with mode: 0644]

diff --git a/queue-4.19/hid-wacom-correct-behavior-when-processing-some-confidence-false-touches.patch b/queue-4.19/hid-wacom-correct-behavior-when-processing-some-confidence-false-touches.patch
new file mode 100644 (file)
index 0000000..90d46ec
--- /dev/null
@@ -0,0 +1,103 @@
+From 502296030ec6b0329e00f9fb15018e170cc63037 Mon Sep 17 00:00:00 2001
+From: Jason Gerecke <jason.gerecke@wacom.com>
+Date: Tue, 19 Dec 2023 13:33:43 -0800
+Subject: HID: wacom: Correct behavior when processing some confidence == false touches
+
+From: Jason Gerecke <jason.gerecke@wacom.com>
+
+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 <tatsunosuke.tobita@wacom.com>
+Signed-off-by: Ping Cheng <ping.cheng@wacom.com>
+Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
+Fixes: 7fb0413baa7f ("HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts")
+Cc: stable@vger.kernel.org
+Signed-off-by: Jiri Kosina <jkosina@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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
+@@ -2533,8 +2533,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) {
+@@ -2573,24 +2573,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)
+ {
+@@ -2633,14 +2615,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-4.19/serial-sc16is7xx-add-check-for-unsupported-spi-modes-during-probe.patch b/queue-4.19/serial-sc16is7xx-add-check-for-unsupported-spi-modes-during-probe.patch
new file mode 100644 (file)
index 0000000..1508a8a
--- /dev/null
@@ -0,0 +1,49 @@
+From 6d710b769c1f5f0d55c9ad9bb49b7dce009ec103 Mon Sep 17 00:00:00 2001
+From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
+Date: Thu, 21 Dec 2023 18:18:09 -0500
+Subject: serial: sc16is7xx: add check for unsupported SPI modes during probe
+
+From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
+
+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:  <stable@vger.kernel.org>
+Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
+Link: https://lore.kernel.org/r/20231221231823.2327894-3-hugo@hugovil.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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
+@@ -1406,7 +1406,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-4.19/serial-sc16is7xx-set-safe-default-spi-clock-frequency.patch b/queue-4.19/serial-sc16is7xx-set-safe-default-spi-clock-frequency.patch
new file mode 100644 (file)
index 0000000..d798f25
--- /dev/null
@@ -0,0 +1,44 @@
+From 3ef79cd1412236d884ab0c46b4d1921380807b48 Mon Sep 17 00:00:00 2001
+From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
+Date: Thu, 21 Dec 2023 18:18:10 -0500
+Subject: serial: sc16is7xx: set safe default SPI clock frequency
+
+From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
+
+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:  <stable@vger.kernel.org>
+Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
+Link: https://lore.kernel.org/r/20231221231823.2327894-4-hugo@hugovil.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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 <linux/tty_flip.h>
+ #include <linux/spi/spi.h>
+ #include <linux/uaccess.h>
++#include <linux/units.h>
+ #include <uapi/linux/sched/types.h>
+ #define SC16IS7XX_NAME                        "sc16is7xx"
+@@ -1411,7 +1412,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;
index cd1807757d974d55477b91ef3a951c6bebfecc94..d4235e77b7c9a619e5a5b023e51bcf289413256a 100644 (file)
@@ -126,3 +126,9 @@ usb-typec-class-fix-typec_altmode_put_partner-to-put-plugs.patch
 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
+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
+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-4.19/wifi-mwifiex-configure-bssid-consistently-when-starting-ap.patch b/queue-4.19/wifi-mwifiex-configure-bssid-consistently-when-starting-ap.patch
new file mode 100644 (file)
index 0000000..7eadfdd
--- /dev/null
@@ -0,0 +1,90 @@
+From f0dd488e11e71ac095df7638d892209c629d9af2 Mon Sep 17 00:00:00 2001
+From: David Lin <yu-hao.lin@nxp.com>
+Date: Fri, 15 Dec 2023 08:51:18 +0800
+Subject: wifi: mwifiex: configure BSSID consistently when starting AP
+
+From: David Lin <yu-hao.lin@nxp.com>
+
+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 <yu-hao.lin@nxp.com>
+Fixes: 12190c5d80bd ("mwifiex: add cfg80211 start_ap and stop_ap handlers")
+Cc: stable@vger.kernel.org
+Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
+Tested-by: Rafael Beims <rafael.beims@toradex.com> # Verdin iMX8MP/SD8997 SD
+Acked-by: Brian Norris <briannorris@chromium.org>
+Signed-off-by: Kalle Valo <kvalo@kernel.org>
+Link: https://msgid.link/20231215005118.17031-1-yu-hao.lin@nxp.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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
+@@ -1957,6 +1957,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-4.19/wifi-rtlwifi-convert-lnkctl-change-to-pcie-cap-rmw-accessors.patch b/queue-4.19/wifi-rtlwifi-convert-lnkctl-change-to-pcie-cap-rmw-accessors.patch
new file mode 100644 (file)
index 0000000..6f057ed
--- /dev/null
@@ -0,0 +1,78 @@
+From 5894d0089cbc146063dcc0239a78ede0a8142efb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>
+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 <ilpo.jarvinen@linux.intel.com>
+
+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 <ilpo.jarvinen@linux.intel.com>
+Signed-off-by: Kalle Valo <kvalo@kernel.org>
+Link: https://lore.kernel.org/r/20231124084725.12738-3-ilpo.jarvinen@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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
+@@ -186,21 +186,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);
+@@ -281,7 +289,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-4.19/wifi-rtlwifi-remove-bogus-and-dangerous-aspm-disable-enable-code.patch b/queue-4.19/wifi-rtlwifi-remove-bogus-and-dangerous-aspm-disable-enable-code.patch
new file mode 100644 (file)
index 0000000..e6993f3
--- /dev/null
@@ -0,0 +1,183 @@
+From b3943b3c2971444364e03224cfc828c5789deada Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com>
+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 <ilpo.jarvinen@linux.intel.com>
+
+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 <bhelgaas@kernel.org>
+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 <ilpo.jarvinen@linux.intel.com>
+Signed-off-by: Kalle Valo <kvalo@kernel.org>
+Link: https://lore.kernel.org/r/20231124084725.12738-2-ilpo.jarvinen@linux.intel.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ 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
+@@ -214,11 +214,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;
+@@ -243,16 +240,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
+@@ -267,9 +256,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)
+@@ -281,25 +268,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;
+@@ -381,22 +349,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)
+ {
+@@ -2063,12 +2015,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) {
+@@ -2085,13 +2031,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
+@@ -258,11 +258,6 @@ struct mp_adapter {
+       u16 pcibridge_vendorid;
+       u16 pcibridge_deviceid;
+-      u8 num4bytes;
+-
+-      u8 pcibridge_pciehdr_offset;
+-      u8 pcibridge_linkctrlreg;
+-
+       bool amd_l1_patch;
+ };