From patchwork Mon Oct 24 11:29:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8917 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp434411wru; Mon, 24 Oct 2022 05:52:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM69J3/HXHsJW+v2IcA9eSVGA2GLF0dxnAM3VWvz3fFqOnTn8sDzybEx4rg5VaLTq2ApH5U2 X-Received: by 2002:a17:907:d22:b0:78e:2788:51ae with SMTP id gn34-20020a1709070d2200b0078e278851aemr26900248ejc.689.1666615930886; Mon, 24 Oct 2022 05:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615930; cv=none; d=google.com; s=arc-20160816; b=gkp6sXQNH//mSDdEFMbKehz78Vuabn1FCcRl8NazhcOiskHF54gz3n7mxpU2IJX++3 OiEWUftw+9PlR1Bu7hCqQ9CfnyFAmKTlXmc99Ktz7PMXSSLJZ1dG5voN5JBGFbqi52EA QGMQUzqKSW2EjF7lohs4X3wlxS1vsJWm1+kQxSD8IzOZ8H6ANO3jAbcfpg2F2DYarjr1 ycjFRBW46GcOkA/eo4xTdvZeJilsy/yKouJDsJxxYzbmkqntx/nsDSBv0vOZrmy43QbL J0tm8HjsGz9oWA4zX4NTFSdvQkPALmGhwcOlV4vmGboVn1fbJuikLhMrl9oh1nU8ljFR nNYw== 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=NCajvmPzlLtTQEuxTL2OzG5eHDyTQ+NLd7FwXLOsMOI=; b=Td7UPU0f+gX+GoHT5vmKvdg4a3uRzkTbzG4fCsA2hK1+oWjN7PN0cXtvjWZNZb/b5K xxob+DcllT9V7QxMMqxcM52UcY28LtZWQcK8RgDc4tZmSU+J8ABf7T6HIsH7+iZV7N3x 7KUOdvXkS6Q5QLz3RQK0WsCUoFFbBa1NedRB4hw2RK+m+4RZITYqXGUS0hNEMdxs05ZE P11XFukkxl53rHFNSN0uWmtHgnCblxU5Mb03Z3qt4mrg15sJkLFj0fqwImxBg5UXLXLL rTWPgHMP1EaLeFFRv0odTFVMdUQDAHow6Jotq4B60F/Sw5eAqmvTzofKYvZO5Nib/qDo m3Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GujPXOXY; 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 g11-20020a17090669cb00b0073d710fec77si24403201ejs.251.2022.10.24.05.51.45; Mon, 24 Oct 2022 05:52:10 -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=GujPXOXY; 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 S234663AbiJXMtO (ORCPT + 99 others); Mon, 24 Oct 2022 08:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234419AbiJXMos (ORCPT ); Mon, 24 Oct 2022 08:44:48 -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 671A712611; Mon, 24 Oct 2022 05:09:32 -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 46FB261252; Mon, 24 Oct 2022 12:08:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A2B6C433D6; Mon, 24 Oct 2022 12:08:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613284; bh=OdCrpPWWG4nWQffHV/hJadngSemBaAi8ZG/iIGDQHl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GujPXOXYgF/Dc8eWSCCG95k2N4Ps3NKmaR+xwa/zPv2rJt221OzPYWlYSOkOdcjn0 zY7YgvO4Dz3oZPI27ZOlGHbBHXg6ntMqwVbL4DIJveCLIk7/zS8Z6HAcHue8PGPu9O 0WfVf6ootn3/+U0iG0+PZs/oOLa+/RMgc1UiQ91g= 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.4 078/255] spi: s3c64xx: Fix large transfers with DMA Date: Mon, 24 Oct 2022 13:29:48 +0200 Message-Id: <20221024113005.102682231@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747573466241681669?= X-GMAIL-MSGID: =?utf-8?q?1747573466241681669?= 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 1d948fee1a03..d9420561236c 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) @@ -654,6 +655,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) @@ -1118,6 +1126,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) |