* [PATCH v4 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference [not found] <20260711055247.5412-1-fourdollars@debian.org> @ 2026-07-11 11:49 ` Shih-Yuan Lee 2026-07-11 11:49 ` [PATCH v4 1/3] Input: applespi - cancel pending work on driver remove Shih-Yuan Lee ` (2 more replies) 2026-07-11 13:11 ` [PATCH v5 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference Shih-Yuan Lee 1 sibling, 3 replies; 8+ messages in thread From: Shih-Yuan Lee @ 2026-07-11 11:49 UTC (permalink / raw) To: Dmitry Torokhov, Mark Brown Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Shih-Yuan Lee, linux-input, linux-spi, linux-kernel, linux-arm-kernel Hi Dmitry, Mark, and the linux-input/linux-spi community, This patch series addresses a long-standing DMA initialization timeout on the early 2015 12" MacBook (MacBook8,1) on any boot (including cold boot), as well as two pre-existing, high-severity UAF/NULL-pointer bugs in the applespi driver. Changes in v4: - Reverted the runtime `can_dma` callback override from `applespi.c` to avoid architectural layering violation, data races (TOCTOU) with concurrent SPI transfers, and execute-after-free vulnerability upon module unload. - Moved the DMI quirk forcing PIO mode for MacBook8,1 to the host PCI glue driver (spi-pxa2xx-pci.c) where LPSS setup occurs. - Formatted the DMI match using a structured `pxa2xx_spi_pci_dmi_table` and helper function `pxa2xx_spi_pci_can_dma()`. - Added a `force_pio` module parameter in spi-pxa2xx-pci.c to allow other users to manually force PIO mode for debugging. Changes in v3: - Added a `force_pio` module parameter to applespi to allow users to manually disable DMA for SPI transfers. - Resolved the execute-after-free vulnerability by unconditionally restoring the original can_dma callback (even if NULL) in the driver remove path. - Fixed the probe timing issue by applying the can_dma override at the very beginning of applespi_probe() so that all early initialization transfers safely use PIO mode, and properly restoring it in all probe error paths. - Documented the Bugzilla link in the commit message of Patch 1. Changes in v2: - Fixed an unbind/remove execute-after-free vulnerability by storing and restoring the host controller's original can_dma callback in applespi_probe() and applespi_remove(). - Split the fixes into a 3-patch logical series. Patch 1 fixes a pre-existing UAF vulnerability in the driver unbind path by explicitly calling cancel_work_sync() on the asynchronous registration worker work struct before devres frees the driver private data. Patch 2 fixes a pre-existing race condition in the debugfs interface where userspace could open the tp_dim file before the asynchronous worker has finished initializing applespi->touchpad_input_dev, leading to a NULL pointer dereference. We resolve this using smp_load_acquire() and checking for NULL. Patch 3 introduces a structured DMI quirk and a `force_pio` module parameter in spi-pxa2xx-pci.c to disable DMA on MacBook8,1. This forces the controller to use the rock-solid PIO mode from the very beginning. Best regards, Shih-Yuan Lee Shih-Yuan Lee (3): Input: applespi - cancel pending work on driver remove Input: applespi - fix NULL pointer dereference in tp_dim open spi: pxa2xx: disable DMA for Apple MacBook8,1 drivers/input/keyboard/applespi.c | 10 +++++++++- drivers/spi/spi-pxa2xx-pci.c | 33 ++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) -- 2.39.5 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 1/3] Input: applespi - cancel pending work on driver remove 2026-07-11 11:49 ` [PATCH v4 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference Shih-Yuan Lee @ 2026-07-11 11:49 ` Shih-Yuan Lee 2026-07-11 11:49 ` [PATCH v4 2/3] Input: applespi - fix NULL pointer dereference in tp_dim open Shih-Yuan Lee 2026-07-11 11:49 ` [PATCH v4 3/3] spi: pxa2xx: disable DMA for Apple MacBook8,1 Shih-Yuan Lee 2 siblings, 0 replies; 8+ messages in thread From: Shih-Yuan Lee @ 2026-07-11 11:49 UTC (permalink / raw) To: Dmitry Torokhov, Mark Brown Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Shih-Yuan Lee, linux-input, linux-spi, linux-kernel, linux-arm-kernel During driver removal in applespi_remove(), the managed private data structure is freed by devres. However, the driver does not cancel the asynchronous work applespi->work, which registers the touchpad input device. This creates a use-after-free (UAF) vulnerability if a pending or running worker thread attempts to access the private data after the remove function returns. Fix this by explicitly calling cancel_work_sync(&applespi->work) in applespi_remove() before cleanups. Signed-off-by: Shih-Yuan Lee <fourdollars@debian.org> --- drivers/input/keyboard/applespi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c index b5ff71cd5a70..3bdb9e7cfb8b 100644 --- a/drivers/input/keyboard/applespi.c +++ b/drivers/input/keyboard/applespi.c @@ -1822,6 +1822,8 @@ static void applespi_remove(struct spi_device *spi) applespi_drain_reads(applespi); + cancel_work_sync(&applespi->work); + debugfs_remove_recursive(applespi->debugfs_root); } -- 2.39.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 2/3] Input: applespi - fix NULL pointer dereference in tp_dim open 2026-07-11 11:49 ` [PATCH v4 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference Shih-Yuan Lee 2026-07-11 11:49 ` [PATCH v4 1/3] Input: applespi - cancel pending work on driver remove Shih-Yuan Lee @ 2026-07-11 11:49 ` Shih-Yuan Lee 2026-07-11 11:49 ` [PATCH v4 3/3] spi: pxa2xx: disable DMA for Apple MacBook8,1 Shih-Yuan Lee 2 siblings, 0 replies; 8+ messages in thread From: Shih-Yuan Lee @ 2026-07-11 11:49 UTC (permalink / raw) To: Dmitry Torokhov, Mark Brown Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Shih-Yuan Lee, linux-input, linux-spi, linux-kernel, linux-arm-kernel The tp_dim debugfs file is registered synchronously during driver probe in applespi_probe(). However, the applespi->touchpad_input_dev is initialized and registered asynchronously in the driver's worker thread. If a userspace process opens the debugfs file before the worker thread has completed initialization, applespi_tp_dim_open() will dereference the NULL applespi->touchpad_input_dev pointer, causing a kernel panic. Fix this by using smp_load_acquire() to safely load touchpad_input_dev and return -ENODEV if it is not yet initialized. Signed-off-by: Shih-Yuan Lee <fourdollars@debian.org> --- drivers/input/keyboard/applespi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c index 3bdb9e7cfb8b..4d339445e9c7 100644 --- a/drivers/input/keyboard/applespi.c +++ b/drivers/input/keyboard/applespi.c @@ -963,12 +963,18 @@ static void applespi_debug_update_dimensions(struct applespi_data *applespi, static int applespi_tp_dim_open(struct inode *inode, struct file *file) { struct applespi_data *applespi = inode->i_private; + struct input_dev *touchpad; file->private_data = applespi; + /* Pairs with smp_store_release in applespi_register_touchpad_device() */ + touchpad = smp_load_acquire(&applespi->touchpad_input_dev); + if (!touchpad) + return -ENODEV; + snprintf(applespi->tp_dim_val, sizeof(applespi->tp_dim_val), "0x%.4x %dx%d+%u+%u\n", - applespi->touchpad_input_dev->id.product, + touchpad->id.product, applespi->tp_dim_min_x, applespi->tp_dim_min_y, applespi->tp_dim_max_x - applespi->tp_dim_min_x, applespi->tp_dim_max_y - applespi->tp_dim_min_y); -- 2.39.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 3/3] spi: pxa2xx: disable DMA for Apple MacBook8,1 2026-07-11 11:49 ` [PATCH v4 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference Shih-Yuan Lee 2026-07-11 11:49 ` [PATCH v4 1/3] Input: applespi - cancel pending work on driver remove Shih-Yuan Lee 2026-07-11 11:49 ` [PATCH v4 2/3] Input: applespi - fix NULL pointer dereference in tp_dim open Shih-Yuan Lee @ 2026-07-11 11:49 ` Shih-Yuan Lee 2 siblings, 0 replies; 8+ messages in thread From: Shih-Yuan Lee @ 2026-07-11 11:49 UTC (permalink / raw) To: Dmitry Torokhov, Mark Brown Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Shih-Yuan Lee, linux-input, linux-spi, linux-kernel, linux-arm-kernel On MacBook8,1 (early 2015 12" MacBook), the LPSS SPI controller's DMA handshake and interrupt routing frequently fail or time out on boot, causing the keyboard and trackpad to become unresponsive. Avoid this architectural bug by disabling DMA and forcing the SPI controller to use PIO mode. Move this platform/motherboard-level quirk to the SPI host controller driver (spi-pxa2xx-pci.c) where LPSS setup occurs, preventing layering violations, TOCTOU races, or execute-after-free bugs in the client driver. Additionally, introduce a `force_pio` module parameter in the PCI host controller driver to allow other users to force PIO mode for debugging. Link: https://bugzilla.kernel.org/show_bug.cgi?id=108331 Signed-off-by: Shih-Yuan Lee <fourdollars@debian.org> --- drivers/spi/spi-pxa2xx-pci.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index cae77ac18520..96bbc7a7c381 100644 --- a/drivers/spi/spi-pxa2xx-pci.c +++ b/drivers/spi/spi-pxa2xx-pci.c @@ -18,9 +18,14 @@ #include <linux/dmaengine.h> #include <linux/platform_data/dma-dw.h> +#include <linux/dmi.h> #include "spi-pxa2xx.h" +static bool spi_pxa2xx_force_pio; +module_param_named(force_pio, spi_pxa2xx_force_pio, bool, 0444); +MODULE_PARM_DESC(force_pio, "Force PIO mode (disables DMA) for SPI transfers. ([0] = disabled, 1 = enabled)"); + #define PCI_DEVICE_ID_INTEL_QUARK_X1000 0x0935 #define PCI_DEVICE_ID_INTEL_BYT 0x0f0e #define PCI_DEVICE_ID_INTEL_MRFLD 0x1194 @@ -93,6 +98,32 @@ static void lpss_dma_put_device(void *dma_dev) pci_dev_put(dma_dev); } +static const struct dmi_system_id pxa2xx_spi_pci_dmi_table[] = { + { + .ident = "Apple MacBook8,1", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "MacBook8,1"), + }, + }, + { } +}; + +static bool pxa2xx_spi_pci_can_dma(struct pci_dev *dev) +{ + if (spi_pxa2xx_force_pio) { + pci_info(dev, "Forcing PIO mode (disabling DMA)\n"); + return false; + } + + if (dmi_check_system(pxa2xx_spi_pci_dmi_table)) { + pci_info(dev, "MacBook8,1 detected: disabling DMA to force PIO mode\n"); + return false; + } + + return true; +} + static int lpss_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c) { struct ssp_device *ssp = &c->ssp; @@ -166,7 +197,7 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c) c->dma_filter = lpss_dma_filter; c->dma_burst_size = 1; - c->enable_dma = 1; + c->enable_dma = pxa2xx_spi_pci_can_dma(dev); return 0; } -- 2.39.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v5 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference [not found] <20260711055247.5412-1-fourdollars@debian.org> 2026-07-11 11:49 ` [PATCH v4 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference Shih-Yuan Lee @ 2026-07-11 13:11 ` Shih-Yuan Lee 2026-07-11 13:11 ` [PATCH v5 1/3] Input: applespi - cancel pending work on driver remove Shih-Yuan Lee ` (2 more replies) 1 sibling, 3 replies; 8+ messages in thread From: Shih-Yuan Lee @ 2026-07-11 13:11 UTC (permalink / raw) To: Dmitry Torokhov, Mark Brown Cc: linux-input, linux-spi, linux-kernel, Shih-Yuan Lee Hi Dmitry, Mark, and the linux-input/linux-spi community, This patch series addresses a long-standing DMA initialization timeout on the early 2015 12" MacBook (MacBook8,1) on any boot (including cold boot), as well as two pre-existing, high-severity UAF/NULL-pointer bugs in the applespi driver. Changes in v5: - Updated both `lpss_spi_setup()` and `mrfld_spi_setup()` in `spi-pxa2xx-pci.c` to consistently respect the `force_pio` module parameter across all supported PCI devices (avoiding hardcoded DMA enable on Merrifield systems). Changes in v4: - Reverted the runtime `can_dma` callback override from `applespi.c` to avoid architectural layering violation, data races (TOCTOU) with concurrent SPI transfers, and execute-after-free vulnerability upon module unload. - Moved the DMI quirk forcing PIO mode for MacBook8,1 to the host PCI glue driver (spi-pxa2xx-pci.c) where LPSS setup occurs. - Formatted the DMI match using a structured `pxa2xx_spi_pci_dmi_table` and helper function `pxa2xx_spi_pci_can_dma()`. - Added a `force_pio` module parameter in spi-pxa2xx-pci.c to allow other users to manually force PIO mode for debugging. Changes in v3: - Added a `force_pio` module parameter to applespi to allow users to manually disable DMA for SPI transfers. - Resolved the execute-after-free vulnerability by unconditionally restoring the original can_dma callback (even if NULL) in the driver remove path. - Fixed the probe timing issue by applying the can_dma override at the very beginning of applespi_probe() so that all early initialization transfers safely use PIO mode, and properly restoring it in all probe error paths. - Documented the Bugzilla link in the commit message of Patch 1. Changes in v2: - Fixed an unbind/remove execute-after-free vulnerability by storing and restoring the host controller's original can_dma callback in applespi_probe() and applespi_remove(). - Split the fixes into a 3-patch logical series. Patch 1 fixes a pre-existing UAF vulnerability in the driver unbind path by explicitly calling cancel_work_sync() on the asynchronous registration worker work struct before devres frees the driver private data. Patch 2 fixes a pre-existing race condition in the debugfs interface where userspace could open the tp_dim file before the asynchronous worker has finished initializing applespi->touchpad_input_dev, leading to a NULL pointer dereference. We resolve this using smp_load_acquire() and checking for NULL. Patch 3 introduces a structured DMI quirk and a `force_pio` module parameter in spi-pxa2xx-pci.c to disable DMA on MacBook8,1. This forces the controller to use the rock-solid PIO mode from the very beginning. Best regards, Shih-Yuan Lee Shih-Yuan Lee (3): Input: applespi - cancel pending work on driver remove Input: applespi - fix NULL pointer dereference in tp_dim open spi: pxa2xx: disable DMA for Apple MacBook8,1 drivers/input/keyboard/applespi.c | 10 ++++++++- drivers/spi/spi-pxa2xx-pci.c | 35 +++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) -- 2.39.5 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v5 1/3] Input: applespi - cancel pending work on driver remove 2026-07-11 13:11 ` [PATCH v5 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference Shih-Yuan Lee @ 2026-07-11 13:11 ` Shih-Yuan Lee 2026-07-11 13:11 ` [PATCH v5 2/3] Input: applespi - fix NULL pointer dereference in tp_dim open Shih-Yuan Lee 2026-07-11 13:11 ` [PATCH v5 3/3] spi: pxa2xx: disable DMA for Apple MacBook8,1 Shih-Yuan Lee 2 siblings, 0 replies; 8+ messages in thread From: Shih-Yuan Lee @ 2026-07-11 13:11 UTC (permalink / raw) To: Dmitry Torokhov, Mark Brown Cc: linux-input, linux-spi, linux-kernel, Shih-Yuan Lee During driver removal in applespi_remove(), the managed private data structure is freed by devres. However, the driver does not cancel the asynchronous work applespi->work, which registers the touchpad input device. This creates a use-after-free (UAF) vulnerability if a pending or running worker thread attempts to access the private data after the remove function returns. Fix this by explicitly calling cancel_work_sync(&applespi->work) in applespi_remove() before cleanups. Signed-off-by: Shih-Yuan Lee <fourdollars@debian.org> --- drivers/input/keyboard/applespi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c index b5ff71cd5a70..3bdb9e7cfb8b 100644 --- a/drivers/input/keyboard/applespi.c +++ b/drivers/input/keyboard/applespi.c @@ -1822,6 +1822,8 @@ static void applespi_remove(struct spi_device *spi) applespi_drain_reads(applespi); + cancel_work_sync(&applespi->work); + debugfs_remove_recursive(applespi->debugfs_root); } -- 2.39.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v5 2/3] Input: applespi - fix NULL pointer dereference in tp_dim open 2026-07-11 13:11 ` [PATCH v5 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference Shih-Yuan Lee 2026-07-11 13:11 ` [PATCH v5 1/3] Input: applespi - cancel pending work on driver remove Shih-Yuan Lee @ 2026-07-11 13:11 ` Shih-Yuan Lee 2026-07-11 13:11 ` [PATCH v5 3/3] spi: pxa2xx: disable DMA for Apple MacBook8,1 Shih-Yuan Lee 2 siblings, 0 replies; 8+ messages in thread From: Shih-Yuan Lee @ 2026-07-11 13:11 UTC (permalink / raw) To: Dmitry Torokhov, Mark Brown Cc: linux-input, linux-spi, linux-kernel, Shih-Yuan Lee The tp_dim debugfs file is registered synchronously during driver probe in applespi_probe(). However, the applespi->touchpad_input_dev is initialized and registered asynchronously in the driver's worker thread. If a userspace process opens the debugfs file before the worker thread has completed initialization, applespi_tp_dim_open() will dereference the NULL applespi->touchpad_input_dev pointer, causing a kernel panic. Fix this by using smp_load_acquire() to safely load touchpad_input_dev and return -ENODEV if it is not yet initialized. Signed-off-by: Shih-Yuan Lee <fourdollars@debian.org> --- drivers/input/keyboard/applespi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c index 3bdb9e7cfb8b..4d339445e9c7 100644 --- a/drivers/input/keyboard/applespi.c +++ b/drivers/input/keyboard/applespi.c @@ -963,12 +963,18 @@ static void applespi_debug_update_dimensions(struct applespi_data *applespi, static int applespi_tp_dim_open(struct inode *inode, struct file *file) { struct applespi_data *applespi = inode->i_private; + struct input_dev *touchpad; file->private_data = applespi; + /* Pairs with smp_store_release in applespi_register_touchpad_device() */ + touchpad = smp_load_acquire(&applespi->touchpad_input_dev); + if (!touchpad) + return -ENODEV; + snprintf(applespi->tp_dim_val, sizeof(applespi->tp_dim_val), "0x%.4x %dx%d+%u+%u\n", - applespi->touchpad_input_dev->id.product, + touchpad->id.product, applespi->tp_dim_min_x, applespi->tp_dim_min_y, applespi->tp_dim_max_x - applespi->tp_dim_min_x, applespi->tp_dim_max_y - applespi->tp_dim_min_y); -- 2.39.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v5 3/3] spi: pxa2xx: disable DMA for Apple MacBook8,1 2026-07-11 13:11 ` [PATCH v5 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference Shih-Yuan Lee 2026-07-11 13:11 ` [PATCH v5 1/3] Input: applespi - cancel pending work on driver remove Shih-Yuan Lee 2026-07-11 13:11 ` [PATCH v5 2/3] Input: applespi - fix NULL pointer dereference in tp_dim open Shih-Yuan Lee @ 2026-07-11 13:11 ` Shih-Yuan Lee 2 siblings, 0 replies; 8+ messages in thread From: Shih-Yuan Lee @ 2026-07-11 13:11 UTC (permalink / raw) To: Dmitry Torokhov, Mark Brown Cc: linux-input, linux-spi, linux-kernel, Shih-Yuan Lee On MacBook8,1 (early 2015 12" MacBook), the LPSS SPI controller's DMA handshake and interrupt routing frequently fail or time out on boot, causing the keyboard and trackpad to become unresponsive. Avoid this architectural bug by disabling DMA and forcing the SPI controller to use PIO mode. Move this platform/motherboard-level quirk to the SPI host controller driver (spi-pxa2xx-pci.c) where LPSS setup occurs, preventing layering violations, TOCTOU races, or execute-after-free bugs in the client driver. Additionally, introduce a `force_pio` module parameter in the PCI host controller driver to allow other users to force PIO mode for debugging. Link: https://bugzilla.kernel.org/show_bug.cgi?id=108331 Signed-off-by: Shih-Yuan Lee <fourdollars@debian.org> --- drivers/spi/spi-pxa2xx-pci.c | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index cae77ac18520..31bdaa096d9e 100644 --- a/drivers/spi/spi-pxa2xx-pci.c +++ b/drivers/spi/spi-pxa2xx-pci.c @@ -18,9 +18,14 @@ #include <linux/dmaengine.h> #include <linux/platform_data/dma-dw.h> +#include <linux/dmi.h> #include "spi-pxa2xx.h" +static bool spi_pxa2xx_force_pio; +module_param_named(force_pio, spi_pxa2xx_force_pio, bool, 0444); +MODULE_PARM_DESC(force_pio, "Force PIO mode (disables DMA) for SPI transfers. ([0] = disabled, 1 = enabled)"); + #define PCI_DEVICE_ID_INTEL_QUARK_X1000 0x0935 #define PCI_DEVICE_ID_INTEL_BYT 0x0f0e #define PCI_DEVICE_ID_INTEL_MRFLD 0x1194 @@ -93,6 +98,32 @@ static void lpss_dma_put_device(void *dma_dev) pci_dev_put(dma_dev); } +static const struct dmi_system_id pxa2xx_spi_pci_dmi_table[] = { + { + .ident = "Apple MacBook8,1", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "MacBook8,1"), + }, + }, + { } +}; + +static bool pxa2xx_spi_pci_can_dma(struct pci_dev *dev) +{ + if (spi_pxa2xx_force_pio) { + pci_info(dev, "Forcing PIO mode (disabling DMA)\n"); + return false; + } + + if (dmi_check_system(pxa2xx_spi_pci_dmi_table)) { + pci_info(dev, "MacBook8,1 detected: disabling DMA to force PIO mode\n"); + return false; + } + + return true; +} + static int lpss_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c) { struct ssp_device *ssp = &c->ssp; @@ -166,7 +197,7 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c) c->dma_filter = lpss_dma_filter; c->dma_burst_size = 1; - c->enable_dma = 1; + c->enable_dma = pxa2xx_spi_pci_can_dma(dev); return 0; } @@ -238,7 +269,7 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa2xx_spi_controller *c) c->dma_filter = lpss_dma_filter; c->dma_burst_size = 8; - c->enable_dma = 1; + c->enable_dma = pxa2xx_spi_pci_can_dma(dev); return 0; } -- 2.39.5 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-07-11 13:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260711055247.5412-1-fourdollars@debian.org>
2026-07-11 11:49 ` [PATCH v4 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference Shih-Yuan Lee
2026-07-11 11:49 ` [PATCH v4 1/3] Input: applespi - cancel pending work on driver remove Shih-Yuan Lee
2026-07-11 11:49 ` [PATCH v4 2/3] Input: applespi - fix NULL pointer dereference in tp_dim open Shih-Yuan Lee
2026-07-11 11:49 ` [PATCH v4 3/3] spi: pxa2xx: disable DMA for Apple MacBook8,1 Shih-Yuan Lee
2026-07-11 13:11 ` [PATCH v5 0/3] Input/SPI: fixes for MacBook8,1 DMA timeout, UAF, and NULL pointer dereference Shih-Yuan Lee
2026-07-11 13:11 ` [PATCH v5 1/3] Input: applespi - cancel pending work on driver remove Shih-Yuan Lee
2026-07-11 13:11 ` [PATCH v5 2/3] Input: applespi - fix NULL pointer dereference in tp_dim open Shih-Yuan Lee
2026-07-11 13:11 ` [PATCH v5 3/3] spi: pxa2xx: disable DMA for Apple MacBook8,1 Shih-Yuan Lee
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox