From patchwork Sat Oct 22 07:22:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7323 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1093680wrr; Sat, 22 Oct 2022 00:58:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44CAx8BlkpjaXiIKy7Le3CUSmSZUZBA59AROIoxk5JVIYDokSkl3cwRYkiVkzlUVKql46h X-Received: by 2002:a17:90b:60e:b0:212:d5cd:4e58 with SMTP id gb14-20020a17090b060e00b00212d5cd4e58mr6640646pjb.165.1666425484306; Sat, 22 Oct 2022 00:58:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666425484; cv=none; d=google.com; s=arc-20160816; b=R6159BBHlROaTfUYxF1/71z2YXSHhIuVGtE3LWbU0L4ZiVafaaazR0vgd86AQnpPeC 34Kk1vnYNv4nqJ71/KwRBkZHBuLD4vVN4WApfnkeKemSA/NYRijIXgD6ZKmLCKRK/htM r/VzlCQFcUSJlIscl8eCRrH9q2jHw0sVhddeq5Zsu8qKC8iAwAGyhSmLEk0OXuuhCZ+V P5SqwMRt0K04NTuQBCdEMg+tWQqqbQ5WE5BsRn8VPdntXTk56oOV2rF/N/hy2nBTaLPt 4CJa2aUkSXRRcpPNxX+3eF314v0MupYMwRw6Sl5dOivLtJ7pKQrj724Ikm/DeHXFPdM0 D3Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tEkSBIyrMM8I/Mqij1EXkeqWlUrNzogi0o8dd5saoSE=; b=k6jkQaeqAIGdZ8dJzVroV5x/vruS7laMfDwNvxrVJCybxnUwM1y+pR6pVfBnYtXDlk v7j+3rhra93QnIOoxbhV7Ki59oRojsRnp2TlESvc26R1RLt7n1sT1w5Jk1t7fxASGhum wqIrh3nR1xHxROmucX/16Aar/G19NbKr0KbfZhaIQ3HAn2yJ2sJCC3JkgwXSmvH6KyW9 Hxs+2HtR5mXmJVX7OPrr7dwLJLjVHBzg7PYh1EBKoON6xV9o2OXMlQjp1hEvC7drteO3 A0IGK8SUFjXrM09WSwjeswvcKoCSicbrWw0Un0axjX1Je57g7HSOjOO+0Fs9uJ+P7ODK RDDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lnsl3KXW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x12-20020a170902ec8c00b00177ee2efd41si18824166plg.265.2022.10.22.00.57.52; Sat, 22 Oct 2022 00:58:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lnsl3KXW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231755AbiJVH5e (ORCPT + 99 others); Sat, 22 Oct 2022 03:57:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232026AbiJVHxk (ORCPT ); Sat, 22 Oct 2022 03:53:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C583E66F3D; Sat, 22 Oct 2022 00:47:13 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 90DE560ADA; Sat, 22 Oct 2022 07:46:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F45EC433D6; Sat, 22 Oct 2022 07:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424780; bh=WFKe53kAeWTn6rXCQwWFO44BGTReVqKDgbguBaL8nb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnsl3KXWXqQVp2/TOOLDwSJy4YsEp2tzGvBBGtSF/9sVbg368RFonLgXRyWLSJem7 TaGHHURiloVR2jTamkvlPFuxXyV0wkd8Ua/txUeaWQ3KS7N48HaJS1Ago2cm3kLtZD MfZAC0GjmTYZ/HBvsHTbae8iO8g3maZsKiORB35I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Whitchurch , Mark Brown , Sasha Levin Subject: [PATCH 5.19 274/717] spi: s3c64xx: Fix large transfers with DMA Date: Sat, 22 Oct 2022 09:22:33 +0200 Message-Id: <20221022072502.830055066@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747373768837178694?= X-GMAIL-MSGID: =?utf-8?q?1747373768837178694?= From: Vincent Whitchurch [ Upstream commit 1224e29572f655facfcd850cf0f0a4784f36a903 ] 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. Implement ->max_transfer_size() and have the core split the transfer as needed. Fixes: 230d42d422e7 ("spi: Add s3c64xx SPI Controller driver") Signed-off-by: Vincent Whitchurch Link: https://lore.kernel.org/r/20220927112117.77599-5-vincent.whitchurch@axis.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-s3c64xx.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 8fa21afc6a35..b77c98bcf93f 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -83,6 +83,7 @@ #define S3C64XX_SPI_ST_TX_FIFORDY (1<<0) #define S3C64XX_SPI_PACKET_CNT_EN (1<<16) +#define S3C64XX_SPI_PACKET_CNT_MASK GENMASK(15, 0) #define S3C64XX_SPI_PND_TX_UNDERRUN_CLR (1<<4) #define S3C64XX_SPI_PND_TX_OVERRUN_CLR (1<<3) @@ -663,6 +664,13 @@ static int s3c64xx_spi_prepare_message(struct spi_master *master, return 0; } +static size_t s3c64xx_spi_max_transfer_size(struct spi_device *spi) +{ + struct spi_controller *ctlr = spi->controller; + + return ctlr->can_dma ? S3C64XX_SPI_PACKET_CNT_MASK : SIZE_MAX; +} + static int s3c64xx_spi_transfer_one(struct spi_master *master, struct spi_device *spi, struct spi_transfer *xfer) @@ -1100,6 +1108,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) master->prepare_transfer_hardware = s3c64xx_spi_prepare_transfer; master->prepare_message = s3c64xx_spi_prepare_message; master->transfer_one = s3c64xx_spi_transfer_one; + master->max_transfer_size = s3c64xx_spi_max_transfer_size; master->num_chipselect = sci->num_cs; master->use_gpio_descriptors = true; master->dma_alignment = 8;