From patchwork Mon Jun 27 01:38:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanho Park X-Patchwork-Id: 12895962 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 438A1C43334 for ; Mon, 27 Jun 2022 01:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:References:MIME-Version:Message-Id:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=7yLqLx/e4A3bkNTlyk43wGpSrcu6/gAuLzjAXXryMqM=; b=T0jlmnOo8sEwq0 BJ/PPx9FLOz1ygYEQOkBkdj/uGS8RYAF8KWC8FMjmfPDKdUQEeaIJQKBcbXkvB/r6X6lbLZR1fHVO tXW/UZwhcsVDd3Vtb3xheqA9jktcQNIKccALWUA17S06Z6Qr8vJhvNgRKMB0fRQ7psojGIt9OYGvX 5sucKNOD0ufWVziNEpKOFy0ysOkRu5lHuDaKEsB2a0zjJI+xkWmC1dptTC9TKtHszZAly7dAfgcQa KW+Fjb1+VDJZD8dd67n4zgJgGsjAgxqP/iOVxbMuhHfWxTPlJCUIQfW3Icn1KsXmY2/D2Sxq4qfoh o7BjQ4OMXxBpHWNet9+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5dkJ-00EVpP-39; Mon, 27 Jun 2022 01:40:59 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o5dkF-00EVnH-Ui for linux-arm-kernel@lists.infradead.org; Mon, 27 Jun 2022 01:40:58 +0000 Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20220627014051epoutp033de061d1bf21c1af029c9b3e14dec1ce~8Vqoph74f2288722887epoutp03H for ; Mon, 27 Jun 2022 01:40:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20220627014051epoutp033de061d1bf21c1af029c9b3e14dec1ce~8Vqoph74f2288722887epoutp03H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1656294051; bh=FTgIlwdCexk43RcygmqXEfu9bpUi2ih8ml1Z2LIlrv4=; h=From:To:Cc:Subject:Date:References:From; b=KzONRtEpBRjU8Hp0NsTjoGqHHySQAyvwGKSbJijA/gq9ot/H+8aNlJxgca5a1Tx25 4E9cgjhmRJKrJgLnxStFBgxo5auBx5XZLayvqz0o1jpZcUoqLGAGFWA4wYiyY4emXx O+j0wavXK0G5HrVpy5gNVLP1Qqg0rcfczEaWiC0Q= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20220627014050epcas2p3219e77e193e8f1c752cf76535dcfe2f7~8Vqnxp5SK3172231722epcas2p3N; Mon, 27 Jun 2022 01:40:50 +0000 (GMT) Received: from epsmges2p2.samsung.com (unknown [182.195.36.97]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4LWVmf2P10z4x9Q9; Mon, 27 Jun 2022 01:40:50 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id A7.B3.09650.2AA09B26; Mon, 27 Jun 2022 10:40:50 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20220627014049epcas2p1fd6b4dddf5b40cd334708043a08ac2f9~8Vqm8Bemy0829608296epcas2p1a; Mon, 27 Jun 2022 01:40:49 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220627014049epsmtrp145f972a96a2db021f40c5d8034b9570e~8Vqm6-5Rd0204502045epsmtrp13; Mon, 27 Jun 2022 01:40:49 +0000 (GMT) X-AuditID: b6c32a46-0b9ff700000025b2-3a-62b90aa28752 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id F2.A3.08802.1AA09B26; Mon, 27 Jun 2022 10:40:49 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.51]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20220627014049epsmtip194ad9f2c15cda06b6eb7bcd7cca62d2c~8VqmxC3_22834328343epsmtip1h; Mon, 27 Jun 2022 01:40:49 +0000 (GMT) From: Chanho Park To: Krzysztof Kozlowski , Andi Shyti , Mark Brown Cc: Alim Akhtar , Adithya K V , linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Chanho Park Subject: [PATCH] spi: s3c64xx: move dma_release_channel to unprepare Date: Mon, 27 Jun 2022 10:38:45 +0900 Message-Id: <20220627013845.138350-1-chanho61.park@samsung.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjk+LIzCtJLcpLzFFi42LZdljTTHcR184kgxUTBC0OTHjFavFg3jY2 i8U/njNZTH34hM3i8n5ti72vt7JbbHp8jdVixvl9TBaNH2+yO3B6XF/yidlj06pONo871/aw eWxeUu/Rt2UVo8fnTXIBbFHZNhmpiSmpRQqpecn5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ZiLihMB3AHoyiEEAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDLMWRmVeSWpSXmKPExsWy7bCSnO5Crp1JBjtPm1scmPCK1eLBvG1s Fot/PGeymPrwCZvF5f3aFntfb2W32PT4GqvFjPP7mCwaP95kd+D0uL7kE7PHplWdbB53ru1h 89i8pN6jb8sqRo/Pm+QC2KK4bFJSczLLUov07RK4Mva3P2YvmChaMfnJQuYGxueCXYycHBIC JhIP5/WwdzFycQgJ7GCUONn8kAUiISvx7N0OdghbWOJ+yxFWEFtI4D2jxOdudxCbTUBXYsvz V4wgtohAjcSZC1cZQQYxCzxjlFh1eRFYg7CAi8TfBe1gg1gEVCVufr4AZvMK2Eu8397HBLFA XmLD/F5miLigxMmZT8COYAaKN2+dzTyBkW8WktQsJKkFjEyrGCVTC4pz03OLDQuM8lLL9YoT c4tL89L1kvNzNzGCA1hLawfjnlUf9A4xMnEwHmKU4GBWEuF9fX1rkhBvSmJlVWpRfnxRaU5q 8SFGaQ4WJXHeC10n44UE0hNLUrNTUwtSi2CyTBycUg1MhZJ813a8nHryKDefhs+zh39znsdH Re0IEZecPPf6hYeHBAx9lTIVVzd8DzVND+uZ7PUuI2X7cStnkeUfJrw6dEbELur5UTeDqufB 9RM1fxZz1DoUbjvF+C3Hd69r889v8qrmpRKVFlMb3v8Odr/ZzLGtgddOdYH4+YezFFZF8RVP VlBX2nbkoKzITOUZ0iYfT03pEn1x93rD92n3hEoPX1rHxVG/nnWBir9Os9GB7sW9n781uqn0 1RRON/y2Mjn76MQHXZOuHp+6XTfOl+Pr1TMOwSvjQz772Vl9lvzv6uo9YfPeu1UROxrbmbos 350I//nB/k3HvSMeRu8fFOZ2L7vCajX5YXx/iU/y3cpvSizFGYmGWsxFxYkAbWfwo88CAAA= X-CMS-MailID: 20220627014049epcas2p1fd6b4dddf5b40cd334708043a08ac2f9 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220627014049epcas2p1fd6b4dddf5b40cd334708043a08ac2f9 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220626_184056_576696_FFE803E1 X-CRM114-Status: GOOD ( 19.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This fixes the sequence of dma_release_channel. Since commit f52b03c70744 ("spi: s3c64xx: requests spi-dma channel only during data transfer"), dma_release_channel has been located in the s3c64xx_spi_transfer_one but this makes invalid return of can_dma callback. __spi_unmap_msg will check whether the request is requested by dma or not via can_dma callback. When it is calling to check it, the channels will be already released at the end of s3c64xx_spi_transfer_one so the callback function will return always "false". So, they can't be unmapped from __spi_unmap_msg call. To fix this, we need to add unprepare_transfer_hardware callback and move the dma_release_channel from s3c64xx_spi_transfer_one to there. Fixes: f52b03c70744 ("spi: s3c64xx: requests spi-dma channel only during data transfer") Signed-off-by: Chanho Park --- drivers/spi/spi-s3c64xx.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 819b660dae82..7f0faf0d75d9 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -373,6 +373,24 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) return 0; } +static int s3c64xx_spi_unprepare_transfer(struct spi_master *spi) +{ + struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); + + if (is_polling(sdd)) + return 0; + + /* Releases DMA channels if they are allocated */ + if (sdd->rx_dma.ch && sdd->tx_dma.ch) { + dma_release_channel(sdd->rx_dma.ch); + dma_release_channel(sdd->tx_dma.ch); + sdd->rx_dma.ch = 0; + sdd->tx_dma.ch = 0; + } + + return 0; +} + static bool s3c64xx_spi_can_dma(struct spi_master *master, struct spi_device *spi, struct spi_transfer *xfer) @@ -804,14 +822,6 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, xfer->len = origin_len; } - /* Releases DMA channels after data transfer is completed */ - if (sdd->rx_dma.ch && sdd->tx_dma.ch) { - dma_release_channel(sdd->rx_dma.ch); - dma_release_channel(sdd->tx_dma.ch); - sdd->rx_dma.ch = NULL; - sdd->tx_dma.ch = NULL; - } - return status; } @@ -1128,6 +1138,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) master->setup = s3c64xx_spi_setup; master->cleanup = s3c64xx_spi_cleanup; master->prepare_transfer_hardware = s3c64xx_spi_prepare_transfer; + master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_transfer; master->prepare_message = s3c64xx_spi_prepare_message; master->transfer_one = s3c64xx_spi_transfer_one; master->num_chipselect = sci->num_cs;