From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EE183C1F24 for ; Sat, 11 Jul 2026 13:11:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783775518; cv=none; b=a6PW1qWH1bv4kZhgUttVZiSfXrwxHlxck4BuJwfQrFcdhGUjOVbcaZspory6SjKJsJCfwqHhz/jfPVHSKQBVJ+G+hT5BEBGcJNBZNG0gR+rvDydSNA1grk0YcyXKoG4HzRRZNK5L2APHTjvjf+81TY9Jwxf6DwKpA62DI3fyAgQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783775518; c=relaxed/simple; bh=YRU9k1lERNTxkTc+5YgTqgr3AgfJ0f+mJ5crHfuI4jE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UUjMOiSI/opF2t18tcEYI5Y1r/xj+U9iawUO6N9h//gK0Ka4ValHstV1F9yoRdCrni2dL39GgVYLhX75c/qT4gOm15whBQR/5Xs+PRBkg9eoJxSLGquwy8/sQcmwsasRe4yKYWevaDtW5QKI5+50gz7/m8T9rC+KgHp3XIQ5bp0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-3811f512167so2298799a91.3 for ; Sat, 11 Jul 2026 06:11:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783775512; x=1784380312; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=kc4/WVQy8fssVht4RAYrhTn5gJQpHPueTRIgj0gLJ/A=; b=RXOsXXeQjfjNM93kmLl4PiBNFWKydWRPkgO4EKfNZs2pDIvnXhQW1dkYgX5obHar8U R7G30yFNFB76lQjpta9JCXWAMYTw2MmyAOkwxq5BGTKXQjti9udIrNwiQZ8LvcinjSWy HK+0Y2DPo4MJ72IlGHK76S/xteCJeN8FH56lwMF3CWrIMRu/EO1pCcQpPgoiZQdXV8En YvKc4JCBxFr2PfMEUBcYGdFUF0TYqr6ZfXtXqN+PoxQCiB/6mmfJrs6A/VyBKiTzS/o0 NxmGwvDPjJ3HFF7kGhuE6UxNEykP8aPZW+a6pkIGQ95HaRluc/Eo5aupuAA40WJSqxBY zDBw== X-Forwarded-Encrypted: i=1; AHgh+RpIyna8eHtMO8jf4gZZ27WEYzZ4EMEp6A1JV6h9jCG9UpH1q5AeX7bPEvDNzP8CUBm0W60t3oaFjBW8yrc=@vger.kernel.org X-Gm-Message-State: AOJu0YyszYQ9UiXoYgGTlZ7xrtx8MHVpFsO08K1UQZTIZLI/dykbqyBo jkt+jtZzAyOHafBE0R+9ev8TuZSF001wtDWnjuSgQEi08KBeRzqGtKo= X-Gm-Gg: AfdE7cnXDgy0uoi6mxXf0qetXyBC8UI/NEXj+caLB0t1SMD6OucFqwuFJjJoup66Bqf QpJHTv5rK4DTnO2OgncTwWIGbt/+UnwwuS55BkD+XFX1jl3/LW6q+CuznYSRDDGUyiET97w3hWJ ttbsjab6TjOqDzcSzykCbNKBsYOp1DBE85hsR2TyE4vj6j+AS82UlBGihPRD4c6wR2hliutPOTh BDRL22/Gv7Wu9NW28E2QPDVd0SRx446L11LqFBZtyLG97xUAc7oQ/QIVOTepf0iioOhpZvo4PDo 0vSYU4D8cx4kkAS1nngNMRBx9Xo4XG7Q9Cd3iiFA2MOet714Z2PogsSK3J3GJGaHx7kctstwhXg JcOVvT9rs+yyKaAn1tiBxbvGGg/Co2jUWyhyGSN9F/Lah/mXAvCBRtialBkKSr2xkgKIjeOcEhU j3uwyjC3llxY3c+V9oO8D40TfqfuXyVcvGxVaPcUgIMwegaM4RHIY5ceeJyisLtmiwm7zWPiy9B hFn+eYGrb0vUxIbeDyZJnjIkA== X-Received: by 2002:a17:90b:4a81:b0:35f:b6a1:8d27 with SMTP id 98e67ed59e1d1-38dc75e184dmr2909302a91.18.1783775512460; Sat, 11 Jul 2026 06:11:52 -0700 (PDT) Received: from penguin.tail0a1999.ts.net (61-228-52-13.dynamic-ip.hinet.net. [61.228.52.13]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38a55557f25sm4136221a91.5.2026.07.11.06.11.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 06:11:51 -0700 (PDT) From: Shih-Yuan Lee To: Dmitry Torokhov , Mark Brown Cc: linux-input@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Shih-Yuan Lee Subject: [PATCH v5 3/3] spi: pxa2xx: disable DMA for Apple MacBook8,1 Date: Sat, 11 Jul 2026 21:11:40 +0800 Message-Id: <20260711131140.18777-4-fourdollars@debian.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260711131140.18777-1-fourdollars@debian.org> References: <20260711055247.5412-1-fourdollars@debian.org> <20260711131140.18777-1-fourdollars@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 #include +#include #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