From nobody Thu Jun 11 11:31:12 2026 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) (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 16F9D3F928B for ; Tue, 9 Jun 2026 10:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781001010; cv=none; b=PUf8HityaPRZ0sm3CbV0BEbSOLkxHwK+GbLdreCpbGs6WcB7bEYpZjK84TJ0YsY79YOCl3UrH0Hka3iuL5cC2Ni12RanCOIqml/kIENuouQkRJb+zw+XV6XP+Fbd6vMhZPlZ0U/39fQbXsC2dYFz3pqohVP3Ed3YdppwLcuPELY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781001010; c=relaxed/simple; bh=L2oliIFC4oKO91SZyPLNwn39SqJ1zt98y4XKspRGfxY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UXTWc/5MBwcHiowZudspcuYiLMrg/LeyS/X9SmYvmghEPt0NlMOJJuJRAfSnNJTSlXgShp1CPN2bcyh4Uqe4EE9cO1DRhScaDH0u4SxNG/Tay3aoyfR7Q0z7paIk5zlhTnWV+WQPK7DIzHAyDfxEKtCA+UWsIThcnYhGBChwuOk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ie+3PcQK; arc=none smtp.client-ip=209.85.215.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ie+3PcQK" Received: by mail-pg1-f195.google.com with SMTP id 41be03b00d2f7-c8588ec1b44so3660187a12.1 for ; Tue, 09 Jun 2026 03:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781001008; x=1781605808; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hHqL/YSEXhmKRvM7PhCW92N+t8/AtMxfb6dfA2XpOXc=; b=Ie+3PcQKDFyzuMZjJd/xEUGt9HZQfaMYDWkiqm+y1J2X5/QyWL4JxOInpfN4aYcHlC fC5PlsSx3EjdlwCC7h7J17XW59iRtdQqXk/HF3MQ/nmfnoWIkXAZPB0JQzXG5GLrzHEQ nG5fJcnhbXWns0I9SqPxsMAI82lFTB6L52GysqbPmfxIGZ+oT1JdNWgW3KZu4EtRDXKJ rgMJKCgGlZ0542gL2cgwozd+4d6PXnjSb0wxxpZqt1jinZsstnbYKk/gqsr+yPo8zzxS AlHSLvwuOltmXmqb6ZUKrnaxLF+D8CGXEAn52WfXy3QXlAEfHlPnGxd7vBlHdK30ky2P QY5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781001008; x=1781605808; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hHqL/YSEXhmKRvM7PhCW92N+t8/AtMxfb6dfA2XpOXc=; b=cS7y63+eBQ2tSNjoVismmyAy/0XzUHtexa4TgDhWjz8wZIpt1dM2IeCcWsaDgsPl2T /4I+JjFTwXra+UG04woMKgRlbQqpHpFSzFiDrkaIOlYqvopQj4U1cav9sKVKsAfavibE Y6rhSNlABMqy3mqFFBXIgqEWTee7L27EUFf9ygRGx1rx6hGXrpfocrAGysh7uG3ER3RW QFuWMFabnoGnz0d4zM8BUQTZI3mt7m93I5tefK3FC5EeFP/z1zdGH3Jfu27MXaHi7bUt 6jHw9Bz+NFUu+hWcMimmeIu/mvVPaq2zZbxGcP8geJmoXGR6RCUCGSVWxUQGb41cNlqv gN9Q== X-Forwarded-Encrypted: i=1; AFNElJ+qezZOJH1sXHnr8IZLh8hUbdzdNL/yoFYRR1Pi/zEO5x+sKVwVDjPaG1lkcKaCxzR+fw0+e7yvfhQIsJ4=@vger.kernel.org X-Gm-Message-State: AOJu0YxSqutP7QlUkpQipu7+sWhkIh9p9HBjtMFCMwGvmYzg5uSwUo15 UnZSt1aq/uErSiVaa6KPbaUF5qcWEDhHMkt4hhxxOeHEhLOJ/cpD6AyZ X-Gm-Gg: Acq92OFMuV6PFdzxCx0gONOiQGqTGVBGcVRiwU/hs6Lo+Up/eQ8QIAlMjJJDoCIG802 f2wmAtmUa6gng0x9S6TlwIiWRZIAwsDONT2/XXQROKGMZwGDNrRF7YtBN5dhlHGEG5R3X9pnS0N JKi+WzOYPYcK7TZ74iGWitxOLINUrDMs7W3dixJcQiK4VwGmTLOJgdWw0KmiKWHzTBJ0Zh+XSLH mwk/YGzTGgIcxWacCCc8YNL7U6NfeB5H5981NZrjh3VDcxLUCB017iHf0b5TbwLh0ls1zcVF8sv sPSCBsfJTOrH+wXE9r1bqUKtrMnO0EBEGGnJwkooNrcRy/b/wLqgf63eDKjC65hPNJzdbpZWjdZ nmF/Mox2sV0+XLw5LzMNkftv20SOCQxvK+x4S42zNSlRT1cq8yavL6qI21WFRQXU4zVeSTu/8vF 6PKLPBz1PEf/mTRZBVkuYG6SllCWA= X-Received: by 2002:a05:6a21:9d4c:b0:398:89b6:1b41 with SMTP id adf61e73a8af0-3b4cd066bc8mr23132697637.32.1781001008433; Tue, 09 Jun 2026 03:30:08 -0700 (PDT) Received: from Dell-5540.. ([2001:926:3:e0:b19c:a6f:385d:df2d]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c85df04ff24sm18328762a12.14.2026.06.09.03.30.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2026 03:30:08 -0700 (PDT) From: Peng Yang X-Google-Original-From: Peng Yang To: Mark Brown Cc: Serge Semin , Jonathan Chocron , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, pyangyyd@amazon.com, pyangyyd@gmail.com Subject: [PATCH v2] spi: dw: fix race between transfer IRQ handler and timeout handler Date: Tue, 9 Jun 2026 18:29:55 +0800 Message-ID: <20260609102956.2811-1-pyangyyd@amazon.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On SMP systems, dw_spi_handle_err() can be called from the SPI core kthread while the IRQ handler is still accessing the FIFO on another CPU. Resetting the chip via dw_spi_reset_chip() during an active FIFO read/write causes a bus error. Fix this by calling disable_irq() before the chip reset, which masks the IRQ and waits for any in-flight handler to complete via synchronize_irq(). This ensures no handler is accessing the FIFO when the reset occurs. Fixes: 0b6bfad4cee4 ("spi: spi-dw: Remove extraneous locking") Signed-off-by: Peng Yang Suggested-by: Jonathan Chocron --- v1 -> v2: - Replace spinlock with disable_irq()/enable_irq() as suggested by Jonathan Chocron. This avoids touching the IRQ handler hot path entirely. v1: https://lore.kernel.org/linux-spi/20260522095727.18307-1-pyangyyd@amazo= n.com/ drivers/spi/spi-dw-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -468,10 +468,12 @@ static inline void dw_spi_abort(struct spi_controller= *ctlr) { struct dw_spi *dws =3D spi_controller_get_devdata(ctlr); =20 if (dws->dma_mapped) dws->dma_ops->dma_stop(dws); =20 + disable_irq(dws->irq); dw_spi_reset_chip(dws); + enable_irq(dws->irq); } =20 static void dw_spi_handle_err(struct spi_controller *ctlr, --=20 2.40.1