--- /dev/null
+From f85031fcbb6bfc99616b8420b8bccfbdee1af62d 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 f1aaa76cc2e4..92e767f3cc16 100644
+--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
++++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+@@ -472,8 +472,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 651022e78f414dc8b77558f54971dbd026d481df 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 a3248ebd28c6..182feab6da25 100644
+--- a/drivers/misc/eeprom/eeprom_93xx46.c
++++ b/drivers/misc/eeprom/eeprom_93xx46.c
+@@ -38,6 +38,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;
+@@ -58,6 +62,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)
+ {
+@@ -99,6 +108,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;
+@@ -366,6 +380,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 36d2428c7290d188a1e99c372b038bb290d28d76 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 8ee9609ef974..7f615ad98aca 100644
+--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
++++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
+@@ -368,6 +368,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;
+ }
+
+ /*
+@@ -396,6 +398,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 = {
+@@ -2980,7 +2984,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 bb08d5f65cb7e9ff97fd8daba72e47a73adb28ba 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 da790f26d295..510cb05aa96f 100644
+--- a/drivers/pci/quirks.c
++++ b/drivers/pci/quirks.c
+@@ -3934,6 +3934,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9182,
+ /* 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 c781f95e6da3238bc5ae992f79987417545f1bf8 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 52ae8bb38813..5ddc359135a8 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -524,6 +524,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 ff38d6a9b2a5b061a3a3dc1dea88224177a6f7a9 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 12aa174a865f..729d0277e100 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -223,6 +223,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
+@@ -2263,10 +2264,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 59de5ff4daedc73db1145fc8a94d2a6337850ed0 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 445e9c17f4a8..12aa174a865f 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -245,6 +245,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;
+@@ -254,11 +255,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 {
+@@ -2230,7 +2233,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;
+ }
+@@ -2260,6 +2263,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 b8eb9e204049ea7565f0fbb296f6c7a2ae352e5c 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 729d0277e100..52ae8bb38813 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -43,6 +43,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");
+@@ -93,7 +94,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 = {
+@@ -140,7 +141,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));
+
+ /*
+@@ -224,6 +227,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
+@@ -333,6 +337,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 = {
+ };
+
+@@ -511,6 +524,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,
++ },
+ {}
+ };
+
+@@ -1554,6 +1585,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
+ */
+@@ -1781,8 +1877,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",
+@@ -1982,6 +2079,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)) {
+@@ -1989,6 +2089,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 ed5a92b655f78abc45013d1cb13ad0b0069ad58a 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 41311c1526a0..445e9c17f4a8 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -223,7 +223,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
+@@ -1528,7 +1527,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);
+@@ -1937,8 +1936,6 @@ static int __init acer_wmi_accel_setup(void)
+ if (err)
+ return err;
+
+- interface->capability |= ACER_CAP_ACCEL;
+-
+ acer_wmi_accel_dev = input_allocate_device();
+ if (!acer_wmi_accel_dev)
+ return -ENOMEM;
+@@ -1964,11 +1961,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;
+@@ -2123,7 +2115,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;
+@@ -2331,8 +2323,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;
+ }
+@@ -2342,8 +2334,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 42d25564ab88599c101af3cf2e253933d820c076 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 29f6f2bbb5ff..41311c1526a0 100644
+--- a/drivers/platform/x86/acer-wmi.c
++++ b/drivers/platform/x86/acer-wmi.c
+@@ -218,14 +218,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
+@@ -1268,10 +1266,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
+
usbip-tools-fix-build-error-for-multiple-definition.patch
alsa-ctxfi-cthw20k2-fix-mask-on-conf-to-allow-4-bits.patch
rsxx-return-efault-if-copy_to_user-fails.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
+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