Update v5.8 patches

Changes:
- SAM:
  - Internal restructuring, cleanup, and documentation.

Links:
- SAM: 6de853a5cd
- kernel: 12216a9ad7
This commit is contained in:
Maximilian Luz 2020-09-12 16:12:52 +02:00
parent 93f386b6ea
commit 9a5fdd5e61
No known key found for this signature in database
GPG key ID: 70EC0937F6C26F02
7 changed files with 486 additions and 168 deletions

View file

@ -1,4 +1,4 @@
From 066e779c7a5805e345f1a9dcdbcca1206b4ece67 Mon Sep 17 00:00:00 2001
From 4248e18d4612d02fd522eb8576037bd7781aece0 Mon Sep 17 00:00:00 2001
From: Chih-Wei Huang <cwhuang@linux.org.tw>
Date: Tue, 18 Sep 2018 11:01:37 +0800
Subject: [PATCH 1/6] surface3-oemb
@ -10,7 +10,7 @@ Subject: [PATCH 1/6] surface3-oemb
3 files changed, 24 insertions(+)
diff --git a/drivers/platform/x86/surface3-wmi.c b/drivers/platform/x86/surface3-wmi.c
index 130b6f52a6001..801083aa56d6d 100644
index 130b6f52a600..801083aa56d6 100644
--- a/drivers/platform/x86/surface3-wmi.c
+++ b/drivers/platform/x86/surface3-wmi.c
@@ -37,6 +37,13 @@ static const struct dmi_system_id surface3_dmi_table[] = {
@ -28,7 +28,7 @@ index 130b6f52a6001..801083aa56d6d 100644
{ }
};
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index e2e1d5b03b381..5ff38592ba6db 100644
index e2e1d5b03b38..5ff38592ba6d 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -3687,6 +3687,15 @@ static const struct dmi_system_id dmi_platform_data[] = {
@ -48,7 +48,7 @@ index e2e1d5b03b381..5ff38592ba6db 100644
/*
* Match for the GPDwin which unfortunately uses somewhat
diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
index 2752dc9557334..ef36a316e2ed6 100644
index 2752dc955733..ef36a316e2ed 100644
--- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
@@ -27,6 +27,14 @@ static const struct dmi_system_id cht_table[] = {

View file

@ -1,4 +1,4 @@
From ca3d192b0e00bebf0ff2352a00a9120d1a2e4e7c Mon Sep 17 00:00:00 2001
From 002b3d0ffa9aa7541e6752b15d8d6779be2f5d08 Mon Sep 17 00:00:00 2001
From: kitakar5525 <34676735+kitakar5525@users.noreply.github.com>
Date: Thu, 20 Feb 2020 16:51:11 +0900
Subject: [PATCH 2/6] wifi
@ -12,7 +12,7 @@ Subject: [PATCH 2/6] wifi
5 files changed, 87 insertions(+), 60 deletions(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index 4e4f59c17ded3..528eedfbf41c9 100644
index 4e4f59c17ded..528eedfbf41c 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -25,6 +25,11 @@
@ -56,7 +56,7 @@ index 4e4f59c17ded3..528eedfbf41c9 100644
}
diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h
index 8047e307892e3..d9f8bdbc817b2 100644
index 8047e307892e..d9f8bdbc817b 100644
--- a/drivers/net/wireless/marvell/mwifiex/fw.h
+++ b/drivers/net/wireless/marvell/mwifiex/fw.h
@@ -954,7 +954,7 @@ struct mwifiex_tkip_param {
@ -69,7 +69,7 @@ index 8047e307892e3..d9f8bdbc817b2 100644
struct mwifiex_wapi_param {
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 87b4ccca4b9a2..3bdad5e80ecbb 100644
index 87b4ccca4b9a..3bdad5e80ecb 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -146,38 +146,45 @@ static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter)
@ -203,7 +203,7 @@ index 87b4ccca4b9a2..3bdad5e80ecbb 100644
pdev->vendor, pdev->device, pdev->revision);
diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
index 8bd355d7974e9..256c8c38deee3 100644
index 8bd355d7974e..256c8c38deee 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
@@ -2247,7 +2247,6 @@ int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
@ -266,7 +266,7 @@ index 8bd355d7974e9..256c8c38deee3 100644
if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
/* Send cmd to FW to enable/disable 11D function */
diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
index 962d8bfe6f101..119ccacd1fcc4 100644
index 962d8bfe6f10..119ccacd1fcc 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
@@ -619,7 +619,7 @@ static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv,

View file

@ -1,4 +1,4 @@
From 4ad6656739cd57b52360b9909af2ab762968a632 Mon Sep 17 00:00:00 2001
From 41b560b65cfa204af0e8d5b6682805dc10b26461 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 3/6] ipts
@ -37,7 +37,7 @@ Subject: [PATCH 3/6] ipts
create mode 100644 drivers/misc/ipts/uapi.h
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index e1b1ba5e2b925..be901ffc66fee 100644
index e1b1ba5e2b92..be901ffc66fe 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -472,4 +472,5 @@ source "drivers/misc/ocxl/Kconfig"
@ -47,7 +47,7 @@ index e1b1ba5e2b925..be901ffc66fee 100644
+source "drivers/misc/ipts/Kconfig"
endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index c7bd01ac62917..f97938d777e13 100644
index c7bd01ac6291..f97938d777e1 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -57,3 +57,4 @@ obj-$(CONFIG_PVPANIC) += pvpanic.o
@ -57,7 +57,7 @@ index c7bd01ac62917..f97938d777e13 100644
+obj-$(CONFIG_MISC_IPTS) += ipts/
diff --git a/drivers/misc/ipts/Kconfig b/drivers/misc/ipts/Kconfig
new file mode 100644
index 0000000000000..7dce12245a4f1
index 000000000000..7dce12245a4f
--- /dev/null
+++ b/drivers/misc/ipts/Kconfig
@@ -0,0 +1,13 @@
@ -76,7 +76,7 @@ index 0000000000000..7dce12245a4f1
+ module will be called ipts.
diff --git a/drivers/misc/ipts/Makefile b/drivers/misc/ipts/Makefile
new file mode 100644
index 0000000000000..a7232badd8b89
index 000000000000..a7232badd8b8
--- /dev/null
+++ b/drivers/misc/ipts/Makefile
@@ -0,0 +1,11 @@
@ -93,7 +93,7 @@ index 0000000000000..a7232badd8b89
+ipts-objs += uapi.o
diff --git a/drivers/misc/ipts/context.h b/drivers/misc/ipts/context.h
new file mode 100644
index 0000000000000..d24fd6ac026b9
index 000000000000..d24fd6ac026b
--- /dev/null
+++ b/drivers/misc/ipts/context.h
@@ -0,0 +1,125 @@
@ -224,7 +224,7 @@ index 0000000000000..d24fd6ac026b9
+#endif /* _IPTS_CONTEXT_H_ */
diff --git a/drivers/misc/ipts/control.c b/drivers/misc/ipts/control.c
new file mode 100644
index 0000000000000..857bcf4987525
index 000000000000..857bcf498752
--- /dev/null
+++ b/drivers/misc/ipts/control.c
@@ -0,0 +1,63 @@
@ -293,7 +293,7 @@ index 0000000000000..857bcf4987525
+}
diff --git a/drivers/misc/ipts/control.h b/drivers/misc/ipts/control.h
new file mode 100644
index 0000000000000..718cde10dd2cd
index 000000000000..718cde10dd2c
--- /dev/null
+++ b/drivers/misc/ipts/control.h
@@ -0,0 +1,17 @@
@ -316,7 +316,7 @@ index 0000000000000..718cde10dd2cd
+#endif /* _IPTS_CONTROL_H_ */
diff --git a/drivers/misc/ipts/init.c b/drivers/misc/ipts/init.c
new file mode 100644
index 0000000000000..c2f237feed11e
index 000000000000..c2f237feed11
--- /dev/null
+++ b/drivers/misc/ipts/init.c
@@ -0,0 +1,87 @@
@ -409,7 +409,7 @@ index 0000000000000..c2f237feed11e
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/ipts/protocol.h b/drivers/misc/ipts/protocol.h
new file mode 100644
index 0000000000000..c8b412899ec4d
index 000000000000..c8b412899ec4
--- /dev/null
+++ b/drivers/misc/ipts/protocol.h
@@ -0,0 +1,236 @@
@ -651,7 +651,7 @@ index 0000000000000..c8b412899ec4d
+#endif /* _IPTS_PROTOCOL_H_ */
diff --git a/drivers/misc/ipts/receiver.c b/drivers/misc/ipts/receiver.c
new file mode 100644
index 0000000000000..bf78b64249a5b
index 000000000000..bf78b64249a5
--- /dev/null
+++ b/drivers/misc/ipts/receiver.c
@@ -0,0 +1,202 @@
@ -859,7 +859,7 @@ index 0000000000000..bf78b64249a5b
+}
diff --git a/drivers/misc/ipts/receiver.h b/drivers/misc/ipts/receiver.h
new file mode 100644
index 0000000000000..d7939ddbaae95
index 000000000000..d7939ddbaae9
--- /dev/null
+++ b/drivers/misc/ipts/receiver.h
@@ -0,0 +1,10 @@
@ -875,7 +875,7 @@ index 0000000000000..d7939ddbaae95
+#endif /* _IPTS_RECEIVER_H_ */
diff --git a/drivers/misc/ipts/resources.c b/drivers/misc/ipts/resources.c
new file mode 100644
index 0000000000000..9f2b60bb7a70e
index 000000000000..9f2b60bb7a70
--- /dev/null
+++ b/drivers/misc/ipts/resources.c
@@ -0,0 +1,133 @@
@ -1014,7 +1014,7 @@ index 0000000000000..9f2b60bb7a70e
+}
diff --git a/drivers/misc/ipts/resources.h b/drivers/misc/ipts/resources.h
new file mode 100644
index 0000000000000..cf9807b0dbe62
index 000000000000..cf9807b0dbe6
--- /dev/null
+++ b/drivers/misc/ipts/resources.h
@@ -0,0 +1,11 @@
@ -1031,7 +1031,7 @@ index 0000000000000..cf9807b0dbe62
+#endif /* _IPTS_RESOURCES_H_ */
diff --git a/drivers/misc/ipts/uapi.c b/drivers/misc/ipts/uapi.c
new file mode 100644
index 0000000000000..f6f7b2cabd836
index 000000000000..f6f7b2cabd83
--- /dev/null
+++ b/drivers/misc/ipts/uapi.c
@@ -0,0 +1,297 @@
@ -1334,7 +1334,7 @@ index 0000000000000..f6f7b2cabd836
+}
diff --git a/drivers/misc/ipts/uapi.h b/drivers/misc/ipts/uapi.h
new file mode 100644
index 0000000000000..7d7eabc74b17d
index 000000000000..7d7eabc74b17
--- /dev/null
+++ b/drivers/misc/ipts/uapi.h
@@ -0,0 +1,11 @@
@ -1350,7 +1350,7 @@ index 0000000000000..7d7eabc74b17d
+
+#endif /* _IPTS_UAPI_H_ */
diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h
index 7becfc768bbcc..0824ef27b08bb 100644
index 7becfc768bbc..0824ef27b08b 100644
--- a/drivers/misc/mei/hw-me-regs.h
+++ b/drivers/misc/mei/hw-me-regs.h
@@ -59,6 +59,7 @@
@ -1378,7 +1378,7 @@ index 7becfc768bbcc..0824ef27b08bb 100644
#define MEI_DEV_ID_JSP_N 0x4DE0 /* Jasper Lake Point N */
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index 2a3f2fd5df507..319158fd43930 100644
index 2a3f2fd5df50..319158fd4393 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -68,6 +68,7 @@ static const struct pci_device_id mei_me_pci_tbl[] = {

View file

@ -1,4 +1,4 @@
From 5d20062d20b656c3a28cbe838842b020179c7114 Mon Sep 17 00:00:00 2001
From 51417cded60784d05b6469e41568ef38cf67320d Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Mon, 17 Aug 2020 01:23:20 +0200
Subject: [PATCH 4/6] surface-sam
@ -7,11 +7,14 @@ Subject: [PATCH 4/6] surface-sam
Documentation/driver-api/index.rst | 1 +
Documentation/driver-api/ssam/client-api.rst | 19 +
Documentation/driver-api/ssam/client.rst | 381 +++
Documentation/driver-api/ssam/index.rst | 20 +
.../driver-api/ssam/clients/dbgdev.rst | 128 +
.../driver-api/ssam/clients/index.rst | 21 +
Documentation/driver-api/ssam/clients/san.rst | 44 +
Documentation/driver-api/ssam/index.rst | 21 +
.../driver-api/ssam/internal-api.rst | 70 +
Documentation/driver-api/ssam/internal.rst | 50 +
Documentation/driver-api/ssam/overview.rst | 76 +
Documentation/driver-api/ssam/ssh.rst | 297 ++
Documentation/driver-api/ssam/ssh.rst | 343 +++
drivers/misc/Kconfig | 1 +
drivers/misc/Makefile | 1 +
drivers/misc/surface_sam/Kconfig | 46 +
@ -20,11 +23,11 @@ Subject: [PATCH 4/6] surface-sam
drivers/misc/surface_sam/bus.h | 14 +
drivers/misc/surface_sam/clients/Kconfig | 121 +
drivers/misc/surface_sam/clients/Makefile | 11 +
.../surface_sam/clients/surface_sam_debugfs.c | 265 ++
.../surface_sam/clients/surface_sam_debugfs.c | 282 ++
.../clients/surface_sam_device_hub.c | 642 +++++
.../surface_sam/clients/surface_sam_dtx.c | 583 ++++
.../surface_sam/clients/surface_sam_hps.c | 1296 +++++++++
.../surface_sam/clients/surface_sam_san.c | 813 ++++++
.../surface_sam/clients/surface_sam_san.c | 841 ++++++
.../clients/surface_sam_sid_perfmode.c | 190 ++
.../clients/surface_sam_sid_power.c | 1114 ++++++++
.../surface_sam/clients/surface_sam_sid_vhf.c | 498 ++++
@ -42,13 +45,16 @@ Subject: [PATCH 4/6] surface-sam
drivers/misc/surface_sam/ssh_request_layer.c | 1246 +++++++++
drivers/misc/surface_sam/ssh_request_layer.h | 136 +
include/linux/mod_devicetable.h | 17 +
include/linux/surface_acpi_notify.h | 30 +
include/linux/surface_acpi_notify.h | 39 +
include/linux/surface_aggregator_module.h | 1722 ++++++++++++
scripts/mod/devicetable-offsets.c | 7 +
scripts/mod/file2alias.c | 22 +
42 files changed, 17402 insertions(+)
45 files changed, 17696 insertions(+)
create mode 100644 Documentation/driver-api/ssam/client-api.rst
create mode 100644 Documentation/driver-api/ssam/client.rst
create mode 100644 Documentation/driver-api/ssam/clients/dbgdev.rst
create mode 100644 Documentation/driver-api/ssam/clients/index.rst
create mode 100644 Documentation/driver-api/ssam/clients/san.rst
create mode 100644 Documentation/driver-api/ssam/index.rst
create mode 100644 Documentation/driver-api/ssam/internal-api.rst
create mode 100644 Documentation/driver-api/ssam/internal.rst
@ -85,7 +91,7 @@ Subject: [PATCH 4/6] surface-sam
create mode 100644 include/linux/surface_aggregator_module.h
diff --git a/Documentation/driver-api/index.rst b/Documentation/driver-api/index.rst
index 6567187e76873..93f663351ed1f 100644
index 6567187e7687..93f663351ed1 100644
--- a/Documentation/driver-api/index.rst
+++ b/Documentation/driver-api/index.rst
@@ -99,6 +99,7 @@ available subsections can be seen below.
@ -98,7 +104,7 @@ index 6567187e76873..93f663351ed1f 100644
vfio-mediated-device
diff --git a/Documentation/driver-api/ssam/client-api.rst b/Documentation/driver-api/ssam/client-api.rst
new file mode 100644
index 0000000000000..3d5fc6a4dc953
index 000000000000..3d5fc6a4dc95
--- /dev/null
+++ b/Documentation/driver-api/ssam/client-api.rst
@@ -0,0 +1,19 @@
@ -123,7 +129,7 @@ index 0000000000000..3d5fc6a4dc953
+ :export:
diff --git a/Documentation/driver-api/ssam/client.rst b/Documentation/driver-api/ssam/client.rst
new file mode 100644
index 0000000000000..fa0aa032a9488
index 000000000000..fa0aa032a948
--- /dev/null
+++ b/Documentation/driver-api/ssam/client.rst
@@ -0,0 +1,381 @@
@ -508,12 +514,223 @@ index 0000000000000..fa0aa032a9488
+flags are therefore only used on the first registered notifier, however, one
+should take care that notifiers for a specific event are always registered
+with the same flag and it is considered a bug to do otherwise.
diff --git a/Documentation/driver-api/ssam/clients/dbgdev.rst b/Documentation/driver-api/ssam/clients/dbgdev.rst
new file mode 100644
index 000000000000..d4d42634f516
--- /dev/null
+++ b/Documentation/driver-api/ssam/clients/dbgdev.rst
@@ -0,0 +1,128 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. |u8| replace:: :c:type:`u8 <u8>`
+.. |u16| replace:: :c:type:`u16 <u16>`
+.. |ssam_dbgdev_request| replace:: :c:type:`struct ssam_dbgdev_request <ssam_dbgdev_request>`
+.. |ssam_request_flags| replace:: :c:type:`enum ssam_request_flags <ssam_request_flags>`
+
+=======================================
+SSAM Debug Device and DebugFS Interface
+=======================================
+
+The ``surface_sam_debugfs`` module provides a DebugFS interface for the SSAM
+controller to allow for a (more or less) direct connection from userspace to
+the SAM EC. It is intended to be used for development and debugging, and
+therefore should not be used or relied upon in any other way. Note that this
+module is not loaded automatically, but instead must be loaded manually.
+
+The provided interface is accessible through the ``ssam/controller``
+device-file in debugfs, so, if the conventional mount path is being used,
+``/sys/kernel/debug/ssam/controller``. All functionality of this interface
+is provided via IOCTLs.
+
+
+Controller IOCTLs
+=================
+
+The following IOCTLs are provided:
+
+.. flat-table:: Controller IOCTLs
+ :widths: 1 1 1 1 4
+ :header-rows: 1
+
+ * - Type
+ - Number
+ - Direction
+ - Name
+ - Description
+
+ * - ``0xA5``
+ - ``0``
+ - ``R``
+ - ``GETVERSION``
+ - Get DebugFS controller interface version.
+
+ * - ``0xA5``
+ - ``1``
+ - ``WR``
+ - ``REQUEST``
+ - Perform synchronous SAM request.
+
+
+``GETVERSION``
+--------------
+
+Defined as ``_IOR(0xA5, 0, __u32)``.
+
+Gets the current interface version. This should be used to check for changes
+in the interface and determine if certain functionality is available. While
+the interface should under normal circumstances kept backward compatible, as
+this is a debug interface, backwards compatibility is not guaranteed.
+
+The version number follows the semantic versioning scheme, roughly meaning
+that an increment in the highest non-zero version number signals a breaking
+change. It can be decomposed as follows:
+
+.. flat-table:: Version Number Format
+ :widths: 2 1 3
+ :header-rows: 1
+
+ * - Offset (bytes)
+ - Type
+ - Description
+
+ * - ``0``
+ - |u8|
+ - Major
+
+ * - ``1``
+ - |u8|
+ - Minor
+
+ * - ``2``
+ - |u16|
+ - Patch
+
+The interface version is currently ``0.1.0``, i.e. ``0x00010000``.
+
+
+``REQUEST``
+-----------
+
+Defined as ``_IOWR(0xA5, 1, struct ssam_dbgdev_request)``.
+
+Executes a synchronous SAM request. The request specification is passed in
+as argument of type |ssam_dbgdev_request|, which is then written to/modified
+by the IOCTL to return status and result of the request.
+
+Request payload data must be allocated separately and is passed in via the
+``payload.data`` and ``payload.length`` members. If a response is required,
+the response buffer must be allocated by the caller and passed in via the
+``response.data`` member. The ``response.length`` member must be set to the
+capacity of this buffer, or if no response is required, zero. Upon
+completion of the request, the call will write the response to the response
+buffer (if its capacity allows it) and overwrite the length field with the
+actual size of the response, in bytes.
+
+Additionally, if the request has a response, this should be indicated via
+the request flags, as is done with in-kernel requests. Request flags can be
+set via the ``flags`` member and the values correspond to the values found
+in |ssam_request_flags|.
+
+Finally, the status of the request itself is returned in the ``status``
+member (a negative value indicating failure). Note that failure indication
+of the IOCTL is separated from failure indication of the request: The IOCTL
+returns a negative status code if anything failed during setup of the
+request (``-EFAULT``) or if the provided argument or any of its fields are
+invalid (``-EINVAL``). In this case, the status value of the request
+argument may be set, providing more detail on what went wrong (e.g.
+``-ENOMEM`` for out-of-memory), but this value may also be zero. The IOCTL
+will return with a zero status code in case the request has been set up,
+submitted, and completed (i.e. handed back to user-space) successfully from
+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:
+
+.. kernel-doc:: drivers/misc/surface_sam/clients/surface_sam_debugfs.c
+ :functions: ssam_dbgdev_request
diff --git a/Documentation/driver-api/ssam/clients/index.rst b/Documentation/driver-api/ssam/clients/index.rst
new file mode 100644
index 000000000000..7cd91fc75e91
--- /dev/null
+++ b/Documentation/driver-api/ssam/clients/index.rst
@@ -0,0 +1,21 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+===========================
+Client Driver Documentation
+===========================
+
+This is the documentation for client drivers themselves. Refer to
+:doc:`../client` for documentation on how to write client drivers.
+
+.. toctree::
+ :maxdepth: 1
+
+ dbgdev
+ san
+
+.. only:: subproject and html
+
+ Indices
+ =======
+
+ * :ref:`genindex`
diff --git a/Documentation/driver-api/ssam/clients/san.rst b/Documentation/driver-api/ssam/clients/san.rst
new file mode 100644
index 000000000000..380b89e61955
--- /dev/null
+++ b/Documentation/driver-api/ssam/clients/san.rst
@@ -0,0 +1,44 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. |san_client_link| replace:: :c:func:`san_client_link`
+.. |san_dgpu_notifier_register| replace:: :c:func:`san_dgpu_notifier_register`
+.. |san_dgpu_notifier_unregister| replace:: :c:func:`san_dgpu_notifier_unregister`
+
+===================
+Surface ACPI Notify
+===================
+
+The Surface ACPI Notify (SAN) device provides the bridge between ACPI and
+SAM controller. Specifically, ACPI code can execute requests and handle
+battery and thermal events via this interface. In addition to this, events
+relating to the discrete GPU (dGPU) of the Surface Book 2 can be sent from
+ACPI code (note: the Surface Book 3 uses a different method for this). The
+only currently known event sent via this interface is a dGPU power-on
+notification. While this driver handles the former part internally, it only
+relays the dGPU events to any other driver interested via its public API and
+does not handle them.
+
+The public interface of this driver is split into two parts: Client
+registration and notifier-block registration.
+
+A client to the SAN interface can be linked as consumer to the SAN device
+via |san_client_link|. This can be used to ensure that the a client
+receiving dGPU events does not miss any events due to the SAN interface not
+being set up as this forces the client driver to unbind once the SAN driver
+is unbound.
+
+Notifier-blocks can be registered by any device for as long as the module is
+loaded, regardless of being linked as client or not. Registration is done
+with |san_dgpu_notifier_register|. If the notifier is not needed any more, it
+should be unregistered via |san_dgpu_notifier_unregister|.
+
+Consult the API documentation below for more details.
+
+
+API Documentation
+=================
+
+.. kernel-doc:: include/linux/surface_acpi_notify.h
+
+.. kernel-doc:: drivers/misc/surface_sam/clients/surface_sam_san.c
+ :export:
diff --git a/Documentation/driver-api/ssam/index.rst b/Documentation/driver-api/ssam/index.rst
new file mode 100644
index 0000000000000..e1274d64db0d2
index 000000000000..5eff57c1836d
--- /dev/null
+++ b/Documentation/driver-api/ssam/index.rst
@@ -0,0 +1,20 @@
@@ -0,0 +1,21 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+=======================================
@ -527,6 +744,7 @@ index 0000000000000..e1274d64db0d2
+ ssh
+ client
+ internal
+ clients/index
+
+.. only:: subproject and html
+
@ -536,7 +754,7 @@ index 0000000000000..e1274d64db0d2
+ * :ref:`genindex`
diff --git a/Documentation/driver-api/ssam/internal-api.rst b/Documentation/driver-api/ssam/internal-api.rst
new file mode 100644
index 0000000000000..cd55b6b206e45
index 000000000000..cd55b6b206e4
--- /dev/null
+++ b/Documentation/driver-api/ssam/internal-api.rst
@@ -0,0 +1,70 @@
@ -612,7 +830,7 @@ index 0000000000000..cd55b6b206e45
+.. kernel-doc:: drivers/misc/surface_sam/ssam_trace.h
diff --git a/Documentation/driver-api/ssam/internal.rst b/Documentation/driver-api/ssam/internal.rst
new file mode 100644
index 0000000000000..0504247d87862
index 000000000000..0504247d8786
--- /dev/null
+++ b/Documentation/driver-api/ssam/internal.rst
@@ -0,0 +1,50 @@
@ -668,7 +886,7 @@ index 0000000000000..0504247d87862
+API and interface options for other kernel drivers.
diff --git a/Documentation/driver-api/ssam/overview.rst b/Documentation/driver-api/ssam/overview.rst
new file mode 100644
index 0000000000000..7b7a6d9e8e22b
index 000000000000..7b7a6d9e8e22
--- /dev/null
+++ b/Documentation/driver-api/ssam/overview.rst
@@ -0,0 +1,76 @@
@ -750,10 +968,10 @@ index 0000000000000..7b7a6d9e8e22b
+See :doc:`ssh` for a more technical protocol documentation.
diff --git a/Documentation/driver-api/ssam/ssh.rst b/Documentation/driver-api/ssam/ssh.rst
new file mode 100644
index 0000000000000..2a8a10e219ac5
index 000000000000..35c903009cf3
--- /dev/null
+++ b/Documentation/driver-api/ssam/ssh.rst
@@ -0,0 +1,297 @@
@@ -0,0 +1,343 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+.. |u8| replace:: :c:type:`u8 <u8>`
@ -806,15 +1024,25 @@ index 0000000000000..2a8a10e219ac5
+(:c:type:`struct ssh_frame <ssh_frame>`). A frame consists of the following
+fields, packed together and in order:
+
+ +--------+-------+--------------------------------------------------+
+ | Field | Type | Description |
+ +========+=======+==================================================+
+ | |TYPE| | |u8| | Type identifier of the frame. |
+ +--------+-------+--------------------------------------------------+
+ | |LEN| | |u16| | Length of the payload associated with the frame. |
+ +--------+-------+--------------------------------------------------+
+ | |SEQ| | |u8| | Sequence ID (see explanation below). |
+ +--------+-------+--------------------------------------------------+
+.. flat-table:: SSH Frame
+ :widths: 1 1 4
+ :header-rows: 1
+
+ * - Field
+ - Type
+ - Description
+
+ * - |TYPE|
+ - |u8|
+ - Type identifier of the frame.
+
+ * - |LEN|
+ - |u16|
+ - Length of the payload associated with the frame.
+
+ * - |SEQ|
+ - |u8|
+ - Sequence ID (see explanation below).
+
+Each frame structure is followed by a CRC over this structure. The CRC over
+the frame structure (|TYPE|, |LEN|, and |SEQ| fields) is placed directly
@ -827,11 +1055,17 @@ index 0000000000000..2a8a10e219ac5
+
+Additionally, the following fixed two-byte sequences are used:
+
+ +-------+------------------+------------------------+
+ | Name | Value | Description |
+ +=======+==================+========================+
+ | |SYN| | ``[0xAA, 0x55]`` | Synchronization bytes. |
+ +-------+------------------+------------------------+
+.. flat-table:: SSH Byte Sequences
+ :widths: 1 1 4
+ :header-rows: 1
+
+ * - Name
+ - Value
+ - Description
+
+ * - |SYN|
+ - ``[0xAA, 0x55]``
+ - Synchronization bytes.
+
+A message consists of |SYN|, followed by the frame (|TYPE|, |LEN|, |SEQ| and
+CRC) and, if specified in the frame (i.e. ``LEN > 0``), payload bytes,
@ -843,17 +1077,29 @@ index 0000000000000..2a8a10e219ac5
+A frame can have the following types
+(:c:type:`enum ssh_frame_type <ssh_frame_type>`):
+
+ +------------+----------+----------------------------------------------------+
+ | Name | Value | Short Description |
+ +============+==========+====================================================+
+ | |NAK| | ``0x04`` | Sent on error in previously received message. |
+ +------------+----------+----------------------------------------------------+
+ | |ACK| | ``0x40`` | Sent to acknowledge receival of |DATA| frame. |
+ +------------+----------+----------------------------------------------------+
+ | |DATA_SEQ| | ``0x80`` | Sent to transfer data. Sequenced. |
+ +------------+----------+----------------------------------------------------+
+ | |DATA_NSQ| | ``0x00`` | Same as |DATA_SEQ|, but does not need to be ACKed. |
+ +------------+----------+----------------------------------------------------+
+.. flat-table:: SSH Frame Types
+ :widths: 1 1 4
+ :header-rows: 1
+
+ * - Name
+ - Value
+ - Short Description
+
+ * - |NAK|
+ - ``0x04``
+ - Sent on error in previously received message.
+
+ * - |ACK|
+ - ``0x40``
+ - Sent to acknowledge receival of |DATA| frame.
+
+ * - |DATA_SEQ|
+ - ``0x80``
+ - Sent to transfer data. Sequenced.
+
+ * - |DATA_NSQ|
+ - ``0x00``
+ - Same as |DATA_SEQ|, but does not need to be ACKed.
+
+Both |NAK|- and |ACK|-type frames are used to control flow of messages and
+thus do not carry a payload. |DATA_SEQ|- and |DATA_NSQ|-type frames on the
@ -930,23 +1176,41 @@ index 0000000000000..2a8a10e219ac5
+``frame.len - sizeof(struct ssh_command)``. The command struct contains the
+following fields, packed together and in order:
+
+ +-------------+-------+----------------------------------------------------+
+ | Field | Type | Description |
+ +=============+=======+====================================================+
+ | |TYPE| | |u8| | Type of the payload. For commands always ``0x80``. |
+ +-------------+-------+----------------------------------------------------+
+ | |TC| | |u8| | Target category. |
+ +-------------+-------+----------------------------------------------------+
+ | |TID| (out) | |u8| | Target ID for outgoing (host to EC) commands. |
+ +-------------+-------+----------------------------------------------------+
+ | |TID| (in) | |u8| | Target ID for incoming (EC to host) commands. |
+ +-------------+-------+----------------------------------------------------+
+ | |IID| | |u8| | Instance ID. |
+ +-------------+-------+----------------------------------------------------+
+ | |RQID| | |u16| | Request ID. |
+ +-------------+-------+----------------------------------------------------+
+ | |CID| | |u8| | Command ID. |
+ +-------------+-------+----------------------------------------------------+
+.. flat-table:: SSH Command
+ :widths: 1 1 4
+ :header-rows: 1
+
+ * - Field
+ - Type
+ - Description
+
+ * - |TYPE|
+ - |u8|
+ - Type of the payload. For commands always ``0x80``.
+
+ * - |TC|
+ - |u8|
+ - Target category.
+
+ * - |TID| (out)
+ - |u8|
+ - Target ID for outgoing (host to EC) commands.
+
+ * - |TID| (in)
+ - |u8|
+ - Target ID for incoming (EC to host) commands.
+
+ * - |IID|
+ - |u8|
+ - Instance ID.
+
+ * - |RQID|
+ - |u16|
+ - Request ID.
+
+ * - |CID|
+ - |u8|
+ - Command ID.
+
+The command struct and data, in general, does not contain any failure
+detection mechanism (e.g. CRCs), this is solely done on the frame level.
@ -997,9 +1261,9 @@ index 0000000000000..2a8a10e219ac5
+Furthermore, requests, responses, and events have an associated target ID
+(``TID``). This target ID is split into output (host to EC) and input (EC to
+host) fields, with the respecting other field (e.g. output field on incoming
+messages) set to zero. Two ``TID`` values are known: Primary (0x01) and
+secondary (0x02). In general, the response to a request should have the same
+``TID`` value, however, the field (output vs. input) should be used in
+messages) set to zero. Two ``TID`` values are known: Primary (``0x01``) and
+secondary (``0x02``). In general, the response to a request should have the
+same ``TID`` value, however, the field (output vs. input) should be used in
+accordance to the direction in which the response is sent (i.e. on the input
+field, as responses are generally sent from the EC to the host).
+
@ -1052,7 +1316,7 @@ index 0000000000000..2a8a10e219ac5
+frames) and at most three pending commands. The limit to synchronous frame
+transfers seems to be consistent with behavior observed on Windows.
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index be901ffc66fee..a5a3ee2ea2e37 100644
index be901ffc66fe..a5a3ee2ea2e3 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -472,5 +472,6 @@ source "drivers/misc/ocxl/Kconfig"
@ -1063,7 +1327,7 @@ index be901ffc66fee..a5a3ee2ea2e37 100644
source "drivers/misc/ipts/Kconfig"
endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index f97938d777e13..7324a1f8b00a7 100644
index f97938d777e1..7324a1f8b00a 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -58,3 +58,4 @@ obj-$(CONFIG_HABANA_AI) += habanalabs/
@ -1073,7 +1337,7 @@ index f97938d777e13..7324a1f8b00a7 100644
+obj-$(CONFIG_SURFACE_SAM) += surface_sam/
diff --git a/drivers/misc/surface_sam/Kconfig b/drivers/misc/surface_sam/Kconfig
new file mode 100644
index 0000000000000..ca560d91e2291
index 000000000000..ca560d91e229
--- /dev/null
+++ b/drivers/misc/surface_sam/Kconfig
@@ -0,0 +1,46 @@
@ -1125,7 +1389,7 @@ index 0000000000000..ca560d91e2291
+source "drivers/misc/surface_sam/clients/Kconfig"
diff --git a/drivers/misc/surface_sam/Makefile b/drivers/misc/surface_sam/Makefile
new file mode 100644
index 0000000000000..0a07dd2297874
index 000000000000..0a07dd229787
--- /dev/null
+++ b/drivers/misc/surface_sam/Makefile
@@ -0,0 +1,14 @@
@ -1145,7 +1409,7 @@ index 0000000000000..0a07dd2297874
+surface_sam_ssh-objs += bus.o
diff --git a/drivers/misc/surface_sam/bus.c b/drivers/misc/surface_sam/bus.c
new file mode 100644
index 0000000000000..6089e7b74f462
index 000000000000..6089e7b74f46
--- /dev/null
+++ b/drivers/misc/surface_sam/bus.c
@@ -0,0 +1,414 @@
@ -1565,7 +1829,7 @@ index 0000000000000..6089e7b74f462
+}
diff --git a/drivers/misc/surface_sam/bus.h b/drivers/misc/surface_sam/bus.h
new file mode 100644
index 0000000000000..8b3ddf2100870
index 000000000000..8b3ddf210087
--- /dev/null
+++ b/drivers/misc/surface_sam/bus.h
@@ -0,0 +1,14 @@
@ -1585,7 +1849,7 @@ index 0000000000000..8b3ddf2100870
+#endif /* _SSAM_BUS_H */
diff --git a/drivers/misc/surface_sam/clients/Kconfig b/drivers/misc/surface_sam/clients/Kconfig
new file mode 100644
index 0000000000000..189bf02e280d7
index 000000000000..189bf02e280d
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/Kconfig
@@ -0,0 +1,121 @@
@ -1712,7 +1976,7 @@ index 0000000000000..189bf02e280d7
+ If you are not sure, say M here.
diff --git a/drivers/misc/surface_sam/clients/Makefile b/drivers/misc/surface_sam/clients/Makefile
new file mode 100644
index 0000000000000..1db9db2f86252
index 000000000000..1db9db2f8625
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/Makefile
@@ -0,0 +1,11 @@
@ -1729,10 +1993,10 @@ index 0000000000000..1db9db2f86252
+obj-$(CONFIG_SURFACE_SAM_DEVICE_HUB) += surface_sam_device_hub.o
diff --git a/drivers/misc/surface_sam/clients/surface_sam_debugfs.c b/drivers/misc/surface_sam/clients/surface_sam_debugfs.c
new file mode 100644
index 0000000000000..191ae7eb9f996
index 000000000000..cd1fd24b0582
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/surface_sam_debugfs.c
@@ -0,0 +1,265 @@
@@ -0,0 +1,282 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/debugfs.h>
@ -1746,9 +2010,26 @@ index 0000000000000..191ae7eb9f996
+#include <linux/surface_aggregator_module.h>
+
+#define SSAM_DBGDEV_NAME "surface_sam_dbgdev"
+#define SSAM_DBGDEV_VERS 0x0100
+#define SSAM_DBGDEV_VERS 0x010000
+
+
+/**
+ * struct ssam_dbgdev_request - Controller request IOCTL argument.
+ * @target_category: Target category of the SAM request.
+ * @target_id: Target ID of the SAM request.
+ * @command_id: Command ID of the SAM request.
+ * @instance_id: Instance ID of the SAM request.
+ * @flags: SAM Request flags.
+ * @status: Request status (output).
+ * @payload: Request payload (input data).
+ * @payload.data: Pointer to request payload data.
+ * @payload.length: Length of request payload data (in bytes).
+ * @response: Request response (output data).
+ * @response.data: Pointer to response buffer.
+ * @response.length: On input: Capacity of response buffer (in bytes).
+ * On output: Length of request response (number of bytes
+ * in the buffer that are actually used).
+ */
+struct ssam_dbgdev_request {
+ __u8 target_category;
+ __u8 target_id;
@ -1925,7 +2206,7 @@ index 0000000000000..191ae7eb9f996
+
+ ddev->ctrl = ctrl;
+
+ ddev->dentry_dir = debugfs_create_dir("surface_sam", NULL);
+ ddev->dentry_dir = debugfs_create_dir("ssam", NULL);
+ if (IS_ERR(ddev->dentry_dir))
+ return PTR_ERR(ddev->dentry_dir);
+
@ -2000,7 +2281,7 @@ index 0000000000000..191ae7eb9f996
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/surface_sam/clients/surface_sam_device_hub.c b/drivers/misc/surface_sam/clients/surface_sam_device_hub.c
new file mode 100644
index 0000000000000..d099def70d605
index 000000000000..d099def70d60
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/surface_sam_device_hub.c
@@ -0,0 +1,642 @@
@ -2648,7 +2929,7 @@ index 0000000000000..d099def70d605
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/surface_sam/clients/surface_sam_dtx.c b/drivers/misc/surface_sam/clients/surface_sam_dtx.c
new file mode 100644
index 0000000000000..ff73f54328069
index 000000000000..ff73f5432806
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/surface_sam_dtx.c
@@ -0,0 +1,583 @@
@ -3237,7 +3518,7 @@ index 0000000000000..ff73f54328069
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/surface_sam/clients/surface_sam_hps.c b/drivers/misc/surface_sam/clients/surface_sam_hps.c
new file mode 100644
index 0000000000000..3a72642d13da5
index 000000000000..b2232043552a
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/surface_sam_hps.c
@@ -0,0 +1,1296 @@
@ -4101,7 +4382,7 @@ index 0000000000000..3a72642d13da5
+{
+ struct shps_driver_data *drvdata = container_of(nb, struct shps_driver_data, dgpu_nf);
+ struct platform_device *pdev = drvdata->pdev;
+ struct ssam_anf_dgpu_event *evt = data;
+ struct san_dgpu_event *evt = data;
+
+ if (evt->category == SAM_DGPU_TC && evt->command == SAM_DGPU_CID_POWERON)
+ return shps_dgpu_powered_on(pdev);
@ -4354,7 +4635,7 @@ index 0000000000000..3a72642d13da5
+
+ if (detected_traits.notification_method == SHPS_NOTIFICATION_METHOD_SAN) {
+ // link to SAN
+ status = ssam_anf_client_link(&pdev->dev);
+ status = san_client_link(&pdev->dev);
+ if (status) {
+ dev_err(&pdev->dev, "failed to register as SAN client: %d\n", status);
+ return status == -ENXIO ? -EPROBE_DEFER : status;
@ -4411,7 +4692,7 @@ index 0000000000000..3a72642d13da5
+ drvdata->dgpu_nf.priority = 1;
+ drvdata->dgpu_nf.notifier_call = shps_dgpu_handle_rqsg;
+
+ status = ssam_anf_dgpu_notifier_register(&drvdata->dgpu_nf);
+ status = san_dgpu_notifier_register(&drvdata->dgpu_nf);
+ if (status) {
+ dev_err(&pdev->dev, "unable to register SAN notification handler (%d)\n", status);
+ goto err_devlink;
@ -4459,7 +4740,7 @@ index 0000000000000..3a72642d13da5
+ if (detected_traits.notification_method == SHPS_NOTIFICATION_METHOD_SGCP) {
+ shps_remove_sgcp_notification(pdev);
+ } else if (detected_traits.notification_method == SHPS_NOTIFICATION_METHOD_SAN) {
+ ssam_anf_dgpu_notifier_unregister(&drvdata->dgpu_nf);
+ san_dgpu_notifier_unregister(&drvdata->dgpu_nf);
+ }
+err_devlink:
+ device_remove_groups(&pdev->dev, shps_power_groups);
@ -4494,7 +4775,7 @@ index 0000000000000..3a72642d13da5
+ if (drvdata->hardware_traits.notification_method == SHPS_NOTIFICATION_METHOD_SGCP) {
+ shps_remove_sgcp_notification(pdev);
+ } else if (drvdata->hardware_traits.notification_method == SHPS_NOTIFICATION_METHOD_SAN) {
+ ssam_anf_dgpu_notifier_unregister(&drvdata->dgpu_nf);
+ san_dgpu_notifier_unregister(&drvdata->dgpu_nf);
+ }
+ device_remove_groups(&pdev->dev, shps_power_groups);
+ shps_gpios_remove_irq(pdev);
@ -4539,10 +4820,10 @@ index 0000000000000..3a72642d13da5
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/surface_sam/clients/surface_sam_san.c b/drivers/misc/surface_sam/clients/surface_sam_san.c
new file mode 100644
index 0000000000000..ff3b59bcae554
index 000000000000..59f2370be8c5
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/surface_sam_san.c
@@ -0,0 +1,813 @@
@@ -0,0 +1,841 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Surface ACPI Notify (SAN) and ACPI integration driver for SAM.
@ -4604,7 +4885,23 @@ index 0000000000000..ff3b59bcae554
+ return status;
+}
+
+int ssam_anf_client_link(struct device *client)
+/**
+ * san_client_link() - Link client as consumer to SAN device.
+ * @client: The client to link.
+ *
+ * Sets up a device link between the provided client device as consumer and
+ * the SAN device as provider. This function can be used to ensure that the
+ * SAN interface has been set up and will be set up for as long as the driver
+ * of the client device is bound. This guarantees that, during that time, all
+ * dGPU events will be received by any registered notifier.
+ *
+ * The link will be automatically removed once the client device's driver is
+ * unbound.
+ *
+ * Return: Returns zero on succes, %-ENXIO if the SAN interface has not been
+ * set up yet, and %-ENOMEM if device link creation failed.
+ */
+int san_client_link(struct device *client)
+{
+ const u32 flags = DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_CONSUMER;
+ struct device_link *link;
@ -4630,21 +4927,33 @@ index 0000000000000..ff3b59bcae554
+ up_read(&san_rqsg_if.lock);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(ssam_anf_client_link);
+EXPORT_SYMBOL_GPL(san_client_link);
+
+int ssam_anf_dgpu_notifier_register(struct notifier_block *nb)
+/**
+ * san_dgpu_notifier_register() - Register a SAN dGPU notifier.
+ * @nb: The notifier-block to register.
+ *
+ * Registers a SAN dGPU notifier, receiving any new SAN dGPU events sent from
+ * ACPI. The registered notifier will be called with &struct san_dgpu_event
+ * as notifier data and the command ID of that event as notifier action.
+ */
+int san_dgpu_notifier_register(struct notifier_block *nb)
+{
+ return blocking_notifier_chain_register(&san_rqsg_if.nh, nb);
+}
+EXPORT_SYMBOL_GPL(ssam_anf_dgpu_notifier_register);
+EXPORT_SYMBOL_GPL(san_dgpu_notifier_register);
+
+int ssam_anf_dgpu_notifier_unregister(struct notifier_block *nb)
+/**
+ * san_dgpu_notifier_unregister() - Unregister a SAN dGPU notifier.
+ * @nb: The notifier-block to unregister.
+ */
+int san_dgpu_notifier_unregister(struct notifier_block *nb)
+{
+ return blocking_notifier_chain_unregister(&san_rqsg_if.nh, nb);
+}
+EXPORT_SYMBOL_GPL(ssam_anf_dgpu_notifier_unregister);
+EXPORT_SYMBOL_GPL(san_dgpu_notifier_unregister);
+
+static int san_dgpu_notifier_call(struct ssam_anf_dgpu_event *evt)
+static int san_dgpu_notifier_call(struct san_dgpu_event *evt)
+{
+ int ret;
+
@ -5108,7 +5417,7 @@ index 0000000000000..ff3b59bcae554
+static acpi_status san_rqsg(struct san_data *d, struct gsb_buffer *buffer)
+{
+ struct gsb_data_rqsx *gsb_rqsg;
+ struct ssam_anf_dgpu_event evt;
+ struct san_dgpu_event evt;
+ int status;
+
+ gsb_rqsg = san_validate_rqsx(d->dev, "RQSG", buffer);
@ -5358,7 +5667,7 @@ index 0000000000000..ff3b59bcae554
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/surface_sam/clients/surface_sam_sid_perfmode.c b/drivers/misc/surface_sam/clients/surface_sam_sid_perfmode.c
new file mode 100644
index 0000000000000..44f5d31709b22
index 000000000000..44f5d31709b2
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/surface_sam_sid_perfmode.c
@@ -0,0 +1,190 @@
@ -5554,7 +5863,7 @@ index 0000000000000..44f5d31709b22
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/surface_sam/clients/surface_sam_sid_power.c b/drivers/misc/surface_sam/clients/surface_sam_sid_power.c
new file mode 100644
index 0000000000000..da8dd1e914b70
index 000000000000..da8dd1e914b7
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/surface_sam_sid_power.c
@@ -0,0 +1,1114 @@
@ -6674,7 +6983,7 @@ index 0000000000000..da8dd1e914b70
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/surface_sam/clients/surface_sam_sid_vhf.c b/drivers/misc/surface_sam/clients/surface_sam_sid_vhf.c
new file mode 100644
index 0000000000000..e995c03f4b733
index 000000000000..e995c03f4b73
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/surface_sam_sid_vhf.c
@@ -0,0 +1,498 @@
@ -7178,7 +7487,7 @@ index 0000000000000..e995c03f4b733
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/surface_sam/clients/surface_sam_vhf.c b/drivers/misc/surface_sam/clients/surface_sam_vhf.c
new file mode 100644
index 0000000000000..8f24e7a7bfea9
index 000000000000..8f24e7a7bfea
--- /dev/null
+++ b/drivers/misc/surface_sam/clients/surface_sam_vhf.c
@@ -0,0 +1,334 @@
@ -7518,7 +7827,7 @@ index 0000000000000..8f24e7a7bfea9
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/surface_sam/controller.c b/drivers/misc/surface_sam/controller.c
new file mode 100644
index 0000000000000..c279159e3aabc
index 000000000000..c279159e3aab
--- /dev/null
+++ b/drivers/misc/surface_sam/controller.c
@@ -0,0 +1,2441 @@
@ -9965,7 +10274,7 @@ index 0000000000000..c279159e3aabc
+}
diff --git a/drivers/misc/surface_sam/controller.h b/drivers/misc/surface_sam/controller.h
new file mode 100644
index 0000000000000..2c328e21df68d
index 000000000000..2c328e21df68
--- /dev/null
+++ b/drivers/misc/surface_sam/controller.h
@@ -0,0 +1,275 @@
@ -10246,7 +10555,7 @@ index 0000000000000..2c328e21df68d
+#endif /* _SSAM_CONTROLLER_H */
diff --git a/drivers/misc/surface_sam/core.c b/drivers/misc/surface_sam/core.c
new file mode 100644
index 0000000000000..5164d13e52f8d
index 000000000000..5164d13e52f8
--- /dev/null
+++ b/drivers/misc/surface_sam/core.c
@@ -0,0 +1,771 @@
@ -11023,7 +11332,7 @@ index 0000000000000..5164d13e52f8d
+MODULE_LICENSE("GPL");
diff --git a/drivers/misc/surface_sam/ssam_trace.h b/drivers/misc/surface_sam/ssam_trace.h
new file mode 100644
index 0000000000000..ad1ce1cdd474f
index 000000000000..ad1ce1cdd474
--- /dev/null
+++ b/drivers/misc/surface_sam/ssam_trace.h
@@ -0,0 +1,619 @@
@ -11648,7 +11957,7 @@ index 0000000000000..ad1ce1cdd474f
+#include <trace/define_trace.h>
diff --git a/drivers/misc/surface_sam/ssh_msgb.h b/drivers/misc/surface_sam/ssh_msgb.h
new file mode 100644
index 0000000000000..4b37c5577897c
index 000000000000..4b37c5577897
--- /dev/null
+++ b/drivers/misc/surface_sam/ssh_msgb.h
@@ -0,0 +1,196 @@
@ -11850,7 +12159,7 @@ index 0000000000000..4b37c5577897c
+#endif /* _SSAM_SSH_MSGB_H */
diff --git a/drivers/misc/surface_sam/ssh_packet_layer.c b/drivers/misc/surface_sam/ssh_packet_layer.c
new file mode 100644
index 0000000000000..21a8f7e4473b4
index 000000000000..21a8f7e4473b
--- /dev/null
+++ b/drivers/misc/surface_sam/ssh_packet_layer.c
@@ -0,0 +1,2001 @@
@ -13857,7 +14166,7 @@ index 0000000000000..21a8f7e4473b4
+}
diff --git a/drivers/misc/surface_sam/ssh_packet_layer.h b/drivers/misc/surface_sam/ssh_packet_layer.h
new file mode 100644
index 0000000000000..2e2d961c5c046
index 000000000000..2e2d961c5c04
--- /dev/null
+++ b/drivers/misc/surface_sam/ssh_packet_layer.h
@@ -0,0 +1,173 @@
@ -14036,7 +14345,7 @@ index 0000000000000..2e2d961c5c046
+#endif /* _SSAM_SSH_PACKET_LAYER_H */
diff --git a/drivers/misc/surface_sam/ssh_parser.c b/drivers/misc/surface_sam/ssh_parser.c
new file mode 100644
index 0000000000000..3e28d502d5eb2
index 000000000000..3e28d502d5eb
--- /dev/null
+++ b/drivers/misc/surface_sam/ssh_parser.c
@@ -0,0 +1,221 @@
@ -14263,7 +14572,7 @@ index 0000000000000..3e28d502d5eb2
+}
diff --git a/drivers/misc/surface_sam/ssh_parser.h b/drivers/misc/surface_sam/ssh_parser.h
new file mode 100644
index 0000000000000..1ee455de7898a
index 000000000000..1ee455de7898
--- /dev/null
+++ b/drivers/misc/surface_sam/ssh_parser.h
@@ -0,0 +1,151 @@
@ -14420,7 +14729,7 @@ index 0000000000000..1ee455de7898a
+#endif /* _SURFACE_SAM_SSH_PARSER_h */
diff --git a/drivers/misc/surface_sam/ssh_protocol.h b/drivers/misc/surface_sam/ssh_protocol.h
new file mode 100644
index 0000000000000..4f35ce93f02e2
index 000000000000..4f35ce93f02e
--- /dev/null
+++ b/drivers/misc/surface_sam/ssh_protocol.h
@@ -0,0 +1,103 @@
@ -14529,7 +14838,7 @@ index 0000000000000..4f35ce93f02e2
+#endif /* _SSAM_SSH_PROTOCOL_H */
diff --git a/drivers/misc/surface_sam/ssh_request_layer.c b/drivers/misc/surface_sam/ssh_request_layer.c
new file mode 100644
index 0000000000000..24aaf6da5b545
index 000000000000..24aaf6da5b54
--- /dev/null
+++ b/drivers/misc/surface_sam/ssh_request_layer.c
@@ -0,0 +1,1246 @@
@ -15781,7 +16090,7 @@ index 0000000000000..24aaf6da5b545
+}
diff --git a/drivers/misc/surface_sam/ssh_request_layer.h b/drivers/misc/surface_sam/ssh_request_layer.h
new file mode 100644
index 0000000000000..954f571862a69
index 000000000000..954f571862a6
--- /dev/null
+++ b/drivers/misc/surface_sam/ssh_request_layer.h
@@ -0,0 +1,136 @@
@ -15922,7 +16231,7 @@ index 0000000000000..954f571862a69
+
+#endif /* _SSAM_SSH_REQUEST_LAYER_H */
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index e14cbe444afcc..82c8660a5c869 100644
index e14cbe444afc..82c8660a5c86 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -836,4 +836,21 @@ struct mhi_device_id {
@ -15949,10 +16258,10 @@ index e14cbe444afcc..82c8660a5c869 100644
#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/include/linux/surface_acpi_notify.h b/include/linux/surface_acpi_notify.h
new file mode 100644
index 0000000000000..37be101afdd95
index 000000000000..aa69fa508140
--- /dev/null
+++ b/include/linux/surface_acpi_notify.h
@@ -0,0 +1,30 @@
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Interface for Surface ACPI/Notify (SAN).
@ -15967,25 +16276,34 @@ index 0000000000000..37be101afdd95
+#define _SURFACE_SAM_SAN_H
+
+#include <linux/types.h>
+#include <linux/notifier.h>
+
+
+struct ssam_anf_dgpu_event {
+ u8 category; // target category
+ u8 target; // target ID
+ u8 command; // command ID
+ u8 instance; // instance ID
+ u16 length; // command data length (length of payload)
+ u8 *payload; // pointer to payload of length cdl
+/**
+ * struct san_dgpu_event - Discrete GPU ACPI event.
+ * @category: Category of the event.
+ * @target: Target ID of the event source.
+ * @command: Command ID of the event.
+ * @instance: Instance ID of the event source.
+ * @length: Length of the event's payload data (in bytes).
+ * @payload: Pointer to the event's payload data.
+ */
+struct san_dgpu_event {
+ u8 category;
+ u8 target;
+ u8 command;
+ u8 instance;
+ u16 length;
+ u8 *payload;
+};
+
+int ssam_anf_client_link(struct device *client);
+int ssam_anf_dgpu_notifier_register(struct notifier_block *nb);
+int ssam_anf_dgpu_notifier_unregister(struct notifier_block *nb);
+int san_client_link(struct device *client);
+int san_dgpu_notifier_register(struct notifier_block *nb);
+int san_dgpu_notifier_unregister(struct notifier_block *nb);
+
+#endif /* _SURFACE_SAM_SAN_H */
diff --git a/include/linux/surface_aggregator_module.h b/include/linux/surface_aggregator_module.h
new file mode 100644
index 0000000000000..8cf14038a89a4
index 000000000000..8cf14038a89a
--- /dev/null
+++ b/include/linux/surface_aggregator_module.h
@@ -0,0 +1,1722 @@
@ -17712,7 +18030,7 @@ index 0000000000000..8cf14038a89a4
+
+#endif /* _SURFACE_AGGREGATOR_MODULE_H */
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index 010be8ba21160..ad40fb4462803 100644
index 010be8ba2116..ad40fb446280 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -241,5 +241,12 @@ int main(void)
@ -17729,7 +18047,7 @@ index 010be8ba21160..ad40fb4462803 100644
return 0;
}
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 9599e2a3f1e61..2f2337eb5d284 100644
index 9599e2a3f1e6..2f2337eb5d28 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1364,6 +1364,27 @@ static int do_mhi_entry(const char *filename, void *symval, char *alias)

View file

@ -1,4 +1,4 @@
From 2c2d6aff72e97d6ce46164d42de267cf3e0dce2d Mon Sep 17 00:00:00 2001
From 0007600e30673281468607934800bd079cad215e Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 25 Jul 2020 17:19:53 +0200
Subject: [PATCH 5/6] surface-sam-over-hid
@ -12,7 +12,7 @@ Subject: [PATCH 5/6] surface-sam-over-hid
create mode 100644 drivers/platform/x86/sb1_dgpu_sw.c
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 2ade99b105b91..60b9cb51d5f7e 100644
index 2ade99b105b9..60b9cb51d5f7 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -574,6 +574,28 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
@ -65,7 +65,7 @@ index 2ade99b105b91..60b9cb51d5f7e 100644
dev_warn(&adapter->dev, "protocol 0x%02x not supported for client 0x%02x\n",
accessor_type, client->addr);
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 0581a54cf562f..14db2795ff638 100644
index 0581a54cf562..14db2795ff63 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -879,6 +879,13 @@ config SURFACE_PRO3_BUTTON
@ -83,7 +83,7 @@ index 0581a54cf562f..14db2795ff638 100644
tristate "MSI Laptop Extras"
depends on ACPI
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 2b85852a1a872..5156523b58639 100644
index 2b85852a1a87..5156523b5863 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -85,6 +85,7 @@ obj-$(CONFIG_SURFACE3_WMI) += surface3-wmi.o
@ -96,7 +96,7 @@ index 2b85852a1a872..5156523b58639 100644
obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
diff --git a/drivers/platform/x86/sb1_dgpu_sw.c b/drivers/platform/x86/sb1_dgpu_sw.c
new file mode 100644
index 0000000000000..8c66ed5110fda
index 000000000000..8c66ed5110fd
--- /dev/null
+++ b/drivers/platform/x86/sb1_dgpu_sw.c
@@ -0,0 +1,162 @@

View file

@ -1,4 +1,4 @@
From 9ec51d0d15ab736230deeeb6a9699163666e159e Mon Sep 17 00:00:00 2001
From 2a3e106d1bc291b1f9656aaa129eca69b2509028 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sun, 16 Aug 2020 23:39:56 +0200
Subject: [PATCH 6/6] surface-gpe
@ -11,7 +11,7 @@ Subject: [PATCH 6/6] surface-gpe
create mode 100644 drivers/platform/x86/surface_gpe.c
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 14db2795ff638..c64267319696c 100644
index 14db2795ff63..c64267319696 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -886,6 +886,15 @@ config SURFACE_BOOK1_DGPU_SWITCH
@ -31,7 +31,7 @@ index 14db2795ff638..c64267319696c 100644
tristate "MSI Laptop Extras"
depends on ACPI
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 5156523b58639..ef0c3fcab3194 100644
index 5156523b5863..ef0c3fcab319 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -86,6 +86,7 @@ obj-$(CONFIG_SURFACE_3_BUTTON) += surface3_button.o
@ -44,7 +44,7 @@ index 5156523b58639..ef0c3fcab3194 100644
obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
diff --git a/drivers/platform/x86/surface_gpe.c b/drivers/platform/x86/surface_gpe.c
new file mode 100644
index 0000000000000..10e563f253b9e
index 000000000000..10e563f253b9
--- /dev/null
+++ b/drivers/platform/x86/surface_gpe.c
@@ -0,0 +1,303 @@

View file

@ -40,12 +40,12 @@ sha256sums=('03f5e769e7b3365a5eaeea1369912f7f142f8c35f596367878831b0cd0330af1'
'181330a9cf4517abbbe29b93165bc859ad8ca14a43582f4e1d69aae2b5ecc2c9'
'1f65b3f042db87952468e99be3f1f688f62dda18401bf9716cb734f5571288b5'
'8dbaa21d2c03621b0c5d96c4fbcc7a839bea5a34a5f2279a409c3b404756e753'
'119fb1a8af1dd4f96cd6ce111be8b97c6269a47ee06ae4c2f7eef41ec20729aa'
'313546bef7d4b3744ec64652411e67ea3460e47c8036c6b616f510d68a1deb55'
'4459f22b346b14bca1f856666e92e2c771d0d844b8c1a709a7ab10e22564a075'
'951710d7a544a8bd6f8750ead837a62b4b5f3cb7751d703208f74defe75eec95'
'1d1f9a5c527f87d47fb417b4968d71e1b3cc57abb673a39c8248c3681d2cc978'
'5a8be55468498b00c77fe7c777d750a86ee7379c1a0baeaa6d4e14d6fc26c5d4')
'362368cb8b635d9f8ad06c5efbabe8e42347ab85d3f911df3b6d81041a67806b'
'445908dac8aa09cc141c2b67af6e3fb50c61ccadbe7e87be606f3e91db7cabfe'
'b7f1296eb5fcf6e0ddb31acc0b7ec7e672aeb075814f6d770abc1dd18ca95d3d'
'6a9a7ffdea6ac0e63d123538de3e0d32f819a1c0f98317e39a3fa13c463f0807'
'b2167ee13afadfb58b2bbe0ee5fe9b26319662b97dbb78f17d6521329f1aaffc'
'05a714876d7e2b97b14779ac5e1e66c95af5eb69c82574339afb803a43f1918b')
export KBUILD_BUILD_HOST=archlinux