From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796342191; b=KKCTKbEzvuZ/lwVXU5WsK3jiM14IGXVUQbX+bbnl6Ua/SIdReMOq1qV5RbW4b92decCU 9zXtNcruEzOr+QojmoYkUyBSk/E4wrD4afFkoRpG6/KxUHHyjxkTZj3xHwiqunjyg0XO3 fZY5epdubRh9+EvdhnQ8f4pqiDnip2xeOaAwL36o5tQHEwOnwMo/eUBFKVUhCvM7mWYKX xn1pB1J7vyv45Zi9DOm5YnmzNqpxj8OBSUbNJ7D8B0AFspiIyYRoCP79KgJ+9GGs1ooFf FgHx7FRd9nWCuDTgWnDK02l28YiAxcobXexbjC46UT0SLOFeW0MZz5ndoh8lNdKD8Eg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796342191; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=e9qfmmDE4CN84vmEzezWG68OwkU/cQLQwEEQoT+2CpM=; b=jJ9S83BIpy62ZW0dO0geBYGMS4uNPxadKrLFDcYbXDUkpHS2xk7+K9I4D8MaJznagqLP dTBW5detV41HKF9xDT+C5d5nrvMWyWsVT5FTNdYBhTUOICiKl7YYLX+0GJ8LPaOwcdCJx fu0wOBoUYyNGTb4iP9ZvzLMQ8KNjXHAcMlNZ0gOPrsZULVC1n6D2E6dsDCcKlHKSy7o2I REM8+gEdw7d/LAkrKrtn6MiIZXxP70QhlmYYpn/yO2rRMAMAaPy2UC/OZUcwRwL6h6ko9 RZ5uH5pjk5em/sbCM5nCdgKTk43ZTaHvyMNCaPeo/YRmevgNbq3eylWQJZBB1P1LoQw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ynt367ry; arc=none smtp.remote-ip=209.85.214.173 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73C86606A322 for ; Thu, 3 Dec 2026 23:56:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 73C86606A322 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.a=rsa-sha256 header.s=20260707 header.b=ynt367ry Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2f052ae3c86so2818585ad.1 for ; Thu, 03 Dec 2026 15:56:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796342191; x=1796946991; 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:content-type; bh=e9qfmmDE4CN84vmEzezWG68OwkU/cQLQwEEQoT+2CpM=; b=ynt367ryC9mQLBWmWFU/sJuNgdHS3q05iGnO3uK0+oD0nWobbaJw5zReho/l9D6LMq o8AxgHuO6yGXEFBZ8eAM+cRNPCLZHTxeZQJTvdFbnWAsnW4nxg3rPDj4iDjmp7nv1S07 9KK7vncEqJKA3PV0eG6TRpEVR5JP8Ey0YzNcmPMh0dLPlpqfwmURVaQvRTYrkYAaExog tc9Fkxzx8Vhymn8Wc0t2GN8m55p/RAaAHbvEood2GlvAjbs5gaDM7yM3RUhCIAxKolUF 7eKOvgTdus6+jKu8aem6mnZ77O5jYtZRxsBEaICqnt+M801r1V2HsGNwDVNFKVN5n9r+ QIlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796342191; x=1796946991; 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:content-type; bh=e9qfmmDE4CN84vmEzezWG68OwkU/cQLQwEEQoT+2CpM=; b=XKDoJMlN7gxrI4rZU9WM/ldn9uoAgOT+pXgaz0oXOHmoDN1cuwheWbd1bQSZ9F6GlM d/tRTLc73l/iDpmS7zrg0ZLiGCYcrFz64paVmp3Ge7fDiwA0GSQgy+Xunz28dEdCpkGE iLePJ0pbIWxyp0GncLAeGN7bDqvNTNnxxSfYck02FIyaOmmgpOC5xL2aYFsPaM6JVPO1 p6E2+pjNfrKD9ubELASwLO0pJMHG9JvCQnKdXjI023Sk17+rwsDc6Ghzz97NR63QZlN/ v3TF2K7qnW1pYexsRC31P6FUGD7e4jDIs/L+Dng9v4bLMNIhMDdcyuBE7VEZlXALn/0H cEeA== X-Gm-Message-State: APuU4Z9vRWVmtoN6twh9HcbCVcSOZR3ClB1tX8aUlPslh5QY8VOUw/9N Dp28xLoRlAjO8/cgMSHxskPvLZsgqkxSf4hGDUGw2ygIQSG90TCfjCIB X-Gm-Gg: AZFdTZcxoM1dQuc0dOFd8l/nhTP/sM4REHbOL3rQa5j7yMbCLFH9cnIzqq86shIKm+N R7WENZf5btDYanpAukfq+vE9mTMY9fxHtbb+Jl53Bo2C3NzwwrDJEfBNzpLmbsrx+SKFcYTzYC1 K1DYRhgw5P/E3y0NVTsdHxoHwq44X0/yXmYAZSozzriPKrg9KX+1ubMtwoOxEOlgS75vEZLOwpS tnJaiyKYRmqj+sf5chffxj2h6aSFILCFLVI1lcG/s7fdMJBM3eDzNd8HAioNPUlj5OocjkjOFgX XtB9i8PcIZ/muipeHhZ3UjELCGs4h0lzQxBlUGNW3Rhf779CjU5YvN5F2aBbvupe7lsRe+3xOtJ HJGMFdKmSWxTWbQKzrqlkEDJ0gz1/boHBKIzB7B2neNSwsCM1BAHBdWV9ekoUWEo1VUvdOctKGU 10qv7IuN+Dt4dzxa8N/FZRK5V9Y3CtxmRjPT9dnjFs/m+Y+MPLz+ot5n/MbAMRYxMormzhqvfyr ZNtWvt8Djh2bod+ZCpS3rC3pywoTCqtPfUNlAyN5GcYxooTNKUxadGay/U7Mx68e6bxa4P8h9UG MXPx9g9jXEMRykYx4D03oBCf1d6+zpT453WvHrFerVUxEep0/TMI7aX07MFbtDpRS1xFQTeg5b4 x3D9DkryeMqhRUdGAfK7ocMTOtks2xlXEeq6uo7Cm7io3/UPzHgSdoTkQFj5H2IID/Rg7HMn4Gr ZdxjbSMLwJ/Sxpd2UHTZXLGO2XCaws8vdIrty3XXF12+LWpmlJW53ruNCJtUaYt4MLZS7KSeyCM Srbj1v4S1l2Y3w= X-Received: by 2002:a17:903:2f83:b0:2e9:740c:36c with SMTP id d9443c01a7336-2f1ba1e6b64mr1636335ad.41.1796342190665; Thu, 03 Dec 2026 15:56:30 -0800 (PST) Received: from josephctchan-96c-1t.c.googlers.com.com (95.100.125.34.bc.googleusercontent.com. [34.125.100.95]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f1b7967a2bsm1660345ad.68.2026.12.03.15.56.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 15:56:30 -0800 (PST) From: Joseph CT Chan To: Mark Brown Cc: linux-spi@vger.kernel.org, David Lechner , Bart Van Assche , Joseph CT Chan Subject: [PATCH v3 0/5] spi: spi-mux: error handling and delay fixes Date: Thu, 3 Dec 2026 23:56:20 +0000 Message-ID: <20261203235626.1437609-1-jctchan@gmail.com> X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Joseph CT Chan Hi Mark, This series fixes four bugs in the generic SPI multiplexer (spi-mux) and adds a KUnit test suite covering them: - Patch 1 releases the mux and resets current_cs to SPI_MUX_NO_CS when spi_setup() on the parent controller fails, preventing permanent mux deadlocks and stale settings on subsequent transfers. - Patch 2 resets current_cs to SPI_MUX_NO_CS in spi_mux_setup() so that setting changes on an already-selected child take effect on its next transfer. - Patch 3 finalizes the child's spi_message with m->status set and restores message fields when spi_mux_select() or parent spi_async() fails, instead of hanging callers forever or leaving the mux locked. - Patch 4 saves the spi-mux device's own cs_setup, cs_hold, cs_inactive, and word_delay at probe time, merges them with the active child's delays before parent spi_setup(), and restores them on unbind. - Patch 5 adds a KUnit test suite (spi_mux) with a Device Tree overlay and enables it in drivers/spi/.kunitconfig (alongside CONFIG_OF=y, CONFIG_OF_OVERLAY=y, and CONFIG_SPI_MUX=y, without CONFIG_COMPILE_TEST). Run the suite on ARCH=um or x86_64 with: ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/spi ./tools/testing/kunit/kunit.py run --arch=x86_64 --kunitconfig=drivers/spi Tested with KUnit: - ARCH=um (full series): 20/20 passed (spi_dma: 4, spi_core_optimize: 7, spi_mux: 9). - x86_64 (full series): 20/20 passed (spi_dma: 4, spi_core_optimize: 7, spi_mux: 9). - ARCH=um (full series + CONFIG_SPI_TI_QSPI_KUNIT_TEST=y): 21/21 passed. - ARCH=um and x86_64 (full series + CONFIG_OF_KUNIT_TEST=y and CONFIG_OF_OVERLAY_KUNIT_TEST=y): 35/35 passed on both architectures. - ARCH=um (default kunit.py run): 924 tests: 894 passed, 30 skipped, 0 failed. - Before fixes, ARCH=um (patch 5 only): 20 tests: 11 passed, 9 failed (all 9 spi_mux cases fail). - Before fixes, x86_64 (patch 5 only): 20 tests: 11 passed, 9 failed (all 9 spi_mux cases fail). - Before patch 1, ARCH=um (patches 3 and 5 without patch 1): spi_mux_error_test 3 passed, 1 failed (parent_setup_fails fails with -EBUSY on mux_control_try_select). - W=1 builds of drivers/spi/ on ARCH=um, x86_64 built-in, x86_64 modular (with MODPOST), and x86_64 KUNIT=n: 0 warnings. - Not tested on hardware. Changes in v3: - Rebased on spi/for-7.5, which already includes commit 91db5febb159 ("spi: unoptimize message when queuing it fails"). - Patch 1: clarified in the commit message why current_cs is also reset to SPI_MUX_NO_CS on failure (priv->spi already holds the failing child's settings). - Patch 3: updated the commit message to reference commit 91db5febb159 directly instead of a separate unmerged SPI core series. - Patch 5: dropped the drivers/spi/Makefile change (already includes tests/); added CONFIG_OF=y, CONFIG_OF_OVERLAY=y, CONFIG_SPI_MUX=y, and CONFIG_SPI_MUX_KUNIT_TEST=y to drivers/spi/.kunitconfig; dropped the redundant "select DTC" from SPI_MUX_KUNIT_TEST; added MODULE_SOFTDEP("pre: spi-mux") to spi-mux-kunit.c; used "{ }" for zero-initialized structs and sentinels; corrected the SCK delay test description in the commit message. Changes in v2: - Split out of the v1 14-patch series, as David suggested, and split the four spi-mux fixes into four separate patches. - Patch 5: used designated initializers for the test tables and trimmed the comments. - Moved the AI assistance note from an Assisted-by tag into the commit messages. v2: https://lore.kernel.org/linux-spi/20261103225308.3633046-1-jctchan@gmail.com/ v1: https://lore.kernel.org/all/20261102163023.2574632-1-jctchan@gmail.com/ Please consider this patch series for the next merge window. Thanks, Joseph Joseph CT Chan (5): spi: spi-mux: release mux when parent setup fails spi: spi-mux: re-apply settings after child calls spi_setup() spi: spi-mux: finalize message when forwarding fails spi: spi-mux: pass child CS and word delays to the parent spi: spi-mux: add KUnit tests for forwarding errors and settings drivers/spi/.kunitconfig | 4 + drivers/spi/Kconfig | 13 + drivers/spi/spi-mux.c | 124 ++++++- drivers/spi/tests/Makefile | 2 + drivers/spi/tests/kunit_spi_mux.dtso | 42 +++ drivers/spi/tests/spi-mux-kunit.c | 507 +++++++++++++++++++++++++++ 6 files changed, 688 insertions(+), 4 deletions(-) create mode 100644 drivers/spi/tests/kunit_spi_mux.dtso create mode 100644 drivers/spi/tests/spi-mux-kunit.c base-commit: 7ab8f46f497dfc470973192f77cb226f4964ff87 -- 2.56.1.915.g69d5ec7298-goog