From e6b16192a7bb1065a1b495e3c5d379631575d868 Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Thu, 3 Jun 2021 20:00:04 +0200 Subject: [PATCH] Update v4.19 patches Changes: - SAM: - Fix bug when disabling events. - Add support for forwarding events to user-space via debug device. - Add quirk to prevent incorrect battery reporting via the Surface Go touchscreen. Links: - SAM: https://github.com/linux-surface/surface-aggregator-module/commit/6b6edef7c794363f5a036784474fe46422d5da70 - kernel: https://github.com/linux-surface/kernel/commit/1028bcec8611e51b68fa8c0dabca4e66e4efadea --- patches/4.19/0001-surface3-power.patch | 2 +- .../0002-surface3-touchscreen-dma-fix.patch | 2 +- patches/4.19/0003-surface3-oemb.patch | 2 +- patches/4.19/0004-surface-buttons.patch | 8 +- patches/4.19/0005-suspend.patch | 2 +- patches/4.19/0006-ipts.patch | 2 +- patches/4.19/0007-wifi.patch | 52 +- patches/4.19/0008-surface-gpe.patch | 2 +- patches/4.19/0009-surface-sam-over-hid.patch | 4 +- patches/4.19/0010-surface-sam.patch | 1073 +++++++++++++++-- patches/4.19/0011-surface-hotplug.patch | 46 +- patches/4.19/0012-surface-typecover.patch | 2 +- .../4.19/0013-surface-go-touchscreen.patch | 39 + ...ch => 0014-ath10k-firmware-override.patch} | 2 +- .../0013-ath10k-firmware-override.patch | 1 - .../0013-surface-go-touchscreen.patch | 1 + .../0014-ath10k-firmware-override.patch | 1 + pkg/arch/kernel-lts/PKGBUILD | 30 +- 18 files changed, 1077 insertions(+), 194 deletions(-) create mode 100644 patches/4.19/0013-surface-go-touchscreen.patch rename patches/4.19/{0013-ath10k-firmware-override.patch => 0014-ath10k-firmware-override.patch} (98%) delete mode 120000 pkg/arch/kernel-lts/0013-ath10k-firmware-override.patch create mode 120000 pkg/arch/kernel-lts/0013-surface-go-touchscreen.patch create mode 120000 pkg/arch/kernel-lts/0014-ath10k-firmware-override.patch diff --git a/patches/4.19/0001-surface3-power.patch b/patches/4.19/0001-surface3-power.patch index 65d99cb60..fb0dc6d6f 100644 --- a/patches/4.19/0001-surface3-power.patch +++ b/patches/4.19/0001-surface3-power.patch @@ -1,4 +1,4 @@ -From af9eef3d03ef51bfcb922de51e14ee8120ae3e66 Mon Sep 17 00:00:00 2001 +From 66bd915cb97590edb63025599405d0b186a0c033 Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Sat, 28 Sep 2019 18:00:43 +0200 Subject: [PATCH] platform/x86: Surface 3 battery platform operation region diff --git a/patches/4.19/0002-surface3-touchscreen-dma-fix.patch b/patches/4.19/0002-surface3-touchscreen-dma-fix.patch index 1b27cbe06..a78e62e03 100644 --- a/patches/4.19/0002-surface3-touchscreen-dma-fix.patch +++ b/patches/4.19/0002-surface3-touchscreen-dma-fix.patch @@ -1,4 +1,4 @@ -From d6b2d50b0ded5ebf8066243c3b5e690d636b175c Mon Sep 17 00:00:00 2001 +From 4bacd340f30a355f99e75704c288240bb1acaadc Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Sun, 5 Jul 2020 14:56:20 +0300 Subject: [PATCH] dmaengine: dw: Initialize channel before each transfer diff --git a/patches/4.19/0003-surface3-oemb.patch b/patches/4.19/0003-surface3-oemb.patch index 2c1d3a9b9..704e91da1 100644 --- a/patches/4.19/0003-surface3-oemb.patch +++ b/patches/4.19/0003-surface3-oemb.patch @@ -1,4 +1,4 @@ -From 1a1273bb96f7da6dea35e3708ea8e0e46d1c5c24 Mon Sep 17 00:00:00 2001 +From 1cb2d25d26aa089c97194e605e5859cdba0f3127 Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto Date: Sun, 18 Oct 2020 16:42:44 +0900 Subject: [PATCH] (surface3-oemb) add DMI matches for Surface 3 with broken DMI diff --git a/patches/4.19/0004-surface-buttons.patch b/patches/4.19/0004-surface-buttons.patch index ed21223c8..89daf04c8 100644 --- a/patches/4.19/0004-surface-buttons.patch +++ b/patches/4.19/0004-surface-buttons.patch @@ -1,4 +1,4 @@ -From 931a3c4875e9a90b338866146703da7ed1a7064f Mon Sep 17 00:00:00 2001 +From a16f833c5b0d2dca416db7c174752b6b59e84791 Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Sat, 27 Jul 2019 17:51:37 +0200 Subject: [PATCH] platform/x86: surfacepro3_button: Fix device check @@ -92,7 +92,7 @@ index 1b491690ce07..96627627060e 100644 -- 2.31.1 -From c7616a060e4a8822c0f61c79bc767888b0ff50cc Mon Sep 17 00:00:00 2001 +From d312af2333244116617b8c9f0b0f7984bc1ffd5b Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Sat, 27 Jul 2019 17:52:01 +0200 Subject: [PATCH] Input: soc_button_array - Add support for newer surface @@ -297,7 +297,7 @@ index 55cd6e0b409c..8f21c062c85d 100644 -- 2.31.1 -From 25e426da4b4be3aa557571b38318032dda3f7854 Mon Sep 17 00:00:00 2001 +From 442aafad3fb76fbd4d41e93dfb9e7677799caff0 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 5 Oct 2019 14:11:58 +0200 Subject: [PATCH] Input: soc_button_array - partial revert of support for newer @@ -386,7 +386,7 @@ index 8f21c062c85d..5983733d78dd 100644 -- 2.31.1 -From ab1eac1a07fc6bdd404fafd96d7ea3304402c426 Mon Sep 17 00:00:00 2001 +From 96201f8faebf66c28485630dfc6f8fbc8cb49312 Mon Sep 17 00:00:00 2001 From: "Tsuchiya Yuto (kitakar5525)" Date: Mon, 11 May 2020 17:40:21 +0900 Subject: [PATCH] Input: soc_button_array - fix Wdiscarded-qualifiers for diff --git a/patches/4.19/0005-suspend.patch b/patches/4.19/0005-suspend.patch index 374f4fc95..11690ee58 100644 --- a/patches/4.19/0005-suspend.patch +++ b/patches/4.19/0005-suspend.patch @@ -1,4 +1,4 @@ -From 99d51d585b97b6d3c93c8738943233edb9d00ae4 Mon Sep 17 00:00:00 2001 +From ae6dc641515e21c80430185873b5bd63b9dd40c1 Mon Sep 17 00:00:00 2001 From: kitakar5525 <34676735+kitakar5525@users.noreply.github.com> Date: Sat, 28 Sep 2019 17:48:21 +0200 Subject: [PATCH] nvme: Backport changes for suspend diff --git a/patches/4.19/0006-ipts.patch b/patches/4.19/0006-ipts.patch index 3d75e6ea9..d2b9fa681 100644 --- a/patches/4.19/0006-ipts.patch +++ b/patches/4.19/0006-ipts.patch @@ -1,4 +1,4 @@ -From 8840f192405d3dc95c2762c48cf2d42cf3b23cbc Mon Sep 17 00:00:00 2001 +From 0a2b7c92bf8b74b75f6f1ca377078dbb6439a244 Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Sat, 28 Sep 2019 17:58:17 +0200 Subject: [PATCH] Add support for Intel IPTS touch devices diff --git a/patches/4.19/0007-wifi.patch b/patches/4.19/0007-wifi.patch index acd966a53..b973b4ab2 100644 --- a/patches/4.19/0007-wifi.patch +++ b/patches/4.19/0007-wifi.patch @@ -1,4 +1,4 @@ -From a3f993caab529ac06f0e1c32106c057d8405780e Mon Sep 17 00:00:00 2001 +From 5fe5d52f6a98aec4ad5ee2a6f13d25692b4ba6db Mon Sep 17 00:00:00 2001 From: Chuhong Yuan Date: Wed, 24 Jul 2019 19:27:45 +0800 Subject: [PATCH] mwifiex: pcie: Use dev_get_drvdata @@ -49,7 +49,7 @@ index 5907b34037c2..4e655038e3f3 100644 -- 2.31.1 -From b3e3a87eefe2243c1aedbfdf21fff0ef05c4c533 Mon Sep 17 00:00:00 2001 +From 756f807795a6b6b4fd094367f7f2885a9322ba35 Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto Date: Mon, 28 Sep 2020 17:46:49 +0900 Subject: [PATCH] mwifiex: pcie: add DMI-based quirk impl for Surface devices @@ -257,7 +257,7 @@ index 000000000000..5326ae7e5671 -- 2.31.1 -From fe1bb44837215cb8d79249dffcc3533a26106609 Mon Sep 17 00:00:00 2001 +From 3861312d1ede27de54f3a231f3d5255efe5f5566 Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto Date: Tue, 29 Sep 2020 17:25:22 +0900 Subject: [PATCH] mwifiex: pcie: add reset_d3cold quirk for Surface gen4+ @@ -458,7 +458,7 @@ index 5326ae7e5671..8b9dcb5070d8 100644 -- 2.31.1 -From 1e1918aed3552d71c4ae73cd5e69673770304996 Mon Sep 17 00:00:00 2001 +From bc846dfd932372544d2327633177bc00f6d121fa Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto Date: Tue, 29 Sep 2020 17:32:22 +0900 Subject: [PATCH] mwifiex: pcie: add reset_wsid quirk for Surface 3 @@ -637,7 +637,7 @@ index 8b9dcb5070d8..3ef7440418e3 100644 -- 2.31.1 -From e0a66c445a63a09306573ed0a87362a4ed8b80c8 Mon Sep 17 00:00:00 2001 +From 3dd94b0277c7651e92033e1566b760668524dc49 Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto Date: Wed, 30 Sep 2020 18:08:24 +0900 Subject: [PATCH] mwifiex: pcie: (OEMB) add quirk for Surface 3 with broken DMI @@ -699,7 +699,7 @@ index f0a6fa0a7ae5..34dcd84f02a6 100644 -- 2.31.1 -From 64ce42228dd5d47589f3470bf19eca197c43fd0a Mon Sep 17 00:00:00 2001 +From 48676c9c13e5b98cc6f97f209dcd7817cce88f43 Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto Date: Sun, 4 Oct 2020 00:11:49 +0900 Subject: [PATCH] mwifiex: pcie: disable bridge_d3 for Surface gen4+ @@ -854,7 +854,7 @@ index 3ef7440418e3..a95ebac06e13 100644 -- 2.31.1 -From 032d6dd3783b170a9d6f8977561b800d745604b0 Mon Sep 17 00:00:00 2001 +From f162468494c91b7d70c63b3fdaa885de0f581abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Tue, 10 Nov 2020 12:49:56 +0100 Subject: [PATCH] mwifiex: Use non-posted PCI register writes @@ -911,7 +911,7 @@ index d0e002cfc295..aae276fc1155 100644 -- 2.31.1 -From 2e0831a2b27eee8c917c7d54e91573cba1a035aa Mon Sep 17 00:00:00 2001 +From f7293c27715e3d18b6403c430557fd4b433fd595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Tue, 3 Nov 2020 13:28:04 +0100 Subject: [PATCH] mwifiex: Add quirk resetting the PCI bridge on MS Surface @@ -1078,7 +1078,7 @@ index a95ebac06e13..4ec2ae72f632 100644 -- 2.31.1 -From 16add04ca91ec36c0d070285350bbb108d92a9c6 Mon Sep 17 00:00:00 2001 +From d25ecded1d333d9df4670003237e6fa66a69843a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sun, 28 Mar 2021 21:10:06 +0200 Subject: [PATCH] mwifiex: Try waking the firmware until we get an interrupt @@ -1167,7 +1167,7 @@ index 6b06f2a76cdc..45dc0bfe26ba 100644 -- 2.31.1 -From 273e918d612039ba7eeb056f27227158e3377a9d Mon Sep 17 00:00:00 2001 +From 33e1ad68fc4a4936698c3ec73b7a226e89fe4031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Thu, 25 Mar 2021 11:33:02 +0100 Subject: [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell @@ -1245,7 +1245,7 @@ index 1b0adf5c2376..283a90928f0e 100644 -- 2.31.1 -From be9f0d8a94c73018997e3b07c9912a02e006c05c Mon Sep 17 00:00:00 2001 +From d38a00c40696cc85857a9a0f31208915e52fbccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Wed, 11 Nov 2020 12:31:26 +0100 Subject: [PATCH] mwifiex: Small cleanup for handling virtual interface type @@ -1346,7 +1346,7 @@ index 650191db25cb..5badf7fef37e 100644 -- 2.31.1 -From baefc79e5f720a6efd8e5f986872a91a0a374786 Mon Sep 17 00:00:00 2001 +From fd7764267fc4a32169585ecc4b43e42c323a1ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Wed, 11 Nov 2020 12:44:39 +0100 Subject: [PATCH] mwifiex: Use function to check whether interface type change @@ -1579,7 +1579,7 @@ index 5badf7fef37e..e73334679992 100644 -- 2.31.1 -From 139f8b2f8aee78695379ac1ae4d99d380c99442f Mon Sep 17 00:00:00 2001 +From 2cc30e306698250a9bd0d7f097c709a4f1a2ba23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Wed, 11 Nov 2020 13:33:04 +0100 Subject: [PATCH] mwifiex: Run SET_BSS_MODE when changing from P2P to STATION @@ -1647,7 +1647,7 @@ index e73334679992..99da637692cc 100644 -- 2.31.1 -From 1839938ee030b0dc96758f3e9669530873291abd Mon Sep 17 00:00:00 2001 +From d1a36cca16a45bbae8b8ae4065bf44bc5ae252e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Wed, 11 Nov 2020 14:42:54 +0100 Subject: [PATCH] mwifiex: Use helper function for counting interface types @@ -1823,7 +1823,7 @@ index 99da637692cc..feb3a858d8c1 100644 -- 2.31.1 -From 9bec5db4ba4535bd2d8753f6dfdeca57d1cbd587 Mon Sep 17 00:00:00 2001 +From c427da241bf49cc49b7eefa59209ca8034d60e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Fri, 26 Mar 2021 15:56:58 +0100 Subject: [PATCH] mwifiex: Update virtual interface counters right after @@ -1926,7 +1926,7 @@ index feb3a858d8c1..54d9e789aa14 100644 -- 2.31.1 -From d29d6c72157e72b71ae5d0cde80f2d8755ce2138 Mon Sep 17 00:00:00 2001 +From da77c8f8f472f7ac39840ba205124e888eec4c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Wed, 11 Nov 2020 13:42:40 +0100 Subject: [PATCH] mwifiex: Allow switching interface type from P2P_CLIENT to @@ -2015,7 +2015,7 @@ index 54d9e789aa14..ec5ed00b4b89 100644 -- 2.31.1 -From 984e21975532f617141488f4c617ebd1825f6a2a Mon Sep 17 00:00:00 2001 +From ae42e15ea2bb3e66a3bd6f3a93cdbdd3f090cbf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Fri, 26 Mar 2021 15:31:08 +0100 Subject: [PATCH] mwifiex: Handle interface type changes from AP to STATION @@ -2042,7 +2042,7 @@ index ec5ed00b4b89..0fc554abfea3 100644 -- 2.31.1 -From 353447dc6f22fac0618c8c8c75c0e04cb1a7f606 Mon Sep 17 00:00:00 2001 +From 8915d1878333f9feb5b0ae7bf58a7f822dbe3863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Fri, 26 Mar 2021 15:32:16 +0100 Subject: [PATCH] mwifiex: Properly initialize private structure on interface @@ -2097,7 +2097,7 @@ index 0fc554abfea3..7c6d31eb058c 100644 -- 2.31.1 -From ed07716be5ba86ace21b84a2fc2909a616f87b9e Mon Sep 17 00:00:00 2001 +From 42d294e9b4ba5a2936b1e10422c4b4142473e98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 27 Mar 2021 12:19:14 +0100 Subject: [PATCH] mwifiex: Fix copy-paste mistake when creating virtual @@ -2129,7 +2129,7 @@ index 7c6d31eb058c..16a94f06a518 100644 -- 2.31.1 -From 964a278789aa8346beaaa1e2a1cb824065b4b483 Mon Sep 17 00:00:00 2001 +From 8fbe953b79a46c70955ff15ef05cbdf3945278dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Tue, 13 Apr 2021 14:30:28 +0200 Subject: [PATCH] mwifiex: Deactive host sleep using HSCFG after it was @@ -2285,7 +2285,7 @@ index 4ed10cf82f9a..057c810a9ef7 100644 -- 2.31.1 -From 2dd03042576b2abd56ec73de9888e8c435627cdc Mon Sep 17 00:00:00 2001 +From 66421414b43b175c1c42c73c281ff591f6cc4a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Tue, 13 Apr 2021 14:23:05 +0200 Subject: [PATCH] mwifiex: Add quirk to disable deep sleep with certain @@ -2388,7 +2388,7 @@ index 7003767eef42..3079ca3e3fdc 100644 -- 2.31.1 -From 0697fd02ee339ecab8432ce0e64b49e755c78014 Mon Sep 17 00:00:00 2001 +From b655458e32900774093756b0fa41c1a211e77b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Wed, 11 Nov 2020 15:17:07 +0100 Subject: [PATCH] mwifiex: Don't log error on suspend if wake-on-wlan is @@ -2420,7 +2420,7 @@ index 16a94f06a518..92d5c9aa5ec7 100644 -- 2.31.1 -From 8868a41a7a351683a8f10363475a89a8f216725f Mon Sep 17 00:00:00 2001 +From 9e9b0dec7feaab050855d6cb40c5e9cfe7823748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sun, 28 Mar 2021 21:42:54 +0200 Subject: [PATCH] mwifiex: Log an error on command failure during key-material @@ -2460,7 +2460,7 @@ index 92d5c9aa5ec7..5786dcea79cc 100644 -- 2.31.1 -From 78bb4405911ac78c6750902bc0d825c7f6a236a0 Mon Sep 17 00:00:00 2001 +From 4faf6c225ce1257b23e6969006b159170774d606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Tue, 13 Apr 2021 12:44:03 +0200 Subject: [PATCH] mwifiex: Fix an incorrect comment @@ -2488,7 +2488,7 @@ index 5d75c971004b..b36b2103d555 100644 -- 2.31.1 -From 555cc46eab894f57d5837fb8b8f65c796b58a507 Mon Sep 17 00:00:00 2001 +From 089a78d4e4587b6ac20dabbe6d7b00dae806e50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Tue, 13 Apr 2021 12:45:59 +0200 Subject: [PATCH] mwifiex: Send DELBA requests according to spec @@ -2531,7 +2531,7 @@ index b36b2103d555..4ed6ae8a96f1 100644 -- 2.31.1 -From 94910256fa0356c33218d1229cbf7c0628261aad Mon Sep 17 00:00:00 2001 +From a848267f9be7d8988576cf813bbb61b40fb6eecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Tue, 13 Apr 2021 12:57:41 +0200 Subject: [PATCH] mwifiex: Ignore BTCOEX events from the firmware diff --git a/patches/4.19/0008-surface-gpe.patch b/patches/4.19/0008-surface-gpe.patch index 0678e8df9..eea3c6458 100644 --- a/patches/4.19/0008-surface-gpe.patch +++ b/patches/4.19/0008-surface-gpe.patch @@ -1,4 +1,4 @@ -From 6813ff190d64f5a3f7053a20bb5738049234fe89 Mon Sep 17 00:00:00 2001 +From 76311394c95798192e476e71b85bb2949e5d86f6 Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Sun, 16 Aug 2020 23:39:56 +0200 Subject: [PATCH] platform/x86: Add Driver to set up lid GPEs on MS Surface diff --git a/patches/4.19/0009-surface-sam-over-hid.patch b/patches/4.19/0009-surface-sam-over-hid.patch index 1b512c336..34571ae86 100644 --- a/patches/4.19/0009-surface-sam-over-hid.patch +++ b/patches/4.19/0009-surface-sam-over-hid.patch @@ -1,4 +1,4 @@ -From c372d961c2fd147a129e3e96a8a26296d0c36e70 Mon Sep 17 00:00:00 2001 +From 0317b179aa42159cd89dc3e757c36f68b0fa35ca Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Sat, 25 Jul 2020 17:19:53 +0200 Subject: [PATCH] i2c: acpi: Implement RawBytes read access @@ -109,7 +109,7 @@ index 8ba4122fb340..f9a24b56fec0 100644 -- 2.31.1 -From beaea304d18ee92ba360c57d876d83953f913ce0 Mon Sep 17 00:00:00 2001 +From ce33b39fa1bffc298b6f9c312ef392c4748322ef Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Sun, 6 Sep 2020 04:01:19 +0200 Subject: [PATCH] platform/x86: Add driver for Surface Book 1 dGPU switch diff --git a/patches/4.19/0010-surface-sam.patch b/patches/4.19/0010-surface-sam.patch index 3efe0cce6..66f186a9a 100644 --- a/patches/4.19/0010-surface-sam.patch +++ b/patches/4.19/0010-surface-sam.patch @@ -1,4 +1,4 @@ -From 6fbb3eabb4f2416201449cda63ba77338d7deb67 Mon Sep 17 00:00:00 2001 +From b18cbfbe9d487c24e272578afcf74cc68af93636 Mon Sep 17 00:00:00 2001 From: qzed Date: Mon, 26 Aug 2019 01:15:40 +0200 Subject: [PATCH] ACPI: Fix buffer/integer type mismatch @@ -81,7 +81,7 @@ index b272c329d45d..cf547883a993 100644 -- 2.31.1 -From 4106bf27de1b49aa2c47727a58d979b33ca1e506 Mon Sep 17 00:00:00 2001 +From 9528beca1088b8ab0b21aaf0b93864c36cf4b441 Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Tue, 24 Sep 2019 17:38:12 +0200 Subject: [PATCH] serdev: Add ACPI devices by ResourceSource field @@ -269,7 +269,7 @@ index c66a04d24f1d..1b18d12d217f 100644 -- 2.31.1 -From 0e718cd4bb7aa3924403cbd160b1eb62677e33d0 Mon Sep 17 00:00:00 2001 +From d3efb7a6b79a5c4b2fcef1d86c4a99f3279acb67 Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Mon, 17 Aug 2020 01:23:20 +0200 Subject: [PATCH] Add file2alias support for Surface Aggregator devices @@ -370,7 +370,7 @@ index 7f40b6aab689..76e3b1d7db45 100644 -- 2.31.1 -From a12b16039b68277800d652d15b9a334baf12d1b5 Mon Sep 17 00:00:00 2001 +From 97b74a8f0b897844b8659e667d56d113c6ea19be Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Mon, 17 Aug 2020 01:44:30 +0200 Subject: [PATCH] platform/x86: Add support for Surface System Aggregator @@ -391,7 +391,7 @@ Patchset: surface-sam Documentation/driver-api/index.rst | 1 + .../surface_aggregator/client-api.rst | 38 + .../driver-api/surface_aggregator/client.rst | 393 +++ - .../surface_aggregator/clients/cdev.rst | 87 + + .../surface_aggregator/clients/cdev.rst | 204 ++ .../surface_aggregator/clients/dtx.rst | 712 +++++ .../surface_aggregator/clients/index.rst | 22 + .../surface_aggregator/clients/san.rst | 44 + @@ -415,7 +415,7 @@ Patchset: surface-sam .../platform/x86/surface_aggregator/Makefile | 17 + drivers/platform/x86/surface_aggregator/bus.c | 415 +++ drivers/platform/x86/surface_aggregator/bus.h | 27 + - .../x86/surface_aggregator/controller.c | 2570 +++++++++++++++++ + .../x86/surface_aggregator/controller.c | 2718 +++++++++++++++++ .../x86/surface_aggregator/controller.h | 285 ++ .../platform/x86/surface_aggregator/core.c | 850 ++++++ .../x86/surface_aggregator/ssh_msgb.h | 205 ++ @@ -426,24 +426,24 @@ Patchset: surface-sam .../surface_aggregator/ssh_request_layer.c | 1263 ++++++++ .../surface_aggregator/ssh_request_layer.h | 143 + .../platform/x86/surface_aggregator/trace.h | 632 ++++ - .../platform/x86/surface_aggregator_cdev.c | 322 +++ + .../platform/x86/surface_aggregator_cdev.c | 804 +++++ .../x86/surface_aggregator_registry.c | 618 ++++ drivers/platform/x86/surface_dtx.c | 1281 ++++++++ drivers/platform/x86/surface_perfmode.c | 122 + drivers/power/supply/Kconfig | 32 + drivers/power/supply/Makefile | 2 + - drivers/power/supply/surface_battery.c | 816 ++++++ + drivers/power/supply/surface_battery.c | 816 +++++ drivers/power/supply/surface_charger.c | 282 ++ include/linux/mod_devicetable.h | 5 +- include/linux/surface_acpi_notify.h | 39 + - include/linux/surface_aggregator/controller.h | 824 ++++++ + include/linux/surface_aggregator/controller.h | 849 +++++ include/linux/surface_aggregator/device.h | 423 +++ - include/linux/surface_aggregator/serial_hub.h | 668 +++++ - include/uapi/linux/surface_aggregator/cdev.h | 78 + + include/linux/surface_aggregator/serial_hub.h | 668 ++++ + include/uapi/linux/surface_aggregator/cdev.h | 147 + include/uapi/linux/surface_aggregator/dtx.h | 146 + scripts/mod/devicetable-offsets.c | 3 +- scripts/mod/file2alias.c | 10 +- - 55 files changed, 19112 insertions(+), 7 deletions(-) + 55 files changed, 19953 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 @@ -947,16 +947,15 @@ index 000000000000..26d13085a117 +with the same flag and it is considered a bug to do otherwise. diff --git a/Documentation/driver-api/surface_aggregator/clients/cdev.rst b/Documentation/driver-api/surface_aggregator/clients/cdev.rst new file mode 100644 -index 000000000000..248c1372d879 +index 000000000000..0134a841a079 --- /dev/null +++ b/Documentation/driver-api/surface_aggregator/clients/cdev.rst -@@ -0,0 +1,87 @@ +@@ -0,0 +1,204 @@ +.. SPDX-License-Identifier: GPL-2.0+ + -+.. |u8| replace:: :c:type:`u8 ` -+.. |u16| replace:: :c:type:`u16 ` +.. |ssam_cdev_request| replace:: :c:type:`struct ssam_cdev_request ` +.. |ssam_cdev_request_flags| replace:: :c:type:`enum ssam_cdev_request_flags ` ++.. |ssam_cdev_event| replace:: :c:type:`struct ssam_cdev_event ` + +============================== +User-Space EC Interface (cdev) @@ -976,6 +975,40 @@ index 000000000000..248c1372d879 +A small python library and scripts for accessing this interface can be found +at https://github.com/linux-surface/surface-aggregator-module/tree/master/scripts/ssam. + ++.. contents:: ++ ++ ++Receiving Events ++================ ++ ++Events can be received by reading from the device-file. The are represented by ++the |ssam_cdev_event| datatype. ++ ++Before events are available to be read, however, the desired notifiers must be ++registered via the ``SSAM_CDEV_NOTIF_REGISTER`` IOCTL. Notifiers are, in ++essence, callbacks, called when the EC sends an event. They are, in this ++interface, associated with a specific target category and device-file-instance. ++They forward any event of this category to the buffer of the corresponding ++instance, from which it can then be read. ++ ++Notifiers themselves do not enable events on the EC. Thus, it may additionally ++be necessary to enable events via the ``SSAM_CDEV_EVENT_ENABLE`` IOCTL. While ++notifiers work per-client (i.e. per-device-file-instance), events are enabled ++globally, for the EC and all of its clients (regardless of userspace or ++non-userspace). The ``SSAM_CDEV_EVENT_ENABLE`` and ``SSAM_CDEV_EVENT_DISABLE`` ++IOCTLs take care of reference counting the events, such that an event is ++enabled as long as there is a client that has requested it. ++ ++Note that enabled events are not automatically disabled once the client ++instance is closed. Therefore any client process (or group of processes) should ++balance their event enable calls with the corresponding event disable calls. It ++is, however, perfectly valid to enable and disable events on different client ++instances. For example, it is valid to set up notifiers and read events on ++client instance ``A``, enable those events on instance ``B`` (note that these ++will also be received by A since events are enabled/disabled globally), and ++after no more events are desired, disable the previously enabled events via ++instance ``C``. ++ + +Controller IOCTLs +================= @@ -998,9 +1031,33 @@ index 000000000000..248c1372d879 + - ``REQUEST`` + - Perform synchronous SAM request. + ++ * - ``0xA5`` ++ - ``2`` ++ - ``W`` ++ - ``NOTIF_REGISTER`` ++ - Register event notifier. + -+``REQUEST`` -+----------- ++ * - ``0xA5`` ++ - ``3`` ++ - ``W`` ++ - ``NOTIF_UNREGISTER`` ++ - Unregister event notifier. ++ ++ * - ``0xA5`` ++ - ``4`` ++ - ``W`` ++ - ``EVENT_ENABLE`` ++ - Enable event source. ++ ++ * - ``0xA5`` ++ - ``5`` ++ - ``W`` ++ - ``EVENT_DISABLE`` ++ - Disable event source. ++ ++ ++``SSAM_CDEV_REQUEST`` ++--------------------- + +Defined as ``_IOWR(0xA5, 1, struct ssam_cdev_request)``. + @@ -1035,7 +1092,67 @@ index 000000000000..248c1372d879 +inside the IOCTL, but the request ``status`` member may still be negative in +case the actual execution of the request failed after it has been submitted. + -+A full definition of the argument struct is provided below: ++A full definition of the argument struct is provided below. ++ ++``SSAM_CDEV_NOTIF_REGISTER`` ++---------------------------- ++ ++Defined as ``_IOW(0xA5, 2, struct ssam_cdev_notifier_desc)``. ++ ++Register a notifier for the event target category specified in the given ++notifier description with the specified priority. Notifiers registration is ++required to receive events, but does not enable events themselves. After a ++notifier for a specific target category has been registered, all events of that ++category will be forwarded to the userspace client and can then be read from ++the device file instance. Note that events may have to be enabled, e.g. via the ++``SSAM_CDEV_EVENT_ENABLE`` IOCTL, before the EC will send them. ++ ++Only one notifier can be registered per target category and client instance. If ++a notifier has already been registered, this IOCTL will fail with ``-EEXIST``. ++ ++Notifiers will automatically be removed when the device file instance is ++closed. ++ ++``SSAM_CDEV_NOTIF_UNREGISTER`` ++------------------------------ ++ ++Defined as ``_IOW(0xA5, 3, struct ssam_cdev_notifier_desc)``. ++ ++Unregisters the notifier associated with the specified target category. The ++priority field will be ignored by this IOCTL. If no notifier has been ++registered for this client instance and the given category, this IOCTL will ++fail with ``-ENOENT``. ++ ++``SSAM_CDEV_EVENT_ENABLE`` ++-------------------------- ++ ++Defined as ``_IOW(0xA5, 4, struct ssam_cdev_event_desc)``. ++ ++Enable the event associated with the given event descriptor. ++ ++Note that this call will not register a notifier itself, it will only enable ++events on the controller. If you want to receive events by reading from the ++device file, you will need to register the corresponding notifier(s) on that ++instance. ++ ++Events are not automatically disabled when the device file is closed. This must ++be done manually, via a call to the ``SSAM_CDEV_EVENT_DISABLE`` IOCTL. ++ ++``SSAM_CDEV_EVENT_DISABLE`` ++--------------------------- ++ ++Defined as ``_IOW(0xA5, 5, struct ssam_cdev_event_desc)``. ++ ++Disable the event associated with the given event descriptor. ++ ++Note that this will not unregister any notifiers. Events may still be received ++and forwarded to user-space after this call. The only safe way of stopping ++events from being received is unregistering all previously registered ++notifiers. ++ ++ ++Structures and Enums ++==================== + +.. kernel-doc:: include/uapi/linux/surface_aggregator/cdev.h diff --git a/Documentation/driver-api/surface_aggregator/clients/dtx.rst b/Documentation/driver-api/surface_aggregator/clients/dtx.rst @@ -4983,12 +5100,12 @@ index 000000000000..ef9c1f8e8336 +MODULE_LICENSE("GPL"); diff --git a/drivers/platform/x86/surface_aggregator/Kconfig b/drivers/platform/x86/surface_aggregator/Kconfig new file mode 100644 -index 000000000000..44c2493706bc +index 000000000000..cab020324256 --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/Kconfig @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: GPL-2.0+ -+# Copyright (C) 2019-2020 Maximilian Luz ++# Copyright (C) 2019-2021 Maximilian Luz + +menuconfig SURFACE_AGGREGATOR + tristate "Microsoft Surface System Aggregator Module Subsystem and Drivers" @@ -5058,12 +5175,12 @@ index 000000000000..44c2493706bc + Intended for development and debugging. diff --git a/drivers/platform/x86/surface_aggregator/Makefile b/drivers/platform/x86/surface_aggregator/Makefile new file mode 100644 -index 000000000000..c112e2c7112b +index 000000000000..c8498c41e758 --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/Makefile @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0+ -+# Copyright (C) 2019-2020 Maximilian Luz ++# Copyright (C) 2019-2021 Maximilian Luz + +# For include/trace/define_trace.h to include trace.h +CFLAGS_core.o = -I$(src) @@ -5081,7 +5198,7 @@ index 000000000000..c112e2c7112b +endif diff --git a/drivers/platform/x86/surface_aggregator/bus.c b/drivers/platform/x86/surface_aggregator/bus.c new file mode 100644 -index 000000000000..b77927b278ca +index 000000000000..e525f34eb92c --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/bus.c @@ -0,0 +1,415 @@ @@ -5089,7 +5206,7 @@ index 000000000000..b77927b278ca +/* + * Surface System Aggregator Module bus and device integration. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#include @@ -5502,7 +5619,7 @@ index 000000000000..b77927b278ca +} diff --git a/drivers/platform/x86/surface_aggregator/bus.h b/drivers/platform/x86/surface_aggregator/bus.h new file mode 100644 -index 000000000000..7712baaed6a5 +index 000000000000..ed032c2cbdb2 --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/bus.h @@ -0,0 +1,27 @@ @@ -5510,7 +5627,7 @@ index 000000000000..7712baaed6a5 +/* + * Surface System Aggregator Module bus and device integration. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#ifndef _SURFACE_AGGREGATOR_BUS_H @@ -5535,15 +5652,15 @@ index 000000000000..7712baaed6a5 +#endif /* _SURFACE_AGGREGATOR_BUS_H */ diff --git a/drivers/platform/x86/surface_aggregator/controller.c b/drivers/platform/x86/surface_aggregator/controller.c new file mode 100644 -index 000000000000..dd1f0ed9481c +index 000000000000..b5ddce8c35cb --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/controller.c -@@ -0,0 +1,2570 @@ +@@ -0,0 +1,2718 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Main SSAM/SSH controller structure and functionality. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#include @@ -7439,7 +7556,7 @@ index 000000000000..dd1f0ed9481c +{ + int status; + -+ status = __ssam_ssh_event_request(ctrl, reg, reg.cid_enable, id, flags); ++ status = __ssam_ssh_event_request(ctrl, reg, reg.cid_disable, id, flags); + + if (status < 0 && status != -EINVAL) { + ssam_err(ctrl, @@ -7659,9 +7776,15 @@ index 000000000000..dd1f0ed9481c + * @ctrl: The controller to register the notifier on. + * @n: The event notifier to register. + * -+ * Register an event notifier and increment the usage counter of the -+ * associated SAM event. If the event was previously not enabled, it will be -+ * enabled during this call. ++ * Register an event notifier. Increment the usage counter of the associated ++ * SAM event if the notifier is not marked as an observer. If the event is not ++ * marked as an observer and is currently not enabled, it will be enabled ++ * during this call. If the notifier is marked as an observer, no attempt will ++ * be made at enabling any event and no reference count will be modified. ++ * ++ * Notifiers marked as observers do not need to be associated with one specific ++ * event, i.e. as long as no event matching is performed, only the event target ++ * category needs to be set. + * + * Return: Returns zero on success, %-ENOSPC if there have already been + * %INT_MAX notifiers for the event ID/type associated with the notifier block @@ -7670,11 +7793,10 @@ index 000000000000..dd1f0ed9481c + * for the specific associated event, returns the status of the event-enable + * EC-command. + */ -+int ssam_notifier_register(struct ssam_controller *ctrl, -+ struct ssam_event_notifier *n) ++int ssam_notifier_register(struct ssam_controller *ctrl, struct ssam_event_notifier *n) +{ + u16 rqid = ssh_tc_to_rqid(n->event.id.target_category); -+ struct ssam_nf_refcount_entry *entry; ++ struct ssam_nf_refcount_entry *entry = NULL; + struct ssam_nf_head *nf_head; + struct ssam_nf *nf; + int status; @@ -7687,29 +7809,32 @@ index 000000000000..dd1f0ed9481c + + mutex_lock(&nf->lock); + -+ entry = ssam_nf_refcount_inc(nf, n->event.reg, n->event.id); -+ if (IS_ERR(entry)) { -+ mutex_unlock(&nf->lock); -+ return PTR_ERR(entry); -+ } ++ if (!(n->flags & SSAM_EVENT_NOTIFIER_OBSERVER)) { ++ entry = ssam_nf_refcount_inc(nf, n->event.reg, n->event.id); ++ if (IS_ERR(entry)) { ++ mutex_unlock(&nf->lock); ++ return PTR_ERR(entry); ++ } + -+ ssam_dbg(ctrl, "enabling event (reg: %#04x, tc: %#04x, iid: %#04x, rc: %d)\n", -+ n->event.reg.target_category, n->event.id.target_category, -+ n->event.id.instance, entry->refcount); ++ ssam_dbg(ctrl, "enabling event (reg: %#04x, tc: %#04x, iid: %#04x, rc: %d)\n", ++ n->event.reg.target_category, n->event.id.target_category, ++ n->event.id.instance, entry->refcount); ++ } + + status = ssam_nfblk_insert(nf_head, &n->base); + if (status) { -+ entry = ssam_nf_refcount_dec(nf, n->event.reg, n->event.id); -+ if (entry->refcount == 0) -+ kfree(entry); ++ if (entry) { ++ entry = ssam_nf_refcount_dec(nf, n->event.reg, n->event.id); ++ if (entry->refcount == 0) ++ kfree(entry); ++ } + + mutex_unlock(&nf->lock); + return status; + } + -+ if (entry->refcount == 1) { -+ status = ssam_ssh_event_enable(ctrl, n->event.reg, n->event.id, -+ n->event.flags); ++ if (entry && entry->refcount == 1) { ++ status = ssam_ssh_event_enable(ctrl, n->event.reg, n->event.id, n->event.flags); + if (status) { + ssam_nfblk_remove(&n->base); + kfree(ssam_nf_refcount_dec(nf, n->event.reg, n->event.id)); @@ -7720,7 +7845,7 @@ index 000000000000..dd1f0ed9481c + + entry->flags = n->event.flags; + -+ } else if (entry->flags != n->event.flags) { ++ } else if (entry && entry->flags != n->event.flags) { + ssam_warn(ctrl, + "inconsistent flags when enabling event: got %#04x, expected %#04x (reg: %#04x, tc: %#04x, iid: %#04x)\n", + n->event.flags, entry->flags, n->event.reg.target_category, @@ -7737,17 +7862,16 @@ index 000000000000..dd1f0ed9481c + * @ctrl: The controller the notifier has been registered on. + * @n: The event notifier to unregister. + * -+ * Unregister an event notifier and decrement the usage counter of the -+ * associated SAM event. If the usage counter reaches zero, the event will be -+ * disabled. ++ * Unregister an event notifier. Decrement the usage counter of the associated ++ * SAM event if the notifier is not marked as an observer. If the usage counter ++ * reaches zero, the event will be disabled. + * + * Return: Returns zero on success, %-ENOENT if the given notifier block has + * not been registered on the controller. If the given notifier block was the + * last one associated with its specific event, returns the status of the + * event-disable EC-command. + */ -+int ssam_notifier_unregister(struct ssam_controller *ctrl, -+ struct ssam_event_notifier *n) ++int ssam_notifier_unregister(struct ssam_controller *ctrl, struct ssam_event_notifier *n) +{ + u16 rqid = ssh_tc_to_rqid(n->event.id.target_category); + struct ssam_nf_refcount_entry *entry; @@ -7768,6 +7892,13 @@ index 000000000000..dd1f0ed9481c + return -ENOENT; + } + ++ /* ++ * If this is an observer notifier, do not attempt to disable the ++ * event, just remove it. ++ */ ++ if (n->flags & SSAM_EVENT_NOTIFIER_OBSERVER) ++ goto remove; ++ + entry = ssam_nf_refcount_dec(nf, n->event.reg, n->event.id); + if (WARN_ON(!entry)) { + /* @@ -7792,8 +7923,7 @@ index 000000000000..dd1f0ed9481c + } + + if (entry->refcount == 0) { -+ status = ssam_ssh_event_disable(ctrl, n->event.reg, n->event.id, -+ n->event.flags); ++ status = ssam_ssh_event_disable(ctrl, n->event.reg, n->event.id, n->event.flags); + kfree(entry); + } + @@ -7807,6 +7937,141 @@ index 000000000000..dd1f0ed9481c +EXPORT_SYMBOL_GPL(ssam_notifier_unregister); + +/** ++ * ssam_controller_event_enable() - Enable the specified event. ++ * @ctrl: The controller to enable the event for. ++ * @reg: The event registry to use for enabling the event. ++ * @id: The event ID specifying the event to be enabled. ++ * @flags: The SAM event flags used for enabling the event. ++ * ++ * Increment the event reference count of the specified event. If the event has ++ * not been enabled previously, it will be enabled by this call. ++ * ++ * Note: In general, ssam_notifier_register() with a non-observer notifier ++ * should be preferred for enabling/disabling events, as this will guarantee ++ * proper ordering and event forwarding in case of errors during event ++ * enabling/disabling. ++ * ++ * Return: Returns zero on success, %-ENOSPC if the reference count for the ++ * specified event has reached its maximum, %-ENOMEM if the corresponding event ++ * entry could not be allocated. If this is the first time that this event has ++ * been enabled (i.e. the reference count was incremented from zero to one by ++ * this call), returns the status of the event-enable EC-command. ++ */ ++int ssam_controller_event_enable(struct ssam_controller *ctrl, ++ struct ssam_event_registry reg, ++ struct ssam_event_id id, u8 flags) ++{ ++ u16 rqid = ssh_tc_to_rqid(id.target_category); ++ struct ssam_nf_refcount_entry *entry; ++ struct ssam_nf_head *nf_head; ++ struct ssam_nf *nf; ++ int status; ++ ++ if (!ssh_rqid_is_event(rqid)) ++ return -EINVAL; ++ ++ nf = &ctrl->cplt.event.notif; ++ nf_head = &nf->head[ssh_rqid_to_event(rqid)]; ++ ++ mutex_lock(&nf->lock); ++ ++ entry = ssam_nf_refcount_inc(nf, reg, id); ++ if (IS_ERR(entry)) { ++ mutex_unlock(&nf->lock); ++ return PTR_ERR(entry); ++ } ++ ++ ssam_dbg(ctrl, "enabling event (reg: %#04x, tc: %#04x, iid: %#04x, rc: %d)\n", ++ reg.target_category, id.target_category, id.instance, ++ entry->refcount); ++ ++ if (entry->refcount == 1) { ++ status = ssam_ssh_event_enable(ctrl, reg, id, flags); ++ if (status) { ++ kfree(ssam_nf_refcount_dec(nf, reg, id)); ++ mutex_unlock(&nf->lock); ++ return status; ++ } ++ ++ entry->flags = flags; ++ ++ } else if (entry->flags != flags) { ++ ssam_warn(ctrl, ++ "inconsistent flags when enabling event: got %#04x, expected %#04x (reg: %#04x, tc: %#04x, iid: %#04x)\n", ++ flags, entry->flags, reg.target_category, ++ id.target_category, id.instance); ++ } ++ ++ mutex_unlock(&nf->lock); ++ return 0; ++} ++EXPORT_SYMBOL_GPL(ssam_controller_event_enable); ++ ++/** ++ * ssam_controller_event_disable() - Disable the specified event. ++ * @ctrl: The controller to disable the event for. ++ * @reg: The event registry to use for disabling the event. ++ * @id: The event ID specifying the event to be disabled. ++ * @flags: The flags used when enabling the event. ++ * ++ * Decrement the reference count of the specified event. If the reference count ++ * reaches zero, the event will be disabled. ++ * ++ * Note: In general, ssam_notifier_register()/ssam_notifier_unregister() with a ++ * non-observer notifier should be preferred for enabling/disabling events, as ++ * this will guarantee proper ordering and event forwarding in case of errors ++ * during event enabling/disabling. ++ * ++ * Return: Returns zero on success, %-ENOENT if the given event has not been ++ * enabled on the controller. If the reference count of the event reaches zero ++ * during this call, returns the status of the event-disable EC-command. ++ */ ++int ssam_controller_event_disable(struct ssam_controller *ctrl, ++ struct ssam_event_registry reg, ++ struct ssam_event_id id, u8 flags) ++{ ++ u16 rqid = ssh_tc_to_rqid(id.target_category); ++ struct ssam_nf_refcount_entry *entry; ++ struct ssam_nf_head *nf_head; ++ struct ssam_nf *nf; ++ int status = 0; ++ ++ if (!ssh_rqid_is_event(rqid)) ++ return -EINVAL; ++ ++ nf = &ctrl->cplt.event.notif; ++ nf_head = &nf->head[ssh_rqid_to_event(rqid)]; ++ ++ mutex_lock(&nf->lock); ++ ++ entry = ssam_nf_refcount_dec(nf, reg, id); ++ if (WARN_ON(!entry)) { ++ mutex_unlock(&nf->lock); ++ return -ENOENT; ++ } ++ ++ ssam_dbg(ctrl, "disabling event (reg: %#04x, tc: %#04x, iid: %#04x, rc: %d)\n", ++ reg.target_category, id.target_category, id.instance, ++ entry->refcount); ++ ++ if (entry->flags != flags) { ++ ssam_warn(ctrl, ++ "inconsistent flags when disabling event: got %#04x, expected %#04x (reg: %#04x, tc: %#04x, iid: %#04x)\n", ++ flags, entry->flags, reg.target_category, ++ id.target_category, id.instance); ++ } ++ ++ if (entry->refcount == 0) { ++ status = ssam_ssh_event_disable(ctrl, reg, id, flags); ++ kfree(entry); ++ } ++ ++ mutex_unlock(&nf->lock); ++ return status; ++} ++EXPORT_SYMBOL_GPL(ssam_controller_event_disable); ++ ++/** + * ssam_notifier_disable_registered() - Disable events for all registered + * notifiers. + * @ctrl: The controller for which to disable the notifiers/events. @@ -8111,7 +8376,7 @@ index 000000000000..dd1f0ed9481c +} diff --git a/drivers/platform/x86/surface_aggregator/controller.h b/drivers/platform/x86/surface_aggregator/controller.h new file mode 100644 -index 000000000000..8297d34e7489 +index 000000000000..a0963c3562ff --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/controller.h @@ -0,0 +1,285 @@ @@ -8119,7 +8384,7 @@ index 000000000000..8297d34e7489 +/* + * Main SSAM/SSH controller structure and functionality. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#ifndef _SURFACE_AGGREGATOR_CONTROLLER_H @@ -8402,7 +8667,7 @@ index 000000000000..8297d34e7489 +#endif /* _SURFACE_AGGREGATOR_CONTROLLER_H */ diff --git a/drivers/platform/x86/surface_aggregator/core.c b/drivers/platform/x86/surface_aggregator/core.c new file mode 100644 -index 000000000000..1b35f3e284da +index 000000000000..698be0e24e9e --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/core.c @@ -0,0 +1,850 @@ @@ -8415,7 +8680,7 @@ index 000000000000..1b35f3e284da + * Handles communication via requests as well as enabling, disabling, and + * relaying of events. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#include @@ -9258,7 +9523,7 @@ index 000000000000..1b35f3e284da +MODULE_LICENSE("GPL"); diff --git a/drivers/platform/x86/surface_aggregator/ssh_msgb.h b/drivers/platform/x86/surface_aggregator/ssh_msgb.h new file mode 100644 -index 000000000000..1221f642dda1 +index 000000000000..e562958ffdf0 --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/ssh_msgb.h @@ -0,0 +1,205 @@ @@ -9266,7 +9531,7 @@ index 000000000000..1221f642dda1 +/* + * SSH message builder functions. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#ifndef _SURFACE_AGGREGATOR_SSH_MSGB_H @@ -9469,7 +9734,7 @@ index 000000000000..1221f642dda1 +#endif /* _SURFACE_AGGREGATOR_SSH_MSGB_H */ diff --git a/drivers/platform/x86/surface_aggregator/ssh_packet_layer.c b/drivers/platform/x86/surface_aggregator/ssh_packet_layer.c new file mode 100644 -index 000000000000..d4a82b42a881 +index 000000000000..8a06beb39aee --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/ssh_packet_layer.c @@ -0,0 +1,2074 @@ @@ -9477,7 +9742,7 @@ index 000000000000..d4a82b42a881 +/* + * SSH packet transport layer. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#include @@ -11549,7 +11814,7 @@ index 000000000000..d4a82b42a881 +} diff --git a/drivers/platform/x86/surface_aggregator/ssh_packet_layer.h b/drivers/platform/x86/surface_aggregator/ssh_packet_layer.h new file mode 100644 -index 000000000000..e8757d03f279 +index 000000000000..2eb329f0b91a --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/ssh_packet_layer.h @@ -0,0 +1,190 @@ @@ -11557,7 +11822,7 @@ index 000000000000..e8757d03f279 +/* + * SSH packet transport layer. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#ifndef _SURFACE_AGGREGATOR_SSH_PACKET_LAYER_H @@ -11745,7 +12010,7 @@ index 000000000000..e8757d03f279 +#endif /* _SURFACE_AGGREGATOR_SSH_PACKET_LAYER_H */ diff --git a/drivers/platform/x86/surface_aggregator/ssh_parser.c b/drivers/platform/x86/surface_aggregator/ssh_parser.c new file mode 100644 -index 000000000000..e2dead8de94a +index 000000000000..b77912f8f13b --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/ssh_parser.c @@ -0,0 +1,228 @@ @@ -11753,7 +12018,7 @@ index 000000000000..e2dead8de94a +/* + * SSH message parser. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#include @@ -11979,7 +12244,7 @@ index 000000000000..e2dead8de94a +} diff --git a/drivers/platform/x86/surface_aggregator/ssh_parser.h b/drivers/platform/x86/surface_aggregator/ssh_parser.h new file mode 100644 -index 000000000000..63c38d350988 +index 000000000000..3bd6e180fd16 --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/ssh_parser.h @@ -0,0 +1,154 @@ @@ -11987,7 +12252,7 @@ index 000000000000..63c38d350988 +/* + * SSH message parser. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#ifndef _SURFACE_AGGREGATOR_SSH_PARSER_H @@ -12139,7 +12404,7 @@ index 000000000000..63c38d350988 +#endif /* _SURFACE_AGGREGATOR_SSH_PARSER_h */ diff --git a/drivers/platform/x86/surface_aggregator/ssh_request_layer.c b/drivers/platform/x86/surface_aggregator/ssh_request_layer.c new file mode 100644 -index 000000000000..52a83a8fcf82 +index 000000000000..bfe1aaf38065 --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/ssh_request_layer.c @@ -0,0 +1,1263 @@ @@ -12147,7 +12412,7 @@ index 000000000000..52a83a8fcf82 +/* + * SSH request transport layer. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#include @@ -13408,7 +13673,7 @@ index 000000000000..52a83a8fcf82 +} diff --git a/drivers/platform/x86/surface_aggregator/ssh_request_layer.h b/drivers/platform/x86/surface_aggregator/ssh_request_layer.h new file mode 100644 -index 000000000000..cb35815858d1 +index 000000000000..9c3cbae2d4bd --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/ssh_request_layer.h @@ -0,0 +1,143 @@ @@ -13416,7 +13681,7 @@ index 000000000000..cb35815858d1 +/* + * SSH request transport layer. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#ifndef _SURFACE_AGGREGATOR_SSH_REQUEST_LAYER_H @@ -13557,7 +13822,7 @@ index 000000000000..cb35815858d1 +#endif /* _SURFACE_AGGREGATOR_SSH_REQUEST_LAYER_H */ diff --git a/drivers/platform/x86/surface_aggregator/trace.h b/drivers/platform/x86/surface_aggregator/trace.h new file mode 100644 -index 000000000000..eb332bb53ae4 +index 000000000000..de64cf169060 --- /dev/null +++ b/drivers/platform/x86/surface_aggregator/trace.h @@ -0,0 +1,632 @@ @@ -13565,7 +13830,7 @@ index 000000000000..eb332bb53ae4 +/* + * Trace points for SSAM/SSH. + * -+ * Copyright (C) 2020 Maximilian Luz ++ * Copyright (C) 2020-2021 Maximilian Luz + */ + +#undef TRACE_SYSTEM @@ -14195,38 +14460,77 @@ index 000000000000..eb332bb53ae4 +#include diff --git a/drivers/platform/x86/surface_aggregator_cdev.c b/drivers/platform/x86/surface_aggregator_cdev.c new file mode 100644 -index 000000000000..cad859e1402d +index 000000000000..93969d9f7f9a --- /dev/null +++ b/drivers/platform/x86/surface_aggregator_cdev.c -@@ -0,0 +1,322 @@ +@@ -0,0 +1,804 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Provides user-space access to the SSAM EC via the /dev/surface/aggregator + * misc device. Intended for debugging and development. + * -+ * Copyright (C) 2020 Maximilian Luz ++ * Copyright (C) 2020-2021 Maximilian Luz + */ + +#include ++#include +#include ++#include +#include +#include +#include +#include ++#include +#include +#include +#include ++#include + +#include +#include + +#define SSAM_CDEV_DEVICE_NAME "surface_aggregator_cdev" + ++ ++/* -- Main structures. ------------------------------------------------------ */ ++ ++enum ssam_cdev_device_state { ++ SSAM_CDEV_DEVICE_SHUTDOWN_BIT = BIT(0), ++}; ++ +struct ssam_cdev { + struct kref kref; + struct rw_semaphore lock; ++ ++ struct device *dev; + struct ssam_controller *ctrl; + struct miscdevice mdev; ++ unsigned long flags; ++ ++ struct rw_semaphore client_lock; /* Guards client list. */ ++ struct list_head client_list; ++}; ++ ++struct ssam_cdev_client; ++ ++struct ssam_cdev_notifier { ++ struct ssam_cdev_client *client; ++ struct ssam_event_notifier nf; ++}; ++ ++struct ssam_cdev_client { ++ struct ssam_cdev *cdev; ++ struct list_head node; ++ ++ struct mutex notifier_lock; /* Guards notifier access for registration */ ++ struct ssam_cdev_notifier *notifier[SSH_NUM_EVENTS]; ++ ++ struct mutex read_lock; /* Guards FIFO buffer read access */ ++ struct mutex write_lock; /* Guards FIFO buffer write access */ ++ DECLARE_KFIFO(buffer, u8, 4096); ++ ++ wait_queue_head_t waitq; ++ struct fasync_struct *fasync; +}; + +static void __ssam_cdev_release(struct kref *kref) @@ -14248,24 +14552,171 @@ index 000000000000..cad859e1402d + kref_put(&cdev->kref, __ssam_cdev_release); +} + -+static int ssam_cdev_device_open(struct inode *inode, struct file *filp) -+{ -+ struct miscdevice *mdev = filp->private_data; -+ struct ssam_cdev *cdev = container_of(mdev, struct ssam_cdev, mdev); + -+ filp->private_data = ssam_cdev_get(cdev); -+ return stream_open(inode, filp); -+} ++/* -- Notifier handling. ---------------------------------------------------- */ + -+static int ssam_cdev_device_release(struct inode *inode, struct file *filp) ++static u32 ssam_cdev_notifier(struct ssam_event_notifier *nf, const struct ssam_event *in) +{ -+ ssam_cdev_put(filp->private_data); ++ struct ssam_cdev_notifier *cdev_nf = container_of(nf, struct ssam_cdev_notifier, nf); ++ struct ssam_cdev_client *client = cdev_nf->client; ++ struct ssam_cdev_event event; ++ size_t n = struct_size(&event, data, in->length); ++ ++ /* Translate event. */ ++ event.target_category = in->target_category; ++ event.target_id = in->target_id; ++ event.command_id = in->command_id; ++ event.instance_id = in->instance_id; ++ event.length = in->length; ++ ++ mutex_lock(&client->write_lock); ++ ++ /* Make sure we have enough space. */ ++ if (kfifo_avail(&client->buffer) < n) { ++ dev_warn(client->cdev->dev, ++ "buffer full, dropping event (tc: %#04x, tid: %#04x, cid: %#04x, iid: %#04x)\n", ++ in->target_category, in->target_id, in->command_id, in->instance_id); ++ mutex_unlock(&client->write_lock); ++ return 0; ++ } ++ ++ /* Copy event header and payload. */ ++ kfifo_in(&client->buffer, (const u8 *)&event, struct_size(&event, data, 0)); ++ kfifo_in(&client->buffer, &in->data[0], in->length); ++ ++ mutex_unlock(&client->write_lock); ++ ++ /* Notify waiting readers. */ ++ kill_fasync(&client->fasync, SIGIO, POLL_IN); ++ wake_up_interruptible(&client->waitq); ++ ++ /* ++ * Don't mark events as handled, this is the job of a proper driver and ++ * not the debugging interface. ++ */ + return 0; +} + -+static long ssam_cdev_request(struct ssam_cdev *cdev, unsigned long arg) ++static int ssam_cdev_notifier_register(struct ssam_cdev_client *client, u8 category, int priority) ++{ ++ struct ssam_cdev_notifier *nf; ++ int index = ((int)category) - 1; ++ int status; ++ ++ lockdep_assert_held_read(&client->cdev->lock); ++ ++ /* Validate notifier target category. */ ++ if (index < 0 || index >= SSH_NUM_EVENTS) ++ return -EINVAL; ++ ++ mutex_lock(&client->notifier_lock); ++ ++ /* Check if the notifier has already been registered. */ ++ if (client->notifier[index]) { ++ mutex_unlock(&client->notifier_lock); ++ return -EEXIST; ++ } ++ ++ /* Allocate new notifier. */ ++ nf = kzalloc(sizeof(*nf), GFP_KERNEL); ++ if (!nf) { ++ mutex_unlock(&client->notifier_lock); ++ return -ENOMEM; ++ } ++ ++ /* ++ * Create a dummy notifier with the minimal required fields for ++ * observer registration. Note that we can skip fully specifying event ++ * and registry here as we do not need any matching and use silent ++ * registration, which does not enable the corresponding event. ++ */ ++ nf->client = client; ++ nf->nf.base.fn = ssam_cdev_notifier; ++ nf->nf.base.priority = priority; ++ nf->nf.event.id.target_category = category; ++ nf->nf.event.mask = 0; /* Do not do any matching. */ ++ nf->nf.flags = SSAM_EVENT_NOTIFIER_OBSERVER; ++ ++ /* Register notifier. */ ++ status = ssam_notifier_register(client->cdev->ctrl, &nf->nf); ++ if (status) ++ kfree(nf); ++ else ++ client->notifier[index] = nf; ++ ++ mutex_unlock(&client->notifier_lock); ++ return status; ++} ++ ++static int ssam_cdev_notifier_unregister(struct ssam_cdev_client *client, u8 category) ++{ ++ int index = ((int)category) - 1; ++ int status; ++ ++ lockdep_assert_held_read(&client->cdev->lock); ++ ++ /* Validate notifier target category. */ ++ if (index < 0 || index >= SSH_NUM_EVENTS) ++ return -EINVAL; ++ ++ mutex_lock(&client->notifier_lock); ++ ++ /* Check if the notifier is currently registered. */ ++ if (!client->notifier[index]) { ++ mutex_unlock(&client->notifier_lock); ++ return -ENOENT; ++ } ++ ++ /* Unregister and free notifier. */ ++ status = ssam_notifier_unregister(client->cdev->ctrl, &client->notifier[index]->nf); ++ kfree(client->notifier[index]); ++ client->notifier[index] = NULL; ++ ++ mutex_unlock(&client->notifier_lock); ++ return status; ++} ++ ++static void ssam_cdev_notifier_unregister_all(struct ssam_cdev_client *client) ++{ ++ int i; ++ ++ down_read(&client->cdev->lock); ++ ++ /* ++ * This function may be used during shutdown, thus we need to test for ++ * cdev->ctrl instead of the SSAM_CDEV_DEVICE_SHUTDOWN_BIT bit. ++ */ ++ if (client->cdev->ctrl) { ++ for (i = 0; i < SSH_NUM_EVENTS; i++) ++ ssam_cdev_notifier_unregister(client, i + 1); ++ ++ } else { ++ int count = 0; ++ ++ /* ++ * Device has been shut down. Any notifier remaining is a bug, ++ * so warn about that as this would otherwise hardly be ++ * noticeable. Nevertheless, free them as well. ++ */ ++ mutex_lock(&client->notifier_lock); ++ for (i = 0; i < SSH_NUM_EVENTS; i++) { ++ count += !!(client->notifier[i]); ++ kfree(client->notifier[i]); ++ client->notifier[i] = NULL; ++ } ++ mutex_unlock(&client->notifier_lock); ++ ++ WARN_ON(count > 0); ++ } ++ ++ up_read(&client->cdev->lock); ++} ++ ++ ++/* -- IOCTL functions. ------------------------------------------------------ */ ++ ++static long ssam_cdev_request(struct ssam_cdev_client *client, struct ssam_cdev_request __user *r) +{ -+ struct ssam_cdev_request __user *r; + struct ssam_cdev_request rqst; + struct ssam_request spec = {}; + struct ssam_response rsp = {}; @@ -14273,7 +14724,8 @@ index 000000000000..cad859e1402d + void __user *rspdata; + int status = 0, ret = 0, tmp; + -+ r = (struct ssam_cdev_request __user *)arg; ++ lockdep_assert_held_read(&client->cdev->lock); ++ + ret = copy_from_user(&rqst, r, sizeof(struct ssam_cdev_request)); + if (ret) + goto out; @@ -14353,7 +14805,7 @@ index 000000000000..cad859e1402d + } + + /* Perform request. */ -+ status = ssam_request_sync(cdev->ctrl, &spec, &rsp); ++ status = ssam_request_sync(client->cdev->ctrl, &spec, &rsp); + if (status) + goto out; + @@ -14378,48 +14830,312 @@ index 000000000000..cad859e1402d + return ret; +} + -+static long __ssam_cdev_device_ioctl(struct ssam_cdev *cdev, unsigned int cmd, ++static long ssam_cdev_notif_register(struct ssam_cdev_client *client, ++ const struct ssam_cdev_notifier_desc __user *d) ++{ ++ struct ssam_cdev_notifier_desc desc; ++ long ret; ++ ++ lockdep_assert_held_read(&client->cdev->lock); ++ ++ ret = copy_from_user(&desc, d, sizeof(*d)); ++ if (ret) ++ return ret; ++ ++ return ssam_cdev_notifier_register(client, desc.target_category, desc.priority); ++} ++ ++static long ssam_cdev_notif_unregister(struct ssam_cdev_client *client, ++ const struct ssam_cdev_notifier_desc __user *d) ++{ ++ struct ssam_cdev_notifier_desc desc; ++ long ret; ++ ++ lockdep_assert_held_read(&client->cdev->lock); ++ ++ ret = copy_from_user(&desc, d, sizeof(*d)); ++ if (ret) ++ return ret; ++ ++ return ssam_cdev_notifier_unregister(client, desc.target_category); ++} ++ ++static long ssam_cdev_event_enable(struct ssam_cdev_client *client, ++ const struct ssam_cdev_event_desc __user *d) ++{ ++ struct ssam_cdev_event_desc desc; ++ struct ssam_event_registry reg; ++ struct ssam_event_id id; ++ long ret; ++ ++ lockdep_assert_held_read(&client->cdev->lock); ++ ++ /* Read descriptor from user-space. */ ++ ret = copy_from_user(&desc, d, sizeof(*d)); ++ if (ret) ++ return ret; ++ ++ /* Translate descriptor. */ ++ reg.target_category = desc.reg.target_category; ++ reg.target_id = desc.reg.target_id; ++ reg.cid_enable = desc.reg.cid_enable; ++ reg.cid_disable = desc.reg.cid_disable; ++ ++ id.target_category = desc.id.target_category; ++ id.instance = desc.id.instance; ++ ++ /* Disable event. */ ++ return ssam_controller_event_enable(client->cdev->ctrl, reg, id, desc.flags); ++} ++ ++static long ssam_cdev_event_disable(struct ssam_cdev_client *client, ++ const struct ssam_cdev_event_desc __user *d) ++{ ++ struct ssam_cdev_event_desc desc; ++ struct ssam_event_registry reg; ++ struct ssam_event_id id; ++ long ret; ++ ++ lockdep_assert_held_read(&client->cdev->lock); ++ ++ /* Read descriptor from user-space. */ ++ ret = copy_from_user(&desc, d, sizeof(*d)); ++ if (ret) ++ return ret; ++ ++ /* Translate descriptor. */ ++ reg.target_category = desc.reg.target_category; ++ reg.target_id = desc.reg.target_id; ++ reg.cid_enable = desc.reg.cid_enable; ++ reg.cid_disable = desc.reg.cid_disable; ++ ++ id.target_category = desc.id.target_category; ++ id.instance = desc.id.instance; ++ ++ /* Disable event. */ ++ return ssam_controller_event_disable(client->cdev->ctrl, reg, id, desc.flags); ++} ++ ++ ++/* -- File operations. ------------------------------------------------------ */ ++ ++static int ssam_cdev_device_open(struct inode *inode, struct file *filp) ++{ ++ struct miscdevice *mdev = filp->private_data; ++ struct ssam_cdev_client *client; ++ struct ssam_cdev *cdev = container_of(mdev, struct ssam_cdev, mdev); ++ ++ /* Initialize client */ ++ client = vzalloc(sizeof(*client)); ++ if (!client) ++ return -ENOMEM; ++ ++ client->cdev = ssam_cdev_get(cdev); ++ ++ INIT_LIST_HEAD(&client->node); ++ ++ mutex_init(&client->notifier_lock); ++ ++ mutex_init(&client->read_lock); ++ mutex_init(&client->write_lock); ++ INIT_KFIFO(client->buffer); ++ init_waitqueue_head(&client->waitq); ++ ++ filp->private_data = client; ++ ++ /* Attach client. */ ++ down_write(&cdev->client_lock); ++ ++ if (test_bit(SSAM_CDEV_DEVICE_SHUTDOWN_BIT, &cdev->flags)) { ++ up_write(&cdev->client_lock); ++ ssam_cdev_put(client->cdev); ++ vfree(client); ++ return -ENODEV; ++ } ++ list_add_tail(&client->node, &cdev->client_list); ++ ++ up_write(&cdev->client_lock); ++ ++ stream_open(inode, filp); ++ return 0; ++} ++ ++static int ssam_cdev_device_release(struct inode *inode, struct file *filp) ++{ ++ struct ssam_cdev_client *client = filp->private_data; ++ ++ /* Force-unregister all remaining notifiers of this client. */ ++ ssam_cdev_notifier_unregister_all(client); ++ ++ /* Detach client. */ ++ down_write(&client->cdev->client_lock); ++ list_del(&client->node); ++ up_write(&client->cdev->client_lock); ++ ++ /* Free client. */ ++ mutex_destroy(&client->write_lock); ++ mutex_destroy(&client->read_lock); ++ ++ mutex_destroy(&client->notifier_lock); ++ ++ ssam_cdev_put(client->cdev); ++ vfree(client); ++ ++ return 0; ++} ++ ++static long __ssam_cdev_device_ioctl(struct ssam_cdev_client *client, unsigned int cmd, + unsigned long arg) +{ ++ lockdep_assert_held_read(&client->cdev->lock); ++ + switch (cmd) { + case SSAM_CDEV_REQUEST: -+ return ssam_cdev_request(cdev, arg); ++ return ssam_cdev_request(client, (struct ssam_cdev_request __user *)arg); ++ ++ case SSAM_CDEV_NOTIF_REGISTER: ++ return ssam_cdev_notif_register(client, ++ (struct ssam_cdev_notifier_desc __user *)arg); ++ ++ case SSAM_CDEV_NOTIF_UNREGISTER: ++ return ssam_cdev_notif_unregister(client, ++ (struct ssam_cdev_notifier_desc __user *)arg); ++ ++ case SSAM_CDEV_EVENT_ENABLE: ++ return ssam_cdev_event_enable(client, (struct ssam_cdev_event_desc __user *)arg); ++ ++ case SSAM_CDEV_EVENT_DISABLE: ++ return ssam_cdev_event_disable(client, (struct ssam_cdev_event_desc __user *)arg); + + default: + return -ENOTTY; + } +} + -+static long ssam_cdev_device_ioctl(struct file *file, unsigned int cmd, -+ unsigned long arg) ++static long ssam_cdev_device_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ -+ struct ssam_cdev *cdev = file->private_data; ++ struct ssam_cdev_client *client = file->private_data; + long status; + + /* Ensure that controller is valid for as long as we need it. */ ++ if (down_read_killable(&client->cdev->lock)) ++ return -ERESTARTSYS; ++ ++ if (test_bit(SSAM_CDEV_DEVICE_SHUTDOWN_BIT, &client->cdev->flags)) { ++ up_read(&client->cdev->lock); ++ return -ENODEV; ++ } ++ ++ status = __ssam_cdev_device_ioctl(client, cmd, arg); ++ ++ up_read(&client->cdev->lock); ++ return status; ++} ++ ++static ssize_t ssam_cdev_read(struct file *file, char __user *buf, size_t count, loff_t *offs) ++{ ++ struct ssam_cdev_client *client = file->private_data; ++ struct ssam_cdev *cdev = client->cdev; ++ unsigned int copied; ++ int status = 0; ++ + if (down_read_killable(&cdev->lock)) + return -ERESTARTSYS; + -+ if (!cdev->ctrl) { ++ /* Make sure we're not shut down. */ ++ if (test_bit(SSAM_CDEV_DEVICE_SHUTDOWN_BIT, &cdev->flags)) { + up_read(&cdev->lock); + return -ENODEV; + } + -+ status = __ssam_cdev_device_ioctl(cdev, cmd, arg); ++ do { ++ /* Check availability, wait if necessary. */ ++ if (kfifo_is_empty(&client->buffer)) { ++ up_read(&cdev->lock); ++ ++ if (file->f_flags & O_NONBLOCK) ++ return -EAGAIN; ++ ++ status = wait_event_interruptible(client->waitq, ++ !kfifo_is_empty(&client->buffer) || ++ test_bit(SSAM_CDEV_DEVICE_SHUTDOWN_BIT, ++ &cdev->flags)); ++ if (status < 0) ++ return status; ++ ++ if (down_read_killable(&cdev->lock)) ++ return -ERESTARTSYS; ++ ++ /* Need to check that we're not shut down again. */ ++ if (test_bit(SSAM_CDEV_DEVICE_SHUTDOWN_BIT, &cdev->flags)) { ++ up_read(&cdev->lock); ++ return -ENODEV; ++ } ++ } ++ ++ /* Try to read from FIFO. */ ++ if (mutex_lock_interruptible(&client->read_lock)) { ++ up_read(&cdev->lock); ++ return -ERESTARTSYS; ++ } ++ ++ status = kfifo_to_user(&client->buffer, buf, count, &copied); ++ mutex_unlock(&client->read_lock); ++ ++ if (status < 0) { ++ up_read(&cdev->lock); ++ return status; ++ } ++ ++ /* We might not have gotten anything, check this here. */ ++ if (copied == 0 && (file->f_flags & O_NONBLOCK)) { ++ up_read(&cdev->lock); ++ return -EAGAIN; ++ } ++ } while (copied == 0); + + up_read(&cdev->lock); -+ return status; ++ return copied; ++} ++ ++static __poll_t ssam_cdev_poll(struct file *file, struct poll_table_struct *pt) ++{ ++ struct ssam_cdev_client *client = file->private_data; ++ __poll_t events = 0; ++ ++ if (test_bit(SSAM_CDEV_DEVICE_SHUTDOWN_BIT, &client->cdev->flags)) ++ return EPOLLHUP | EPOLLERR; ++ ++ poll_wait(file, &client->waitq, pt); ++ ++ if (!kfifo_is_empty(&client->buffer)) ++ events |= EPOLLIN | EPOLLRDNORM; ++ ++ return events; ++} ++ ++static int ssam_cdev_fasync(int fd, struct file *file, int on) ++{ ++ struct ssam_cdev_client *client = file->private_data; ++ ++ return fasync_helper(fd, file, on, &client->fasync); +} + +static const struct file_operations ssam_controller_fops = { + .owner = THIS_MODULE, + .open = ssam_cdev_device_open, + .release = ssam_cdev_device_release, ++ .read = ssam_cdev_read, ++ .poll = ssam_cdev_poll, ++ .fasync = ssam_cdev_fasync, + .unlocked_ioctl = ssam_cdev_device_ioctl, + .compat_ioctl = ssam_cdev_device_ioctl, -+ .llseek = noop_llseek, ++ .llseek = no_llseek, +}; + ++ ++/* -- Device and driver setup ----------------------------------------------- */ ++ +static int ssam_dbg_device_probe(struct platform_device *pdev) +{ + struct ssam_controller *ctrl; @@ -14437,6 +15153,7 @@ index 000000000000..cad859e1402d + kref_init(&cdev->kref); + init_rwsem(&cdev->lock); + cdev->ctrl = ctrl; ++ cdev->dev = &pdev->dev; + + cdev->mdev.parent = &pdev->dev; + cdev->mdev.minor = MISC_DYNAMIC_MINOR; @@ -14444,6 +15161,9 @@ index 000000000000..cad859e1402d + cdev->mdev.nodename = "surface/aggregator"; + cdev->mdev.fops = &ssam_controller_fops; + ++ init_rwsem(&cdev->client_lock); ++ INIT_LIST_HEAD(&cdev->client_list); ++ + status = misc_register(&cdev->mdev); + if (status) { + kfree(cdev); @@ -14457,8 +15177,32 @@ index 000000000000..cad859e1402d +static int ssam_dbg_device_remove(struct platform_device *pdev) +{ + struct ssam_cdev *cdev = platform_get_drvdata(pdev); ++ struct ssam_cdev_client *client; + -+ misc_deregister(&cdev->mdev); ++ /* ++ * Mark device as shut-down. Prevent new clients from being added and ++ * new operations from being executed. ++ */ ++ set_bit(SSAM_CDEV_DEVICE_SHUTDOWN_BIT, &cdev->flags); ++ ++ down_write(&cdev->client_lock); ++ ++ /* Remove all notifiers registered by us. */ ++ list_for_each_entry(client, &cdev->client_list, node) { ++ ssam_cdev_notifier_unregister_all(client); ++ } ++ ++ /* Wake up async clients. */ ++ list_for_each_entry(client, &cdev->client_list, node) { ++ kill_fasync(&client->fasync, SIGIO, POLL_HUP); ++ } ++ ++ /* Wake up blocking clients. */ ++ list_for_each_entry(client, &cdev->client_list, node) { ++ wake_up_interruptible(&client->waitq); ++ } ++ ++ up_write(&cdev->client_lock); + + /* + * The controller is only guaranteed to be valid for as long as the @@ -14467,8 +15211,11 @@ index 000000000000..cad859e1402d + */ + down_write(&cdev->lock); + cdev->ctrl = NULL; ++ cdev->dev = NULL; + up_write(&cdev->lock); + ++ misc_deregister(&cdev->mdev); ++ + ssam_cdev_put(cdev); + return 0; +} @@ -17791,10 +18538,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..f4b1ba887384 +index 000000000000..8cee730e01f3 --- /dev/null +++ b/include/linux/surface_aggregator/controller.h -@@ -0,0 +1,824 @@ +@@ -0,0 +1,849 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Surface System Aggregator Module (SSAM) controller interface. @@ -17803,7 +18550,7 @@ index 000000000000..f4b1ba887384 + * managing access and communication to and from the SSAM EC, as well as main + * communication structures and definitions. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#ifndef _LINUX_SURFACE_AGGREGATOR_CONTROLLER_H @@ -18593,6 +19340,20 @@ index 000000000000..f4b1ba887384 + SSAM_EVENT_REGISTRY(SSAM_SSH_TC_REG, 0x02, 0x01, 0x02) + +/** ++ * enum ssam_event_notifier_flags - Flags for event notifiers. ++ * @SSAM_EVENT_NOTIFIER_OBSERVER: ++ * The corresponding notifier acts as observer. Registering a notifier ++ * with this flag set will not attempt to enable any event. Equally, ++ * unregistering will not attempt to disable any event. Note that a ++ * notifier with this flag may not even correspond to a certain event at ++ * all, only to a specific event target category. Event matching will not ++ * be influenced by this flag. ++ */ ++enum ssam_event_notifier_flags { ++ SSAM_EVENT_NOTIFIER_OBSERVER = BIT(0), ++}; ++ ++/** + * struct ssam_event_notifier - Notifier block for SSAM events. + * @base: The base notifier block with callback function and priority. + * @event: The event for which this block will receive notifications. @@ -18600,6 +19361,7 @@ index 000000000000..f4b1ba887384 + * @event.id: ID specifying the event. + * @event.mask: Flags determining how events are matched to the notifier. + * @event.flags: Flags used for enabling the event. ++ * @flags: Notifier flags (see &enum ssam_event_notifier_flags). + */ +struct ssam_event_notifier { + struct ssam_notifier_block base; @@ -18610,6 +19372,8 @@ index 000000000000..f4b1ba887384 + enum ssam_event_mask mask; + u8 flags; + } event; ++ ++ unsigned long flags; +}; + +int ssam_notifier_register(struct ssam_controller *ctrl, @@ -18618,10 +19382,18 @@ index 000000000000..f4b1ba887384 +int ssam_notifier_unregister(struct ssam_controller *ctrl, + struct ssam_event_notifier *n); + ++int ssam_controller_event_enable(struct ssam_controller *ctrl, ++ struct ssam_event_registry reg, ++ struct ssam_event_id id, u8 flags); ++ ++int ssam_controller_event_disable(struct ssam_controller *ctrl, ++ struct ssam_event_registry reg, ++ struct ssam_event_id id, u8 flags); ++ +#endif /* _LINUX_SURFACE_AGGREGATOR_CONTROLLER_H */ diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h new file mode 100644 -index 000000000000..9345ad67fb6a +index 000000000000..c092211a154d --- /dev/null +++ b/include/linux/surface_aggregator/device.h @@ -0,0 +1,423 @@ @@ -18634,7 +19406,7 @@ index 000000000000..9345ad67fb6a + * Provides support for non-platform/non-ACPI SSAM clients via dedicated + * subsystem. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#ifndef _LINUX_SURFACE_AGGREGATOR_DEVICE_H @@ -19050,7 +19822,7 @@ index 000000000000..9345ad67fb6a +#endif /* _LINUX_SURFACE_AGGREGATOR_DEVICE_H */ diff --git a/include/linux/surface_aggregator/serial_hub.h b/include/linux/surface_aggregator/serial_hub.h new file mode 100644 -index 000000000000..c78ab6e472c8 +index 000000000000..f02d89168533 --- /dev/null +++ b/include/linux/surface_aggregator/serial_hub.h @@ -0,0 +1,668 @@ @@ -19062,7 +19834,7 @@ index 000000000000..c78ab6e472c8 + * Surface System Aggregator Module (SSAM). Provides the interface for basic + * packet- and request-based communication with the SSAM EC via SSH. + * -+ * Copyright (C) 2019-2020 Maximilian Luz ++ * Copyright (C) 2019-2021 Maximilian Luz + */ + +#ifndef _LINUX_SURFACE_AGGREGATOR_SERIAL_HUB_H @@ -19724,10 +20496,10 @@ index 000000000000..c78ab6e472c8 +#endif /* _LINUX_SURFACE_AGGREGATOR_SERIAL_HUB_H */ diff --git a/include/uapi/linux/surface_aggregator/cdev.h b/include/uapi/linux/surface_aggregator/cdev.h new file mode 100644 -index 000000000000..fbcce04abfe9 +index 000000000000..08f46b60b151 --- /dev/null +++ b/include/uapi/linux/surface_aggregator/cdev.h -@@ -0,0 +1,78 @@ +@@ -0,0 +1,147 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * Surface System Aggregator Module (SSAM) user-space EC interface. @@ -19736,7 +20508,7 @@ index 000000000000..fbcce04abfe9 + * device. This device provides direct user-space access to the SSAM EC. + * Intended for debugging and development. + * -+ * Copyright (C) 2020 Maximilian Luz ++ * Copyright (C) 2020-2021 Maximilian Luz + */ + +#ifndef _UAPI_LINUX_SURFACE_AGGREGATOR_CDEV_H @@ -19803,7 +20575,76 @@ index 000000000000..fbcce04abfe9 + } response; +} __attribute__((__packed__)); + -+#define SSAM_CDEV_REQUEST _IOWR(0xA5, 1, struct ssam_cdev_request) ++/** ++ * struct ssam_cdev_notifier_desc - Notifier descriptor. ++ * @priority: Priority value determining the order in which notifier ++ * callbacks will be called. A higher value means higher ++ * priority, i.e. the associated callback will be executed ++ * earlier than other (lower priority) callbacks. ++ * @target_category: The event target category for which this notifier should ++ * receive events. ++ * ++ * Specifies the notifier that should be registered or unregistered, ++ * specifically with which priority and for which target category of events. ++ */ ++struct ssam_cdev_notifier_desc { ++ __s32 priority; ++ __u8 target_category; ++} __attribute__((__packed__)); ++ ++/** ++ * struct ssam_cdev_event_desc - Event descriptor. ++ * @reg: Registry via which the event will be enabled/disabled. ++ * @reg.target_category: Target category for the event registry requests. ++ * @reg.target_id: Target ID for the event registry requests. ++ * @reg.cid_enable: Command ID for the event-enable request. ++ * @reg.cid_disable: Command ID for the event-disable request. ++ * @id: ID specifying the event. ++ * @id.target_category: Target category of the event source. ++ * @id.instance: Instance ID of the event source. ++ * @flags: Flags used for enabling the event. ++ * ++ * Specifies which event should be enabled/disabled and how to do that. ++ */ ++struct ssam_cdev_event_desc { ++ struct { ++ __u8 target_category; ++ __u8 target_id; ++ __u8 cid_enable; ++ __u8 cid_disable; ++ } reg; ++ ++ struct { ++ __u8 target_category; ++ __u8 instance; ++ } id; ++ ++ __u8 flags; ++} __attribute__((__packed__)); ++ ++/** ++ * struct ssam_cdev_event - SSAM event sent by the EC. ++ * @target_category: Target category of the event source. See &enum ssam_ssh_tc. ++ * @target_id: Target ID of the event source. ++ * @command_id: Command ID of the event. ++ * @instance_id: Instance ID of the event source. ++ * @length: Length of the event payload in bytes. ++ * @data: Event payload data. ++ */ ++struct ssam_cdev_event { ++ __u8 target_category; ++ __u8 target_id; ++ __u8 command_id; ++ __u8 instance_id; ++ __u16 length; ++ __u8 data[]; ++} __attribute__((__packed__)); ++ ++#define SSAM_CDEV_REQUEST _IOWR(0xA5, 1, struct ssam_cdev_request) ++#define SSAM_CDEV_NOTIF_REGISTER _IOW(0xA5, 2, struct ssam_cdev_notifier_desc) ++#define SSAM_CDEV_NOTIF_UNREGISTER _IOW(0xA5, 3, struct ssam_cdev_notifier_desc) ++#define SSAM_CDEV_EVENT_ENABLE _IOW(0xA5, 4, struct ssam_cdev_event_desc) ++#define SSAM_CDEV_EVENT_DISABLE _IOW(0xA5, 5, struct ssam_cdev_event_desc) + +#endif /* _UAPI_LINUX_SURFACE_AGGREGATOR_CDEV_H */ diff --git a/include/uapi/linux/surface_aggregator/dtx.h b/include/uapi/linux/surface_aggregator/dtx.h diff --git a/patches/4.19/0011-surface-hotplug.patch b/patches/4.19/0011-surface-hotplug.patch index 260a902e5..76813a328 100644 --- a/patches/4.19/0011-surface-hotplug.patch +++ b/patches/4.19/0011-surface-hotplug.patch @@ -1,4 +1,4 @@ -From 0486334746b9ca6affd92c974eace8aa960032bc Mon Sep 17 00:00:00 2001 +From 8ee5e9b76e7d28202a565ebf52ddfe84a6a09d89 Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Tue, 31 Jul 2018 07:50:37 +0200 Subject: [PATCH] PCI: pciehp: Differentiate between surprise and safe removal @@ -197,7 +197,7 @@ index 5c58c22e0c08..18f83e554c73 100644 -- 2.31.1 -From ccb8bab5799aff9d8cd94de30341cc77785acf51 Mon Sep 17 00:00:00 2001 +From 3793c22bbed9cec0c3f478473515fd1ad0a56b9c Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Sun, 19 Aug 2018 16:29:00 +0200 Subject: [PATCH] PCI: pciehp: Drop unnecessary includes @@ -336,7 +336,7 @@ index 18f83e554c73..c512b2ed85ed 100644 -- 2.31.1 -From fc2cf7ca45c6e94e8a845cf23bcdf73ded3b451a Mon Sep 17 00:00:00 2001 +From 989f1eb5721c0da40ac074b55d4616fac3e6f364 Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Sun, 19 Aug 2018 16:29:00 +0200 Subject: [PATCH] PCI: pciehp: Drop hotplug_slot_ops wrappers @@ -549,7 +549,7 @@ index d4b7049cbc70..576362d0b1cd 100644 -- 2.31.1 -From aa4d8f63fbbfd6e903f5f1b6c9b8938fb49be0fe Mon Sep 17 00:00:00 2001 +From 6c66af2e66a170778615773efb37944496a6cd65 Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Sat, 8 Sep 2018 09:59:01 +0200 Subject: [PATCH] PCI: pciehp: Tolerate Presence Detect hardwired to zero @@ -747,7 +747,7 @@ index 576362d0b1cd..7f4173d6771a 100644 -- 2.31.1 -From 18231377b5f4ccac2a0adc0aadb7b79c30090d9a Mon Sep 17 00:00:00 2001 +From 4fef561a946b093f706f0c9af87ccf9cfcebaf9b Mon Sep 17 00:00:00 2001 From: Patrick Talbert Date: Wed, 5 Sep 2018 09:12:53 +0200 Subject: [PATCH] PCI/ASPM: Do not initialize link state when aspm_disabled is @@ -792,7 +792,7 @@ index cb474338f39d..18aa830e79e4 100644 -- 2.31.1 -From a2564044fb837d7276e9ac26c6f4be0f910fe606 Mon Sep 17 00:00:00 2001 +From 8883f432c68512dab04ae829bd5ed96a91ac92e1 Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Sun, 19 Aug 2018 16:29:00 +0200 Subject: [PATCH] PCI: Simplify disconnected marking @@ -878,7 +878,7 @@ index 2c3b5bd59b18..dee5a7507403 100644 -- 2.31.1 -From 345216bbf5af741739bc37700c9bc3bc60832910 Mon Sep 17 00:00:00 2001 +From a8bc4afa95893d37267b8c1335f7da28890ea334 Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Tue, 18 Sep 2018 21:46:17 +0200 Subject: [PATCH] PCI: pciehp: Unify controller and slot structs @@ -2070,7 +2070,7 @@ index 8da87931bd45..b9c1396db6fe 100644 -- 2.31.1 -From e6f20005f285c7ad15e030890c48d65bc38a4b38 Mon Sep 17 00:00:00 2001 +From 38a4236ea893c183ffa6cd38cd8a07240e58485f Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Sat, 8 Sep 2018 09:59:01 +0200 Subject: [PATCH] PCI: pciehp: Rename controller struct members for clarity @@ -2377,7 +2377,7 @@ index 4a17d71e15d3..e4d6ec960630 100644 -- 2.31.1 -From 70eaba3b48fb55e7f5b359b6bf98842e1322a965 Mon Sep 17 00:00:00 2001 +From d34485aebd5e534c3b4d58b983f2c9505ecdb0a5 Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Sat, 8 Sep 2018 09:59:01 +0200 Subject: [PATCH] PCI: pciehp: Reshuffle controller struct for clarity @@ -2508,7 +2508,7 @@ index 2499489158cc..df82a0335515 100644 -- 2.31.1 -From 139436ff3f31a4824a9961ef0919fb6639da6223 Mon Sep 17 00:00:00 2001 +From 3192dc6166aa22e301c412180cf8b3486b1c8705 Mon Sep 17 00:00:00 2001 From: Keith Busch Date: Thu, 20 Sep 2018 10:27:17 -0600 Subject: [PATCH] PCI: Make link active reporting detection generic @@ -2705,7 +2705,7 @@ index ec6c48ecd7d5..74c8e9190fed 100644 -- 2.31.1 -From c50fb35076f22f25ed8fec7745189d8705f711fc Mon Sep 17 00:00:00 2001 +From ea7477d96f140962febc4f5d5b3e3e3d114ec8d6 Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Thu, 27 Sep 2018 16:53:53 -0500 Subject: [PATCH] PCI: Do not skip power-managed bridges in pci_enable_wake() @@ -2756,7 +2756,7 @@ index 07d4a00131bc..77ba4f65e18b 100644 -- 2.31.1 -From 9ff99b5d5c9b5c04fcdafdace5d7030d2b619cc7 Mon Sep 17 00:00:00 2001 +From c8aa03db7da31b6275ed72ce96be08d1119244b9 Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Thu, 27 Sep 2018 16:38:19 -0500 Subject: [PATCH] PCI: pciehp: Disable hotplug interrupt during suspend @@ -2870,7 +2870,7 @@ index 0693870a9e24..b5c7f5ef597a 100644 -- 2.31.1 -From d6dfc22634bfbf27e1e316ca1df40077fd5a4d48 Mon Sep 17 00:00:00 2001 +From a7725bfc25fc7e4577290f7b93dc9e7395d7bc26 Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Thu, 27 Sep 2018 16:41:46 -0500 Subject: [PATCH] PCI: pciehp: Do not handle events if interrupts are masked @@ -2912,7 +2912,7 @@ index b5c7f5ef597a..242b9f30210a 100644 -- 2.31.1 -From 183e1412a3627a1912554ea8aaca28117c85fe25 Mon Sep 17 00:00:00 2001 +From 05cb6d9f3f5aa32c70d763d5096495f3fa0eee4f Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Thu, 27 Sep 2018 16:41:47 -0500 Subject: [PATCH] PCI/portdrv: Resume upon exit from system suspend if left @@ -2965,7 +2965,7 @@ index 23a5a0c2c3fe..5badf8a1ce0a 100644 -- 2.31.1 -From a3162dc30caaea5b348efbeea2af507fa88b6592 Mon Sep 17 00:00:00 2001 +From cf58d7fa05f24856380c962cb4d6c84491ca0332 Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Thu, 27 Sep 2018 16:41:48 -0500 Subject: [PATCH] PCI/portdrv: Add runtime PM hooks for port service drivers @@ -3077,7 +3077,7 @@ index 5badf8a1ce0a..59d2567e2db2 100644 -- 2.31.1 -From 225f9fee393926543b28d41a2d19d49acd77f155 Mon Sep 17 00:00:00 2001 +From ac10e8884445075ca4ae0fec001efa576e35ad55 Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Thu, 27 Sep 2018 16:41:49 -0500 Subject: [PATCH] PCI: pciehp: Implement runtime PM callbacks @@ -3134,7 +3134,7 @@ index 8e6e4ce869fb..e5de25ebc4cf 100644 -- 2.31.1 -From 432488d67b691c3d4726e1a708a7aabb6b6bb052 Mon Sep 17 00:00:00 2001 +From 507b1a84685f12061a6892312353bdc468eace8f Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Thu, 27 Sep 2018 16:57:05 -0500 Subject: [PATCH] ACPI / property: Allow multiple property compatible _DSD @@ -3429,7 +3429,7 @@ index 1a37748766b7..50a09003bb43 100644 -- 2.31.1 -From 11330347945d1855a457e4675699519794b8860f Mon Sep 17 00:00:00 2001 +From d7c690c9d7df4d0c338d5512d867bdbf11177537 Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Thu, 27 Sep 2018 16:57:14 -0500 Subject: [PATCH] PCI / ACPI: Whitelist D3 for more PCIe hotplug ports @@ -3594,7 +3594,7 @@ index 39725b71300f..ee3e94c6ea6c 100644 -- 2.31.1 -From 5231cf349159f15515b37728adb7c6cb797e8ba1 Mon Sep 17 00:00:00 2001 +From 61bf54c71a0cdd08ccc3305ff3bf883892c5cd9e Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Mon, 7 Jan 2019 16:09:40 +0300 Subject: [PATCH] PCI: pciehp: Assign ctrl->slot_ctrl before writing it to @@ -3648,7 +3648,7 @@ index 242b9f30210a..7074d4923811 100644 -- 2.31.1 -From 5a0143e949e2106640a9f536ce64a704f92da362 Mon Sep 17 00:00:00 2001 +From 94876f28f24c02e1960c3bbfd202f419a6107ca4 Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Thu, 31 Jan 2019 20:07:46 +0300 Subject: [PATCH] PCI: pciehp: Disable Data Link Layer State Changed event on @@ -3737,7 +3737,7 @@ index 7074d4923811..a37ff79a6e9e 100644 -- 2.31.1 -From e1d6999d6e69a864e032c0e0933a52f1f35d9e57 Mon Sep 17 00:00:00 2001 +From 50533e4a6d3878657bbad10c57182181e582ce56 Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Thu, 29 Oct 2020 22:04:38 +0100 Subject: [PATCH] PCI: Allow D3cold for hot-plug ports on Surface Books @@ -3822,7 +3822,7 @@ index ab930e5994dd..5f3f35d314c3 100644 -- 2.31.1 -From 87e0edf3e49a04f91ac6ba0e78e98aa23b88a591 Mon Sep 17 00:00:00 2001 +From 40b7d85f69171f9ec4d7d58339295cbc1abb97c1 Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Sat, 31 Oct 2020 20:46:33 +0100 Subject: [PATCH] PCI: Add sysfs attribute for PCI device power state @@ -3895,7 +3895,7 @@ index 1edf5a1836ea..ee1518650d55 100644 -- 2.31.1 -From 4b509dae4c9ecba9de632b17eb80c5312ae998f8 Mon Sep 17 00:00:00 2001 +From 1d4912955b393798fe39f10714cf4eafd1f5dbec Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Mon, 14 Dec 2020 20:50:59 +0100 Subject: [PATCH] platform/x86: Add Surface Hotplug driver diff --git a/patches/4.19/0012-surface-typecover.patch b/patches/4.19/0012-surface-typecover.patch index 8a6a7f98f..95db5ef05 100644 --- a/patches/4.19/0012-surface-typecover.patch +++ b/patches/4.19/0012-surface-typecover.patch @@ -1,4 +1,4 @@ -From e919505817c574773f50ec0a7cd1bbd408eacdfe Mon Sep 17 00:00:00 2001 +From 311f61be8d550dad45ed63339caa05e072fbbda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Thu, 5 Nov 2020 13:09:45 +0100 Subject: [PATCH] hid/multitouch: Turn off Type Cover keyboard backlight when diff --git a/patches/4.19/0013-surface-go-touchscreen.patch b/patches/4.19/0013-surface-go-touchscreen.patch new file mode 100644 index 000000000..ea890d2a1 --- /dev/null +++ b/patches/4.19/0013-surface-go-touchscreen.patch @@ -0,0 +1,39 @@ +From 3b2b53b2a0db89f6be3273f21b9b42c47f2989b7 Mon Sep 17 00:00:00 2001 +From: Zoltan Tamas Vajda +Date: Thu, 3 Jun 2021 10:50:55 +0200 +Subject: [PATCH] Added quirk for Surface Go touchscreen + +Patchset: surface-go-touchscreen +--- + drivers/hid/hid-ids.h | 1 + + drivers/hid/hid-input.c | 2 ++ + 2 files changed, 3 insertions(+) + +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h +index 75342f3dfb86..a5ed1ca93216 100644 +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -388,6 +388,7 @@ + #define USB_DEVICE_ID_HP_X2 0x074d + #define USB_DEVICE_ID_HP_X2_10_COVER 0x0755 + #define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706 ++#define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN 0x261A + + #define USB_VENDOR_ID_ELECOM 0x056e + #define USB_DEVICE_ID_ELECOM_BM084 0x0061 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c +index 4dd151b2924e..4f5e58a9b19e 100644 +--- a/drivers/hid/hid-input.c ++++ b/drivers/hid/hid-input.c +@@ -336,6 +336,8 @@ static const struct hid_device_id hid_battery_quirks[] = { + HID_BATTERY_QUIRK_IGNORE }, + { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN), + HID_BATTERY_QUIRK_IGNORE }, ++ { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN), ++ HID_BATTERY_QUIRK_IGNORE }, + {} + }; + +-- +2.31.1 + diff --git a/patches/4.19/0013-ath10k-firmware-override.patch b/patches/4.19/0014-ath10k-firmware-override.patch similarity index 98% rename from patches/4.19/0013-ath10k-firmware-override.patch rename to patches/4.19/0014-ath10k-firmware-override.patch index 16b683f9f..6fe325404 100644 --- a/patches/4.19/0013-ath10k-firmware-override.patch +++ b/patches/4.19/0014-ath10k-firmware-override.patch @@ -1,4 +1,4 @@ -From c7275e6481bcbe5ee72a9a2ecee131fb8211a0bd Mon Sep 17 00:00:00 2001 +From addb5afe5249eea71a4f922ea168614685a6c95d Mon Sep 17 00:00:00 2001 From: Maximilian Luz Date: Sat, 27 Feb 2021 00:45:52 +0100 Subject: [PATCH] ath10k: Add module parameters to override board files diff --git a/pkg/arch/kernel-lts/0013-ath10k-firmware-override.patch b/pkg/arch/kernel-lts/0013-ath10k-firmware-override.patch deleted file mode 120000 index 1384f1bc8..000000000 --- a/pkg/arch/kernel-lts/0013-ath10k-firmware-override.patch +++ /dev/null @@ -1 +0,0 @@ -../../../patches/4.19/0013-ath10k-firmware-override.patch \ No newline at end of file diff --git a/pkg/arch/kernel-lts/0013-surface-go-touchscreen.patch b/pkg/arch/kernel-lts/0013-surface-go-touchscreen.patch new file mode 120000 index 000000000..b3cd26f08 --- /dev/null +++ b/pkg/arch/kernel-lts/0013-surface-go-touchscreen.patch @@ -0,0 +1 @@ +../../../patches/4.19/0013-surface-go-touchscreen.patch \ No newline at end of file diff --git a/pkg/arch/kernel-lts/0014-ath10k-firmware-override.patch b/pkg/arch/kernel-lts/0014-ath10k-firmware-override.patch new file mode 120000 index 000000000..505c9ed28 --- /dev/null +++ b/pkg/arch/kernel-lts/0014-ath10k-firmware-override.patch @@ -0,0 +1 @@ +../../../patches/4.19/0014-ath10k-firmware-override.patch \ No newline at end of file diff --git a/pkg/arch/kernel-lts/PKGBUILD b/pkg/arch/kernel-lts/PKGBUILD index 4a86ee4c7..e470c93f0 100644 --- a/pkg/arch/kernel-lts/PKGBUILD +++ b/pkg/arch/kernel-lts/PKGBUILD @@ -33,7 +33,8 @@ source=( 0010-surface-sam.patch 0011-surface-hotplug.patch 0012-surface-typecover.patch - 0013-ath10k-firmware-override.patch + 0013-surface-go-touchscreen.patch + 0014-ath10k-firmware-override.patch ) validpgpkeys=( 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds @@ -45,19 +46,20 @@ sha256sums=('074dcda77c7c413dece370b3cf8713997d909a8c06724c910ae23cc9c96f0099' '4e68572e7cc4c5368f0236e0792660ae8498373988625dca46e509399a7eaea6' 'a13581d3c6dc595206e4fe7fcf6b542e7a1bdbe96101f0f010fc5be49f99baf2' 'c523d8ba9f02992c34b325cd7b07e27bfead33ecab29877e659a12b2d56b1118' - 'fb66157e45084261f0d7fc953e11aa0d44fc297269f8acd008e2f386e308327b' - 'eec1d7c594e79f5125556426351d54be865b8c61da1250134a8c2e8a330181b1' - 'b9e7d521d08e8ef0ba772c02ace0a49a051e68fa11104b68b6ddf3f0776b7269' - '2233592a23fd8e3296addcc81ffd1c37494d279a093324e1bb888b1f35ac7f33' - '59bbd2e21a93a7623e908d4aff90fcc33e66365d382a2e7b77c55414de64041e' - '7d26fa24c0b2506d4dc22d147f644667b9738119d6f2db47b462225ffe7058d0' - '0e13bf5d02808a7ed4ff6c00156c6de415596413d315e092d1bc7006a42e4ea6' - '79af04adf989abc303736874f23eb230c69ae921beb9274b4cc97fa29063f2f2' - '243d9353045809a56d654ca8eec62af811dcde37453411e1fa0ac443f9fa0dc6' - 'e0675a521440f0f23696834bfd0a799204d65701419b42894fadefb7d3eed6c7' - '6b720037d99345f51897e0b2899c68bbf40081871da01490da26f046ed284708' - 'e2e028ff39b9a097e71cbffba9d4d795374c13bda2e7bede9b04a6a0eb8ba0e5' - '83bb5ffcf9abfd46d4f45df954ba85a12e76bd430fad1b4b15814b1804d5d0f6') + '1db89e197b05aafeab4257fd2610823137297d0f38761c5463f178903a81c730' + '960788d1f8e59965e6e68dc3c83fad09edade041738c85c277ad3fbcc3f3b66f' + '9e872762e8ab8513c8402864f124d0b34de348d625fe64193987c50b98770ae0' + 'bd8677d585cb2cbdd8138ed475b1c1744d5f7f3ca5d95274b90b9961be459278' + 'c22ec8bf62046a203a1c5d9e1e15425eef0933714d23d2e7f2e39023bf322a53' + '2d3ba06a04e652722ce804bfbbd478e40bdc83ce0fe106b4f62cde169207ff51' + 'cfc277e4a36d50d815c274020a192ffc4cb77b67d7a54913c1259782d7f1d785' + 'f511907d1f1e6ca8a7e6a2f4d9e464f4378de1095f8618a3abfa4cc1ac194577' + '8956b5be58f556064b5f29d149c7f2965c642c228faf828c4d7b09f93af44efa' + '1e31bd2ad6953b09e9f9fddfced439e8ff126accd40fb0726e0d7a23be71d2a8' + '5ae7331873642bb99f0b4bb0cf4c665f5ce73ec93ab21b75e6db460f9f946faf' + '4c44ba127c6430db1f1d17d021216cccba738900a446e246a3b1c36702c23d20' + '363f4bec0c02770b615efca07586de498b19a097d26c55ba8a2a22ea83512739' + 'fe6a9f042b3d991b40c0e7676babb2778fb6fc3d53a2e43b919c18d9a57a8c3b') export KBUILD_BUILD_HOST=archlinux export KBUILD_BUILD_USER=$pkgbase