From patchwork Mon Jan 3 07:11:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 12702436 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E311C433FE for ; Mon, 3 Jan 2022 07:11:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbiACHLd (ORCPT ); Mon, 3 Jan 2022 02:11:33 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:54340 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbiACHLd (ORCPT ); Mon, 3 Jan 2022 02:11:33 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 691F1B80DB9; Mon, 3 Jan 2022 07:11:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 710A5C36AEE; Mon, 3 Jan 2022 07:11:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641193890; bh=n6UKfjDTeuJX+4v4MoQgf67EJXqNInpbReC0k/n5QLY=; h=From:To:Cc:Subject:Date:From; b=Za3aussdGledJrUCxdXhrj28blnBYS1EMT6svIlkBFhnB9FSnfkoBV+xjy9egqmUj eKEnw7Sid42XR5BqqMVn4Z0RgVllmqZKnNMuXB8oY2xY+doG1H2HW5h/K76v3+w9lC EUFFsoanp99mmqnSO0xMcri8+Zii78OhiXdiVkQ7iN5kAzCEqcMmIwmHurdNvbe+7H BqG/VZBXqknNIm0aGpQ2rgOq3ylxTzc1yo+xMQhRsT/KC0DAc/2qaJbDuxuq92nQCs SDE5ylzPbGqQG/VUg2Z2LkUGOiDSniZnplX9/bXU/sCTMuYosLPX1rk/CDwk16afxE joJOl+nIn4D1Q== From: Vinod Koul To: Bjorn Andersson , Mark Brown Cc: linux-arm-msm@vger.kernel.org, Vinod Koul , Douglas Anderson , Matthias Kaehlcke , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] spi: qcom: geni: set the error code for gpi transfer Date: Mon, 3 Jan 2022 12:41:17 +0530 Message-Id: <20220103071118.27220-1-vkoul@kernel.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Before we invoke spi_finalize_current_transfer() in spi_gsi_callback_result() we should set the spi->cur_msg->status as appropriate (0 for success, error otherwise). The helps to return error on transfer and not wait till it timesout on error Fixes: b59c122484ec ("spi: spi-geni-qcom: Add support for GPI dma") Signed-off-by: Vinod Koul Reviewed-by: Douglas Anderson --- Changes in v2: - add missing spi_finalize_current_transfer() for dma error case drivers/spi/spi-geni-qcom.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index 413fa1a7a936..b82f3ddff0f4 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -346,17 +346,21 @@ spi_gsi_callback_result(void *cb, const struct dmaengine_result *result) { struct spi_master *spi = cb; + spi->cur_msg->status = -EIO; if (result->result != DMA_TRANS_NOERROR) { dev_err(&spi->dev, "DMA txn failed: %d\n", result->result); + spi_finalize_current_transfer(spi); return; } if (!result->residue) { + spi->cur_msg->status = 0; dev_dbg(&spi->dev, "DMA txn completed\n"); - spi_finalize_current_transfer(spi); } else { dev_err(&spi->dev, "DMA xfer has pending: %d\n", result->residue); } + + spi_finalize_current_transfer(spi); } static int setup_gsi_xfer(struct spi_transfer *xfer, struct spi_geni_master *mas, From patchwork Mon Jan 3 07:11:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 12702437 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68215C433FE for ; Mon, 3 Jan 2022 07:11:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230185AbiACHLh (ORCPT ); Mon, 3 Jan 2022 02:11:37 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:54370 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230162AbiACHLf (ORCPT ); Mon, 3 Jan 2022 02:11:35 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 75D2DB80AD6; Mon, 3 Jan 2022 07:11:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B681C36AF1; Mon, 3 Jan 2022 07:11:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641193893; bh=GzcRUDfPJW9SzmAleWae6nsRoc+qGYZor16guuT0ELo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t0u5DOP2JrkhAkE1nxdu5sKX0gQEYcOUyM78qxEa4Bo1PaHZd+DiDtiZNFoD1dD0O GrFzHEfqIDcQXx8bQF3EpVH7I9o1orMNQ4SYDvwWOx0d8UGoCo7C4DF/riQ933K1hw 69G2ZBWjekZBmGOPbu2fNDdGjnbF6TEbfKe1hNQBCoWXhSvGy1AFv6IefZzEaQY+qt wsQJJOxSxN638kOtwjYFouo9k0hxXrRYd2JcnrpybPrDFmb/06VJ+R4hTHrc0KVok7 mzghpMsrY+l4fq23WwZSxhp4YH7lsayibYR8nmMC7GmNY5zGC4Bqn+vPgKxN0tErwd qfRQbd9Tik/hQ== From: Vinod Koul To: Bjorn Andersson , Mark Brown Cc: linux-arm-msm@vger.kernel.org, Vinod Koul , Douglas Anderson , Matthias Kaehlcke , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] spi: qcom: geni: handle timeout for gpi mode Date: Mon, 3 Jan 2022 12:41:18 +0530 Message-Id: <20220103071118.27220-2-vkoul@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220103071118.27220-1-vkoul@kernel.org> References: <20220103071118.27220-1-vkoul@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org We missed adding handle_err for gpi mode, so add a new function spi_geni_handle_err() which would call handle_fifo_timeout() or newly added handle_gpi_timeout() based on mode Fixes: b59c122484ec ("spi: spi-geni-qcom: Add support for GPI dma") Reported-by: Douglas Anderson Reviewed-by: Douglas Anderson Signed-off-by: Vinod Koul --- changes in v2: - add tags from Doug drivers/spi/spi-geni-qcom.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index b82f3ddff0f4..f7d905d2a90f 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -164,6 +164,30 @@ static void handle_fifo_timeout(struct spi_master *spi, } } +static void handle_gpi_timeout(struct spi_master *spi, struct spi_message *msg) +{ + struct spi_geni_master *mas = spi_master_get_devdata(spi); + + dmaengine_terminate_sync(mas->tx); + dmaengine_terminate_sync(mas->rx); +} + +static void spi_geni_handle_err(struct spi_master *spi, struct spi_message *msg) +{ + struct spi_geni_master *mas = spi_master_get_devdata(spi); + + switch (mas->cur_xfer_mode) { + case GENI_SE_FIFO: + handle_fifo_timeout(spi, msg); + break; + case GENI_GPI_DMA: + handle_gpi_timeout(spi, msg); + break; + default: + dev_err(mas->dev, "Abort on Mode:%d not supported", mas->cur_xfer_mode); + } +} + static bool spi_geni_is_abort_still_pending(struct spi_geni_master *mas) { struct geni_se *se = &mas->se; @@ -922,7 +946,7 @@ static int spi_geni_probe(struct platform_device *pdev) spi->can_dma = geni_can_dma; spi->dma_map_dev = dev->parent; spi->auto_runtime_pm = true; - spi->handle_err = handle_fifo_timeout; + spi->handle_err = spi_geni_handle_err; spi->use_gpio_descriptors = true; init_completion(&mas->cs_done);