|
@@ -1,4 +1,4 @@
|
|
|
-From b63983a6536a99be8da444149232adc6a8d5e6c2 Mon Sep 17 00:00:00 2001
|
|
|
+From c6ec3e5b5b1a52ab00779d096c6afdf600a9c5b2 Mon Sep 17 00:00:00 2001
|
|
|
From: Lukas Wunner <lukas@wunner.de>
|
|
|
Date: Tue, 31 Jul 2018 07:50:37 +0200
|
|
|
Subject: [PATCH] PCI: pciehp: Differentiate between surprise and safe removal
|
|
@@ -195,9 +195,9 @@ index 5c58c22e0c08..18f83e554c73 100644
|
|
|
pci_lock_rescan_remove();
|
|
|
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From f235e14a8a90af341b58041555d2f2eedcfcf46e Mon Sep 17 00:00:00 2001
|
|
|
+From d1d9637d9975bf4c51055a9ce1476c86b9d17d55 Mon Sep 17 00:00:00 2001
|
|
|
From: Lukas Wunner <lukas@wunner.de>
|
|
|
Date: Sun, 19 Aug 2018 16:29:00 +0200
|
|
|
Subject: [PATCH] PCI: pciehp: Drop unnecessary includes
|
|
@@ -334,9 +334,9 @@ index 18f83e554c73..c512b2ed85ed 100644
|
|
|
#include <linux/types.h>
|
|
|
#include <linux/pci.h>
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From d2f8db35b8a57856afecb7eac3939e228ede6a38 Mon Sep 17 00:00:00 2001
|
|
|
+From 4e4551f354b1b225a1c8da3889c310fb42d35e59 Mon Sep 17 00:00:00 2001
|
|
|
From: Lukas Wunner <lukas@wunner.de>
|
|
|
Date: Sun, 19 Aug 2018 16:29:00 +0200
|
|
|
Subject: [PATCH] PCI: pciehp: Drop hotplug_slot_ops wrappers
|
|
@@ -547,9 +547,9 @@ index d4b7049cbc70..576362d0b1cd 100644
|
|
|
struct pci_dev *pdev = ctrl_dev(ctrl);
|
|
|
u16 stat_mask = 0, ctrl_mask = 0;
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 130b0053672f79bb9afc3dbfe7ef0e93114aa176 Mon Sep 17 00:00:00 2001
|
|
|
+From 01074b180b2cd3e2a9a64c3f6050a94b644cbab0 Mon Sep 17 00:00:00 2001
|
|
|
From: Lukas Wunner <lukas@wunner.de>
|
|
|
Date: Sat, 8 Sep 2018 09:59:01 +0200
|
|
|
Subject: [PATCH] PCI: pciehp: Tolerate Presence Detect hardwired to zero
|
|
@@ -745,9 +745,9 @@ index 576362d0b1cd..7f4173d6771a 100644
|
|
|
pciehp_power_off_slot(ctrl->slot);
|
|
|
}
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From c10f22ffa0b0bb52c0bcef1b261e4e2173bd2d91 Mon Sep 17 00:00:00 2001
|
|
|
+From e13fc0694036cbf187b3c90892cd41bdee149f45 Mon Sep 17 00:00:00 2001
|
|
|
From: Patrick Talbert <ptalbert@redhat.com>
|
|
|
Date: Wed, 5 Sep 2018 09:12:53 +0200
|
|
|
Subject: [PATCH] PCI/ASPM: Do not initialize link state when aspm_disabled is
|
|
@@ -790,9 +790,9 @@ index cb474338f39d..18aa830e79e4 100644
|
|
|
|
|
|
if (pdev->link_state)
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 5e68e471040f1e81e9374ac2da3cf2439997d1ec Mon Sep 17 00:00:00 2001
|
|
|
+From 6eef763e4e66b0c36b8f48c1a51ee8c59f14cb92 Mon Sep 17 00:00:00 2001
|
|
|
From: Lukas Wunner <lukas@wunner.de>
|
|
|
Date: Sun, 19 Aug 2018 16:29:00 +0200
|
|
|
Subject: [PATCH] PCI: Simplify disconnected marking
|
|
@@ -876,9 +876,9 @@ index 2c3b5bd59b18..dee5a7507403 100644
|
|
|
|
|
|
result = reset_link(udev, service);
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From c53dc649b8cb265ef4d409d43a1dec2aec4c4f17 Mon Sep 17 00:00:00 2001
|
|
|
+From a656221bf84eda4e2a4ece3e2f88d6d54234b64d Mon Sep 17 00:00:00 2001
|
|
|
From: Lukas Wunner <lukas@wunner.de>
|
|
|
Date: Tue, 18 Sep 2018 21:46:17 +0200
|
|
|
Subject: [PATCH] PCI: pciehp: Unify controller and slot structs
|
|
@@ -2068,9 +2068,9 @@ index 8da87931bd45..b9c1396db6fe 100644
|
|
|
ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n",
|
|
|
__func__, pci_domain_nr(parent), parent->number);
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 66568278cc479142e079bbd8f42e7304e22b67a6 Mon Sep 17 00:00:00 2001
|
|
|
+From 561d3a071aa5e361ac3e1d5aeb591411816d8219 Mon Sep 17 00:00:00 2001
|
|
|
From: Lukas Wunner <lukas@wunner.de>
|
|
|
Date: Sat, 8 Sep 2018 09:59:01 +0200
|
|
|
Subject: [PATCH] PCI: pciehp: Rename controller struct members for clarity
|
|
@@ -2375,9 +2375,9 @@ index 4a17d71e15d3..e4d6ec960630 100644
|
|
|
}
|
|
|
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From f2b741a4e0b8b35bdb59e993dae758f61c5088b5 Mon Sep 17 00:00:00 2001
|
|
|
+From 2569dde86684d3ac54af3cbcdfd61afc409d2116 Mon Sep 17 00:00:00 2001
|
|
|
From: Lukas Wunner <lukas@wunner.de>
|
|
|
Date: Sat, 8 Sep 2018 09:59:01 +0200
|
|
|
Subject: [PATCH] PCI: pciehp: Reshuffle controller struct for clarity
|
|
@@ -2506,9 +2506,9 @@ index 2499489158cc..df82a0335515 100644
|
|
|
int request_result;
|
|
|
wait_queue_head_t requester;
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From b2b5683cb9c5e7a04b7eb116f3ceecfcc33367a0 Mon Sep 17 00:00:00 2001
|
|
|
+From 580a8e7376f9c3b3206626811d8dc2a01b08e259 Mon Sep 17 00:00:00 2001
|
|
|
From: Keith Busch <keith.busch@intel.com>
|
|
|
Date: Thu, 20 Sep 2018 10:27:17 -0600
|
|
|
Subject: [PATCH] PCI: Make link active reporting detection generic
|
|
@@ -2703,9 +2703,9 @@ index ec6c48ecd7d5..74c8e9190fed 100644
|
|
|
atomic_t enable_cnt; /* pci_enable_device has been called */
|
|
|
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From df496c591f4b1c0fa77f732d2aaaf67d45444546 Mon Sep 17 00:00:00 2001
|
|
|
+From f70ebf21b624e9c1cc00bf3ad27cb883c5a59d1c Mon Sep 17 00:00:00 2001
|
|
|
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
Date: Thu, 27 Sep 2018 16:53:53 -0500
|
|
|
Subject: [PATCH] PCI: Do not skip power-managed bridges in pci_enable_wake()
|
|
@@ -2754,9 +2754,9 @@ index 25b0fe79420f..6a0dc12187ed 100644
|
|
|
|
|
|
/* Don't do the same thing twice in a row for one device. */
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From aebee92343c39b3104b8dcbe6ac24b84e8b6b5b6 Mon Sep 17 00:00:00 2001
|
|
|
+From af417f9fd8e00fdabf69d6c928b524a079cbcfbb Mon Sep 17 00:00:00 2001
|
|
|
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
Date: Thu, 27 Sep 2018 16:38:19 -0500
|
|
|
Subject: [PATCH] PCI: pciehp: Disable hotplug interrupt during suspend
|
|
@@ -2868,9 +2868,9 @@ index 0693870a9e24..b5c7f5ef597a 100644
|
|
|
* pciehp has a 1:1 bus:slot relationship so we ultimately want a secondary
|
|
|
* bus reset of the bridge, but at the same time we want to ensure that it is
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 22444a6c9e7dc204d10bc7df7afa9f302f9a2c1d Mon Sep 17 00:00:00 2001
|
|
|
+From 83bc09e60eee0e67590d229ce2429ac76581b4aa Mon Sep 17 00:00:00 2001
|
|
|
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
Date: Thu, 27 Sep 2018 16:41:46 -0500
|
|
|
Subject: [PATCH] PCI: pciehp: Do not handle events if interrupts are masked
|
|
@@ -2910,9 +2910,9 @@ index b5c7f5ef597a..242b9f30210a 100644
|
|
|
|
|
|
/*
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 6c84300d115a3b0e3a74a773f686834665e29efe Mon Sep 17 00:00:00 2001
|
|
|
+From 4922b32274a5b699f7e1976dda9b55c21476b399 Mon Sep 17 00:00:00 2001
|
|
|
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
Date: Thu, 27 Sep 2018 16:41:47 -0500
|
|
|
Subject: [PATCH] PCI/portdrv: Resume upon exit from system suspend if left
|
|
@@ -2963,9 +2963,9 @@ index 23a5a0c2c3fe..5badf8a1ce0a 100644
|
|
|
if (pci_bridge_d3_possible(dev)) {
|
|
|
/*
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From a4f6dff3069f9e7de10e93e8b19f263deddbf902 Mon Sep 17 00:00:00 2001
|
|
|
+From b8269200290bfc69d1eb1a4bbb4c2f7f2db7fc77 Mon Sep 17 00:00:00 2001
|
|
|
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
Date: Thu, 27 Sep 2018 16:41:48 -0500
|
|
|
Subject: [PATCH] PCI/portdrv: Add runtime PM hooks for port service drivers
|
|
@@ -3075,9 +3075,9 @@ index 5badf8a1ce0a..59d2567e2db2 100644
|
|
|
};
|
|
|
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 4e6fea38d9539ae22de646bc11c74db56c5b39eb Mon Sep 17 00:00:00 2001
|
|
|
+From b5e250fe37307bc562451f4b3171bc9112e13166 Mon Sep 17 00:00:00 2001
|
|
|
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
Date: Thu, 27 Sep 2018 16:41:49 -0500
|
|
|
Subject: [PATCH] PCI: pciehp: Implement runtime PM callbacks
|
|
@@ -3132,9 +3132,9 @@ index 8e6e4ce869fb..e5de25ebc4cf 100644
|
|
|
};
|
|
|
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 66ee2bafce6e1d4a57d40566aa769654b672889b Mon Sep 17 00:00:00 2001
|
|
|
+From a226b5411414301513e36c3698022347a88f34ed Mon Sep 17 00:00:00 2001
|
|
|
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
Date: Thu, 27 Sep 2018 16:57:05 -0500
|
|
|
Subject: [PATCH] ACPI / property: Allow multiple property compatible _DSD
|
|
@@ -3427,9 +3427,9 @@ index 019468f072b7..2b2d92863923 100644
|
|
|
void **valptr);
|
|
|
int acpi_dev_prop_read_single(struct acpi_device *adev,
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 6fd470c78b119778c26d33b66d077768071deae8 Mon Sep 17 00:00:00 2001
|
|
|
+From 6bd89d871c667263d811129a6df4206e846ba405 Mon Sep 17 00:00:00 2001
|
|
|
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
Date: Thu, 27 Sep 2018 16:57:14 -0500
|
|
|
Subject: [PATCH] PCI / ACPI: Whitelist D3 for more PCIe hotplug ports
|
|
@@ -3592,9 +3592,9 @@ index e9ede82ee2c2..0a5efc437bd1 100644
|
|
|
int (*set_state)(struct pci_dev *dev, pci_power_t state);
|
|
|
pci_power_t (*get_state)(struct pci_dev *dev);
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 6a9cb4adc9b9977b96ebb3bfa24781227134f25e Mon Sep 17 00:00:00 2001
|
|
|
+From a67484471ab3dac5cd7722b95d0304d4d2f6597f Mon Sep 17 00:00:00 2001
|
|
|
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
Date: Mon, 7 Jan 2019 16:09:40 +0300
|
|
|
Subject: [PATCH] PCI: pciehp: Assign ctrl->slot_ctrl before writing it to
|
|
@@ -3646,9 +3646,9 @@ index 242b9f30210a..7074d4923811 100644
|
|
|
/*
|
|
|
* Controllers with the Intel CF118 and similar errata advertise
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 9930b5f74a80ab2726eb9bc9b5fb5867f6e11155 Mon Sep 17 00:00:00 2001
|
|
|
+From 035b9b44d38de57cd4274538bb83f97e88be9d40 Mon Sep 17 00:00:00 2001
|
|
|
From: Mika Westerberg <mika.westerberg@linux.intel.com>
|
|
|
Date: Thu, 31 Jan 2019 20:07:46 +0300
|
|
|
Subject: [PATCH] PCI: pciehp: Disable Data Link Layer State Changed event on
|
|
@@ -3735,9 +3735,9 @@ index 7074d4923811..a37ff79a6e9e 100644
|
|
|
|
|
|
/*
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 41a48a80db0ef8735680192fffb47ceee80990a1 Mon Sep 17 00:00:00 2001
|
|
|
+From 71c780397f5df6089e59337a6b8c5349553d0080 Mon Sep 17 00:00:00 2001
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
Date: Thu, 29 Oct 2020 22:04:38 +0100
|
|
|
Subject: [PATCH] PCI: Allow D3cold for hot-plug ports on Surface Books
|
|
@@ -3820,9 +3820,9 @@ index c5fd51d7f153..737d3a34e623 100644
|
|
|
if (dmi_check_system(bridge_d3_blacklist))
|
|
|
return false;
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 1e986e86d95c2363e37159d761aaa174dedd4762 Mon Sep 17 00:00:00 2001
|
|
|
+From 75a7bb2d62538131ec7ec7a672ed5d9b2c0f0842 Mon Sep 17 00:00:00 2001
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
Date: Mon, 9 Nov 2020 14:23:00 +0100
|
|
|
Subject: [PATCH] PCI: Run platform power transition on initial D0 entry
|
|
@@ -3882,9 +3882,9 @@ index 737d3a34e623..f72651684719 100644
|
|
|
bridge = pci_upstream_bridge(dev);
|
|
|
if (bridge)
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 721822b3add605c0c14ccfdad7610cbc8001e6e7 Mon Sep 17 00:00:00 2001
|
|
|
+From 05f32f984be2b20defcdde87e6767a1ebff578fc Mon Sep 17 00:00:00 2001
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
Date: Sat, 31 Oct 2020 20:46:33 +0100
|
|
|
Subject: [PATCH] PCI: Add sysfs attribute for PCI device power state
|
|
@@ -3955,9 +3955,9 @@ index 1edf5a1836ea..ee1518650d55 100644
|
|
|
&dev_attr_vendor.attr,
|
|
|
&dev_attr_device.attr,
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|
|
|
-From 7d15e2ca136be1ee071b72a973ee0be15da1651d Mon Sep 17 00:00:00 2001
|
|
|
+From bc3339efb04e86fcce1eb8011842f1fadab1f118 Mon Sep 17 00:00:00 2001
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
Date: Mon, 14 Dec 2020 20:50:59 +0100
|
|
|
Subject: [PATCH] platform/x86: Add Surface Hotplug driver
|
|
@@ -3970,40 +3970,47 @@ appropriate signal to the PCIe hot-plug driver core.
|
|
|
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
Patchset: surface-hotplug
|
|
|
---
|
|
|
- drivers/platform/x86/Kconfig | 12 ++
|
|
|
+ drivers/platform/x86/Kconfig | 19 ++
|
|
|
drivers/platform/x86/Makefile | 1 +
|
|
|
- drivers/platform/x86/surface_hotplug.c | 267 +++++++++++++++++++++++++
|
|
|
- 3 files changed, 280 insertions(+)
|
|
|
+ drivers/platform/x86/surface_hotplug.c | 282 +++++++++++++++++++++++++
|
|
|
+ 3 files changed, 302 insertions(+)
|
|
|
create mode 100644 drivers/platform/x86/surface_hotplug.c
|
|
|
|
|
|
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
|
|
|
-index 52fdf87b21f2..4b8757bb0146 100644
|
|
|
+index 9aed8f6941cc..d48bf3b2fdfd 100644
|
|
|
--- a/drivers/platform/x86/Kconfig
|
|
|
+++ b/drivers/platform/x86/Kconfig
|
|
|
-@@ -708,6 +708,18 @@ config ACPI_WMI
|
|
|
+@@ -708,6 +708,25 @@ config ACPI_WMI
|
|
|
It is safe to enable this driver even if your DSDT doesn't define
|
|
|
any ACPI-WMI devices.
|
|
|
|
|
|
+config SURFACE_HOTPLUG
|
|
|
-+ tristate "Surface Hot-Plug System Driver"
|
|
|
-+ depends on ACPI
|
|
|
-+ default m
|
|
|
++ tristate "Surface Hot-Plug Driver"
|
|
|
++ depends on GPIOLIB
|
|
|
+ help
|
|
|
-+ Driver for the Surface discrete GPU (dGPU) hot-plug system.
|
|
|
++ Driver for out-of-band hot-plug event signaling on Microsoft Surface
|
|
|
++ devices with hot-pluggable PCIe cards.
|
|
|
+
|
|
|
-+ This driver provides support for out-of-band hot-plug event signaling
|
|
|
-+ on Surface Book 2 and 3 devices. This out-of-band signaling is
|
|
|
-+ required to notify the kernel of any hot-plug events when the dGPU is
|
|
|
-+ powered off, i.e. in D3cold.
|
|
|
++ This driver is used on Surface Book (2 and 3) devices with a
|
|
|
++ hot-pluggable discrete GPU (dGPU). When not in use, the dGPU on those
|
|
|
++ devices can enter D3cold, which prevents in-band (standard) PCIe
|
|
|
++ hot-plug signaling. Thus, without this driver, detaching the base
|
|
|
++ containing the dGPU will not correctly update the state of the
|
|
|
++ corresponding PCIe device if it is in D3cold. This driver adds support
|
|
|
++ for out-of-band hot-plug notifications, ensuring that the device state
|
|
|
++ is properly updated even when the device in question is in D3cold.
|
|
|
++
|
|
|
++ Select M or Y here, if you want to (fully) support hot-plugging of
|
|
|
++ dGPU devices on the Surface Book 2 and/or 3 during D3cold.
|
|
|
+
|
|
|
config WMI_BMOF
|
|
|
tristate "WMI embedded Binary MOF driver"
|
|
|
depends on ACPI_WMI
|
|
|
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
|
|
|
-index 6b028d1ee802..443b52da8060 100644
|
|
|
+index 2737a78616c8..d08f7e254d47 100644
|
|
|
--- a/drivers/platform/x86/Makefile
|
|
|
+++ b/drivers/platform/x86/Makefile
|
|
|
-@@ -83,6 +83,7 @@ obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o
|
|
|
+@@ -89,6 +89,7 @@ obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o
|
|
|
obj-$(CONFIG_SURFACE_3_BUTTON) += surface3_button.o
|
|
|
obj-$(CONFIG_SURFACE_3_POWER_OPREGION) += surface3_power.o
|
|
|
obj-$(CONFIG_SURFACE_GPE) += surface_gpe.o
|
|
@@ -4013,13 +4020,13 @@ index 6b028d1ee802..443b52da8060 100644
|
|
|
obj-$(CONFIG_INTEL_BXTWC_PMIC_TMU) += intel_bxtwc_tmu.o
|
|
|
diff --git a/drivers/platform/x86/surface_hotplug.c b/drivers/platform/x86/surface_hotplug.c
|
|
|
new file mode 100644
|
|
|
-index 000000000000..572fba30cd77
|
|
|
+index 000000000000..cfcc15cfbacb
|
|
|
--- /dev/null
|
|
|
+++ b/drivers/platform/x86/surface_hotplug.c
|
|
|
-@@ -0,0 +1,267 @@
|
|
|
+@@ -0,0 +1,282 @@
|
|
|
+// SPDX-License-Identifier: GPL-2.0+
|
|
|
+/*
|
|
|
-+ * Surface Book (gen. 2 and later) hot-plug driver.
|
|
|
++ * Surface Book (2 and later) hot-plug driver.
|
|
|
+ *
|
|
|
+ * Surface Book devices (can) have a hot-pluggable discrete GPU (dGPU). This
|
|
|
+ * driver is responsible for out-of-band hot-plug event signaling on these
|
|
@@ -4029,7 +4036,7 @@ index 000000000000..572fba30cd77
|
|
|
+ * Event signaling is handled via ACPI, which will generate the appropriate
|
|
|
+ * device-check notifications to be picked up by the PCIe hot-plug driver.
|
|
|
+ *
|
|
|
-+ * Copyright (C) 2019-2020 Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
++ * Copyright (C) 2019-2021 Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
+ */
|
|
|
+
|
|
|
+#include <linux/acpi.h>
|
|
@@ -4059,8 +4066,7 @@ index 000000000000..572fba30cd77
|
|
|
+
|
|
|
+/* 5515a847-ed55-4b27-8352-cd320e10360a */
|
|
|
+static const guid_t shps_dsm_guid =
|
|
|
-+ GUID_INIT(0x5515a847, 0xed55, 0x4b27, 0x83, 0x52, 0xcd,
|
|
|
-+ 0x32, 0x0e, 0x10, 0x36, 0x0a);
|
|
|
++ GUID_INIT(0x5515a847, 0xed55, 0x4b27, 0x83, 0x52, 0xcd, 0x32, 0x0e, 0x10, 0x36, 0x0a);
|
|
|
+
|
|
|
+#define SHPS_DSM_REVISION 1
|
|
|
+
|
|
@@ -4073,11 +4079,10 @@ index 000000000000..572fba30cd77
|
|
|
+};
|
|
|
+
|
|
|
+enum shps_irq_type {
|
|
|
-+ /* NOTE: Must be in order of DSM function */
|
|
|
++ /* NOTE: Must be in order of enum shps_dsm_fn above. */
|
|
|
+ SHPS_IRQ_TYPE_BASE_PRESENCE = 0,
|
|
|
+ SHPS_IRQ_TYPE_DEVICE_POWER = 1,
|
|
|
+ SHPS_IRQ_TYPE_DEVICE_PRESENCE = 2,
|
|
|
-+
|
|
|
+ SHPS_NUM_IRQS,
|
|
|
+};
|
|
|
+
|
|
@@ -4088,15 +4093,19 @@ index 000000000000..572fba30cd77
|
|
|
+};
|
|
|
+
|
|
|
+struct shps_device {
|
|
|
-+ struct mutex lock[SHPS_NUM_IRQS];
|
|
|
++ struct mutex lock[SHPS_NUM_IRQS]; /* Protects update in shps_dsm_notify_irq() */
|
|
|
+ struct gpio_desc *gpio[SHPS_NUM_IRQS];
|
|
|
+ unsigned int irq[SHPS_NUM_IRQS];
|
|
|
+};
|
|
|
+
|
|
|
+#define SHPS_IRQ_NOT_PRESENT ((unsigned int)-1)
|
|
|
+
|
|
|
-+static void shps_dsm_notify_irq(struct platform_device *pdev,
|
|
|
-+ enum shps_irq_type type)
|
|
|
++static enum shps_dsm_fn shps_dsm_fn_for_irq(enum shps_irq_type type)
|
|
|
++{
|
|
|
++ return SHPS_DSM_FN_IRQ_BASE_PRESENCE + type;
|
|
|
++}
|
|
|
++
|
|
|
++static void shps_dsm_notify_irq(struct platform_device *pdev, enum shps_irq_type type)
|
|
|
+{
|
|
|
+ struct shps_device *sdev = platform_get_drvdata(pdev);
|
|
|
+ acpi_handle handle = ACPI_HANDLE(&pdev->dev);
|
|
@@ -4109,42 +4118,37 @@ index 000000000000..572fba30cd77
|
|
|
+ value = gpiod_get_value_cansleep(sdev->gpio[type]);
|
|
|
+ if (value < 0) {
|
|
|
+ mutex_unlock(&sdev->lock[type]);
|
|
|
-+ dev_err(&pdev->dev, "failed to get gpio: %d (irq=%d)\n",
|
|
|
-+ type, value);
|
|
|
++ dev_err(&pdev->dev, "failed to get gpio: %d (irq=%d)\n", type, value);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
-+ dev_dbg(&pdev->dev, "IRQ notification via DSM (irq=%d, value=%d)\n",
|
|
|
-+ type, value);
|
|
|
++ dev_dbg(&pdev->dev, "IRQ notification via DSM (irq=%d, value=%d)\n", type, value);
|
|
|
+
|
|
|
+ param.type = ACPI_TYPE_INTEGER;
|
|
|
+ param.integer.value = value;
|
|
|
+
|
|
|
+ result = acpi_evaluate_dsm(handle, &shps_dsm_guid, SHPS_DSM_REVISION,
|
|
|
-+ SHPS_DSM_FN_IRQ_BASE_PRESENCE + type, ¶m);
|
|
|
++ shps_dsm_fn_for_irq(type), ¶m);
|
|
|
+
|
|
|
+ if (!result) {
|
|
|
-+ mutex_unlock(&sdev->lock[type]);
|
|
|
-+ dev_err(&pdev->dev,
|
|
|
-+ "IRQ notification via DSM failed (irq=%d, gpio=%d)\n",
|
|
|
++ dev_err(&pdev->dev, "IRQ notification via DSM failed (irq=%d, gpio=%d)\n",
|
|
|
+ type, value);
|
|
|
-+ return;
|
|
|
-+ }
|
|
|
+
|
|
|
-+ if (result->type != ACPI_TYPE_BUFFER) {
|
|
|
++ } else if (result->type != ACPI_TYPE_BUFFER) {
|
|
|
+ dev_err(&pdev->dev,
|
|
|
+ "IRQ notification via DSM failed: unexpected result type (irq=%d, gpio=%d)\n",
|
|
|
+ type, value);
|
|
|
-+ }
|
|
|
+
|
|
|
-+ if (result->buffer.length != 1 || result->buffer.pointer[0] != 0) {
|
|
|
++ } else if (result->buffer.length != 1 || result->buffer.pointer[0] != 0) {
|
|
|
+ dev_err(&pdev->dev,
|
|
|
+ "IRQ notification via DSM failed: unexpected result value (irq=%d, gpio=%d)\n",
|
|
|
+ type, value);
|
|
|
+ }
|
|
|
+
|
|
|
+ mutex_unlock(&sdev->lock[type]);
|
|
|
-+ ACPI_FREE(result);
|
|
|
++
|
|
|
++ if (result)
|
|
|
++ ACPI_FREE(result);
|
|
|
+}
|
|
|
+
|
|
|
+static irqreturn_t shps_handle_irq(int irq, void *data)
|
|
@@ -4174,17 +4178,16 @@ index 000000000000..572fba30cd77
|
|
|
+ struct gpio_desc *gpiod;
|
|
|
+ acpi_handle handle = ACPI_HANDLE(&pdev->dev);
|
|
|
+ const char *irq_name;
|
|
|
-+ const int dsm = SHPS_DSM_FN_IRQ_BASE_PRESENCE + type;
|
|
|
++ const int dsm = shps_dsm_fn_for_irq(type);
|
|
|
+ int status, irq;
|
|
|
+
|
|
|
-+ /* Initialize as "not present". */
|
|
|
-+ sdev->gpio[type] = NULL;
|
|
|
-+ sdev->irq[type] = SHPS_IRQ_NOT_PRESENT;
|
|
|
-+
|
|
|
-+ /* Only set up interrupts that we actually need. */
|
|
|
++ /*
|
|
|
++ * Only set up interrupts that we actually need: The Surface Book 3
|
|
|
++ * does not have a DSM for base presence, so don't set up an interrupt
|
|
|
++ * for that.
|
|
|
++ */
|
|
|
+ if (!acpi_check_dsm(handle, &shps_dsm_guid, SHPS_DSM_REVISION, BIT(dsm))) {
|
|
|
-+ dev_dbg(&pdev->dev, "IRQ notification via DSM not present (irq=%d)\n",
|
|
|
-+ type);
|
|
|
++ dev_dbg(&pdev->dev, "IRQ notification via DSM not present (irq=%d)\n", type);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
@@ -4213,11 +4216,33 @@ index 000000000000..572fba30cd77
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
++static int surface_hotplug_remove(struct platform_device *pdev)
|
|
|
++{
|
|
|
++ struct shps_device *sdev = platform_get_drvdata(pdev);
|
|
|
++ int i;
|
|
|
++
|
|
|
++ /* Ensure that IRQs have been fully handled and won't trigger any more. */
|
|
|
++ for (i = 0; i < SHPS_NUM_IRQS; i++) {
|
|
|
++ if (sdev->irq[i] != SHPS_IRQ_NOT_PRESENT)
|
|
|
++ disable_irq(sdev->irq[i]);
|
|
|
++
|
|
|
++ mutex_destroy(&sdev->lock[i]);
|
|
|
++ }
|
|
|
++
|
|
|
++ return 0;
|
|
|
++}
|
|
|
++
|
|
|
+static int surface_hotplug_probe(struct platform_device *pdev)
|
|
|
+{
|
|
|
+ struct shps_device *sdev;
|
|
|
+ int status, i;
|
|
|
+
|
|
|
++ /*
|
|
|
++ * The MSHW0153 device is also present on the Surface Laptop 3,
|
|
|
++ * however that doesn't have a hot-pluggable PCIe device. It also
|
|
|
++ * doesn't have any GPIO interrupts/pins under the MSHW0153, so filter
|
|
|
++ * it out here.
|
|
|
++ */
|
|
|
+ if (gpiod_count(&pdev->dev, NULL) < 0)
|
|
|
+ return -ENODEV;
|
|
|
+
|
|
@@ -4231,15 +4256,21 @@ index 000000000000..572fba30cd77
|
|
|
+
|
|
|
+ platform_set_drvdata(pdev, sdev);
|
|
|
+
|
|
|
++ /*
|
|
|
++ * Initialize IRQs so that we can safely call surface_hotplug_remove()
|
|
|
++ * on errors.
|
|
|
++ */
|
|
|
++ for (i = 0; i < SHPS_NUM_IRQS; i++)
|
|
|
++ sdev->irq[i] = SHPS_IRQ_NOT_PRESENT;
|
|
|
++
|
|
|
+ /* Set up IRQs. */
|
|
|
+ for (i = 0; i < SHPS_NUM_IRQS; i++) {
|
|
|
+ mutex_init(&sdev->lock[i]);
|
|
|
+
|
|
|
+ status = shps_setup_irq(pdev, i);
|
|
|
+ if (status) {
|
|
|
-+ dev_err(&pdev->dev, "failed to set up IRQ %d: %d\n",
|
|
|
-+ i, status);
|
|
|
-+ return status;
|
|
|
++ dev_err(&pdev->dev, "failed to set up IRQ %d: %d\n", i, status);
|
|
|
++ goto err;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
@@ -4249,19 +4280,10 @@ index 000000000000..572fba30cd77
|
|
|
+ shps_dsm_notify_irq(pdev, i);
|
|
|
+
|
|
|
+ return 0;
|
|
|
-+}
|
|
|
-+
|
|
|
-+static int surface_hotplug_remove(struct platform_device *pdev)
|
|
|
-+{
|
|
|
-+ struct shps_device *sdev = platform_get_drvdata(pdev);
|
|
|
-+ int i;
|
|
|
+
|
|
|
-+ /* Ensure that IRQs have been fully handled and won't trigger any more. */
|
|
|
-+ for (i = 0; i < SHPS_NUM_IRQS; i++)
|
|
|
-+ if (sdev->irq[i] != SHPS_IRQ_NOT_PRESENT)
|
|
|
-+ disable_irq(sdev->irq[i]);
|
|
|
-+
|
|
|
-+ return 0;
|
|
|
++err:
|
|
|
++ surface_hotplug_remove(pdev);
|
|
|
++ return status;
|
|
|
+}
|
|
|
+
|
|
|
+static const struct acpi_device_id surface_hotplug_acpi_match[] = {
|
|
@@ -4285,5 +4307,5 @@ index 000000000000..572fba30cd77
|
|
|
+MODULE_DESCRIPTION("Surface Hot-Plug Signaling Driver for Surface Book Devices");
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
--
|
|
|
-2.30.0
|
|
|
+2.30.1
|
|
|
|