浏览代码

Update v5.9 patches

Changes:
 - SAM:
   - Retry more SAM requests on communication failure to increase
     stability.
   - Fix bug in PCI platform power state initialization preventing the
     Intel LPSS driver from loading on 7th generation Surface devices.

Links:
 - SAM: https://github.com/linux-surface/surface-aggregator-module/commit/bfab2be7d39ea51031d13215a373c9b8dcdab757
 - kernel: https://github.com/linux-surface/kernel/commit/e8470c735dc421881ae96e4189e81fc9dce8743a
Maximilian Luz 4 年之前
父节点
当前提交
c4b1d6dac4

+ 1 - 1
patches/5.9/0001-surface3-oemb.patch

@@ -1,4 +1,4 @@
-From 35b94287ce1e118cecd1636c54e0cd931b66ddf0 Mon Sep 17 00:00:00 2001
+From dadbf16bf0d1d1adb32690f7855301dbe8d7262e Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Sun, 18 Oct 2020 16:42:44 +0900
 Subject: [PATCH] (surface3-oemb) add DMI matches for Surface 3 with broken DMI

+ 12 - 12
patches/5.9/0002-wifi.patch

@@ -1,4 +1,4 @@
-From 344f5a695c99e176964c1d8e3250c8913a0863e6 Mon Sep 17 00:00:00 2001
+From 42fe2b89d9670455d396f63e5dc6dbcdf98d07c5 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Thu, 24 Sep 2020 18:02:06 +0900
 Subject: [PATCH] mwifiex: pcie: skip cancel_work_sync() on reset failure path
@@ -156,7 +156,7 @@ index fc59b522f670..048f4db6027a 100644
 -- 
 2.29.2
 
-From f856acbb4ffc08dadde43b012a0b7de8b57cd7c8 Mon Sep 17 00:00:00 2001
+From 958d23356668aba685e2b3f6d7035e616c167370 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Mon, 28 Sep 2020 17:46:49 +0900
 Subject: [PATCH] mwifiex: pcie: add DMI-based quirk impl for Surface devices
@@ -364,7 +364,7 @@ index 000000000000..5326ae7e5671
 -- 
 2.29.2
 
-From 75190ee0ec83aadac31094c92658b3b2fb60d917 Mon Sep 17 00:00:00 2001
+From c0c0073a829e6e49ce3f338a21133d1035369cc8 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Tue, 29 Sep 2020 17:25:22 +0900
 Subject: [PATCH] mwifiex: pcie: add reset_d3cold quirk for Surface gen4+
@@ -565,7 +565,7 @@ index 5326ae7e5671..8b9dcb5070d8 100644
 -- 
 2.29.2
 
-From 7678156d317fb6fe7c8630d0351d7835e159fa0d Mon Sep 17 00:00:00 2001
+From 55af2ed1ee7806cb323a0dd8665fab4b6f81f466 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Tue, 29 Sep 2020 17:32:22 +0900
 Subject: [PATCH] mwifiex: pcie: add reset_wsid quirk for Surface 3
@@ -744,7 +744,7 @@ index 8b9dcb5070d8..3ef7440418e3 100644
 -- 
 2.29.2
 
-From 3ce2a07dcc042765314049b4f2ecc67aa0c20d48 Mon Sep 17 00:00:00 2001
+From 3c71ca6ff0abd5f2e4944a261965fe99254da4e0 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Wed, 30 Sep 2020 18:08:24 +0900
 Subject: [PATCH] mwifiex: pcie: (OEMB) add quirk for Surface 3 with broken DMI
@@ -806,7 +806,7 @@ index f0a6fa0a7ae5..34dcd84f02a6 100644
 -- 
 2.29.2
 
-From b7fd7192e0791964c8dd4f9082316c2fdc903324 Mon Sep 17 00:00:00 2001
+From 292528bfec67e63a9d53b784b324497ac9d23be5 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Thu, 24 Sep 2020 01:56:29 +0900
 Subject: [PATCH] mwifiex: fix mwifiex_shutdown_sw() causing sw reset failure
@@ -883,7 +883,7 @@ index 9ee5600351a7..5965999f1b9b 100644
 -- 
 2.29.2
 
-From e810d3b79d5cb2da17313fb818c0d014160566ee Mon Sep 17 00:00:00 2001
+From 1199446441d2a1ec8a958f00597456a1b6677cde Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Thu, 24 Sep 2020 01:56:34 +0900
 Subject: [PATCH] mwifiex: pcie: use shutdown_sw()/reinit_sw() on
@@ -1025,7 +1025,7 @@ index daae572ce94e..b46d56389c3b 100644
 -- 
 2.29.2
 
-From 7b1b2992e5b48ca78e676babefe9ee8742087b2e Mon Sep 17 00:00:00 2001
+From 48633dc307a191cc6269c3a29606a5097f96ae1e Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Mon, 24 Aug 2020 17:11:35 +0900
 Subject: [PATCH] mwifiex: pcie: add enable_device_dump module parameter
@@ -1074,7 +1074,7 @@ index b46d56389c3b..1847a0274991 100644
 -- 
 2.29.2
 
-From 2135e0c6f4b0a6f8a38e467855c9950bbb066e36 Mon Sep 17 00:00:00 2001
+From 754f78890391d95f50c71cccb59e50ac7bf6516a Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Sun, 4 Oct 2020 00:11:49 +0900
 Subject: [PATCH] mwifiex: pcie: disable bridge_d3 for Surface gen4+
@@ -1229,7 +1229,7 @@ index 3ef7440418e3..a95ebac06e13 100644
 -- 
 2.29.2
 
