|
| 1 | +From f92f8ec52735c40c41e2b6ba22e38d412e3cff43 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Tsuchiya Yuto < [email protected]> |
| 3 | +Date: Sun, 18 Oct 2020 16:42:44 +0900 |
| 4 | +Subject: [PATCH] (surface3-oemb) add DMI matches for Surface 3 with broken DMI |
| 5 | + table |
| 6 | + |
| 7 | +On some Surface 3, the DMI table gets corrupted for unknown reasons |
| 8 | +and breaks existing DMI matching used for device-specific quirks. |
| 9 | + |
| 10 | +This commit adds the (broken) DMI data into dmi_system_id tables used |
| 11 | +for quirks so that each driver can enable quirks even on the affected |
| 12 | +systems. |
| 13 | + |
| 14 | +On affected systems, DMI data will look like this: |
| 15 | + $ grep . /sys/devices/virtual/dmi/id/{bios_vendor,board_name,board_vendor,\ |
| 16 | + chassis_vendor,product_name,sys_vendor} |
| 17 | + /sys/devices/virtual/dmi/id/bios_vendor:American Megatrends Inc. |
| 18 | + /sys/devices/virtual/dmi/id/board_name:OEMB |
| 19 | + /sys/devices/virtual/dmi/id/board_vendor:OEMB |
| 20 | + /sys/devices/virtual/dmi/id/chassis_vendor:OEMB |
| 21 | + /sys/devices/virtual/dmi/id/product_name:OEMB |
| 22 | + /sys/devices/virtual/dmi/id/sys_vendor:OEMB |
| 23 | + |
| 24 | +Expected: |
| 25 | + $ grep . /sys/devices/virtual/dmi/id/{bios_vendor,board_name,board_vendor,\ |
| 26 | + chassis_vendor,product_name,sys_vendor} |
| 27 | + /sys/devices/virtual/dmi/id/bios_vendor:American Megatrends Inc. |
| 28 | + /sys/devices/virtual/dmi/id/board_name:Surface 3 |
| 29 | + /sys/devices/virtual/dmi/id/board_vendor:Microsoft Corporation |
| 30 | + /sys/devices/virtual/dmi/id/chassis_vendor:Microsoft Corporation |
| 31 | + /sys/devices/virtual/dmi/id/product_name:Surface 3 |
| 32 | + /sys/devices/virtual/dmi/id/sys_vendor:Microsoft Corporation |
| 33 | + |
| 34 | +Signed-off-by: Tsuchiya Yuto < [email protected]> |
| 35 | +Patchset: surface3 |
| 36 | +--- |
| 37 | + drivers/platform/surface/surface3-wmi.c | 7 +++++++ |
| 38 | + sound/soc/codecs/rt5645.c | 9 +++++++++ |
| 39 | + sound/soc/intel/common/soc-acpi-intel-cht-match.c | 8 ++++++++ |
| 40 | + 3 files changed, 24 insertions(+) |
| 41 | + |
| 42 | +diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/surface/surface3-wmi.c |
| 43 | +index 6c8fb7a4dde4..22797a53f4d8 100644 |
| 44 | +--- a/drivers/platform/surface/surface3-wmi.c |
| 45 | ++++ b/drivers/platform/surface/surface3-wmi.c |
| 46 | +@@ -37,6 +37,13 @@ static const struct dmi_system_id surface3_dmi_table[] = { |
| 47 | + DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"), |
| 48 | + }, |
| 49 | + }, |
| 50 | ++ { |
| 51 | ++ .matches = { |
| 52 | ++ DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."), |
| 53 | ++ DMI_MATCH(DMI_SYS_VENDOR, "OEMB"), |
| 54 | ++ DMI_MATCH(DMI_PRODUCT_NAME, "OEMB"), |
| 55 | ++ }, |
| 56 | ++ }, |
| 57 | + #endif |
| 58 | + { } |
| 59 | + }; |
| 60 | +diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c |
| 61 | +index f7701b8d0d3c..0708c2fe8f61 100644 |
| 62 | +--- a/sound/soc/codecs/rt5645.c |
| 63 | ++++ b/sound/soc/codecs/rt5645.c |
| 64 | +@@ -3793,6 +3793,15 @@ static const struct dmi_system_id dmi_platform_data[] = { |
| 65 | + }, |
| 66 | + .driver_data = (void *)&intel_braswell_platform_data, |
| 67 | + }, |
| 68 | ++ { |
| 69 | ++ .ident = "Microsoft Surface 3", |
| 70 | ++ .matches = { |
| 71 | ++ DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."), |
| 72 | ++ DMI_MATCH(DMI_SYS_VENDOR, "OEMB"), |
| 73 | ++ DMI_MATCH(DMI_PRODUCT_NAME, "OEMB"), |
| 74 | ++ }, |
| 75 | ++ .driver_data = (void *)&intel_braswell_platform_data, |
| 76 | ++ }, |
| 77 | + { |
| 78 | + /* |
| 79 | + * Match for the GPDwin which unfortunately uses somewhat |
| 80 | +diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c |
| 81 | +index e4c3492a0c28..0b930c91bccb 100644 |
| 82 | +--- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c |
| 83 | ++++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c |
| 84 | +@@ -27,6 +27,14 @@ static const struct dmi_system_id cht_table[] = { |
| 85 | + DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"), |
| 86 | + }, |
| 87 | + }, |
| 88 | ++ { |
| 89 | ++ .callback = cht_surface_quirk_cb, |
| 90 | ++ .matches = { |
| 91 | ++ DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."), |
| 92 | ++ DMI_MATCH(DMI_SYS_VENDOR, "OEMB"), |
| 93 | ++ DMI_MATCH(DMI_PRODUCT_NAME, "OEMB"), |
| 94 | ++ }, |
| 95 | ++ }, |
| 96 | + { } |
| 97 | + }; |
| 98 | + |
| 99 | +-- |
| 100 | +2.54.0 |
| 101 | + |
| 102 | +From d4fd452b9de4b6826ceaec28d6179cafe313285f Mon Sep 17 00:00:00 2001 |
| 103 | +From: kitakar5525 < [email protected]> |
| 104 | +Date: Fri, 6 Dec 2019 23:10:30 +0900 |
| 105 | +Subject: [PATCH] surface3-spi: workaround: disable DMA mode to avoid crash by |
| 106 | + default |
| 107 | + |
| 108 | +On Arch Linux kernel at least after 4.19, touch input is broken after suspend |
| 109 | +(s2idle). |
| 110 | + |
| 111 | + kern :err : [ +0.203408] Surface3-spi spi-MSHW0037:00: SPI transfer timed out |
| 112 | + |
| 113 | +On recent stable Arch Linux kernel (at least after 5.1), touch input will |
| 114 | +crash after the first touch. |
| 115 | + |
| 116 | + kern :err : [ +0.203592] Surface3-spi spi-MSHW0037:00: SPI transfer timed out |
| 117 | + kern :err : [ +0.000173] spi_master spi1: failed to transfer one message from queue |
| 118 | + |
| 119 | +I found on an affected system (Arch Linux kernel, etc.), the touchscreen |
| 120 | +driver uses DMA mode by default. Then, we found some kernels with different |
| 121 | +kernel config (5.1 kernel config from Jakeday [1] or Chromium OS kernel |
| 122 | +chromeos-4.19 [2]) will use PIO mode by default and no such issues there. |
| 123 | + |
| 124 | +So, this commit disables DMA mode on the touchscreen driver side as a quick |
| 125 | +workaround to avoid touch input crash. |
| 126 | +We may need to properly set up DMA mode to use the touchscreen driver with |
| 127 | +DMA mode. |
| 128 | + |
| 129 | +You can still switch DMA/PIO mode if you want: |
| 130 | + |
| 131 | + switch to DMA mode (maybe broken) |
| 132 | + echo 1 | sudo tee /sys/module/surface3_spi/parameters/use_dma |
| 133 | + back to PIO mode |
| 134 | + echo 0 | sudo tee /sys/module/surface3_spi/parameters/use_dma |
| 135 | + |
| 136 | +Link to issue: https://github.com/jakeday/linux-surface/issues/596 |
| 137 | + |
| 138 | +References: |
| 139 | +[1] https://github.com/jakeday/linux-surface/blob/master/configs/5.1/config |
| 140 | +[2] https://chromium.googlesource.com/chromiumos/third_party/kernel/+/refs/heads/chromeos-4.19 |
| 141 | + |
| 142 | +Tested on Arch Linux 5.4.1 with Surface 3, which will use DMA by default. |
| 143 | +This commit made the driver use PIO by default and no touch input crash. |
| 144 | +Also tested on chromeos-4.19 4.19.90 with Surface 3, which will use PIO by default |
| 145 | +even without this commit. After this commit, it still uses PIO and confirmed |
| 146 | +no functional changes regarding touch input. |
| 147 | + |
| 148 | +More details: |
| 149 | + We can confirm which mode the touchscreen driver uses; first, enable |
| 150 | + debug output: |
| 151 | + |
| 152 | + echo "file drivers/spi/spi-pxa2xx.c +p" | sudo tee /sys/kernel/debug/dynamic_debug/control |
| 153 | + echo "file drivers/input/touchscreen/surface3_spi.c +p" | sudo tee /sys/kernel/debug/dynamic_debug/control |
| 154 | + |
| 155 | + Then, try to make a touch input and see dmesg log |
| 156 | + |
| 157 | + (On Arch Linux kernel, uses DMA) |
| 158 | + kern :debug : [ +0.006383] Surface3-spi spi-MSHW0037:00: 7692307 Hz actual, DMA |
| 159 | + kern :debug : [ +0.000495] Surface3-spi spi-MSHW0037:00: surface3_spi_irq_handler received |
| 160 | + -> ff ff ff ff a5 5a e7 7e 01 d2 00 80 01 03 03 18 00 e4 01 00 04 1a 04 1a e3 0c e3 0c b0 00 |
| 161 | + c5 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |
| 162 | + |
| 163 | + (On the kernels I referenced above, uses PIO) |
| 164 | + kern :debug : [ +0.009260] Surface3-spi spi-MSHW0037:00: 7692307 Hz actual, PIO |
| 165 | + kern :debug : [ +0.001105] Surface3-spi spi-MSHW0037:00: surface3_spi_irq_handler received |
| 166 | + -> ff ff ff ff a5 5a e7 7e 01 d2 00 80 01 03 03 24 00 e4 01 00 58 0b 58 0b 83 12 83 12 26 01 |
| 167 | + 95 01 00 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |
| 168 | + |
| 169 | +Note (2025-03-08): This patch was originally dropped due to the |
| 170 | +comments in [3]. However, according to the commments in [4] it is still |
| 171 | +required. |
| 172 | + |
| 173 | +[3]: https://github.com/linux-surface/kernel/commit/a3421c12bed0e46c28518bcb8c6b22f237c6dc7a |
| 174 | +[4]: https://github.com/linux-surface/linux-surface/issues/1184 |
| 175 | + |
| 176 | +Patchset: surface3 |
| 177 | +--- |
| 178 | + drivers/input/touchscreen/surface3_spi.c | 26 ++++++++++++++++++++++++ |
| 179 | + 1 file changed, 26 insertions(+) |
| 180 | + |
| 181 | +diff --git a/drivers/input/touchscreen/surface3_spi.c b/drivers/input/touchscreen/surface3_spi.c |
| 182 | +index 6074b7730e86..6aa3e1d6f160 100644 |
| 183 | +--- a/drivers/input/touchscreen/surface3_spi.c |
| 184 | ++++ b/drivers/input/touchscreen/surface3_spi.c |
| 185 | +@@ -25,6 +25,12 @@ |
| 186 | + #define SURFACE3_REPORT_TOUCH 0xd2 |
| 187 | + #define SURFACE3_REPORT_PEN 0x16 |
| 188 | + |
| 189 | ++bool use_dma = false; |
| 190 | ++module_param(use_dma, bool, 0644); |
| 191 | ++MODULE_PARM_DESC(use_dma, |
| 192 | ++ "Disable DMA mode if you encounter touch input crash. " |
| 193 | ++ "(default: false, disabled to avoid crash)"); |
| 194 | ++ |
| 195 | + struct surface3_ts_data { |
| 196 | + struct spi_device *spi; |
| 197 | + struct gpio_desc *gpiod_rst[2]; |
| 198 | +@@ -317,6 +323,13 @@ static int surface3_spi_create_pen_input(struct surface3_ts_data *data) |
| 199 | + return 0; |
| 200 | + } |
| 201 | + |
| 202 | ++static bool surface3_spi_can_dma(struct spi_controller *ctlr, |
| 203 | ++ struct spi_device *spi, |
| 204 | ++ struct spi_transfer *tfr) |
| 205 | ++{ |
| 206 | ++ return use_dma; |
| 207 | ++} |
| 208 | ++ |
| 209 | + static int surface3_spi_probe(struct spi_device *spi) |
| 210 | + { |
| 211 | + struct surface3_ts_data *data; |
| 212 | +@@ -359,6 +372,19 @@ static int surface3_spi_probe(struct spi_device *spi) |
| 213 | + if (error) |
| 214 | + return error; |
| 215 | + |
| 216 | ++ /* |
| 217 | ++ * Set up DMA |
| 218 | ++ * |
| 219 | ++ * TODO: Currently, touch input with DMA seems to be broken. |
| 220 | ++ * On 4.19 LTS, touch input will crash after suspend. |
| 221 | ++ * On recent stable kernel (at least after 5.1), touch input will crash after |
| 222 | ++ * the first touch. No problem with PIO on those kernels. |
| 223 | ++ * Maybe we need to configure DMA here. |
| 224 | ++ * |
| 225 | ++ * Link to issue: https://github.com/jakeday/linux-surface/issues/596 |
| 226 | ++ */ |
| 227 | ++ spi->controller->can_dma = surface3_spi_can_dma; |
| 228 | ++ |
| 229 | + return 0; |
| 230 | + } |
| 231 | + |
| 232 | +-- |
| 233 | +2.54.0 |
| 234 | + |
0 commit comments