From patchwork Mon Oct 24 11:28:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9075 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp445251wru; Mon, 24 Oct 2022 06:12:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4xXGQbEgzZl5LfXZSP8/KLlgPsfvkn91oNW+W7QOKGDcSsGyzH54vBCnDbQ7HaX5efbSCt X-Received: by 2002:a17:90a:ab06:b0:20d:8764:b97a with SMTP id m6-20020a17090aab0600b0020d8764b97amr39103783pjq.7.1666617126602; Mon, 24 Oct 2022 06:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666617126; cv=none; d=google.com; s=arc-20160816; b=CZgQ0H1oiBjdDWd7tj8EHf4VxLXnbIZdcIrugjyVvOCd+rpqX+utITxJjoIV7CRF2a //+5+IQzDpawEv75nwWPbZdvL8LznEC/TqQgsIRMRhnd19wSpPpj7jXJd52G24bXkEmx GwKMAZLBJPaJRWCo9MWPuRLvBmEjsYLHBhtnBkn1J3hguLaA7LquvUB1aYQ1l62+xFL/ YDlE5/hF1cWhkmI0dMqBgMBbKkw8MFr5ZBSsaKvG1Nt9lspSfYY8AeZoW92OIfXzEO2Z 8lRWDcXuu11ytX0YShWkjKDwIhxyg3K2hOERT0wQPHBeknKP8KDmvoAp5g8a4kOqgK3v El9A== 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=T3hwwqcey7SW+4POXniOZedwYCUWUXItxFjaArhQHQE=; b=SvuPk6YzIm/4WHBwocBUDnzDG2KyXvzwrrdH0lsOrv6XJ6T8izUzA2fY8oQOSoGCqj xs0au/mYtVQmJwtM/WgN8XoIJJxG/2d2CrLQJYPOK7XF7I7ze7mW+mJA+S0lcPLeH6JG A79xmxJ2R3tNiZ+8ycrA0SdZipniqO7k9aO5+Q6flDVK+RzNqqL6VLdpzeOzUu1JT0t0 Vt5vY/QHXzY2y+JewBEqd8IIWE0pAOu8Sh7GV3rsohvMGxYSkiq+FkYG7X36n6BH/+DB 1F/Xuag5ecosCBmI2zZKjAki/Twe1dM9mQdV0kL4EFycEFsUzoIYUqzTQXk9Oy0kEFxB RvpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d6YdRVTO; 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 q13-20020a63cc4d000000b0043895127033si34932545pgi.335.2022.10.24.06.11.52; Mon, 24 Oct 2022 06:12:06 -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=d6YdRVTO; 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 S235515AbiJXNLG (ORCPT + 99 others); Mon, 24 Oct 2022 09:11:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235221AbiJXNIr (ORCPT ); Mon, 24 Oct 2022 09:08:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0A4E9E698; Mon, 24 Oct 2022 05:21:58 -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 D984061014; Mon, 24 Oct 2022 12:21:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA88FC433C1; Mon, 24 Oct 2022 12:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614090; bh=wBMz9c/+kTAzdDXShkoI5xBtRWobbz8zGVNHMA/nQ+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d6YdRVTOj8yNYBWql+xB26zipgJwFf3UvR5LK8atC+X46CQSi4gMf8I1/G1yslTca P3IoykQ8Y06xOXP9oMg1fUr3+9r4i4Hvhd7UNjq5i6GCR9EVCjOqDpYvjALkc1ae+L piJIVAWceMOW4skWxet4BEv/Fex6QYQUtEO8kKA8= 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.10 129/390] spi: s3c64xx: Fix large transfers with DMA Date: Mon, 24 Oct 2022 13:28:46 +0200 Message-Id: <20221024113028.166532087@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747574720105396939?= X-GMAIL-MSGID: =?utf-8?q?1747574720105396939?= 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 dfa7c91e13aa..d435df1b715b 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -84,6 +84,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) @@ -660,6 +661,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) @@ -1135,6 +1143,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->dma_alignment = 8; master->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(16) |