From patchwork Wed Nov 17 13:31:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 12624585 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83AE9C433F5 for ; Wed, 17 Nov 2021 13:31:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6395B61B1B for ; Wed, 17 Nov 2021 13:31:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232261AbhKQNeT (ORCPT ); Wed, 17 Nov 2021 08:34:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:46838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231977AbhKQNeT (ORCPT ); Wed, 17 Nov 2021 08:34:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BC8C761B1E; Wed, 17 Nov 2021 13:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637155880; bh=33bRfbMDfWohdew3q0h0oJFiJrEU9QRWSRrNJ0UHk7U=; h=From:To:Cc:Subject:Date:From; b=by00Ve2WLafWkl76i97JRGysVEVEByUutTkJbGK5kgXnQRVMOrtqbX5gnFYNNZWSR m/vP4hLPfwRmWcpACsDLJb30AiM069a6L3/XlQU2auwwqE30povUkBu/cWr3WK97p2 PjMwH1lhP5iufwvD5O+/1fzs0ZedEC8YN+iGs1jz4YyOyMJHTUCF8ArwAYPL7Q3P2a 7B2UocvJ3NaRfDtOuIBHtw0kL0huB1k+EqLaY7Zv+3xC1Po49URDyqd9TMSF60A045 2REBASspxknEXGFUjTJ71JH5WcOXVDJrYJcDkhKRIzwF4PWbXXc7/yU+DfxMqh7rJn iDEY1DCA8LgRA== 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 1/3] spi: qcom: geni: remove unused defines Date: Wed, 17 Nov 2021 19:01:08 +0530 Message-Id: <20211117133110.2682631-1-vkoul@kernel.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Commit b59c122484ec ("spi: spi-geni-qcom: Add support for GPI dma") added GPI support but also added unused defines, so remove them Signed-off-by: Vinod Koul Reviewed-by: Douglas Anderson --- drivers/spi/spi-geni-qcom.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index e2affaee4e76..413fa1a7a936 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -71,10 +71,6 @@ #define GSI_CPHA BIT(4) #define GSI_CPOL BIT(5) -#define MAX_TX_SG 3 -#define NUM_SPI_XFER 8 -#define SPI_XFER_TIMEOUT_MS 250 - struct spi_geni_master { struct geni_se se; struct device *dev; From patchwork Wed Nov 17 13:31:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 12624587 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBF38C433EF for ; Wed, 17 Nov 2021 13:31:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADC0F61B2B for ; Wed, 17 Nov 2021 13:31:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231977AbhKQNeW (ORCPT ); Wed, 17 Nov 2021 08:34:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:46936 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237579AbhKQNeW (ORCPT ); Wed, 17 Nov 2021 08:34:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B2A961B1E; Wed, 17 Nov 2021 13:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637155883; bh=bIfKk8x8FPQrwjQCXe/QcQKHD2wOs1Tj104cFQl0pWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UyjuDYaOnMfauFh2YcgOU77XuQCHWb78IjoGf220omneriTg5QVkCs1hyE1E1qLfQ m4exTtCy1lmOJRFZyXeDWRszvBld3Gn6JCY+BToT5TrH7NMHtbcPo5WkMHPjC4mj9D yOpZVh/p60o3LgkTfvKRQltYkvCmwx55umJIrEthnxfjkevp4ZHFohxVBWgyj1cjo9 rJ3ZQJE6iwi7FK7dsIn4hKqq/MNz3IVOPO5ELb07/vdbKAk0JWxA5bUYKTqn6lJ3BJ ny2NSBq/+MGi9F9YyjCliZX/IIpKg24DswvKuUVG1NI8rmq/CSoQBGiC9IV+T5uQLx bhg0jE9Mpqxxg== 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 2/3] spi: qcom: geni: set the error code for gpi transfer Date: Wed, 17 Nov 2021 19:01:09 +0530 Message-Id: <20211117133110.2682631-2-vkoul@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211117133110.2682631-1-vkoul@kernel.org> References: <20211117133110.2682631-1-vkoul@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@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 Signed-off-by: Vinod Koul --- drivers/spi/spi-geni-qcom.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index 413fa1a7a936..b9769de1f5f0 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -346,17 +346,20 @@ 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); 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 Wed Nov 17 13:31:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 12624589 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E195AC433EF for ; Wed, 17 Nov 2021 13:31:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C78D961B1E for ; Wed, 17 Nov 2021 13:31:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237600AbhKQNe0 (ORCPT ); Wed, 17 Nov 2021 08:34:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:46984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237596AbhKQNeZ (ORCPT ); Wed, 17 Nov 2021 08:34:25 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 65B0061B1E; Wed, 17 Nov 2021 13:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1637155887; bh=pTV4LcjmVPnAyqU7zEzrz73e0jNTWFPJ2DUCAvoW0BU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VSO834autQlUdOukJw2HuAJQC/irBqU/V8BpNazOOKqz0YbeV0fdHfUjoZ9fZw9dW 402NVJly+e/bcwnJo10prMtWsOiUBYm7DsCJSJWXDp63EtFxLVdmtluL5jYfj0gZep lVSZZPgbN1iMnH5bk9261fcTtGdew8Z0/q/jkJht/K2glLZVcIr9cFx3Kyz3coY+my lpjVTf17jR9trPInXk66h/oYkg3AyGosHwsvhefTvP/Bdi38I0izwW1eqrLUoWED0b a9WNW4git2jYRwdLZsk23ESLnV7yeeczReQ5eTQOAMwOIRcmuDivog68mpz9Ghx+6B TdMBlG4NIrxXg== 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 3/3] spi: qcom: geni: handle timeout for gpi mode Date: Wed, 17 Nov 2021 19:01:10 +0530 Message-Id: <20211117133110.2682631-3-vkoul@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211117133110.2682631-1-vkoul@kernel.org> References: <20211117133110.2682631-1-vkoul@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@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 Signed-off-by: Vinod Koul Reported-by: Douglas Anderson Reviewed-by: Douglas Anderson --- 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 b9769de1f5f0..5b6e9a6643d8 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; @@ -921,7 +945,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);