-From 130cdeb74b99af7dcaefe2a7ac8e41d68da82c2c Mon Sep 17 00:00:00 2001
+From 1dbf4162d0c0f4cabadb29bf21fc16900f6c13d9 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Sun, 4 Oct 2020 00:25:48 +0900
 Subject: [PATCH] mwifiex: add allow_ps_mode module parameter
@@ -1291,7 +1291,7 @@ index 96848fa0e417..786f7a197613 100644
 -- 
 2.29.2
 
-From 49bb5edf570046c429f7b4c55f1225e840948f1d Mon Sep 17 00:00:00 2001
+From f0ca4ec775946c120540ef982443a07025d19e92 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Sun, 4 Oct 2020 00:38:48 +0900
 Subject: [PATCH] mwifiex: print message when changing ps_mode
@@ -1326,7 +1326,7 @@ index 786f7a197613..8f4b8bc5ff03 100644
 -- 
 2.29.2
 
-From ada5d2a04c623004cbbb6a01d02476dd2ecff07a Mon Sep 17 00:00:00 2001
+From 4239f69e8c25df6de066c20ca0731c4dbd508e17 Mon Sep 17 00:00:00 2001
 From: Tsuchiya Yuto <kitakar@gmail.com>
 Date: Sun, 4 Oct 2020 00:59:37 +0900
 Subject: [PATCH] mwifiex: disable ps_mode explicitly by default instead

+ 3 - 3
patches/5.9/0003-ipts.patch

@@ -1,4 +1,4 @@
-From 8b515545bffc2eae3dda29600ad2bc9c53216c9b Mon Sep 17 00:00:00 2001
+From ca997d3c72504065e84c1da0613fa85dded60f16 Mon Sep 17 00:00:00 2001
 From: Dorian Stoll <dorian.stoll@tmsp.io>
 Date: Fri, 25 Sep 2020 18:06:05 +0200
 Subject: [PATCH] mei: Remove client devices before shutting down
@@ -27,7 +27,7 @@ index bcee77768b91..21ed765003e1 100644
 -- 
 2.29.2
 
-From 358acad2d442d408e4ffb8dad4919dd2d39a63ff Mon Sep 17 00:00:00 2001
+From 9b2ccee8b3d6014e2a5299c46cb828352d9a2def Mon Sep 17 00:00:00 2001
 From: Dorian Stoll <dorian.stoll@tmsp.io>
 Date: Thu, 30 Jul 2020 13:21:53 +0200
 Subject: [PATCH] misc: mei: Add missing IPTS device IDs
@@ -65,7 +65,7 @@ index 1de9ef7a272b..e12484840f88 100644
 -- 
 2.29.2
 
-From 5c682c2a3ff988c14e7905935bbca3a7241920d9 Mon Sep 17 00:00:00 2001
+From 1b0d69cbca89b9b0611dc45b0dd2e03524d268c0 Mon Sep 17 00:00:00 2001
 From: Dorian Stoll <dorian.stoll@tmsp.io>
 Date: Thu, 6 Aug 2020 11:20:41 +0200
 Subject: [PATCH] misc: Add support for Intel Precise Touch & Stylus

+ 1 - 1
patches/5.9/0004-surface-gpe.patch

@@ -1,4 +1,4 @@
-From 4ebc750fed6330a867efa48c85918d2996f3d27a Mon Sep 17 00:00:00 2001
+From c48e6dbc46e67d74e563d4bb7a01c30d79cfa757 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Sun, 16 Aug 2020 23:39:56 +0200
 Subject: [PATCH] platform/x86: Add Driver to set up lid GPEs on MS Surface

+ 2 - 2
patches/5.9/0005-surface-sam-over-hid.patch

@@ -1,4 +1,4 @@
-From e127b51248880adf78caa4b2e186aa1f87cbab34 Mon Sep 17 00:00:00 2001
+From 4d30a710542ea9d1dc6ec9c04def69a9d55b2e69 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Sat, 25 Jul 2020 17:19:53 +0200
 Subject: [PATCH] i2c: acpi: Implement RawBytes read access
@@ -109,7 +109,7 @@ index 37c510d9347a..aed579942436 100644
 -- 
 2.29.2
 
-From 3d13ed4cc56176579d0f24f6d70dacf972284456 Mon Sep 17 00:00:00 2001
+From 88b355f62148d5363cc3b7f5d58770fa5d12ab40 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Sun, 6 Sep 2020 04:01:19 +0200
 Subject: [PATCH] platform/x86: Add driver for Surface Book 1 dGPU switch

+ 129 - 137
patches/5.9/0006-surface-sam.patch

@@ -1,4 +1,4 @@
-From 3846ff4b9f01b75acc4531341b2b592b10f5c40b Mon Sep 17 00:00:00 2001
+From 84fcc76b6ec6fb447d76e367695b35cce5fbea8e Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Thu, 29 Oct 2020 22:04:38 +0100
 Subject: [PATCH] PCI: Allow D3cold for hot-plug ports on Surface Books
@@ -83,90 +83,67 @@ index e39c5499770f..31d8811ee5c5 100644
 -- 
 2.29.2
 
-From f79f89f6c76cb6f50f454d833aad7314f39b744c Mon Sep 17 00:00:00 2001
+From 989461594c2a167d8292a217a05563341c792dbf Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
-Date: Sat, 31 Oct 2020 19:48:06 +0100
-Subject: [PATCH] PCI: Update platform power state when updating PCI state
+Date: Mon, 9 Nov 2020 14:23:00 +0100
+Subject: [PATCH] PCI: Run platform power transition on initial D0 entry
 
 On some devices and platforms, the initial platform power state is not
 in sync with the power state of the PCI device.
 
