From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 9C0E9356760 for ; Sun, 12 Jul 2026 16:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783873516; cv=none; b=j7gfDMw1LlbUrtl2PeJ4+hsd3Jn1nAj1hwZl4TrbGaBk3CH9ubiJAj9XrAGwBnGhf2zFXbDnaOqZsJovinE0mukj5UiNwIjP7uBkJltyEzrJvSFjxBaTY9xI5LlkaSpay9lcr0znTDpJ1bSkEbWHHHh+z7pjEMm53BlWUS9rQ94= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783873516; c=relaxed/simple; bh=o2Vhi7GivQSf2+k7EfqeLt1YyVoT3zZsUCJbqV9r+oI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MQogd4/wP+MAQiLspnuci4Bp2arpTuFYokSD0sCSJn4Xlc1sWsIyBt19oqwH/SbQeuhlybhWmz4d5O+dfLhZhOL2cpMPydmqYxDlQAYw1xxRjvAyhpms71z8Zz7s+TPFUBAIzHTQcxMvMzrFxHWPESbVN7XabZi6uMdsf43Yg6M= 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.210.179 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-pf1-f179.google.com with SMTP id d2e1a72fcca58-84a2c90e383so290375b3a.0 for ; Sun, 12 Jul 2026 09:25:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783873515; x=1784478315; 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=K78DbQmH0SJ594fefmYwIC8GEcVEilCgoWHJzZIgOoM=; b=RcNblHudDlUMFf9DOkZIH1wl/Ue88JXj9NTiABTBfh7RSdPN8flgbgJveUIdazM1yY 0G4n8Be2PmsIS6We/PFE6Vsujj7u/wAgg6IYwVZBvfXH/fNQ2knaVEULVMZh5HVCPLHe 3Sn8Ym8cJXGeL+fRXBLMhD7iI8sbaHxyWHnW/+/tphVN1Y6JaWbODfitIYkMxyhRsSwF nOoXCPuB94d0T3+xOmi8lcLtRL4qeWTM/OjSLmhmUddwaCojMCqAAUnGfGeE1GPrt3F+ rKpwjDwzswoAGfr+QfrWrSu1SkgD/ZM3r7ezhN86cmjP5Qh9Hjn486OSPIXEF3Meh4wb LFHg== X-Forwarded-Encrypted: i=1; AHgh+RrY27WS0CvImnWKa6GxnMXLXxPAZulaWqHlNRgosGDiy4ElmarAPkestC1HWHMwBdiBvXffqvUYN5kES2U=@vger.kernel.org X-Gm-Message-State: AOJu0YxEYxWhfCU+KpgkWn6ZVm+aw+VRpDZVOzZFhmPabbYbbG5JNlE1 ycJb+fsUEG4FWXnJSlTg6M80g2TcRLyhk551M1e4QkKhKv/vG8sqQB4= X-Gm-Gg: AfdE7cnJ2w2XnnF8e3ZIHTkPDbHqMcrXIsMTG9P94SAvFarDFnxr3dY1h3JVow/2xUW f6WdcBTX3otiGvotc4LaFNBJ6myyL17X2m8pCWBc5c/gXnYscdEN22sKbMCIay4+7HSkZ8hLJdv MD0JCZnnEgrSYSFAWxfmAxPUAY4368xwWo+P89q8QgrEU8HJNp9cd4nDkltL+U26+2kdb8YFxhI UN6hVToKIwtDucIYAq9m00yMTlcaESAps/wF16OhoC46b7XLdhw673y/+GSPy6ZBnFeN+EgNQm4 XESyAJ32JWSdz71vW0kBZhs7aTBN+9jiwjKpY6GQ1P0vK3MfSesx+pJ2MzfR5RiEjgFa9HSfUc0 HAlwKcxZyGRJbN+YyRWYVklbwvTU5PKTCyg8UVNGS9Xet0UhMF0iR8+I/u+WrD6qwWb8P6K/+ce dFMJhWQx3WxqgrowHyI8elO86vLB00Bvqc+19avlrGmtsRTfv/AMv5N6KlM9FCmNx54YTBl6kyQ ZGgTj7ILT846LpCrx1w4E4JdBVX X-Received: by 2002:a05:6a20:3d0c:b0:3a8:800:bdf4 with SMTP id adf61e73a8af0-3c0f0beee64mr13024754637.33.1783873514864; Sun, 12 Jul 2026 09:25:14 -0700 (PDT) Received: from penguin.tail0a1999.ts.net (61-228-44-142.dynamic-ip.hinet.net. [61.228.44.142]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13b93ae3b45sm12329887c88.15.2026.07.12.09.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2026 09:25:14 -0700 (PDT) From: Shih-Yuan Lee To: Mark Brown Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Shih-Yuan Lee Subject: [PATCH 1/2] spi: pxa2xx: disable DMA and fix runtime PM for Apple MacBook8,1 Date: Mon, 13 Jul 2026 00:24:19 +0800 Message-Id: <20260712162420.7453-2-fourdollars@debian.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260712162420.7453-1-fourdollars@debian.org> References: <20260712162420.7453-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 at 00:15.4 has two related problems: 1. The DMA handshake and interrupt routing frequently fail or time out, causing the keyboard and trackpad (driven by the applespi driver via SPI) to become unresponsive. Force PIO mode to avoid this. 2. When DMA is disabled, pm_runtime_allow() must not be called for the controller, because runtime autosuspend clock-gates the LPSS block between transfers. Accessing its MMIO registers while clock-gated triggers a PCIe Completion Timeout which causes a watchdog reset. Move the force-PIO quirk to spi-pxa2xx-pci.c (the LPSS host controller driver) to avoid layering violations in the client driver, and guard pm_runtime_allow() with the same pxa2xx_spi_pci_can_dma() check used to set enable_dma so that PIO-mode controllers stay permanently active. Link: https://bugzilla.kernel.org/show_bug.cgi?id=108331 Signed-off-by: Shih-Yuan Lee --- drivers/spi/spi-pxa2xx-pci.c | 38 +++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c index cae77ac18520..cb61f1d2d9e6 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; } @@ -303,7 +334,8 @@ static int pxa2xx_spi_pci_probe(struct pci_dev *dev, pm_runtime_set_autosuspend_delay(&dev->dev, 50); pm_runtime_use_autosuspend(&dev->dev); pm_runtime_put_autosuspend(&dev->dev); - pm_runtime_allow(&dev->dev); + if (pxa2xx_spi_pci_can_dma(dev)) + pm_runtime_allow(&dev->dev); return 0; } -- 2.39.5