--- /dev/null
+From 8bf952490dbbee7359cfe1a841cd5a8f7736739a Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 2 Dec 2020 14:39:42 +0800
+Subject: ACPI: video: Add DMI quirk for GIGABYTE GB-BXBT-2807
+
+From: Jasper St. Pierre <jstpierre@mecheye.net>
+
+[ Upstream commit 25417185e9b5ff90746d50769d2a3fcd1629e254 ]
+
+The GIGABYTE GB-BXBT-2807 is a mini-PC which uses off the shelf
+components, like an Intel GPU which is meant for mobile systems.
+As such, it, by default, has a backlight controller exposed.
+
+Unfortunately, the backlight controller only confuses userspace, which
+sees the existence of a backlight device node and has the unrealistic
+belief that there is actually a backlight there!
+
+Add a DMI quirk to force the backlight off on this system.
+
+Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
+Reviewed-by: Chris Chiu <chiu@endlessos.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/acpi/video_detect.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c
+index 55af78b55c51..301ffe5b8feb 100644
+--- a/drivers/acpi/video_detect.c
++++ b/drivers/acpi/video_detect.c
+@@ -143,6 +143,13 @@ static const struct dmi_system_id video_detect_dmi_table[] = {
+ },
+ {
+ .callback = video_detect_force_vendor,
++ .ident = "GIGABYTE GB-BXBT-2807",
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
++ DMI_MATCH(DMI_PRODUCT_NAME, "GB-BXBT-2807"),
++ },
++ },
++ {
+ .ident = "Sony VPCEH3U1E",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
+--
+2.30.1
+
--- /dev/null
+From 284f65fe1b22cb2bfd90e4a2e5fc274e79e35539 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 8 Dec 2020 14:04:14 +0800
+Subject: ASoC: Intel: bytcr_rt5640: Add quirk for ARCHOS Cesium 140
+
+From: Chris Chiu <chiu@endlessos.org>
+
+[ Upstream commit 1bea2256aa96a2d7b1b576eb74e29d79edc9bea8 ]
+
+Tha ARCHOS Cesium 140 tablet has problem with the jack-sensing,
+thus the heaset functions are not working.
+
+Add quirk for this model to select the correct input map, jack-detect
+options and channel map to enable jack sensing and headset microphone.
+This device uses IN1 for its internal MIC and JD2 for jack-detect.
+
+Signed-off-by: Chris Chiu <chiu@endlessos.org>
+Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Link: https://lore.kernel.org/r/20201208060414.27646-1-chiu@endlessos.org
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ sound/soc/intel/boards/bytcr_rt5640.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
+index 9ee610504bac..cfd307717473 100644
+--- a/sound/soc/intel/boards/bytcr_rt5640.c
++++ b/sound/soc/intel/boards/bytcr_rt5640.c
+@@ -435,6 +435,18 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
+ BYT_RT5640_SSP0_AIF1 |
+ BYT_RT5640_MCLK_EN),
+ },
++ {
++ .matches = {
++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"),
++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 140 CESIUM"),
++ },
++ .driver_data = (void *)(BYT_RT5640_IN1_MAP |
++ BYT_RT5640_JD_SRC_JD2_IN4N |
++ BYT_RT5640_OVCD_TH_2000UA |
++ BYT_RT5640_OVCD_SF_0P75 |
++ BYT_RT5640_SSP0_AIF1 |
++ BYT_RT5640_MCLK_EN),
++ },
+ {
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+--
+2.30.1
+
--- /dev/null
+From 42147ab5b27fc68167e476fb064b7998d691d404 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 13 Jan 2021 19:33:33 +0100
+Subject: drm/msm/a5xx: Remove overwriting A5XX_PC_DBG_ECO_CNTL register
+
+From: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
+
+[ Upstream commit 8f03c30cb814213e36032084a01f49a9e604a3e3 ]
+
+The PC_DBG_ECO_CNTL register on the Adreno A5xx family gets
+programmed to some different values on a per-model basis.
+At least, this is what we intend to do here;
+
+Unfortunately, though, this register is being overwritten with a
+static magic number, right after applying the GPU-specific
+configuration (including the GPU-specific quirks) and that is
+effectively nullifying the efforts.
+
+Let's remove the redundant and wrong write to the PC_DBG_ECO_CNTL
+register in order to retain the wanted configuration for the
+target GPU.
+
+Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@somainline.org>
+Reviewed-by: Jordan Crouse <jcrouse@codeaurora.org>
+Signed-off-by: Rob Clark <robdclark@chromium.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+index c8fb21cc0d6f..f84049119f1c 100644
+--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
++++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+@@ -581,8 +581,6 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
+ if (adreno_gpu->info->quirks & ADRENO_QUIRK_TWO_PASS_USE_WFI)
+ gpu_rmw(gpu, REG_A5XX_PC_DBG_ECO_CNTL, 0, (1 << 8));
+
+- gpu_write(gpu, REG_A5XX_PC_DBG_ECO_CNTL, 0xc0200100);
+-
+ /* Enable USE_RETENTION_FLOPS */
+ gpu_write(gpu, REG_A5XX_CP_CHICKEN_DBG, 0x02000000);
+
+--
+2.30.1
+
--- /dev/null
+From 53dc0cb9c9d93db94d46a2e1eb9d5d57e62ea574 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sat, 30 Jan 2021 21:33:23 +0100
+Subject: HID: i2c-hid: Add I2C_HID_QUIRK_NO_IRQ_AFTER_RESET for ITE8568 EC on
+ Voyo Winpad A15
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit fc6a31b00739356809dd566e16f2c4325a63285d ]
+
+The ITE8568 EC on the Voyo Winpad A15 presents itself as an I2C-HID
+attached keyboard and mouse (which seems to never send any events).
+
+This needs the I2C_HID_QUIRK_NO_IRQ_AFTER_RESET quirk, otherwise we get
+the following errors:
+
+[ 3688.770850] i2c_hid i2c-ITE8568:00: failed to reset device.
+[ 3694.915865] i2c_hid i2c-ITE8568:00: failed to reset device.
+[ 3701.059717] i2c_hid i2c-ITE8568:00: failed to reset device.
+[ 3707.205944] i2c_hid i2c-ITE8568:00: failed to reset device.
+[ 3708.227940] i2c_hid i2c-ITE8568:00: can't add hid device: -61
+[ 3708.236518] i2c_hid: probe of i2c-ITE8568:00 failed with error -61
+
+Which leads to a significant boot delay.
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hid/hid-ids.h | 2 ++
+ drivers/hid/i2c-hid/i2c-hid-core.c | 2 ++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
+index fc499c9039a0..d004f5645b30 100644
+--- a/drivers/hid/hid-ids.h
++++ b/drivers/hid/hid-ids.h
+@@ -641,6 +641,8 @@
+ #define USB_DEVICE_ID_INNEX_GENESIS_ATARI 0x4745
+
+ #define USB_VENDOR_ID_ITE 0x048d
++#define I2C_VENDOR_ID_ITE 0x103c
++#define I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15 0x184f
+ #define USB_DEVICE_ID_ITE_LENOVO_YOGA 0x8386
+ #define USB_DEVICE_ID_ITE_LENOVO_YOGA2 0x8350
+ #define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720 0x837a
+diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
+index 592176aff027..96898983db99 100644
+--- a/drivers/hid/i2c-hid/i2c-hid-core.c
++++ b/drivers/hid/i2c-hid/i2c-hid-core.c
+@@ -173,6 +173,8 @@ static const struct i2c_hid_quirks {
+ I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV },
+ { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288,
+ I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
++ { I2C_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15,
++ I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
+ { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_3118,
+ I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
+ { USB_VENDOR_ID_ELAN, HID_ANY_ID,
+--
+2.30.1
+
--- /dev/null
+From afd27ab7786593c7e0a7c929adc540ffc36e2cce Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 17 Nov 2020 09:48:00 +0100
+Subject: HID: mf: add support for 0079:1846 Mayflash/Dragonrise USB Gamecube
+ Adapter
+
+From: Ethan Warth <redyoshi49q@gmail.com>
+
+[ Upstream commit 1008230f2abeb624f6d71b2e1c424fa4eeebbf84 ]
+
+Mayflash/Dragonrise seems to have yet another device ID for one of their
+Gamecube controller adapters. Previous to this commit, the adapter
+registered only one /dev/input/js* device, and all controller inputs (from
+any controller) were mapped to this device. This patch defines the 1846
+USB device ID and enables the HID_QUIRK_MULTI_INPUT quirk for it, which
+fixes that (with the patch, four /dev/input/js* devices are created, one
+for each of the four controller ports).
+
+Signed-off-by: Ethan Warth <redyoshi49q@gmail.com>
+Tested-by: Wladimir J. van der Laan <laanwj@gmail.com>
+Signed-off-by: Jiri Kosina <jkosina@suse.cz>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/hid/hid-ids.h | 1 +
+ drivers/hid/hid-mf.c | 2 ++
+ drivers/hid/hid-quirks.c | 2 ++
+ 3 files changed, 5 insertions(+)
+
+diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
+index 33183933337a..fc499c9039a0 100644
+--- a/drivers/hid/hid-ids.h
++++ b/drivers/hid/hid-ids.h
+@@ -365,6 +365,7 @@
+ #define USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR 0x1803
+ #define USB_DEVICE_ID_DRAGONRISE_GAMECUBE1 0x1843
+ #define USB_DEVICE_ID_DRAGONRISE_GAMECUBE2 0x1844
++#define USB_DEVICE_ID_DRAGONRISE_GAMECUBE3 0x1846
+
+ #define USB_VENDOR_ID_DWAV 0x0eef
+ #define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER 0x0001
+diff --git a/drivers/hid/hid-mf.c b/drivers/hid/hid-mf.c
+index fc75f30f537c..92d7ecd41a78 100644
+--- a/drivers/hid/hid-mf.c
++++ b/drivers/hid/hid-mf.c
+@@ -153,6 +153,8 @@ static const struct hid_device_id mf_devices[] = {
+ .driver_data = HID_QUIRK_MULTI_INPUT },
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE2),
+ .driver_data = 0 }, /* No quirk required */
++ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE3),
++ .driver_data = HID_QUIRK_MULTI_INPUT },
+ { }
+ };
+ MODULE_DEVICE_TABLE(hid, mf_devices);
+diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
+index 60d188a704e5..f35d919c4eba 100644
+--- a/drivers/hid/hid-quirks.c
++++ b/drivers/hid/hid-quirks.c
+@@ -72,6 +72,7 @@ static const struct hid_device_id hid_quirks[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_REDRAGON_SEYMUR2), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE },
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR), HID_QUIRK_MULTI_INPUT },
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE1), HID_QUIRK_MULTI_INPUT },
++ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE3), HID_QUIRK_MULTI_INPUT },
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_PS3), HID_QUIRK_MULTI_INPUT },
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU), HID_QUIRK_MULTI_INPUT },
+ { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER), HID_QUIRK_MULTI_INPUT | HID_QUIRK_NOGET },
+@@ -491,6 +492,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE1) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE2) },
++ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE3) },
+ #endif
+ #if IS_ENABLED(CONFIG_HID_MICROSOFT)
+ { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) },
+--
+2.30.1
+
--- /dev/null
+From c3228bebc4795b8d489db4b8225d5332b555a6b9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 30 Sep 2020 05:36:35 +0200
+Subject: media: cx23885: add more quirks for reset DMA on some AMD IOMMU
+
+From: Daniel Lee Kruse <daniel.lee.kruse@protonmail.com>
+
+[ Upstream commit dbf0b3a7b719eb3f72cb53c2ce7d34a012a9c261 ]
+
+On AMD Family 15h (Models 30h-3fh), I/O Memory Management Unit
+RiSC engine sometimes stalls, requiring a reset.
+
+As result, MythTV and w-scan won't scan channels on the AMD Kaveri
+APU with the Hauppauge QuadHD TV tuner card.
+
+For the solution I added the Input/Output Memory Management Unit's PCI
+Identity of 0x1423 to the broken_dev_id[] array, which is used by
+a quirks logic meant to fix similar problems with other AMD
+chipsets.
+
+Signed-off-by: Daniel Lee Kruse <daniel.lee.kruse@protonmail.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/media/pci/cx23885/cx23885-core.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c
+index 7e0b0b7cc2a3..ead0acb7807c 100644
+--- a/drivers/media/pci/cx23885/cx23885-core.c
++++ b/drivers/media/pci/cx23885/cx23885-core.c
+@@ -2074,6 +2074,10 @@ static struct {
+ * 0x1451 is PCI ID for the IOMMU found on Ryzen
+ */
+ { PCI_VENDOR_ID_AMD, 0x1451 },
++ /* According to sudo lspci -nn,
++ * 0x1423 is the PCI ID for the IOMMU found on Kaveri
++ */
++ { PCI_VENDOR_ID_AMD, 0x1423 },
+ };
+
+ static bool cx23885_does_need_dma_reset(void)
+--
+2.30.1
+
--- /dev/null
+From b7fee2115f48258000437b06e9e99e81bb3d8abc Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 5 Jan 2021 16:28:12 +0530
+Subject: misc: eeprom_93xx46: Add quirk to support Microchip 93LC46B eeprom
+
+From: Aswath Govindraju <a-govindraju@ti.com>
+
+[ Upstream commit f6f1f8e6e3eea25f539105d48166e91f0ab46dd1 ]
+
+A dummy zero bit is sent preceding the data during a read transfer by the
+Microchip 93LC46B eeprom (section 2.7 of[1]). This results in right shift
+of data during a read. In order to ignore this bit a quirk can be added to
+send an extra zero bit after the read address.
+
+Add a quirk to ignore the zero bit sent before data by adding a zero bit
+after the read address.
+
+[1] - https://www.mouser.com/datasheet/2/268/20001749K-277859.pdf
+
+Signed-off-by: Aswath Govindraju <a-govindraju@ti.com>
+Link: https://lore.kernel.org/r/20210105105817.17644-3-a-govindraju@ti.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/misc/eeprom/eeprom_93xx46.c | 15 +++++++++++++++
+ include/linux/eeprom_93xx46.h | 2 ++
+ 2 files changed, 17 insertions(+)
+
+diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c
+index 414dcbd3c3c2..8b355fc0607b 100644
+--- a/drivers/misc/eeprom/eeprom_93xx46.c
++++ b/drivers/misc/eeprom/eeprom_93xx46.c
+@@ -35,6 +35,10 @@ static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = {
+ EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH,
+ };
+
++static const struct eeprom_93xx46_devtype_data microchip_93lc46b_data = {
++ .quirks = EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE,
++};
++
+ struct eeprom_93xx46_dev {
+ struct spi_device *spi;
+ struct eeprom_93xx46_platform_data *pdata;
+@@ -55,6 +59,11 @@ static inline bool has_quirk_instruction_length(struct eeprom_93xx46_dev *edev)
+ return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH;
+ }
+
++static inline bool has_quirk_extra_read_cycle(struct eeprom_93xx46_dev *edev)
++{
++ return edev->pdata->quirks & EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE;
++}
++
+ static int eeprom_93xx46_read(void *priv, unsigned int off,
+ void *val, size_t count)
+ {
+@@ -96,6 +105,11 @@ static int eeprom_93xx46_read(void *priv, unsigned int off,
+ dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n",
+ cmd_addr, edev->spi->max_speed_hz);
+
++ if (has_quirk_extra_read_cycle(edev)) {
++ cmd_addr <<= 1;
++ bits += 1;
++ }
++
+ spi_message_init(&m);
+
+ t[0].tx_buf = (char *)&cmd_addr;
+@@ -363,6 +377,7 @@ static void select_deassert(void *context)
+ static const struct of_device_id eeprom_93xx46_of_table[] = {
+ { .compatible = "eeprom-93xx46", },
+ { .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, },
++ { .compatible = "microchip,93lc46b", .data = µchip_93lc46b_data, },
+ {}
+ };
+ MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table);
+diff --git a/include/linux/eeprom_93xx46.h b/include/linux/eeprom_93xx46.h
+index eec7928ff8fe..99580c22f91a 100644
+--- a/include/linux/eeprom_93xx46.h
++++ b/include/linux/eeprom_93xx46.h
+@@ -16,6 +16,8 @@ struct eeprom_93xx46_platform_data {
+ #define EEPROM_93XX46_QUIRK_SINGLE_WORD_READ (1 << 0)
+ /* Instructions such as EWEN are (addrlen + 2) in length. */
+ #define EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH (1 << 1)
++/* Add extra cycle after address during a read */
++#define EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE BIT(2)
+
+ /*
+ * optional hooks to control additional logic
+--
+2.30.1
+
--- /dev/null
+From f4f8304a645d57219bc02e511d51f8f9b9b271f1 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Thu, 10 Dec 2020 16:55:10 +0800
+Subject: mmc: sdhci-of-dwcmshc: set SDHCI_QUIRK2_PRESET_VALUE_BROKEN
+
+From: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
+
+[ Upstream commit 5f7dfda4f2cec580c135fd81d96a05006651c128 ]
+
+The SDHCI_PRESET_FOR_* registers are not set(all read as zeros), so
+set the quirk.
+
+Signed-off-by: Jisheng Zhang <Jisheng.Zhang@synaptics.com>
+Link: https://lore.kernel.org/r/20201210165510.76b917e5@xhacker.debian
+Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/mmc/host/sdhci-of-dwcmshc.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c
+index a5137845a1c7..6793fb8fe976 100644
+--- a/drivers/mmc/host/sdhci-of-dwcmshc.c
++++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
+@@ -58,6 +58,7 @@ static const struct sdhci_ops sdhci_dwcmshc_ops = {
+ static const struct sdhci_pltfm_data sdhci_dwcmshc_pdata = {
+ .ops = &sdhci_dwcmshc_ops,
+ .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN,
++ .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN,
+ };
+
+ static int dwcmshc_probe(struct platform_device *pdev)
+--
+2.30.1
+
--- /dev/null
+From ff9d919da0220f0ce67f01dcb34f3edb13b1c3d3 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 28 Oct 2020 23:23:46 +0900
+Subject: mwifiex: pcie: skip cancel_work_sync() on reset failure path
+
+From: Tsuchiya Yuto <kitakar@gmail.com>
+
+[ Upstream commit 4add4d988f95f47493500a7a19c623827061589b ]
+
+If a reset is performed, but even the reset fails for some reasons (e.g.,
+on Surface devices, the fw reset requires another quirks),
+cancel_work_sync() hangs in mwifiex_cleanup_pcie().
+
+ # firmware went into a bad state
+ [...]
+ [ 1608.281690] mwifiex_pcie 0000:03:00.0: info: shutdown mwifiex...
+ [ 1608.282724] mwifiex_pcie 0000:03:00.0: rx_pending=0, tx_pending=1, cmd_pending=0
+ [ 1608.292400] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed
+ [ 1608.292405] mwifiex_pcie 0000:03:00.0: PREP_CMD: card is removed
+ # reset performed after firmware went into a bad state
+ [ 1609.394320] mwifiex_pcie 0000:03:00.0: WLAN FW already running! Skip FW dnld
+ [ 1609.394335] mwifiex_pcie 0000:03:00.0: WLAN FW is active
+ # but even the reset failed
+ [ 1619.499049] mwifiex_pcie 0000:03:00.0: mwifiex_cmd_timeout_func: Timeout cmd id = 0xfa, act = 0xe000
+ [ 1619.499094] mwifiex_pcie 0000:03:00.0: num_data_h2c_failure = 0
+ [ 1619.499103] mwifiex_pcie 0000:03:00.0: num_cmd_h2c_failure = 0
+ [ 1619.499110] mwifiex_pcie 0000:03:00.0: is_cmd_timedout = 1
+ [ 1619.499117] mwifiex_pcie 0000:03:00.0: num_tx_timeout = 0
+ [ 1619.499124] mwifiex_pcie 0000:03:00.0: last_cmd_index = 0
+ [ 1619.499133] mwifiex_pcie 0000:03:00.0: last_cmd_id: fa 00 07 01 07 01 07 01 07 01
+ [ 1619.499140] mwifiex_pcie 0000:03:00.0: last_cmd_act: 00 e0 00 00 00 00 00 00 00 00
+ [ 1619.499147] mwifiex_pcie 0000:03:00.0: last_cmd_resp_index = 3
+ [ 1619.499155] mwifiex_pcie 0000:03:00.0: last_cmd_resp_id: 07 81 07 81 07 81 07 81 07 81
+ [ 1619.499162] mwifiex_pcie 0000:03:00.0: last_event_index = 2
+ [ 1619.499169] mwifiex_pcie 0000:03:00.0: last_event: 58 00 58 00 58 00 58 00 58 00
+ [ 1619.499177] mwifiex_pcie 0000:03:00.0: data_sent=0 cmd_sent=1
+ [ 1619.499185] mwifiex_pcie 0000:03:00.0: ps_mode=0 ps_state=0
+ [ 1619.499215] mwifiex_pcie 0000:03:00.0: info: _mwifiex_fw_dpc: unregister device
+ # mwifiex_pcie_work hang happening
+ [ 1823.233923] INFO: task kworker/3:1:44 blocked for more than 122 seconds.
+ [ 1823.233932] Tainted: G WC OE 5.10.0-rc1-1-mainline #1
+ [ 1823.233935] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
+ [ 1823.233940] task:kworker/3:1 state:D stack: 0 pid: 44 ppid: 2 flags:0x00004000
+ [ 1823.233960] Workqueue: events mwifiex_pcie_work [mwifiex_pcie]
+ [ 1823.233965] Call Trace:
+ [ 1823.233981] __schedule+0x292/0x820
+ [ 1823.233990] schedule+0x45/0xe0
+ [ 1823.233995] schedule_timeout+0x11c/0x160
+ [ 1823.234003] wait_for_completion+0x9e/0x100
+ [ 1823.234012] __flush_work.isra.0+0x156/0x210
+ [ 1823.234018] ? flush_workqueue_prep_pwqs+0x130/0x130
+ [ 1823.234026] __cancel_work_timer+0x11e/0x1a0
+ [ 1823.234035] mwifiex_cleanup_pcie+0x28/0xd0 [mwifiex_pcie]
+ [ 1823.234049] mwifiex_free_adapter+0x24/0xe0 [mwifiex]
+ [ 1823.234060] _mwifiex_fw_dpc+0x294/0x560 [mwifiex]
+ [ 1823.234074] mwifiex_reinit_sw+0x15d/0x300 [mwifiex]
+ [ 1823.234080] mwifiex_pcie_reset_done+0x50/0x80 [mwifiex_pcie]
+ [ 1823.234087] pci_try_reset_function+0x5c/0x90
+ [ 1823.234094] process_one_work+0x1d6/0x3a0
+ [ 1823.234100] worker_thread+0x4d/0x3d0
+ [ 1823.234107] ? rescuer_thread+0x410/0x410
+ [ 1823.234112] kthread+0x142/0x160
+ [ 1823.234117] ? __kthread_bind_mask+0x60/0x60
+ [ 1823.234124] ret_from_fork+0x22/0x30
+ [...]
+
+This is a deadlock caused by calling cancel_work_sync() in
+mwifiex_cleanup_pcie():
+
+- Device resets are done via mwifiex_pcie_card_reset()
+- which schedules card->work to call mwifiex_pcie_card_reset_work()
+- which calls pci_try_reset_function().
+- This leads to mwifiex_pcie_reset_done() be called on the same workqueue,
+ which in turn calls
+- mwifiex_reinit_sw() and that calls
+- _mwifiex_fw_dpc().
+
+The problem is now that _mwifiex_fw_dpc() calls mwifiex_free_adapter()
+in case firmware initialization fails. That ends up calling
+mwifiex_cleanup_pcie().
+
+Note that all those calls are still running on the workqueue. So when
+mwifiex_cleanup_pcie() now calls cancel_work_sync(), it's really waiting
+on itself to complete, causing a deadlock.
+
+This commit fixes the deadlock by skipping cancel_work_sync() on a reset
+failure path.
+
+After this commit, when reset fails, the following output is
+expected to be shown:
+
+ kernel: mwifiex_pcie 0000:03:00.0: info: _mwifiex_fw_dpc: unregister device
+ kernel: mwifiex: Failed to bring up adapter: -5
+ kernel: mwifiex_pcie 0000:03:00.0: reinit failed: -5
+
+To reproduce this issue, for example, try putting the root port of wifi
+into D3 (replace "00:1d.3" with your setup).
+
+ # put into D3 (root port)
+ sudo setpci -v -s 00:1d.3 CAP_PM+4.b=0b
+
+Cc: Maximilian Luz <luzmaximilian@gmail.com>
+Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+Link: https://lore.kernel.org/r/20201028142346.18355-1-kitakar@gmail.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/net/wireless/marvell/mwifiex/pcie.c | 18 +++++++++++++++++-
+ drivers/net/wireless/marvell/mwifiex/pcie.h | 2 ++
+ 2 files changed, 19 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
+index fc1706d0647d..58c9623c3a91 100644
+--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
++++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
+@@ -377,6 +377,8 @@ static void mwifiex_pcie_reset_prepare(struct pci_dev *pdev)
+ clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags);
+ clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags);
+ mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
++
++ card->pci_reset_ongoing = true;
+ }
+
+ /*
+@@ -405,6 +407,8 @@ static void mwifiex_pcie_reset_done(struct pci_dev *pdev)
+ dev_err(&pdev->dev, "reinit failed: %d\n", ret);
+ else
+ mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__);
++
++ card->pci_reset_ongoing = false;
+ }
+
+ static const struct pci_error_handlers mwifiex_pcie_err_handler = {
+@@ -2995,7 +2999,19 @@ static void mwifiex_cleanup_pcie(struct mwifiex_adapter *adapter)
+ int ret;
+ u32 fw_status;
+
+- cancel_work_sync(&card->work);
++ /* Perform the cancel_work_sync() only when we're not resetting
++ * the card. It's because that function never returns if we're
++ * in reset path. If we're here when resetting the card, it means
++ * that we failed to reset the card (reset failure path).
++ */
++ if (!card->pci_reset_ongoing) {
++ mwifiex_dbg(adapter, MSG, "performing cancel_work_sync()...\n");
++ cancel_work_sync(&card->work);
++ mwifiex_dbg(adapter, MSG, "cancel_work_sync() done\n");
++ } else {
++ mwifiex_dbg(adapter, MSG,
++ "skipped cancel_work_sync() because we're in card reset failure path\n");
++ }
+
+ ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status);
+ if (fw_status == FIRMWARE_READY_PCIE) {
+diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.h b/drivers/net/wireless/marvell/mwifiex/pcie.h
+index f7ce9b6db6b4..72d0c01ff359 100644
+--- a/drivers/net/wireless/marvell/mwifiex/pcie.h
++++ b/drivers/net/wireless/marvell/mwifiex/pcie.h
+@@ -391,6 +391,8 @@ struct pcie_service_card {
+ struct mwifiex_msix_context share_irq_ctx;
+ struct work_struct work;
+ unsigned long work_flags;
++
++ bool pci_reset_ongoing;
+ };
+
+ static inline int
+--
+2.30.1
+
--- /dev/null
+From 2b37bb6428b5b6b999320b7ebcf8f04133765d0e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 23 Feb 2021 22:10:46 +0000
+Subject: nvme-pci: add quirks for Lexar 256GB SSD
+
+From: Pascal Terjan <pterjan@google.com>
+
+[ Upstream commit 6e6a6828c517fb6819479bf5187df5f39084eb9e ]
+
+Add the NVME_QUIRK_NO_NS_DESC_LIST and NVME_QUIRK_IGNORE_DEV_SUBNQN
+quirks for this buggy device.
+
+Reported and tested in https://bugs.mageia.org/show_bug.cgi?id=28417
+
+Signed-off-by: Pascal Terjan <pterjan@google.com>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/nvme/host/pci.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
+index 197a5cd253c3..fc18738dcf8f 100644
+--- a/drivers/nvme/host/pci.c
++++ b/drivers/nvme/host/pci.c
+@@ -3179,6 +3179,9 @@ static const struct pci_device_id nvme_id_table[] = {
+ NVME_QUIRK_IGNORE_DEV_SUBNQN, },
+ { PCI_DEVICE(0x1987, 0x5016), /* Phison E16 */
+ .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, },
++ { PCI_DEVICE(0x1b4b, 0x1092), /* Lexar 256 GB SSD */
++ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST |
++ NVME_QUIRK_IGNORE_DEV_SUBNQN, },
+ { PCI_DEVICE(0x1d1d, 0x1f1f), /* LighNVM qemu device */
+ .driver_data = NVME_QUIRK_LIGHTNVM, },
+ { PCI_DEVICE(0x1d1d, 0x2807), /* CNEX WL */
+--
+2.30.1
+
--- /dev/null
+From a4d0e1ece41c522466d101f9c86de50109539cf9 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 16 Feb 2021 13:25:43 +0100
+Subject: nvme-pci: mark Seagate Nytro XM1440 as QUIRK_NO_NS_DESC_LIST.
+
+From: Julian Einwag <jeinwag-nvme@marcapo.com>
+
+[ Upstream commit 5e112d3fb89703a4981ded60561b5647db3693bf ]
+
+The kernel fails to fully detect these SSDs, only the character devices
+are present:
+
+[ 10.785605] nvme nvme0: pci function 0000:04:00.0
+[ 10.876787] nvme nvme1: pci function 0000:81:00.0
+[ 13.198614] nvme nvme0: missing or invalid SUBNQN field.
+[ 13.198658] nvme nvme1: missing or invalid SUBNQN field.
+[ 13.206896] nvme nvme0: Shutdown timeout set to 20 seconds
+[ 13.215035] nvme nvme1: Shutdown timeout set to 20 seconds
+[ 13.225407] nvme nvme0: 16/0/0 default/read/poll queues
+[ 13.233602] nvme nvme1: 16/0/0 default/read/poll queues
+[ 13.239627] nvme nvme0: Identify Descriptors failed (8194)
+[ 13.246315] nvme nvme1: Identify Descriptors failed (8194)
+
+Adding the NVME_QUIRK_NO_NS_DESC_LIST fixes this problem.
+
+BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205679
+Signed-off-by: Julian Einwag <jeinwag-nvme@marcapo.com>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Reviewed-by: Keith Busch <kbusch@kernel.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/nvme/host/pci.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
+index abc342db3b33..197a5cd253c3 100644
+--- a/drivers/nvme/host/pci.c
++++ b/drivers/nvme/host/pci.c
+@@ -3164,7 +3164,8 @@ static const struct pci_device_id nvme_id_table[] = {
+ { PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */
+ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST, },
+ { PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */
+- .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
++ .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY |
++ NVME_QUIRK_NO_NS_DESC_LIST, },
+ { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */
+ .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
+ { PCI_DEVICE(0x1c58, 0x0023), /* WDC SN200 adapter */
+--
+2.30.1
+
--- /dev/null
+From c0089bf059e6e17295febb3e6d321526efee4e51 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Tue, 10 Nov 2020 16:00:57 -0600
+Subject: PCI: Add function 1 DMA alias quirk for Marvell 9215 SATA controller
+
+From: Bjorn Helgaas <bhelgaas@google.com>
+
+[ Upstream commit 059983790a4c963d92943e55a61fca55be427d55 ]
+
+Add function 1 DMA alias quirk for Marvell 88SS9215 PCIe SSD Controller.
+
+Link: https://bugzilla.kernel.org/show_bug.cgi?id=42679#c135
+Link: https://lore.kernel.org/r/20201110220516.697934-1-helgaas@kernel.org
+Reported-by: John Smith <LK7S2ED64JHGLKj75shg9klejHWG49h5hk@protonmail.com>
+Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/pci/quirks.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
+index c98067579e9f..53376bcda1f3 100644
+--- a/drivers/pci/quirks.c
++++ b/drivers/pci/quirks.c
+@@ -4055,6 +4055,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9183,
+ /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c46 */
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x91a0,
+ quirk_dma_func1_alias);
++/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c135 */
++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9215,
++ quirk_dma_func1_alias);
+ /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c127 */
+ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9220,
+ quirk_dma_func1_alias);
+--
+2.30.1
+
--- /dev/null
+From bffe3a4422dab852636ce001330ed5078e389e42 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 23 Nov 2020 16:16:25 +0100
+Subject: platform/x86: acer-wmi: Add ACER_CAP_KBD_DOCK quirk for the Aspire
+ Switch 10E SW3-016
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit bf753400280d1384abb783efc0b42c491d6deec3 ]
+
+Add the Acer Aspire Switch 10E SW3-016 to the list of models which use the
+Acer Switch WMI interface for reporting SW_TABLET_MODE.
+
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Link: https://lore.kernel.org/r/20201123151625.5530-1-hdegoede@redhat.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/platform/x86/acer-wmi.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
+index 427dd0987338..d27a564389a4 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -511,6 +511,15 @@ static const struct dmi_system_id acer_quirks[] __initconst = {
+ },
+ .driver_data = &quirk_acer_travelmate_2490,
+ },
++ {
++ .callback = set_force_caps,
++ .ident = "Acer Aspire Switch 10E SW3-016",
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
++ DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW3-016"),
++ },
++ .driver_data = (void *)ACER_CAP_KBD_DOCK,
++ },
+ {
+ .callback = set_force_caps,
+ .ident = "Acer Aspire Switch 10 SW5-012",
+--
+2.30.1
+
--- /dev/null
+From 3e9f6d11b3f2f2f9f9ee498bfdbbac7cc8cfe10d Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 19 Oct 2020 20:56:27 +0200
+Subject: platform/x86: acer-wmi: Add ACER_CAP_SET_FUNCTION_MODE capability
+ flag
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit 82cb8a5c395ea5be20e0fe31a8fe84380a502ca5 ]
+
+Not all devices supporting WMID_GUID3 support the wmid3_set_function_mode()
+call, leading to errors like these:
+
+[ 60.138358] acer_wmi: Enabling RF Button failed: 0x1 - 0xff
+[ 60.140036] acer_wmi: Enabling Launch Manager failed: 0x1 - 0xff
+
+Add an ACER_CAP_SET_FUNCTION_MODE capability flag, so that these calls
+can be disabled through the new force_caps mechanism.
+
+Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Link: https://lore.kernel.org/r/20201019185628.264473-5-hdegoede@redhat.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/platform/x86/acer-wmi.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
+index e26ae1d917ea..bde37be6973e 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -211,6 +211,7 @@ struct hotkey_function_type_aa {
+ #define ACER_CAP_BLUETOOTH BIT(2)
+ #define ACER_CAP_BRIGHTNESS BIT(3)
+ #define ACER_CAP_THREEG BIT(4)
++#define ACER_CAP_SET_FUNCTION_MODE BIT(5)
+
+ /*
+ * Interface type flags
+@@ -2202,10 +2203,14 @@ static int __init acer_wmi_init(void)
+ if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
+ interface->capability &= ~ACER_CAP_BRIGHTNESS;
+
++ if (wmi_has_guid(WMID_GUID3))
++ interface->capability |= ACER_CAP_SET_FUNCTION_MODE;
++
+ if (force_caps != -1)
+ interface->capability = force_caps;
+
+- if (wmi_has_guid(WMID_GUID3)) {
++ if (wmi_has_guid(WMID_GUID3) &&
++ (interface->capability & ACER_CAP_SET_FUNCTION_MODE)) {
+ if (ACPI_FAILURE(acer_wmi_enable_rf_button()))
+ pr_warn("Cannot enable RF Button Driver\n");
+
+--
+2.30.1
+
--- /dev/null
+From 937e2d3cb47413a405229a33152fa70a634cec81 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 19 Oct 2020 20:56:26 +0200
+Subject: platform/x86: acer-wmi: Add new force_caps module parameter
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit 39aa009bb66f9d5fbd1e58ca4aa03d6e6f2c9915 ]
+
+Add a new force_caps module parameter to allow overriding the drivers
+builtin capability detection mechanism.
+
+This can be used to for example:
+-Disable rfkill functionality on devices where there is an AA OEM DMI
+ record advertising non functional rfkill switches
+-Force loading of the driver on devices with a missing AA OEM DMI record
+
+Note that force_caps is -1 when unset, this allows forcing the
+capability field to 0, which results in acer-wmi only providing WMI
+hotkey handling while disabling all other (led, rfkill, backlight)
+functionality.
+
+Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Link: https://lore.kernel.org/r/20201019185628.264473-4-hdegoede@redhat.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/platform/x86/acer-wmi.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
+index 167d0446f560..e26ae1d917ea 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -233,6 +233,7 @@ static int mailled = -1;
+ static int brightness = -1;
+ static int threeg = -1;
+ static int force_series;
++static int force_caps = -1;
+ static bool ec_raw_mode;
+ static bool has_type_aa;
+ static u16 commun_func_bitmap;
+@@ -242,11 +243,13 @@ module_param(mailled, int, 0444);
+ module_param(brightness, int, 0444);
+ module_param(threeg, int, 0444);
+ module_param(force_series, int, 0444);
++module_param(force_caps, int, 0444);
+ module_param(ec_raw_mode, bool, 0444);
+ MODULE_PARM_DESC(mailled, "Set initial state of Mail LED");
+ MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness");
+ MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware");
+ MODULE_PARM_DESC(force_series, "Force a different laptop series");
++MODULE_PARM_DESC(force_caps, "Force the capability bitmask to this value");
+ MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode");
+
+ struct acer_data {
+@@ -2169,7 +2172,7 @@ static int __init acer_wmi_init(void)
+ }
+ /* WMID always provides brightness methods */
+ interface->capability |= ACER_CAP_BRIGHTNESS;
+- } else if (!wmi_has_guid(WMID_GUID2) && interface && !has_type_aa) {
++ } else if (!wmi_has_guid(WMID_GUID2) && interface && !has_type_aa && force_caps == -1) {
+ pr_err("No WMID device detection method found\n");
+ return -ENODEV;
+ }
+@@ -2199,6 +2202,9 @@ static int __init acer_wmi_init(void)
+ if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
+ interface->capability &= ~ACER_CAP_BRIGHTNESS;
+
++ if (force_caps != -1)
++ interface->capability = force_caps;
++
+ if (wmi_has_guid(WMID_GUID3)) {
+ if (ACPI_FAILURE(acer_wmi_enable_rf_button()))
+ pr_warn("Cannot enable RF Button Driver\n");
+--
+2.30.1
+
--- /dev/null
+From aa44cf07d51e20c0b161f875d6b5716d19f0c45e Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 19 Oct 2020 20:56:28 +0200
+Subject: platform/x86: acer-wmi: Add support for SW_TABLET_MODE on Switch
+ devices
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit 5c54cb6c627e8f50f490e6b5656051a5ac29eab4 ]
+
+Add support for SW_TABLET_MODE on the Acer Switch 10 (SW5-012) and the
+acer Switch 10 (S1003) models.
+
+There is no way to detect if this is supported, so this uses DMI based
+quirks setting force_caps to ACER_CAP_KBD_DOCK (these devices have no
+other acer-wmi based functionality).
+
+The new SW_TABLET_MODE functionality can be tested on devices which
+are not in the DMI table by passing acer_wmi.force_caps=0x40 on the
+kernel commandline.
+
+Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Link: https://lore.kernel.org/r/20201019185628.264473-6-hdegoede@redhat.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/platform/x86/acer-wmi.c | 109 +++++++++++++++++++++++++++++++-
+ 1 file changed, 106 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
+index bde37be6973e..427dd0987338 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -30,6 +30,7 @@
+ #include <linux/input/sparse-keymap.h>
+ #include <acpi/video.h>
+
++ACPI_MODULE_NAME(KBUILD_MODNAME);
+ MODULE_AUTHOR("Carlos Corbacho");
+ MODULE_DESCRIPTION("Acer Laptop WMI Extras Driver");
+ MODULE_LICENSE("GPL");
+@@ -80,7 +81,7 @@ MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026");
+
+ enum acer_wmi_event_ids {
+ WMID_HOTKEY_EVENT = 0x1,
+- WMID_ACCEL_EVENT = 0x5,
++ WMID_ACCEL_OR_KBD_DOCK_EVENT = 0x5,
+ };
+
+ static const struct key_entry acer_wmi_keymap[] __initconst = {
+@@ -128,7 +129,9 @@ struct event_return_value {
+ u8 function;
+ u8 key_num;
+ u16 device_state;
+- u32 reserved;
++ u16 reserved1;
++ u8 kbd_dock_state;
++ u8 reserved2;
+ } __attribute__((packed));
+
+ /*
+@@ -212,6 +215,7 @@ struct hotkey_function_type_aa {
+ #define ACER_CAP_BRIGHTNESS BIT(3)
+ #define ACER_CAP_THREEG BIT(4)
+ #define ACER_CAP_SET_FUNCTION_MODE BIT(5)
++#define ACER_CAP_KBD_DOCK BIT(6)
+
+ /*
+ * Interface type flags
+@@ -320,6 +324,15 @@ static int __init dmi_matched(const struct dmi_system_id *dmi)
+ return 1;
+ }
+
++static int __init set_force_caps(const struct dmi_system_id *dmi)
++{
++ if (force_caps == -1) {
++ force_caps = (uintptr_t)dmi->driver_data;
++ pr_info("Found %s, set force_caps to 0x%x\n", dmi->ident, force_caps);
++ }
++ return 1;
++}
++
+ static struct quirk_entry quirk_unknown = {
+ };
+
+@@ -498,6 +511,24 @@ static const struct dmi_system_id acer_quirks[] __initconst = {
+ },
+ .driver_data = &quirk_acer_travelmate_2490,
+ },
++ {
++ .callback = set_force_caps,
++ .ident = "Acer Aspire Switch 10 SW5-012",
++ .matches = {
++ DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
++ DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
++ },
++ .driver_data = (void *)ACER_CAP_KBD_DOCK,
++ },
++ {
++ .callback = set_force_caps,
++ .ident = "Acer One 10 (S1003)",
++ .matches = {
++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Acer"),
++ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "One S1003"),
++ },
++ .driver_data = (void *)ACER_CAP_KBD_DOCK,
++ },
+ {}
+ };
+
+@@ -1542,6 +1573,71 @@ static int acer_gsensor_event(void)
+ return 0;
+ }
+
++/*
++ * Switch series keyboard dock status
++ */
++static int acer_kbd_dock_state_to_sw_tablet_mode(u8 kbd_dock_state)
++{
++ switch (kbd_dock_state) {
++ case 0x01: /* Docked, traditional clamshell laptop mode */
++ return 0;
++ case 0x04: /* Stand-alone tablet */
++ case 0x40: /* Docked, tent mode, keyboard not usable */
++ return 1;
++ default:
++ pr_warn("Unknown kbd_dock_state 0x%02x\n", kbd_dock_state);
++ }
++
++ return 0;
++}
++
++static void acer_kbd_dock_get_initial_state(void)
++{
++ u8 *output, input[8] = { 0x05, 0x00, };
++ struct acpi_buffer input_buf = { sizeof(input), input };
++ struct acpi_buffer output_buf = { ACPI_ALLOCATE_BUFFER, NULL };
++ union acpi_object *obj;
++ acpi_status status;
++ int sw_tablet_mode;
++
++ status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input_buf, &output_buf);
++ if (ACPI_FAILURE(status)) {
++ ACPI_EXCEPTION((AE_INFO, status, "Error getting keyboard-dock initial status"));
++ return;
++ }
++
++ obj = output_buf.pointer;
++ if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) {
++ pr_err("Unexpected output format getting keyboard-dock initial status\n");
++ goto out_free_obj;
++ }
++
++ output = obj->buffer.pointer;
++ if (output[0] != 0x00 || (output[3] != 0x05 && output[3] != 0x45)) {
++ pr_err("Unexpected output [0]=0x%02x [3]=0x%02x getting keyboard-dock initial status\n",
++ output[0], output[3]);
++ goto out_free_obj;
++ }
++
++ sw_tablet_mode = acer_kbd_dock_state_to_sw_tablet_mode(output[4]);
++ input_report_switch(acer_wmi_input_dev, SW_TABLET_MODE, sw_tablet_mode);
++
++out_free_obj:
++ kfree(obj);
++}
++
++static void acer_kbd_dock_event(const struct event_return_value *event)
++{
++ int sw_tablet_mode;
++
++ if (!has_cap(ACER_CAP_KBD_DOCK))
++ return;
++
++ sw_tablet_mode = acer_kbd_dock_state_to_sw_tablet_mode(event->kbd_dock_state);
++ input_report_switch(acer_wmi_input_dev, SW_TABLET_MODE, sw_tablet_mode);
++ input_sync(acer_wmi_input_dev);
++}
++
+ /*
+ * Rfkill devices
+ */
+@@ -1769,8 +1865,9 @@ static void acer_wmi_notify(u32 value, void *context)
+ sparse_keymap_report_event(acer_wmi_input_dev, scancode, 1, true);
+ }
+ break;
+- case WMID_ACCEL_EVENT:
++ case WMID_ACCEL_OR_KBD_DOCK_EVENT:
+ acer_gsensor_event();
++ acer_kbd_dock_event(&return_value);
+ break;
+ default:
+ pr_warn("Unknown function number - %d - %d\n",
+@@ -1935,6 +2032,9 @@ static int __init acer_wmi_input_setup(void)
+ if (err)
+ goto err_free_dev;
+
++ if (has_cap(ACER_CAP_KBD_DOCK))
++ input_set_capability(acer_wmi_input_dev, EV_SW, SW_TABLET_MODE);
++
+ status = wmi_install_notify_handler(ACERWMID_EVENT_GUID,
+ acer_wmi_notify, NULL);
+ if (ACPI_FAILURE(status)) {
+@@ -1942,6 +2042,9 @@ static int __init acer_wmi_input_setup(void)
+ goto err_free_dev;
+ }
+
++ if (has_cap(ACER_CAP_KBD_DOCK))
++ acer_kbd_dock_get_initial_state();
++
+ err = input_register_device(acer_wmi_input_dev);
+ if (err)
+ goto err_uninstall_notifier;
+--
+2.30.1
+
--- /dev/null
+From e5d5fd07a33c591238b1b51b6cec39a296c10cad Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 19 Oct 2020 20:56:25 +0200
+Subject: platform/x86: acer-wmi: Cleanup accelerometer device handling
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit 9feb0763e4985ccfae632de3bb2f029cc8389842 ]
+
+Cleanup accelerometer device handling:
+-Drop acer_wmi_accel_destroy instead directly call input_unregister_device.
+-The information tracked by the CAP_ACCEL flag mirrors acer_wmi_accel_dev
+ being NULL. Drop the CAP flag, this is a preparation change for allowing
+ users to override the capability flags. Dropping the flag stops users
+ from causing a NULL pointer dereference by forcing the capability.
+
+Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Link: https://lore.kernel.org/r/20201019185628.264473-3-hdegoede@redhat.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/platform/x86/acer-wmi.c | 20 ++++++--------------
+ 1 file changed, 6 insertions(+), 14 deletions(-)
+
+diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
+index daf692fe7f77..167d0446f560 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -211,7 +211,6 @@ struct hotkey_function_type_aa {
+ #define ACER_CAP_BLUETOOTH BIT(2)
+ #define ACER_CAP_BRIGHTNESS BIT(3)
+ #define ACER_CAP_THREEG BIT(4)
+-#define ACER_CAP_ACCEL BIT(5)
+
+ /*
+ * Interface type flags
+@@ -1516,7 +1515,7 @@ static int acer_gsensor_event(void)
+ struct acpi_buffer output;
+ union acpi_object out_obj[5];
+
+- if (!has_cap(ACER_CAP_ACCEL))
++ if (!acer_wmi_accel_dev)
+ return -1;
+
+ output.length = sizeof(out_obj);
+@@ -1890,8 +1889,6 @@ static int __init acer_wmi_accel_setup(void)
+ gsensor_handle = acpi_device_handle(adev);
+ acpi_dev_put(adev);
+
+- interface->capability |= ACER_CAP_ACCEL;
+-
+ acer_wmi_accel_dev = input_allocate_device();
+ if (!acer_wmi_accel_dev)
+ return -ENOMEM;
+@@ -1917,11 +1914,6 @@ err_free_dev:
+ return err;
+ }
+
+-static void acer_wmi_accel_destroy(void)
+-{
+- input_unregister_device(acer_wmi_accel_dev);
+-}
+-
+ static int __init acer_wmi_input_setup(void)
+ {
+ acpi_status status;
+@@ -2076,7 +2068,7 @@ static int acer_resume(struct device *dev)
+ if (has_cap(ACER_CAP_BRIGHTNESS))
+ set_u32(data->brightness, ACER_CAP_BRIGHTNESS);
+
+- if (has_cap(ACER_CAP_ACCEL))
++ if (acer_wmi_accel_dev)
+ acer_gsensor_init();
+
+ return 0;
+@@ -2266,8 +2258,8 @@ error_device_alloc:
+ error_platform_register:
+ if (wmi_has_guid(ACERWMID_EVENT_GUID))
+ acer_wmi_input_destroy();
+- if (has_cap(ACER_CAP_ACCEL))
+- acer_wmi_accel_destroy();
++ if (acer_wmi_accel_dev)
++ input_unregister_device(acer_wmi_accel_dev);
+
+ return err;
+ }
+@@ -2277,8 +2269,8 @@ static void __exit acer_wmi_exit(void)
+ if (wmi_has_guid(ACERWMID_EVENT_GUID))
+ acer_wmi_input_destroy();
+
+- if (has_cap(ACER_CAP_ACCEL))
+- acer_wmi_accel_destroy();
++ if (acer_wmi_accel_dev)
++ input_unregister_device(acer_wmi_accel_dev);
+
+ remove_debugfs();
+ platform_device_unregister(acer_platform_device);
+--
+2.30.1
+
--- /dev/null
+From 75bc08bc3fe4a834266b530090fefd85d7fe3af7 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 19 Oct 2020 20:56:24 +0200
+Subject: platform/x86: acer-wmi: Cleanup ACER_CAP_FOO defines
+
+From: Hans de Goede <hdegoede@redhat.com>
+
+[ Upstream commit 7c936d8d26afbc74deac0651d613dead2f76e81c ]
+
+Cleanup the ACER_CAP_FOO defines:
+-Switch to using BIT() macro.
+-The ACER_CAP_RFBTN flag is set, but it is never checked anywhere, drop it.
+-Drop the unused ACER_CAP_ANY define.
+
+Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Link: https://lore.kernel.org/r/20201019185628.264473-2-hdegoede@redhat.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/platform/x86/acer-wmi.c | 18 +++++++-----------
+ 1 file changed, 7 insertions(+), 11 deletions(-)
+
+diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c
+index 7fa27e753691..daf692fe7f77 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -206,14 +206,12 @@ struct hotkey_function_type_aa {
+ /*
+ * Interface capability flags
+ */
+-#define ACER_CAP_MAILLED (1<<0)
+-#define ACER_CAP_WIRELESS (1<<1)
+-#define ACER_CAP_BLUETOOTH (1<<2)
+-#define ACER_CAP_BRIGHTNESS (1<<3)
+-#define ACER_CAP_THREEG (1<<4)
+-#define ACER_CAP_ACCEL (1<<5)
+-#define ACER_CAP_RFBTN (1<<6)
+-#define ACER_CAP_ANY (0xFFFFFFFF)
++#define ACER_CAP_MAILLED BIT(0)
++#define ACER_CAP_WIRELESS BIT(1)
++#define ACER_CAP_BLUETOOTH BIT(2)
++#define ACER_CAP_BRIGHTNESS BIT(3)
++#define ACER_CAP_THREEG BIT(4)
++#define ACER_CAP_ACCEL BIT(5)
+
+ /*
+ * Interface type flags
+@@ -1253,10 +1251,8 @@ static void __init type_aa_dmi_decode(const struct dmi_header *header, void *d)
+ interface->capability |= ACER_CAP_THREEG;
+ if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_BLUETOOTH)
+ interface->capability |= ACER_CAP_BLUETOOTH;
+- if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_RFBTN) {
+- interface->capability |= ACER_CAP_RFBTN;
++ if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_RFBTN)
+ commun_func_bitmap &= ~ACER_WMID3_GDS_RFBTN;
+- }
+
+ commun_fn_key_number = type_aa->commun_fn_key_number;
+ }
+--
+2.30.1
+
dm-table-fix-dax-iterate_devices-based-device-capability-checks.patch
dm-table-fix-zoned-iterate_devices-based-device-capability-checks.patch
acpica-fix-race-in-generic_serial_bus-i2c-and-gpio-op_region-parameter-handling.patch
+mwifiex-pcie-skip-cancel_work_sync-on-reset-failure-.patch
+platform-x86-acer-wmi-cleanup-acer_cap_foo-defines.patch
+platform-x86-acer-wmi-cleanup-accelerometer-device-h.patch
+platform-x86-acer-wmi-add-new-force_caps-module-para.patch
+platform-x86-acer-wmi-add-acer_cap_set_function_mode.patch
+platform-x86-acer-wmi-add-support-for-sw_tablet_mode.patch
+platform-x86-acer-wmi-add-acer_cap_kbd_dock-quirk-fo.patch
+hid-mf-add-support-for-0079-1846-mayflash-dragonrise.patch
+media-cx23885-add-more-quirks-for-reset-dma-on-some-.patch
+acpi-video-add-dmi-quirk-for-gigabyte-gb-bxbt-2807.patch
+asoc-intel-bytcr_rt5640-add-quirk-for-archos-cesium-.patch
+pci-add-function-1-dma-alias-quirk-for-marvell-9215-.patch
+misc-eeprom_93xx46-add-quirk-to-support-microchip-93.patch
+drm-msm-a5xx-remove-overwriting-a5xx_pc_dbg_eco_cntl.patch
+mmc-sdhci-of-dwcmshc-set-sdhci_quirk2_preset_value_b.patch
+hid-i2c-hid-add-i2c_hid_quirk_no_irq_after_reset-for.patch
+nvme-pci-mark-seagate-nytro-xm1440-as-quirk_no_ns_de.patch
+nvme-pci-add-quirks-for-lexar-256gb-ssd.patch