-Specifically, on the Surface Book 2 and 3, some ACPI power regions that
-should be "on" for the D0 state (and others) are initialized as "off" in
-ACPI, whereas the PCI device is in D0. As the state is updated in
-pci_enable_device_flags() without ensuring that the platform state is
-also updated, the power resource will never be properly turned on.
-Instead, it lives in a sort of on-but-marked-as-off zombie-state, which
-confuses things down the line when attempting to transition the device
-into D3cold: As the resource is already marked as off, it won't be
-turned off and the device does not fully enter D3cold, causing increased
-power consumption during (runtime-)suspend.
+pci_enable_device_flags() updates the state of a PCI device by reading
+from the the PCI_PM_CTRL register. This may change the stored power
+state of the device without running the appropriate platform power
+transition.
 
-Ensuring that the platform power state is in sync with the PCI power
-state when updating the latter guarantees that all required ACPI power
-regions are powered on/off in accordance with the requirements
-(specified in the ACPI _PRn fields) for the current PCI power state.
+Due to the stored power-state being changed, the later call to
+pci_set_power_state(..., PCI_D0) in do_pci_enable_device() can evaluate
+to a no-op if the stored state has been changed to D0 via that. This
+will then prevent the appropriate platform power transition to be run,
+which can on some devices and platforms lead to platform and PCI power
+state being entirely different, i.e. out-of-sync. On ACPI platforms,
+this can lead to power resources not being turned on, even though they
+are marked as required for D0.
+
+Specifically, on the Microsoft Surface Book 2 and 3, some ACPI power
+regions that should be "on" for the D0 state (and others) are
+initialized as "off" in ACPI, whereas the PCI device is in D0. As the
+state is updated in pci_enable_device_flags() without ensuring that the
+platform state is also updated, the power resource will never be
+properly turned on. Instead, it lives in a sort of on-but-marked-as-off
+zombie-state, which confuses things down the line when attempting to
+transition the device into D3cold: As the resource is already marked as
+off, it won't be turned off and the device does not fully enter D3cold,
+causing increased power consumption during (runtime-)suspend.
+
+By replacing pci_set_power_state() in do_pci_enable_device() with
+pci_power_up(), we can force pci_platform_power_transition() to be
+called, which will then check if the platform power state needs updating
+and appropriate actions need to be taken.
 
 Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
 Patchset: surface-sam
 ---
- drivers/pci/pci.c | 30 ++++++++++++++++++++++++++++--
- 1 file changed, 28 insertions(+), 2 deletions(-)
+ drivers/pci/pci.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
-index 31d8811ee5c5..8efdd71f66c4 100644
+index 31d8811ee5c5..4d652c3abae8 100644
 --- a/drivers/pci/pci.c
 +++ b/drivers/pci/pci.c
