From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 F10193C1966 for ; Sat, 11 Jul 2026 11:50:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783770608; cv=none; b=IKa4VbFznEH3c5567RrtuLhUYa7CGmfLq3oNLLnxBWKpVPWzmE6KDMRKW2/DvrsVxjHw6E3jPv5LJ3gFJCo8im0ciCxbTVwyRKgsKWGbX6z1ILrWfIAS4y9OEfugvLNkpOPlkh26+SNId5aO76/XS1a7Z2z1abdMaM4qaQWtIog= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783770608; c=relaxed/simple; bh=FImt+bsSj++vXBt8dl06uq7wyPYDWF8eV3nAHecKHCA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Riqmlesfq7J0TiJFmslTrmXJcYbwrYFyLnthogOirGX7DTm7KYl2QC9vId+m7MdEuUI/TEzDOkX6F3N7ZcWpkj6tMBIriycmpcy5D09inc4k59DihuqB4/o03UAjMPPR1p9h7i51bnGx3H6Id7zJtLZPLhV4O0g1y+DXeK+pOX0= 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.53 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-f53.google.com with SMTP id 98e67ed59e1d1-384930ca5e2so2054217a91.3 for ; Sat, 11 Jul 2026 04:50:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783770606; x=1784375406; 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=HRFub8kSA/fS8InEMuVJNmE6mYQvQVfDODAvVSAOiMA=; b=ep69Ktql5lRngGwapCRgBhkkf6358x0oW1Y4S8ReCsphk41dy9Sc6TxkWqaboPdba3 Fw4BW/+aW4/D9E+zwFniKiVYCrPD7THynFeVkD/vd9AA/ApCadezPgom7PLpH834nMqV mjLvvd/W8dD1z16fVmNUW+KUw76c2oPr8pprjuQzaRGCUvhCS0n1+opNs9Tw0BnpxKcj pJXAFyq/jxJ7Gt73QCqgW8su/rz+0g6lOoc4zlzJLZ2YOXJjnh/9U9BlDdavLNmupyPe Z/NzpOO5zJeoj1Sb1NU9pOO75wMv8hNvtw88WEF/m4Id8RR8hTUEMiFLCNH/+JoD7l8U 1R5g== X-Forwarded-Encrypted: i=1; AHgh+RqSVs5C4A7yfhAEhnJoeG8MdTbDjey5O1qkHyZmDvIF8s3e4we5FvHA2MBZKW9s99exBuv5MeqozisR3+8=@vger.kernel.org X-Gm-Message-State: AOJu0YysVgTXZkmxAeFwqZ8QTMzHHKxtKZwKFD/Aet5UIeH9A8cJtD8J mm9n9ajitFq25EXFtTAi20XejtI2/xnqBASxFYJXUfIlShAjKA23OrRZgL8b+NKHtqnz X-Gm-Gg: AfdE7cloWvK0QexigE+70W+OuP9XNr0J9E3wKnI0wKOldRzriQVLv0eXvVbuFdaPA0Z NNCngmeuDck6BtHIyuOu3/CmEKeaOQOSNVnCPsDs844523Y61Hu2bFpZvU0BWmyHzwJjYcwdD0r IgB2y434ZYmyXL/ODT52t49g3EzahL524vD8lZRSwMbZsmd/HPV1XJUls/AP5J45XVDtORF/1eg Gqwv9lcpGEDursWJfV8Gdj1WumCTQ5EBUsts3+5lDgCOkfRhW4AVvS87c3GR3ojXxpEuAffsF1o ijkyBAJ5fn72RDRn+31B6+PR2/vMwxdPeAQjdB0HBmFmRILBBS8a5I1WgfiDdUZy9DYEkhPzxR6 DH9uY8sCvy1t4pkxt+jcSSpvSk1ROSSa1TUuT/CDikpDB+gcZfP0pZG0BgYp8zcdinMfw6fNjgV 0woJ4MU+hC8fRuHOmg+qifErmUlJ7oJcGA7AwwvvVPrgPJ0/VIIfcVmpCBrlJt6O+TOw+/M0Fz/ kbbSSlBlPWaQgyAGhFGpcHTBw== X-Received: by 2002:a17:90b:3806:b0:384:5dbc:cba5 with SMTP id 98e67ed59e1d1-38dc777c6d4mr2735418a91.26.1783770606205; Sat, 11 Jul 2026 04:50:06 -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-38a5506b48bsm3957570a91.1.2026.07.11.04.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 04:50:05 -0700 (PDT) From: Shih-Yuan Lee To: Dmitry Torokhov , Mark Brown Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Shih-Yuan Lee , linux-input@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 3/3] spi: pxa2xx: disable DMA for Apple MacBook8,1 Date: Sat, 11 Jul 2026 19:49:37 +0800 Message-Id: <20260711114937.16670-4-fourdollars@debian.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260711114937.16670-1-fourdollars@debian.org> References: <20260711055247.5412-1-fourdollars@debian.org> <20260711114937.16670-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 | 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 #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; } -- 2.39.5