From nobody Sat Jul 25 00:02:23 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.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 127DB3DCD87 for ; Wed, 22 Jul 2026 03:41:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784691677; cv=none; b=l9wwwS0MJDnNu4lvUSO+9S7tZrYcyMS7ZRgEZXyuEMestiIZdh6r9OFOwERW4edHOFRsLKmPW+O50aCt2iI5flQgi0SoRN2SZtIRqMhF5Meo+eqhwnEcIPxPyZslKHpKRWJmkURpkn/b5zgd2pdPzIHlvWALZt+VLxBDXkLoDVw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784691677; c=relaxed/simple; bh=omr1+5FGqP/4cAjLJuIvC7am2JBR6QvgB8tGwxi3xIM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=sF9mmkkGE4zTOxWLN769wqabwEXmErYcQlgdoij2Ko46EhCdgDXF/YLmISZvAWTFHdvVk3GCnthKbAuqB1pHGISiDoCaBgY+WdToRhLGDYjwGlhcPZQhXwso4Ydd+bWlRumgs7302+i7u6bE3zVfpkUecfDPVOiQUSkSLuTMWis= 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=HAjMGWjo; arc=none smtp.client-ip=209.85.214.179 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="HAjMGWjo" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2ceaf8a1265so120863855ad.2 for ; Tue, 21 Jul 2026 20:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784691673; x=1785296473; 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=fMsLP/6JMCFywbSNUxwQOz2CeAVV57hRVViNt75YJiE=; b=HAjMGWjo1cFnZNC9vmWxdr6dgguJJZcbOmA56CgQHS25PFjXFYuOu2hXFvrqk6igyi JVaZ5s1DVoZvJ6pP8e/AI7kAky6nDMk0x8KscIjMsJSHctne0/tMUyBF6p12ynJjzU1Y ZNhZgQ8esURuefcLXEUnYkRtWxsQWMsDF9yFdSuE2LljBJInz5rd6+TsxmdaO+EIrshH tUeqyrbn70ItGJjpAI+AeJ8zX0E8SDLU0DXo76EdRazJmRPvIrnmkmluuEKVWYF3m1G4 5hT0OgFSRN3ShETl+iae6t6uk5gj7ljzLmAetlloe/SCVYVB4ELA3G8S7Z4bcPs3+Q8o 6rMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784691673; x=1785296473; 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=fMsLP/6JMCFywbSNUxwQOz2CeAVV57hRVViNt75YJiE=; b=bx8COLDOyyPF1apYUFWPhxzEqsY0C9Aa19HA500hGPzPPSuf7TycqRGliBzakD5srO vhOoKbIEANwwnxprmPRXKdnZz/zQhFnEMy0I6bpRagF6Y6cZdH/2YYhgAXLPTc53Dm1q TOubTGH4DmqDe6aaEkuyXmCyXDzWlYHx/ANP0ylKp0uqiyZyi/jVBz2HvmrerhEP27or 7yq93h9wLsFenuhK7Vzc0ZMSH6eKm8cWkiaLMawsrlvglblNxjogLBwRN4HfWoOMJO7A 0w2+7U8Nn0UF9fQFCLqbezTVfyufAA9QfRRYTfIB6IewFJD8u7uvvuhej4yhIcXhDIiT 74dw== X-Forwarded-Encrypted: i=1; AHgh+RoPH+2S0QGSbJs0BOZmGgBA2mpbQqBlizqSaM271zbD4o5S9wb79d3j6pm8D5ulASeuhr0gkko82VOa3Kw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz1zFU+DKoSkXTV4Pigz6UUr9YQrz/nD9ftmDzyMLj8l7E0UfdU aLixDPQwFOxcFSCRdAAfjDizoQqIls87m4gBY6kP4zbpOk7c0C+p4bE= X-Gm-Gg: AR+sD10kJJywA3GHAHpkGbwdjrYipucnrAyc0iAE1VAIY9ZB3JKckoZ29bKp32ksV/j aSJBrAVGB41URVRZ7zh4PRbPtzxyY+g6uUxmB4WsiJNw2j0WVIrt+cJ+uDElu0fktHFD3lzhY2N KAF7kRHdiDwoL78VRRWn1T0uU1RcrgVZdNyhpOxF+rsofsYs99ssXUJGzLFuiT6DYowpKosLVY7 PNVi7I0uD4iP9VtrbACF3ijsIo4zUErrY1RLXYgJwKWZndDUQnARCg9LR7yxaymcEWctjUkEKYf dm6WjO9GTKBnJyjjtiLnXBThTOwR/3bLnoEih3O+of2t7bvH0ZgPLkSRMBvTH2jARS+zEc8WdpC fVE2pqA8QmpOWb8+NXTnBfZKp5t+6OH7GARA6oxXNoaNRHlXIrjofjlO5zLt/9yc+Kw76cYbTTu FTIXBF5GJ4O9MG+jErYLRvzKkGNPk= X-Received: by 2002:a17:903:1247:b0:2ca:de3:15e1 with SMTP id d9443c01a7336-2cf34a0a682mr225407425ad.31.1784691673137; Tue, 21 Jul 2026 20:41:13 -0700 (PDT) Received: from t-rex ([2401:4900:adaa:53ec:4dd9:f3bc:714a:d631]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3147dc193f8sm7523404eec.1.2026.07.21.20.41.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2026 20:41:12 -0700 (PDT) From: kr494167@gmail.com To: broonie@kernel.org, dlan@kernel.org Cc: elder@riscstar.com, guodong@riscstar.com, linux-spi@vger.kernel.org, linux-riscv@lists.infradead.org, spacemit@lists.linux.dev, linux-kernel@vger.kernel.org, surendra Subject: [PATCH] spi: spacemit: prepare both DMA descriptors before submitting Date: Wed, 22 Jul 2026 09:11:03 +0530 Message-ID: <20260722034103.12190-1-kr494167@gmail.com> X-Mailer: git-send-email 2.55.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" From: surendra k1_spi_dma_one() currently submits the TX DMA descriptor to the DMA engine before preparing the RX DMA descriptor. If preparing the RX descriptor subsequently fails, the function jumps to the fallback error path without canceling or aborting the already submitted TX DMA descriptor. Fix this by preparing both the TX and RX descriptors before submitting either of them to the DMA engine. Fixes: efcd8b9d1111 ("spi: spacemit: introduce SpacemiT K1 SPI controller d= river") Signed-off-by: surendra Reviewed-by: Alex Elder --- drivers/spi/spi-spacemit-k1.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-spacemit-k1.c b/drivers/spi/spi-spacemit-k1.c index 215fe66d27b4..96b41b67fcbf 100644 --- a/drivers/spi/spi-spacemit-k1.c +++ b/drivers/spi/spi-spacemit-k1.c @@ -278,25 +278,25 @@ static int k1_spi_dma_one(struct spi_controller *host= , struct spi_device *spi, struct spi_transfer *transfer) { struct k1_spi_driver_data *drv_data =3D spi_controller_get_devdata(host); - struct dma_async_tx_descriptor *desc; + struct dma_async_tx_descriptor *txdesc, *rxdesc; u32 val; =20 - /* Prepare the TX descriptor and submit it */ - desc =3D k1_spi_dma_prep(drv_data, transfer, true); - if (!desc) + /* Prepare the TX descriptor */ + txdesc =3D k1_spi_dma_prep(drv_data, transfer, true); + if (!txdesc) goto fallback; - dmaengine_submit(desc); =20 - /* Prepare the RX descriptor and submit it */ - desc =3D k1_spi_dma_prep(drv_data, transfer, false); - if (!desc) + /* Prepare the RX descriptor */ + rxdesc =3D k1_spi_dma_prep(drv_data, transfer, false); + if (!rxdesc) goto fallback; =20 /* When RX is complete we also know TX has completed */ - desc->callback =3D k1_spi_dma_callback; - desc->callback_param =3D drv_data; + rxdesc->callback =3D k1_spi_dma_callback; + rxdesc->callback_param =3D drv_data; =20 - dmaengine_submit(desc); + dmaengine_submit(txdesc); + dmaengine_submit(rxdesc); =20 val =3D readl(drv_data->base + SSP_TOP_CTRL); val |=3D TOP_TRAIL; /* Trailing bytes handled by DMA */ --=20 2.55.0