-@@ -1858,7 +1858,7 @@ static void pci_enable_bridge(struct pci_dev *dev)
- static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
- {
- 	struct pci_dev *bridge;
--	int err;
-+	int err = 0;
- 	int i, bars = 0;
+@@ -1791,7 +1791,7 @@ static int do_pci_enable_device(struct pci_dev *dev, int bars)
+ 	u16 cmd;
+ 	u8 pin;
  
- 	/*
-@@ -1868,9 +1868,35 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
- 	 * (e.g. if the device really is in D0 at enable time).
- 	 */
- 	if (dev->pm_cap) {
-+		pci_power_t current_state;
- 		u16 pmcsr;
-+
- 		pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
--		dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
-+		current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
-+
-+		/*
-+		 * On some platforms, the initial power state may not be in
-+		 * sync with the PCI power state. Specifically, on ACPI based
-+		 * platforms, power-resources for the current state may not
-+		 * have been properly enabled (or power-resources not required
-+		 * for the current state disabled) yet. Thus, ensure that the
-+		 * platform power state reflects the PCI state.
-+		 *
-+		 * Update platform state before actually setting current state
-+		 * so that it can still be accessed in platform code, if
-+		 * necessary.
-+		 */
-+		if (platform_pci_power_manageable(dev))
-+			err = platform_pci_set_power_state(dev, current_state);
-+
-+		// always update current state
-+		dev->current_state = current_state;
-+
-+		if (err) {
-+			pci_err(dev, "failed to update platform power state: %d\n",
-+				err);
-+			return err;
-+		}
- 	}
+-	err = pci_set_power_state(dev, PCI_D0);
++	err = pci_power_up(dev);
+ 	if (err < 0 && err != -EIO)
+ 		return err;
  
- 	if (atomic_inc_return(&dev->enable_cnt) > 1)
 -- 
 2.29.2
 
-From 959462f7242189d74e93803cf62547779bbd931b Mon Sep 17 00:00:00 2001
+From e2c51058cff0cf3d07661843a15985ca5fcaabe4 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Sat, 31 Oct 2020 20:46:33 +0100
 Subject: [PATCH] PCI: Add sysfs attribute for PCI device power state
@@ -239,7 +216,7 @@ index 6d78df981d41..17f186ce8e87 100644
 -- 
 2.29.2
 
-From 7772a3785ade124014c17a0bc05970f9341dc730 Mon Sep 17 00:00:00 2001
+From 7dfe04d75bc2e8384291feb37c2873c924aa4ea1 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Mon, 17 Aug 2020 01:23:20 +0200
 Subject: [PATCH] misc: surface_sam: Add file2alias support for Surface SAM
@@ -341,7 +318,7 @@ index 2417dd1dee33..a6c583362b92 100644
 -- 
 2.29.2
 
-From 7ffe090d82dbe0c8cf1a7cc1f4e5f63e94a1214a Mon Sep 17 00:00:00 2001
+From 920c67f6103567f540fe84069833051429e12a45 Mon Sep 17 00:00:00 2001
 From: Maximilian Luz <luzmaximilian@gmail.com>
 Date: Mon, 17 Aug 2020 01:44:30 +0200
 Subject: [PATCH] misc: Add support for Surface System Aggregator Module
@@ -381,12 +358,12 @@ Patchset: surface-sam
  .../clients/surface_acpi_notify.c             |  884 ++++++
  .../clients/surface_aggregator_cdev.c         |  299 ++
  .../clients/surface_aggregator_registry.c     |  656 +++++
- .../clients/surface_battery.c                 | 1195 ++++++++
- .../surface_aggregator/clients/surface_dtx.c  | 1277 ++++++++
- .../surface_aggregator/clients/surface_hid.c  |  925 ++++++
+ .../clients/surface_battery.c                 | 1192 ++++++++
+ .../surface_aggregator/clients/surface_dtx.c  | 1279 +++++++++
+ .../surface_aggregator/clients/surface_hid.c  |  922 ++++++
  .../clients/surface_hotplug.c                 |  269 ++
  .../clients/surface_perfmode.c                |  122 +
- drivers/misc/surface_aggregator/controller.c  | 2555 +++++++++++++++++
+ drivers/misc/surface_aggregator/controller.c  | 2557 +++++++++++++++++
  drivers/misc/surface_aggregator/controller.h  |  288 ++
  drivers/misc/surface_aggregator/core.c        |  831 ++++++
  drivers/misc/surface_aggregator/ssh_msgb.h    |  201 ++
@@ -399,14 +376,14 @@ Patchset: surface-sam
  drivers/misc/surface_aggregator/trace.h       |  625 ++++
  include/linux/mod_devicetable.h               |    5 +-
  include/linux/surface_acpi_notify.h           |   39 +
- include/linux/surface_aggregator/controller.h |  815 ++++++
+ include/linux/surface_aggregator/controller.h |  832 ++++++
  include/linux/surface_aggregator/device.h     |  430 +++
  include/linux/surface_aggregator/serial_hub.h |  659 +++++
  include/uapi/linux/surface_aggregator/cdev.h  |   58 +
  include/uapi/linux/surface_aggregator/dtx.h   |  150 +
  scripts/mod/devicetable-offsets.c             |    3 +-
  scripts/mod/file2alias.c                      |   10 +-
- 48 files changed, 18808 insertions(+), 7 deletions(-)
+ 48 files changed, 18823 insertions(+), 7 deletions(-)
  create mode 100644 Documentation/driver-api/surface_aggregator/client-api.rst
  create mode 100644 Documentation/driver-api/surface_aggregator/client.rst
  create mode 100644 Documentation/driver-api/surface_aggregator/clients/cdev.rst
@@ -3136,7 +3113,7 @@ index 000000000000..7320922ba755
 +obj-$(CONFIG_SURFACE_PERFMODE) 			+= surface_perfmode.o
 diff --git a/drivers/misc/surface_aggregator/clients/surface_acpi_notify.c b/drivers/misc/surface_aggregator/clients/surface_acpi_notify.c
 new file mode 100644
-index 000000000000..9010f3aafd28
+index 000000000000..7a5b8f280036
 --- /dev/null
 +++ b/drivers/misc/surface_aggregator/clients/surface_acpi_notify.c
 @@ -0,0 +1,884 @@
@@ -3728,8 +3705,8 @@ index 000000000000..9010f3aafd28
 +		return san_rqst_fixup_suspended(d, &rqst, buffer);
 +	}
 +
