From nobody Sat Feb 7 21:24:56 2026 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B56F81DDC1D for ; Thu, 16 Jan 2025 22:55:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737068140; cv=none; b=nLeQ9x5MVepEEMmB8+Jp02drB0jhN88uyQGtEgfSS42CBZQDzBfkEcB6rdTKOOQmOEKcY5+rKiVZPGDaOLiJ1yFD09UqNWGI1dFfO7BW0TVOXoEz0Mxo62m7rqfqRdAuOJl9IR6ndfzrKqt5R2degZ+Z05xeSBkb5TTu4LErpT0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737068140; c=relaxed/simple; bh=hUXs6LILra9jbW4eVbc1ZvdB/92/mHOgKG067hYliAo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q5lhhTmydDiaFRo86SWKA1kbLDnVYldX2A6ImHD/n29K+v4Znjv0kkedQicZvUn2II6ebysOEJRxmON0FE+wgor4kjRlrtVPJsWCPWQU2tOVgT0LABIBlHGarez1reZclj0SCSfeBf7f1bn0MFIYZ+b9mTkS9Vkpajil8mjAbX8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=G5ILOaLW; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="G5ILOaLW" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1737068134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SzhM/Cr/Vt/YQ+Zr0i1+zKtZFp4IFfQdz9T0ezUL7Xo=; b=G5ILOaLW37eG2x8g9HsqxICmTElAyMnTR2Jl+XD+EYxSkDF9IRY4XsRCMro0vtN8h4NkL7 gvlxUfET2ipfpkFMv+0UZ4d+a58V2kHh2k+trC6Y0vz2T3ZNCiQJJFD0mk0+uFNoWELZ7i J+emAHK3hJNGhg5794Hs++Ny7F6Tk04= From: Sean Anderson To: Mark Brown , Michal Simek , linux-spi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jinjie Ruan , linux-arm-kernel@lists.infradead.org, Amit Kumar Mahapatra , Miquel Raynal , Sean Anderson , Conor Dooley , Krzysztof Kozlowski , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH 1/5] dt-bindings: spi: zynqmp-qspi: Add reset Date: Thu, 16 Jan 2025 17:55:17 -0500 Message-Id: <20250116225521.2688224-2-sean.anderson@linux.dev> In-Reply-To: <20250116225521.2688224-1-sean.anderson@linux.dev> References: <20250116225521.2688224-1-sean.anderson@linux.dev> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Add a reset to help recover from cancelled operations. Signed-off-by: Sean Anderson --- Documentation/devicetree/bindings/spi/spi-zynqmp-qspi.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/spi-zynqmp-qspi.yaml b/D= ocumentation/devicetree/bindings/spi/spi-zynqmp-qspi.yaml index 04d4d3b4916d..901e15fcce2d 100644 --- a/Documentation/devicetree/bindings/spi/spi-zynqmp-qspi.yaml +++ b/Documentation/devicetree/bindings/spi/spi-zynqmp-qspi.yaml @@ -36,12 +36,16 @@ properties: power-domains: maxItems: 1 =20 + resets: + maxItems: 1 + required: - compatible - reg - interrupts - clock-names - clocks + - resets =20 unevaluatedProperties: false =20 @@ -66,6 +70,7 @@ allOf: examples: - | #include + #include soc { #address-cells =3D <2>; #size-cells =3D <2>; @@ -76,6 +81,7 @@ examples: clock-names =3D "ref_clk", "pclk"; interrupts =3D <0 15 4>; interrupt-parent =3D <&gic>; + resets =3D <&zynqmp_reset ZYNQMP_RESET_QSPI>; reg =3D <0x0 0xff0f0000 0x0 0x1000>, <0x0 0xc0000000 0x0 0x8000000>; }; --=20 2.35.1.1320.gc452695387.dirty From nobody Sat Feb 7 21:24:56 2026 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D32C1DE2CC for ; Thu, 16 Jan 2025 22:55:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737068142; cv=none; b=oSdpizeR9KbSiTgDRfRCifDwDiqJEVb+sbGrsP7oJC0HKJbUHCEB4N1HMK5Wcv6Xi9Z4hzUvNwwEL/njGe76yhH2Wn36Nptsj/YAmrulwhdltteTdQYBgkgbXYlUZjnB4UxxuSs7xY+V5aSzkD2pgHIBxZFN6ANGJnwcuhO8tbU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737068142; c=relaxed/simple; bh=eY/eaELoWrsvth7t7ZoGKiHeId+2n5EaWWrJKJ1e0gg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y8Mpfw2wCLvUOk/En1LMLETJQ57bkXpaZCv37UUHvu3OdseU9O0kvgmrfoUUsEE5VCAwtY7PpK17S8aqbyn1ZOU3wRRQ8RXgNK5QI5II4NIpNzdn1V16tRJ1S+dzekpkK5OWB+Gzbx99tllEIV4znnAzztSLBhcvBYWjhNd4HD8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=HqSjS39s; arc=none smtp.client-ip=91.218.175.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="HqSjS39s" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1737068138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vgnMG6pJBvdU2HUT93EP8LTpJb1730xDsO9aVBeLZE0=; b=HqSjS39sCx1/8b+P1gWd98wQX8dz5L7tEUVtHzPgZxCKdACiIywurRdbHDCUANiI67fMHq NWZXZI6UwmOW0/sByqg57FkK4umUM06xUhjCUna30sdmiXct32oAvCftbYnl8Xy0uygIru 6IYiVj282sCb7U25m/QVyM+zRL9kzAY= From: Sean Anderson To: Mark Brown , Michal Simek , linux-spi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jinjie Ruan , linux-arm-kernel@lists.infradead.org, Amit Kumar Mahapatra , Miquel Raynal , Sean Anderson Subject: [PATCH 2/5] spi: zynqmp-gqspi: Reset device in probe Date: Thu, 16 Jan 2025 17:55:18 -0500 Message-Id: <20250116225521.2688224-3-sean.anderson@linux.dev> In-Reply-To: <20250116225521.2688224-1-sean.anderson@linux.dev> References: <20250116225521.2688224-1-sean.anderson@linux.dev> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Ensure we get a clean slate (without any bootloader settings) by resetting the device before we initialize it. Signed-off-by: Sean Anderson --- drivers/spi/spi-zynqmp-gqspi.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index 549a6e0c9654..7d138f45b692 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -171,6 +172,7 @@ struct qspi_platform_data { * @regs: Virtual address of the QSPI controller registers * @refclk: Pointer to the peripheral clock * @pclk: Pointer to the APB clock + * @reset: Pointer to reset controller * @irq: IRQ number * @dev: Pointer to struct device * @txbuf: Pointer to the TX buffer @@ -193,6 +195,7 @@ struct zynqmp_qspi { void __iomem *regs; struct clk *refclk; struct clk *pclk; + struct reset_control *reset; int irq; struct device *dev; const void *txbuf; @@ -351,10 +354,17 @@ static void zynqmp_qspi_set_tapdelay(struct zynqmp_qs= pi *xqspi, u32 baudrateval) * - Set clock polarity and * - Enable the QSPI controller */ -static void zynqmp_qspi_init_hw(struct zynqmp_qspi *xqspi) +static int zynqmp_qspi_init_hw(struct zynqmp_qspi *xqspi) { u32 config_reg, baud_rate_val =3D 0; ulong clk_rate; + int ret; + + ret =3D reset_control_reset(xqspi->reset); + if (ret) { + dev_err(xqspi->dev, "Unable to reset: %pe\n", &ret); + return ret; + } =20 /* Select the GQSPI mode */ zynqmp_gqspi_write(xqspi, GQSPI_SEL_OFST, GQSPI_SEL_MASK); @@ -436,6 +446,8 @@ static void zynqmp_qspi_init_hw(struct zynqmp_qspi *xqs= pi) =20 /* Enable the GQSPI */ zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, GQSPI_EN_MASK); + + return 0; } =20 /** @@ -1259,6 +1271,12 @@ static int zynqmp_qspi_probe(struct platform_device = *pdev) if (IS_ERR(xqspi->regs)) return PTR_ERR(xqspi->regs); =20 + xqspi->reset =3D + devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); + if (IS_ERR(xqspi->reset)) + return dev_err_probe(dev, PTR_ERR(xqspi->reset), + "could not get reset\n"); + xqspi->pclk =3D devm_clk_get(&pdev->dev, "pclk"); if (IS_ERR(xqspi->pclk)) return dev_err_probe(dev, PTR_ERR(xqspi->pclk), @@ -1300,7 +1318,9 @@ static int zynqmp_qspi_probe(struct platform_device *= pdev) xqspi->speed_hz =3D ctlr->max_speed_hz; =20 /* QSPI controller initializations */ - zynqmp_qspi_init_hw(xqspi); + ret =3D zynqmp_qspi_init_hw(xqspi); + if (ret) + goto clk_dis_all; =20 xqspi->irq =3D platform_get_irq(pdev, 0); if (xqspi->irq < 0) { --=20 2.35.1.1320.gc452695387.dirty From nobody Sat Feb 7 21:24:56 2026 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17FAE236A79; Thu, 16 Jan 2025 22:55:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737068143; cv=none; b=uIMiKcA0IQc6/2Ma1UiOpj78AaZLfrqQxbnoEXvliltHjqbfUerN8kHul4SJgyKRVokDZdH20XKdlCDyehVeGz5GtEIamd5c6RURyguOj9/K+aK4SLDrInElVX8FIgc4gjBTi7yESkLgbzTPTEV8At49B3gepjafpbZTKFY29L4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737068143; c=relaxed/simple; bh=KIT1n1bX3eDng3r+qwid11vHDsNx3quVnbQL3jXaPqk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AMEBkMeOzbvfNyzhBJSho++M9k+scopgXNwhKE8XDhXuYNnKiU5LNqbYMRlkze1gG0JiK6f0p5S3+d5mg+LvfWQ+C+VT2KkQG+gZVfV//Fhti8Zi7XFlHTT4rS0zeGMoj76d42AOIIZ+1yNMwpcfztm5YyyrY1MkCWh1IP8/fsw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=SlvTl+QM; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="SlvTl+QM" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1737068140; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sgUvBMBWULyeQIjVoTQGL6xz3yswwmfd8gZCRxzSVkk=; b=SlvTl+QMSw+AfBh7e1XBZA4UxJHyUmFO8w2J1UXKRGYXgzqh7DxdSvpIefbU2o0HgWxnVH zSDfhzQLfQ9E3Dg3v4Bn2cAIb6mIYUkuhoy6n1CzGv2IeDbMoPnFx4myOKalEVB8jHNYUx hd1VnehJRgf3YYy92tJ94N6OxYXbXB4= From: Sean Anderson To: Mark Brown , Michal Simek , linux-spi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jinjie Ruan , linux-arm-kernel@lists.infradead.org, Amit Kumar Mahapatra , Miquel Raynal , Sean Anderson Subject: [PATCH 3/5] spi: zynqmp-gqspi: Abort operations on timeout Date: Thu, 16 Jan 2025 17:55:19 -0500 Message-Id: <20250116225521.2688224-4-sean.anderson@linux.dev> In-Reply-To: <20250116225521.2688224-1-sean.anderson@linux.dev> References: <20250116225521.2688224-1-sean.anderson@linux.dev> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" When an operation times out, we leave the device (and driver) in an inconsistent state. This generally results in all subsequent operations timing out. Attempt to address this by resetting/reinitializing the device when we have a timeout. This tends to be fairly robust. Signed-off-by: Sean Anderson --- drivers/spi/spi-zynqmp-gqspi.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index 7d138f45b692..cf47466ec982 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -1057,6 +1057,21 @@ static unsigned long zynqmp_qspi_timeout(struct zynq= mp_qspi *xqspi, u8 bits, return msecs_to_jiffies(timeout + 100); } =20 + +static int zynqmp_qspi_wait(struct zynqmp_qspi *xqspi, unsigned long timeo= ut) +{ + int ret; + + ret =3D wait_for_completion_timeout(&xqspi->data_completion, timeout); + if (ret) + return 0; + dev_err(xqspi->dev, "Operation timed out\n"); + + /* Attempt to recover as best we can */ + zynqmp_qspi_init_hw(xqspi); + return -ETIMEDOUT; +} + /** * zynqmp_qspi_exec_op() - Initiates the QSPI transfer * @mem: The SPI memory @@ -1104,11 +1119,9 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, GQSPI_IER_TXNOT_FULL_MASK); timeout =3D zynqmp_qspi_timeout(xqspi, op->cmd.buswidth, op->cmd.nbytes); - if (!wait_for_completion_timeout(&xqspi->data_completion, - timeout)) { - err =3D -ETIMEDOUT; + err =3D zynqmp_qspi_wait(xqspi, timeout); + if (err) goto return_err; - } } =20 if (op->addr.nbytes) { @@ -1133,11 +1146,9 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, GQSPI_IER_TXNOT_FULL_MASK); timeout =3D zynqmp_qspi_timeout(xqspi, op->addr.buswidth, op->addr.nbytes); - if (!wait_for_completion_timeout(&xqspi->data_completion, - timeout)) { - err =3D -ETIMEDOUT; + err =3D zynqmp_qspi_wait(xqspi, timeout); + if (err) goto return_err; - } } =20 if (op->dummy.nbytes) { @@ -1204,8 +1215,7 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem, } timeout =3D zynqmp_qspi_timeout(xqspi, op->data.buswidth, op->data.nbytes); - if (!wait_for_completion_timeout(&xqspi->data_completion, timeout)) - err =3D -ETIMEDOUT; + err =3D zynqmp_qspi_wait(xqspi, timeout); } =20 return_err: --=20 2.35.1.1320.gc452695387.dirty From nobody Sat Feb 7 21:24:56 2026 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C658B22FAFC for ; Thu, 16 Jan 2025 22:55:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737068145; cv=none; b=AJgP4zUdm3OcYc/rm2923JjyyelazEFAnw5l8VitPNp99GGmMnlf9XHedVUWOrZUIJ90jX7f26jYQBU7X9bhJkdqkNnaiiJ4+i0yVOxrjXNU0MtmDtfkyxZqDAQf7WXhGj3oTx2wScbh1Qk5IOUCN1/Gn9gFsojnPwu5kc7Mx4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737068145; c=relaxed/simple; bh=ba8hLmCk3005C8TXKZHQSGE03vULFLV7U6Bv6zHV6h0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GpWeSoAvDDlOL46SaaFkB+GZT21pFv+OLFEnD0kTEC7Sv/AeXWVNCTp7zaraoCW9+ppNfxF26OQnkRNNTllaMN/nDC3I1A9Wi5n0KPUXbgf465omvhp8JzVl4ahkERAIrMque4HG4TsViLq8f6wqz3ReXNqyJRLKSktb6P8ZXW0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=kDWFGToA; arc=none smtp.client-ip=91.218.175.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="kDWFGToA" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1737068141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=myOtv1Ti+fSD/oUnnjMPiLo6ViBfIn8lXDe7UnZSh0A=; b=kDWFGToAYreA642mEaPCSTgL8yMCyoWf1ryblhiDYjNDN/jNrkOpR6vFAqcmahj41e3+FG n8//t5wXav35O4QoYpGTvE2t9oCA5AxyrNKwEjmv7w4zr0IKjo+0ySN+W9wvQdok+vZWbg iWJ/p18qs+HmYN0fkO6qSNwMDnuvFF8= From: Sean Anderson To: Mark Brown , Michal Simek , linux-spi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jinjie Ruan , linux-arm-kernel@lists.infradead.org, Amit Kumar Mahapatra , Miquel Raynal , Sean Anderson Subject: [PATCH 4/5] spi: zynqmp-gqspi: Allow interrupting operations Date: Thu, 16 Jan 2025 17:55:20 -0500 Message-Id: <20250116225521.2688224-5-sean.anderson@linux.dev> In-Reply-To: <20250116225521.2688224-1-sean.anderson@linux.dev> References: <20250116225521.2688224-1-sean.anderson@linux.dev> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Some operations (such as reading several megabytes of data from a flash) can take several seconds or more. Users may want to cancel such operations. Allow them to do so now that we have a way to recover. Signed-off-by: Sean Anderson --- drivers/spi/spi-zynqmp-gqspi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c index cf47466ec982..fa4bff73324e 100644 --- a/drivers/spi/spi-zynqmp-gqspi.c +++ b/drivers/spi/spi-zynqmp-gqspi.c @@ -1062,14 +1062,24 @@ static int zynqmp_qspi_wait(struct zynqmp_qspi *xqs= pi, unsigned long timeout) { int ret; =20 - ret =3D wait_for_completion_timeout(&xqspi->data_completion, timeout); - if (ret) + /* Only allow interrupting if we can reset the device */ + if (xqspi->reset) + ret =3D wait_for_completion_interruptible_timeout(&xqspi->data_completio= n, + timeout); + else + ret =3D wait_for_completion_timeout(&xqspi->data_completion, + timeout); + if (ret > 0) return 0; - dev_err(xqspi->dev, "Operation timed out\n"); + + if (!ret) { + dev_err(xqspi->dev, "Operation timed out\n"); + ret =3D -ETIMEDOUT; + } =20 /* Attempt to recover as best we can */ zynqmp_qspi_init_hw(xqspi); - return -ETIMEDOUT; + return ret; } =20 /** --=20 2.35.1.1320.gc452695387.dirty From nobody Sat Feb 7 21:24:56 2026 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6B72236A62 for ; Thu, 16 Jan 2025 22:55:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737068152; cv=none; b=kNoc0viRNuytrn21X1risQas1iyXPj3sHgvYiNytcUSvxmvZyg/zjefzRr63JgapZ+aWp3oqr0ATogsjj+96ol7agHGes1AuN95iS8lCPVV/L+A16zuPPQWq/BYxxD+sBdJDDU8UgAUE0NlpoV6sUDxhXP12QDi3u+rXQZHyVW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737068152; c=relaxed/simple; bh=itnHrqNHSm5DpYbOb1UJ0WRFSy/4BZ6dwcLlAkCtKJI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VEieTZ5U8ueUWBkWISsNxJJpLjKnxT9Lpld7crgRbqUqfvNBZ+e7gQQe+DWU+exCC/CAfMGBhHfXOHQ63C810I+GxGSV/vVUOU6Bzmz+DFvY+eD8OLJnu0iLcIlKPmQNbXWhph+QZ55osAe+Pgg9uFguteIGK7gqEJqqdmBhCcI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=nhDo6Ujg; arc=none smtp.client-ip=91.218.175.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="nhDo6Ujg" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1737068144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+quEYUkZhidwpAeLqq43u3BemjnbBw7+zBdpWqiraU=; b=nhDo6UjgeIKQmiyR5pQ04UEbN2zDRWdCs5UadY8A98Tt8cMQLdQHTnSjQ4xpH8esmUGDl8 5ojOPwtNzMzbw2BhasYfr0heaIa6MfZn2n/NTMPtcTpA1+Fi00g52AYwjBANMjFl0Pkym6 F6fwb0zfW4IJREt/5xrt1XB9n9LMuz8= From: Sean Anderson To: Mark Brown , Michal Simek , linux-spi@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Jinjie Ruan , linux-arm-kernel@lists.infradead.org, Amit Kumar Mahapatra , Miquel Raynal , Sean Anderson , Conor Dooley , Krzysztof Kozlowski , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH 5/5] ARM64: xilinx: zynqmp: Add QSPI reset Date: Thu, 16 Jan 2025 17:55:21 -0500 Message-Id: <20250116225521.2688224-6-sean.anderson@linux.dev> In-Reply-To: <20250116225521.2688224-1-sean.anderson@linux.dev> References: <20250116225521.2688224-1-sean.anderson@linux.dev> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Add a reset to the QSPI. Signed-off-by: Sean Anderson --- arch/arm64/boot/dts/xilinx/zynqmp.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi b/arch/arm64/boot/dts/x= ilinx/zynqmp.dtsi index 467f084c6469..5dac0542a48d 100644 --- a/arch/arm64/boot/dts/xilinx/zynqmp.dtsi +++ b/arch/arm64/boot/dts/xilinx/zynqmp.dtsi @@ -986,6 +986,7 @@ qspi: spi@ff0f0000 { #size-cells =3D <0>; /* iommus =3D <&smmu 0x873>; */ power-domains =3D <&zynqmp_firmware PD_QSPI>; + resets =3D <&zynqmp_reset ZYNQMP_RESET_QSPI>; }; =20 psgtr: phy@fd400000 { --=20 2.35.1.1320.gc452695387.dirty