From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796290647; b=PcCE/WZv9MoT1fm2nWN80UchRVNBttsQa5mH3g8Qm5H8FNkvX3+9JdrCND3MPGkvRQnK /8kIrt498+kKdv57LenLIIxlY+OVtgBKdYIxs/NfSs+Mf52LmItMuQZeLm9boqyroefEH RWJluGKmN2DbYMc7jTmpVGnmkcWa4obv8hvlZiTdzcRH4gmowO42qDHij6tmCm/QyO7Ga kMQO4viLEJX+gq3D/2RrWrmwokjTPsZY2U/hUEGeZbwbEfuWZMsEX9aSEin1l0E9Lr/HJ JfLppTeG6TJYL0q35B7EoyVJ8CRA/mzMdqQ+owoOEo1w4cuUKH7zYVthaHH1DojKqWA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796290647; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=f6hyHs1Xdy5gDL9Cl/Dz7bp1eZlMHdAzysmo7OJvf1M=; b=x6hIFy0d8iQuDdktF5epjS5XK34ACwX2o/U6Zi6IV7GDVevnGqL6BUm0TDx+8qx6qVJo BFiB2ryOJY1bgHKI5f3namYUlIiIaBnUJvIgp3D2IPJIcPz6hG43/DH+j04vXaGjGLr3C 7/7M4dWnE6PyCOZnYY8XL4XivOS2QeDs9/v88k7Dc1Zk7rLuu6naKqyHBHbBYl+dPEILh Nd1oAyW7F4cd5jl/xdJ3niNll2DevfEbeNDcQrrpqkt7jXJFzShWcpEtVF+Qbc4wbox2h qLcfrpgSCVPL3HvQQ76OCCYyB68RfskGDPOEpMlQsXMy7xt8u7ahW2M0QkJHAz6wCuA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SLJzy4Sh; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 259DC606A322 for ; Thu, 3 Dec 2026 09:37:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SLJzy4Sh Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5DE31F00899; Thu, 3 Dec 2026 09:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796290647; bh=f6hyHs1Xdy5gDL9Cl/Dz7bp1eZlMHdAzysmo7OJvf1M=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=SLJzy4ShDJcWvDXbtenowtR3UbrAGQGI9Obx13kldV1yAGWfOBWH6RS0EO0RofD8T Y9ohIWtpL/QGGJtBQc9+y6a22dBRpXvkL23S7hTgb71uRvbAqs21/bGR9FvXQ/x3TJ 9CWtf5bA5iNMQVb43knvIxb1L2L3RSDXBrb6HE28XY2xvqUW7WvREKzvLCWlcOylqy 9OD/bn1skbtlV2w+ncqpv1MgffKa0ZwTSYp/H96fOEDscXuwsCatvAPI1Ii+3f0PLd 8wBEZJXAUg8iuIFfzWzoNq8Bm8o5WJpqNrN8JbCV5ukWSRr3pnQ1pYasWmZsi0M4Di gtQ5s1lXybVnQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 3/4] spi: cadence-xspi: Add support for panic writes Reply-To: sashiko-reviews@lists.linux.dev To: "Paul Cercueil" Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261203091112.9449-4-paul.cercueil@bootlin.com> References: <20261203091112.9449-1-paul.cercueil@bootlin.com> <20261203091112.9449-4-paul.cercueil@bootlin.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 09:37:26 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] spi: cadence-xspi: stale INTR_STATUS bits and missed SDMA errors in poll mode - [Medium] spi: cadence-xspi: cdns_xspi_supports_op() takes devtree_lock in panic write -- commit eea24ee8b207103bf755dc8e3c7be6db03c744ea Author: Tanmay Jagdale spi: cadence-xspi: Add support for panic writes This commit advertises panic_write support on the Cadence XSPI controller and updates STIG command execution and polling helpers to run without interrupts, DMA, or sleeping when op->panic_write is set. > diff --git a/drivers/spi/spi-cadence-xspi.c b/drivers/spi/spi-cadence-xsp= i.c > index 1738a5983f054..974dd78518e39 100644 > --- a/drivers/spi/spi-cadence-xspi.c > +++ b/drivers/spi/spi-cadence-xspi.c [ ... ] > @@ -684,13 +689,13 @@ static int cdns_xspi_send_stig_command(struct cdns_= xspi_dev *cdns_xspi, > int ret; > int dummybytes =3D op->dummy.nbytes; > =20 > - ret =3D cdns_xspi_set_stig_mode(cdns_xspi); > + ret =3D cdns_xspi_set_stig_mode(cdns_xspi, !op->panic_write); > if (ret) > return ret; > =20 > reinit_completion(&cdns_xspi->cmd_complete); > reinit_completion(&cdns_xspi->sdma_complete); > - if (cdns_xspi->irq >=3D 0) > + if (cdns_xspi->irq >=3D 0 && !op->panic_write) > cdns_xspi->set_interrupts_handler(cdns_xspi, true); > cdns_xspi->sdma_error =3D false; > =20 > @@ -720,16 +725,16 @@ static int cdns_xspi_send_stig_command(struct cdns_= xspi_dev *cdns_xspi, > =20 > cdns_xspi_trigger_command(cdns_xspi, cmd_regs); > =20 > - if (cdns_xspi->irq >=3D 0) { > + if (cdns_xspi->irq >=3D 0 && !op->panic_write) { > wait_for_completion(&cdns_xspi->sdma_complete); > if (cdns_xspi->sdma_error) { > cdns_xspi->set_interrupts_handler(cdns_xspi, false); > return -EIO; > } > - } else if (!cdns_xspi_is_sdma_ready(cdns_xspi, true)) { > + } else if (!cdns_xspi_is_sdma_ready(cdns_xspi, !op->panic_write)) { > return -EIO; > } > - ret =3D cdns_xspi->sdma_handler(cdns_xspi); > + ret =3D cdns_xspi->sdma_handler(cdns_xspi, !op->panic_write); > if (ret || cdns_xspi->sdma_error) { > if (cdns_xspi->irq >=3D 0) > cdns_xspi->set_interrupts_handler(cdns_xspi, false); [Severity: Medium] Can stale CDNS_XSPI_SDMA_TRIGGER or CDNS_XSPI_SDMA_ERROR bits in CDNS_XSPI_INTR_STATUS_REG break polling and panic_write commands here? Nothing clears CDNS_XSPI_INTR_STATUS_REG before triggering the STIG command when set_interrupts_handler() is skipped (and cdns_xspi_set_interrupts() never clears it either). In addition, cdns_xspi->sdma_error is only set by cdns_xspi_irq_handler(), so an SDMA error raised during sdma_handler() in polling or panic_write mode goes undetected and stays latched in CDNS_XSPI_INTR_STATUS_REG. On the next data-phase STIG command, cdns_xspi_is_sdma_ready() then observes the stale bit immediately and either aborts with -EIO (leaving the STIG engine busy) or runs sdma_handler() prematurely against stale SDMA register= s. Clearing CDNS_XSPI_INTR_STATUS_REG before triggering the command and checki= ng it for CDNS_XSPI_SDMA_ERROR after sdma_handler() in polling mode would avoid this. [ ... ] > @@ -1550,6 +1555,7 @@ static int cdns_xspi_probe(struct platform_device *= pdev) > } > =20 > host->num_chipselect =3D 1 << cdns_xspi->hw_num_banks; > + host->mem_caps =3D &cdns_xspi_mem_caps; > =20 > ret =3D devm_spi_register_controller(dev, host); > if (ret) { [Severity: Medium] Can advertising panic_write deadlock on devtree_lock during a kernel panic? When CONFIG_ACPI is enabled (such as arm64 defconfig), both cadence_xspi_mem_ops and marvell_xspi_mem_ops install cdns_xspi_supports_op= () even on Device Tree booted systems. spi_mem_exec_op() calls supports_op() unconditionally before exec_op(), including when op->panic_write is set. cdns_xspi_supports_op() calls device_property_read_u32() for spi-tx-bus-width and spi-rx-bus-width, which on OF-backed devices reaches of_find_property() and acquires devtree_lock via raw_spin_lock_irqsave(): CPU0 CPU1 of_find_property() raw_spin_lock_irqsave(&devtree_lock) vpanic() panic_other_cpus_shutdown() kmsg_dump_desc(KMSG_DUMP_PANIC, ...) spi_mem_exec_op() cdns_xspi_supports_op() device_property_read_u32() ... of_find_property() raw_spin_lock_irqsave( &devtree_lock) <-- spins forever If devtree_lock is held by the panicking CPU or an NMI-stopped CPU, the pan= ic dump hangs permanently before writing the log or rebooting. Skipping the property lookups in cdns_xspi_supports_op() when op->panic_write is set (or when !has_acpi_companion(dev)) would avoid taking devtree_lock in panic context. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203091112.9449= -1-paul.cercueil@bootlin.com?part=3D3