-+	status = ssam_retry(ssam_request_sync_onstack, SAN_REQUEST_NUM_TRIES,
-+			    d->ctrl, &rqst, &rsp, SAN_GSB_MAX_RQSX_PAYLOAD);
++	status = __ssam_retry(ssam_request_sync_onstack, SAN_REQUEST_NUM_TRIES,
++			      d->ctrl, &rqst, &rsp, SAN_GSB_MAX_RQSX_PAYLOAD);
 +
 +	if (!status) {
 +		gsb_rqsx_response_success(buffer, rsp.pointer, rsp.length);
@@ -4331,7 +4308,7 @@ index 000000000000..f5e81cd67357
 +MODULE_LICENSE("GPL");
 diff --git a/drivers/misc/surface_aggregator/clients/surface_aggregator_registry.c b/drivers/misc/surface_aggregator/clients/surface_aggregator_registry.c
 new file mode 100644
-index 000000000000..569d1b96bb1a
+index 000000000000..77ef266b88f3
 --- /dev/null
 +++ b/drivers/misc/surface_aggregator/clients/surface_aggregator_registry.c
 @@ -0,0 +1,656 @@
@@ -4654,7 +4631,7 @@ index 000000000000..569d1b96bb1a
 +	u8 opmode;
 +	int status;
 +
-+	status = ssam_bas_query_opmode(sdev->ctrl, &opmode);
++	status = ssam_retry(ssam_bas_query_opmode, sdev->ctrl, &opmode);
 +	if (status < 0) {
 +		dev_err(&sdev->dev, "failed to query base state: %d\n", status);
 +		return status;
@@ -4993,10 +4970,10 @@ index 000000000000..569d1b96bb1a
 +MODULE_LICENSE("GPL");
 diff --git a/drivers/misc/surface_aggregator/clients/surface_battery.c b/drivers/misc/surface_aggregator/clients/surface_battery.c
 new file mode 100644
-index 000000000000..e1e0804eeb54
+index 000000000000..7ed9ba3f98d7
 --- /dev/null
 +++ b/drivers/misc/surface_aggregator/clients/surface_battery.c
-@@ -0,0 +1,1195 @@
+@@ -0,0 +1,1192 @@
 +// SPDX-License-Identifier: GPL-2.0+
 +/*
 + * Surface battery and AC device driver.
@@ -5018,9 +4995,6 @@ index 000000000000..e1e0804eeb54
 +
 +#include <linux/surface_aggregator/device.h>
 +
-+#define SPWR_RETRY			3
-+#define spwr_retry(fn, args...)		ssam_retry(fn, SPWR_RETRY, args)
-+
 +#define SPWR_AC_BAT_UPDATE_DELAY	msecs_to_jiffies(5000)
 +
 +
@@ -5249,7 +5223,7 @@ index 000000000000..e1e0804eeb54
 +
 +static int spwr_battery_load_sta(struct spwr_battery_device *bat)
 +{
-+	return spwr_retry(ssam_bat_get_sta, bat->sdev, &bat->sta);
++	return ssam_retry(ssam_bat_get_sta, bat->sdev, &bat->sta);
 +}
 +
 +static int spwr_battery_load_bix(struct spwr_battery_device *bat)
@@ -5259,7 +5233,7 @@ index 000000000000..e1e0804eeb54
 +	if (!spwr_battery_present(bat))
 +		return 0;
 +
-+	status = spwr_retry(ssam_bat_get_bix, bat->sdev, &bat->bix);
++	status = ssam_retry(ssam_bat_get_bix, bat->sdev, &bat->bix);
 +
 +	// enforce NULL terminated strings in case anything goes wrong...
 +	bat->bix.model[ARRAY_SIZE(bat->bix.model) - 1] = 0;
@@ -5275,7 +5249,7 @@ index 000000000000..e1e0804eeb54
 +	if (!spwr_battery_present(bat))
 +		return 0;
 +
-+	return spwr_retry(ssam_bat_get_bst, bat->sdev, &bat->bst);
++	return ssam_retry(ssam_bat_get_bst, bat->sdev, &bat->bst);
 +}
 +
 +static int spwr_battery_set_alarm_unlocked(struct spwr_battery_device *bat,
@@ -5284,7 +5258,7 @@ index 000000000000..e1e0804eeb54
 +	__le32 value_le = cpu_to_le32(value);
 +
 +	bat->alarm = value;
-+	return spwr_retry(ssam_bat_set_btp, bat->sdev, &value_le);
++	return ssam_retry(ssam_bat_set_btp, bat->sdev, &value_le);
 +}
 +
 +static int spwr_battery_set_alarm(struct spwr_battery_device *bat, u32 value)
@@ -5361,7 +5335,7 @@ index 000000000000..e1e0804eeb54
 +	int status;
 +	u32 old = ac->state;
 +
-+	status = spwr_retry(ssam_bat_get_psrc, ac->sdev, &ac->state);
++	status = ssam_retry(ssam_bat_get_psrc, ac->sdev, &ac->state);
 +	if (status < 0)
 +		return status;
 +
@@ -5889,7 +5863,7 @@ index 000000000000..e1e0804eeb54
 +	int status;
 +
 +	// make sure the device is there and functioning properly
-+	status = spwr_retry(ssam_bat_get_sta, ac->sdev, &sta);
++	status = ssam_retry(ssam_bat_get_sta, ac->sdev, &sta);
 +	if (status)
 +		return status;
 +
@@ -5952,7 +5926,7 @@ index 000000000000..e1e0804eeb54
 +	int status;
 +
 +	// make sure the device is there and functioning properly
-+	status = spwr_retry(ssam_bat_get_sta, bat->sdev, &sta);
++	status = ssam_retry(ssam_bat_get_sta, bat->sdev, &sta);
 +	if (status)
 +		return status;
 +
@@ -6194,10 +6168,10 @@ index 000000000000..e1e0804eeb54
 +MODULE_LICENSE("GPL");
 diff --git a/drivers/misc/surface_aggregator/clients/surface_dtx.c b/drivers/misc/surface_aggregator/clients/surface_dtx.c
 new file mode 100644
-index 000000000000..588931ddcb48
+index 000000000000..346b54848b8f
 --- /dev/null
 +++ b/drivers/misc/surface_aggregator/clients/surface_dtx.c
-@@ -0,0 +1,1277 @@
+@@ -0,0 +1,1279 @@
 +// SPDX-License-Identifier: GPL-2.0+
 +/*
 + * Surface Book (gen. 2 and later) detachment system (DTX) driver.
@@ -6486,7 +6460,7 @@ index 000000000000..588931ddcb48
 +	struct sdtx_base_info info;
 +	int status;
 +
-+	status = ssam_bas_get_base(ddev->ctrl, &raw);
++	status = ssam_retry(ssam_bas_get_base, ddev->ctrl, &raw);
 +	if (status < 0)
 +		return status;
 +
@@ -6504,7 +6478,7 @@ index 000000000000..588931ddcb48
 +	u8 mode;
 +	int status;
 +
-+	status = ssam_bas_get_device_mode(ddev->ctrl, &mode);
++	status = ssam_retry(ssam_bas_get_device_mode, ddev->ctrl, &mode);
 +	if (status < 0)
 +		return status;
 +
@@ -6516,7 +6490,7 @@ index 000000000000..588931ddcb48
 +	u8 latch;
 +	int status;
 +
-+	status = ssam_bas_get_latch_status(ddev->ctrl, &latch);
++	status = ssam_retry(ssam_bas_get_latch_status, ddev->ctrl, &latch);
 +	if (status < 0)
 +		return status;
 +
@@ -6538,22 +6512,22 @@ index 000000000000..588931ddcb48
 +		return 0;
 +
 +	case SDTX_IOCTL_LATCH_LOCK:
-+		return ssam_bas_latch_lock(ddev->ctrl);
++		return ssam_retry(ssam_bas_latch_lock, ddev->ctrl);
 +
 +	case SDTX_IOCTL_LATCH_UNLOCK:
-+		return ssam_bas_latch_unlock(ddev->ctrl);
++		return ssam_retry(ssam_bas_latch_unlock, ddev->ctrl);
 +
 +	case SDTX_IOCTL_LATCH_REQUEST:
-+		return ssam_bas_latch_request(ddev->ctrl);
++		return ssam_retry(ssam_bas_latch_request, ddev->ctrl);
 +
 +	case SDTX_IOCTL_LATCH_CONFIRM:
-+		return ssam_bas_latch_confirm(ddev->ctrl);
++		return ssam_retry(ssam_bas_latch_confirm, ddev->ctrl);
 +
 +	case SDTX_IOCTL_LATCH_HEARTBEAT:
-+		return ssam_bas_latch_heartbeat(ddev->ctrl);
++		return ssam_retry(ssam_bas_latch_heartbeat, ddev->ctrl);
 +
 +	case SDTX_IOCTL_LATCH_CANCEL:
-+		return ssam_bas_latch_cancel(ddev->ctrl);
++		return ssam_retry(ssam_bas_latch_cancel, ddev->ctrl);
 +
 +	case SDTX_IOCTL_GET_BASE_INFO:
 +		return sdtx_ioctl_get_base_info(ddev,
@@ -6934,14 +6908,14 @@ index 000000000000..588931ddcb48
 +	ddev = container_of(work, struct sdtx_device, mode_work.work);
 +
 +	// get operation mode
-+	status = ssam_bas_get_device_mode(ddev->ctrl, &mode);
++	status = ssam_retry(ssam_bas_get_device_mode, ddev->ctrl, &mode);
 +	if (status) {
 +		dev_err(ddev->dev, "failed to get device mode: %d\n", status);
 +		return;
 +	}
 +
 +	// get base info
-+	status = ssam_bas_get_base(ddev->ctrl, &base);
++	status = ssam_retry(ssam_bas_get_base, ddev->ctrl, &base);
 +	if (status) {
 +		dev_err(ddev->dev, "failed to get base info: %d\n", status);
 +		return;
@@ -7085,19 +7059,19 @@ index 000000000000..588931ddcb48
 +	 */
 +	smp_mb__after_atomic();
 +
-+	status = ssam_bas_get_base(ddev->ctrl, &base);
++	status = ssam_retry(ssam_bas_get_base, ddev->ctrl, &base);
 +	if (status) {
 +		dev_err(ddev->dev, "failed to get base state: %d\n", status);
 +		return;
 +	}
 +
-+	status = ssam_bas_get_device_mode(ddev->ctrl, &mode);
++	status = ssam_retry(ssam_bas_get_device_mode, ddev->ctrl, &mode);
 +	if (status) {
 +		dev_err(ddev->dev, "failed to get device mode: %d\n", status);
 +		return;
 +	}
 +
-+	status = ssam_bas_get_latch_status(ddev->ctrl, &latch);
++	status = ssam_retry(ssam_bas_get_latch_status, ddev->ctrl, &latch);
 +	if (status) {
 +		dev_err(ddev->dev, "failed to get latch status: %d\n", status);
 +		return;
@@ -7175,15 +7149,17 @@ index 000000000000..588931ddcb48
 +	 * Note that we also need to do this before registring the event
 +	 * notifier, as that may access the state values.
 +	 */
-+	status = ssam_bas_get_base(ddev->ctrl, &ddev->state.base);
++	status = ssam_retry(ssam_bas_get_base, ddev->ctrl, &ddev->state.base);
 +	if (status)
 +		return status;
 +
-+	status = ssam_bas_get_device_mode(ddev->ctrl, &ddev->state.device_mode);
++	status = ssam_retry(ssam_bas_get_device_mode, ddev->ctrl,
++			    &ddev->state.device_mode);
 +	if (status)
 +		return status;
 +
-+	status = ssam_bas_get_latch_status(ddev->ctrl, &ddev->state.latch_status);
++	status = ssam_retry(ssam_bas_get_latch_status, ddev->ctrl,
++			    &ddev->state.latch_status);
 +	if (status)
 +		return status;
 +
@@ -7477,10 +7453,10 @@ index 000000000000..588931ddcb48
 +MODULE_LICENSE("GPL");
 diff --git a/drivers/misc/surface_aggregator/clients/surface_hid.c b/drivers/misc/surface_aggregator/clients/surface_hid.c
 new file mode 100644
-index 000000000000..60691800e7e5
+index 000000000000..033abc9aa95e
 --- /dev/null
 +++ b/drivers/misc/surface_aggregator/clients/surface_hid.c
-@@ -0,0 +1,925 @@
+@@ -0,0 +1,922 @@
 +// SPDX-License-Identifier: GPL-2.0+
 +/*
 + * Surface System Aggregator Module (SSAM) HID device driver.
@@ -7505,9 +7481,6 @@ index 000000000000..60691800e7e5
 +#include <linux/surface_aggregator/controller.h>
 +#include <linux/surface_aggregator/device.h>
 +
-+#define SHID_RETRY			3
-+#define shid_retry(fn, args...)		ssam_retry(fn, SHID_RETRY, args)
-+
 +
 +enum surface_hid_descriptor_entry {
 +	SURFACE_HID_DESC_HID    = 0,
@@ -7629,7 +7602,7 @@ index 000000000000..60691800e7e5
 +
 +		rsp.length = 0;
 +
-+		status = shid_retry(ssam_request_sync_onstack, shid->ctrl,
++		status = ssam_retry(ssam_request_sync_onstack, shid->ctrl,
 +				    &rqst, &rsp, sizeof(*slice));
 +		if (status)
 +			return status;
@@ -7681,7 +7654,7 @@ index 000000000000..60691800e7e5
 +
 +	buf[0] = report_id;
 +
-+	return shid_retry(ssam_request_sync, shid->ctrl, &rqst, NULL);
++	return ssam_retry(ssam_request_sync, shid->ctrl, &rqst, NULL);
 +}
 +
 +static int ssam_hid_get_raw_report(struct surface_hid_device *shid,
@@ -7702,7 +7675,7 @@ index 000000000000..60691800e7e5
 +	rsp.length = 0;
 +	rsp.pointer = buf;
 +
-+	return shid_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
++	return ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
 +			  sizeof(report_id));
 +}
 +
@@ -7787,7 +7760,7 @@ index 000000000000..60691800e7e5
 +	rsp.length = 0;
 +	rsp.pointer = buf;
 +
-+	status = shid_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
++	status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
 +			    sizeof(entry));
 +	if (status)
 +		return status;
@@ -7814,7 +7787,7 @@ index 000000000000..60691800e7e5
 +	rqst.length = sizeof(value_u8);
 +	rqst.payload = &value_u8;
 +
-+	return shid_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, NULL,
++	return ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, NULL,
 +			  sizeof(value_u8));
 +}
 +
@@ -7838,7 +7811,7 @@ index 000000000000..60691800e7e5
 +	rsp.length = 0;
 +	rsp.pointer = buf;
 +
-+	status = shid_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
++	status = ssam_retry(ssam_request_sync_onstack, shid->ctrl, &rqst, &rsp,
 +			    sizeof(payload));
 +	if (status)
 +		return status;
@@ -8683,7 +8656,7 @@ index 000000000000..9afddfc6a358
 +MODULE_LICENSE("GPL");
 diff --git a/drivers/misc/surface_aggregator/clients/surface_perfmode.c b/drivers/misc/surface_aggregator/clients/surface_perfmode.c
 new file mode 100644
-index 000000000000..006601b3bea6
+index 000000000000..e13f4995b28b
 --- /dev/null
 +++ b/drivers/misc/surface_aggregator/clients/surface_perfmode.c
 @@ -0,0 +1,122 @@
@@ -8739,7 +8712,7 @@ index 000000000000..006601b3bea6
 +	if (mode < __SAM_PERF_MODE__MIN || mode > __SAM_PERF_MODE__MAX)
 +		return -EINVAL;
 +
-+	return __ssam_tmp_perf_mode_set(sdev, &mode_le);
++	return ssam_retry(__ssam_tmp_perf_mode_set, sdev, &mode_le);
 +}
 +
 +static ssize_t perf_mode_show(struct device *dev, struct device_attribute *attr,
@@ -8749,7 +8722,7 @@ index 000000000000..006601b3bea6
 +	struct ssam_perf_info info;
 +	int status;
 +
-+	status = ssam_tmp_perf_mode_get(sdev, &info);
++	status = ssam_retry(ssam_tmp_perf_mode_get, sdev, &info);
 +	if (status) {
 +		dev_err(dev, "failed to get current performance mode: %d\n",
 +			status);
@@ -8811,10 +8784,10 @@ index 000000000000..006601b3bea6
 +MODULE_LICENSE("GPL");
 diff --git a/drivers/misc/surface_aggregator/controller.c b/drivers/misc/surface_aggregator/controller.c
 new file mode 100644
-index 000000000000..c5d19feb4d38
+index 000000000000..feee7c7c5945
 --- /dev/null
 +++ b/drivers/misc/surface_aggregator/controller.c
-@@ -0,0 +1,2555 @@
+@@ -0,0 +1,2557 @@
 +// SPDX-License-Identifier: GPL-2.0+
 +/*
 + * Main SSAM/SSH controller structure and functionality.
@@ -10634,7 +10607,8 @@ index 000000000000..c5d19feb4d38
 +	result.length = 0;
 +	result.pointer = buf;
 +
-+	status = ssam_request_sync_onstack(ctrl, &rqst, &result, sizeof(params));
++	status = ssam_retry(ssam_request_sync_onstack, ctrl, &rqst, &result,
++			    sizeof(params));
 +	if (status) {
 +		ssam_err(ctrl, "failed to enable event source (tc: 0x%02x, "
 +			 "iid: 0x%02x, reg: 0x%02x)\n", id.target_category,
@@ -10702,7 +10676,8 @@ index 000000000000..c5d19feb4d38
 +	result.length = 0;
 +	result.pointer = buf;
 +
-+	status = ssam_request_sync_onstack(ctrl, &rqst, &result, sizeof(params));
++	status = ssam_retry(ssam_request_sync_onstack, ctrl, &rqst, &result,
++			    sizeof(params));
 +	if (status) {
 +		ssam_err(ctrl, "failed to disable event source (tc: 0x%02x, "
 +			 "iid: 0x%02x, reg: 0x%02x)\n", id.target_category,
@@ -10736,7 +10711,7 @@ index 000000000000..c5d19feb4d38
 +	__le32 __version;
 +	int status;
 +
-+	status = ssam_ssh_get_firmware_version(ctrl, &__version);
++	status = ssam_retry(ssam_ssh_get_firmware_version, ctrl, &__version);
 +	if (status)
 +		return status;
 +
@@ -10778,7 +10753,7 @@ index 000000000000..c5d19feb4d38
 +
 +	ssam_dbg(ctrl, "pm: notifying display off\n");
 +
-+	status = ssam_ssh_notif_display_off(ctrl, &response);
++	status = ssam_retry(ssam_ssh_notif_display_off, ctrl, &response);
 +	if (status)
 +		return status;
 +
@@ -10817,7 +10792,7 @@ index 000000000000..c5d19feb4d38
 +
 +	ssam_dbg(ctrl, "pm: notifying display on\n");
 +
-+	status = ssam_ssh_notif_display_on(ctrl, &response);
++	status = ssam_retry(ssam_ssh_notif_display_on, ctrl, &response);
 +	if (status)
 +		return status;
 +
@@ -10859,7 +10834,7 @@ index 000000000000..c5d19feb4d38
 +
 +	ssam_dbg(ctrl, "pm: notifying D0 exit\n");
 +
-+	status = ssam_ssh_notif_d0_exit(ctrl, &response);
++	status = ssam_retry(ssam_ssh_notif_d0_exit, ctrl, &response);
 +	if (status)
 +		return status;
 +
@@ -10901,7 +10876,7 @@ index 000000000000..c5d19feb4d38
 +
 +	ssam_dbg(ctrl, "pm: notifying D0 entry\n");
 +
-+	status = ssam_ssh_notif_d0_entry(ctrl, &response);
++	status = ssam_retry(ssam_ssh_notif_d0_entry, ctrl, &response);
 +	if (status)
 +		return status;
 +
@@ -17411,10 +17386,10 @@ index 000000000000..8e3e86c7d78c
 +#endif /* _LINUX_SURFACE_ACPI_NOTIFY_H */
 diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h
 new file mode 100644
-index 000000000000..447cda590409
+index 000000000000..d128c68c04e0
 --- /dev/null
 +++ b/include/linux/surface_aggregator/controller.h
-@@ -0,0 +1,815 @@
+@@ -0,0 +1,832 @@
 +/* SPDX-License-Identifier: GPL-2.0+ */
 +/*
 + * Surface System Aggregator Module (SSAM) controller interface.
@@ -17663,7 +17638,7 @@ index 000000000000..447cda590409
 +	})
 +
 +/**
-+ * ssam_retry - Retry request in case of I/O errors or timeouts.
++ * __ssam_retry - Retry request in case of I/O errors or timeouts.
 + * @request: The request function to execute. Must return an integer.
 + * @n:       Number of tries.
 + * @args:    Arguments for the request function.
@@ -17675,7 +17650,7 @@ index 000000000000..447cda590409
 + *
 + * Return: Returns the return value of the last execution of @request.
 + */
-+#define ssam_retry(request, n, args...)					\
++#define __ssam_retry(request, n, args...)				\
 +	({								\
 +		int __i, __s = 0;					\
 +									\
@@ -17687,6 +17662,23 @@ index 000000000000..447cda590409
 +		__s;							\
 +	})
 +
++/**
++ * ssam_retry - Retry request in case of I/O errors or timeouts up to three
++ * times in total.
++ * @request: The request function to execute. Must return an integer.
++ * @args:    Arguments for the request function.
++ *
++ * Executes the given request function, i.e. calls @request. In case the
++ * request returns %-EREMOTEIO (indicates I/O error) or -%ETIMEDOUT (request
++ * or underlying packet timed out), @request will be re-executed again, up to
++ * three times in total.
++ *
++ * See __ssam_retry() for a more generic macro for this purpose.
++ *
++ * Return: Returns the return value of the last execution of @request.
++ */
++#define ssam_retry(request, args...) \
++	__ssam_retry(request, 3, args)
 +
 +/**
 + * struct ssam_request_spec - Blue-print specification of SAM request.

+ 6 - 6
pkg/arch/kernel/PKGBUILD

@@ -41,12 +41,12 @@ sha256sums=('84b161d5143e8996b4a9fd7fe968e9c51e9f43e715243cc190a3f4a1ad678740'
             '36439a90c9d2f860298d90e141f3bf9d897dd8ece9e21cd46508f4ed7b2151bb'
             'cad2f23b058938c27ccdeb1944dcc492cf8696651b1ca9c74a86eb73a039f8c1'
             '8cd2b019aac6d3807a5cdcbbbe0aad81e63193ff3e8dffd7a79d4a1421b858f6'
-            'ab3886ff7266cf518d409a03261e496ffa992e1e9e5f74160f38907d392810a1'
-            'affe80a0d097740a0523cbad5dd7657df5772a57e93af3dd318138866987198f'
-            'c5143277de5086f20f4bd605d5e82f7abdfc725871c103f461b701588b7558e1'
-            '1bd872785623a547ee0e7f0d4c6e68c2067ebde73fcc96bc2bfabfaf4fda5515'
-            '8d4fd88b450e9e7bc6050d9a69e42ef255a664f8b70bdb10eb8fff49bd7d6484'
-            '184693d8003fc85213c5f662a2bbd729402e2ddba6035f67fa360179414fea36')
+            '77602c298f25d76a91c31ae37e6f4c9c77f3185e716092518f755a285eddb60b'
+            'c508a8998161668b6f836c391bb7d8fdcb1424669f92cd49bd865cdeadca95e9'
+            '05eed9ef5bfd29e66b72631d7ec46400fceca3f1ea02fb531c3162593f5a9b65'
+            'da4539a87bfd688f7e5fb7a52d6ac65b545861710f12e9e66863171e0704594e'
+            'e350b1f0ed4631102dd723af7466e0051462d5627325cae1b92476cf63f5c4f5'
+            '545a8dc1a8f0db38c1e7dadb616d1a037886d221137640957e552865a602a1fd')
 
 
 export KBUILD_BUILD_HOST=archlinux