From mboxrd@z Thu Jan 1 00:00:00 1970 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 39B88C54EE9 for ; Fri, 16 Sep 2022 11:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231349AbiIPLkQ (ORCPT ); Fri, 16 Sep 2022 07:40:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231139AbiIPLkA (ORCPT ); Fri, 16 Sep 2022 07:40:00 -0400 Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EC972CC97; Fri, 16 Sep 2022 04:39:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1663328398; x=1694864398; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=522Kxf6U1q7s2dtT3SsExSNapFPwyU8RLSswskWzai8=; b=TfneD9eTL6XivhGCtWAcEhjTVLROmOQBXNFGkByRRWKCXS3gojsIEUJ+ +JstlQrYh/ONRk/RdkJ2sTBYkK2XxQkGADU6p/JBWRyZYKzTRcy/41EVV PzT1Za44VbqDsB1hZ/9dw73sXN3QQXbGA1by870v6dFWy1slk+X8iwKd5 TzA5KHPkZaJ+oex1F9lv5NhcEUBej9sG6S8PIb6d+/y55RUAnpoqJ0UM6 zlibkTW1SJhHbuzBYexO3UY5Tw5ZQgCSVl3VYjZTLlzxbHAFEIi06pdcP p+od6pD8W4RMrnmkRq+Hq0tszA+IWEe+NrKGuaU3RQc8PuRSI/iPL3YDn A==; From: Vincent Whitchurch To: , , CC: , Vincent Whitchurch , , , , , Subject: [PATCH 4/4] spi: s3c64xx: Fix large transfers with DMA Date: Fri, 16 Sep 2022 13:39:51 +0200 Message-ID: <20220916113951.228398-5-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916113951.228398-1-vincent.whitchurch@axis.com> References: <20220916113951.228398-1-vincent.whitchurch@axis.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The COUNT_VALUE in the PACKET_CNT register is 16-bit so the maximum value is 65535. Asking the driver to transfer a larger size currently leads to the DMA transfer timing out. Fix this by splitting the transfer as needed. With this, the len>64 KiB tests in spi-loopback-test pass. (Note that len==64 KiB tests work even without this patch for some reason. The driver programs 0 to the COUNT_VALUE field in that case, but it's unclear if it's by design, since the hardware documentation doesn't say anything about the behaviour when COUNT_VALUE == 0, so play it safe and split at 65535.) Fixes: 230d42d422e7b69 ("spi: Add s3c64xx SPI Controller driver") Signed-off-by: Vincent Whitchurch --- drivers/spi/spi-s3c64xx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 7f346866614a..85e1d1f90109 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -701,6 +701,16 @@ static int s3c64xx_spi_prepare_message(struct spi_master *master, struct spi_device *spi = msg->spi; struct s3c64xx_spi_csinfo *cs = spi->controller_data; + if (master->can_dma) { + int ret; + + /* Limited by size of PACKET_CNT.COUNT_VALUE. */ + ret = spi_split_transfers_maxsize(master, msg, 65535, + GFP_KERNEL | GFP_DMA); + if (ret) + return ret; + } + /* Configure feedback delay */ if (!cs) /* No delay if not defined */ -- 2.34.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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 D0261C54EE9 for ; Fri, 16 Sep 2022 11:41:46 +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:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=OvqsEGkcd21NPeyVRve4HVda6c9wmOFZ3V68kr0Fm2I=; b=hG5VwIRdI++u+4 +6Ffaa9SnsD4w9ickAmkmQbU1hU6WMk4yu91GL5RfCqpzvOdY1j3fBUTV9jP7+ydAofD36MZ4b6wY t1w0Z5aFuTIXbp7yltZuPItap7CSjuLgGzh0ATYvBeFEjqd0WBvzTTozOstConBE4VcCVqUlVyYNR 4YGBOcenWQmLgHmOTf5mJbejgbJYMeyKTEvrKuItcSkh95XyyyR7jWxhQxEj94/bRDBiuQMX93aFF dTIhoNKQAfCfwJH+yaLQxV7TEGZiR/4y3BvYbzCUitbrxG4C+0rPLTpmps1ybz7NfycpLRJiHKJ0A y+LbxQvUxbOGI16tVcgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ9iC-00CmNs-Bh; Fri, 16 Sep 2022 11:40:48 +0000 Received: from smtp1.axis.com ([195.60.68.17]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZ9hV-00Cm3n-Js for linux-arm-kernel@lists.infradead.org; Fri, 16 Sep 2022 11:40:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1663328405; x=1694864405; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=522Kxf6U1q7s2dtT3SsExSNapFPwyU8RLSswskWzai8=; b=IH8ipn/7WTH3/jCP13YbiCtYpwCYr5/1GYshZWu3U6vE6Mpf7pcX9RZF 9ic5ZAC+l7BJ3GaiXEqC7wtx9NKkxIxOFYtaPRlyliq31fGyLAHeQlXTs H9WYWSpOloDPUhZknpJBF8qeuJmKqDksKIm1HWA8ANO8Q4S7KiguJYkYw kIdf/G19GWOwi1ocIuE3Z5f1+6RM72+88KynJLpFGHHN97CuXUzFyp8E2 1YIPfB0KLJMiF3WsULmFvNexH/X8nMNI0hpQEHHtzVVSILAavuJlTbzTQ GSVMvIwuh8507gVEz+Hud9H8RBenM/dMGCZHmy16hMRWiBH9XK8o76Uc3 A==; From: Vincent Whitchurch To: , , CC: , Vincent Whitchurch , , , , , Subject: [PATCH 4/4] spi: s3c64xx: Fix large transfers with DMA Date: Fri, 16 Sep 2022 13:39:51 +0200 Message-ID: <20220916113951.228398-5-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220916113951.228398-1-vincent.whitchurch@axis.com> References: <20220916113951.228398-1-vincent.whitchurch@axis.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220916_044006_081655_8CD92AAA X-CRM114-Status: GOOD ( 12.19 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The COUNT_VALUE in the PACKET_CNT register is 16-bit so the maximum value is 65535. Asking the driver to transfer a larger size currently leads to the DMA transfer timing out. Fix this by splitting the transfer as needed. With this, the len>64 KiB tests in spi-loopback-test pass. (Note that len==64 KiB tests work even without this patch for some reason. The driver programs 0 to the COUNT_VALUE field in that case, but it's unclear if it's by design, since the hardware documentation doesn't say anything about the behaviour when COUNT_VALUE == 0, so play it safe and split at 65535.) Fixes: 230d42d422e7b69 ("spi: Add s3c64xx SPI Controller driver") Signed-off-by: Vincent Whitchurch --- drivers/spi/spi-s3c64xx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 7f346866614a..85e1d1f90109 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -701,6 +701,16 @@ static int s3c64xx_spi_prepare_message(struct spi_master *master, struct spi_device *spi = msg->spi; struct s3c64xx_spi_csinfo *cs = spi->controller_data; + if (master->can_dma) { + int ret; + + /* Limited by size of PACKET_CNT.COUNT_VALUE. */ + ret = spi_split_transfers_maxsize(master, msg, 65535, + GFP_KERNEL | GFP_DMA); + if (ret) + return ret; + } + /* Configure feedback delay */ if (!cs) /* No delay if not defined */ -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel