From patchwork Wed Oct 19 08:26:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4670 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp212803wrs; Wed, 19 Oct 2022 02:08:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5j7cRtHleMgmc5XbAc+mnGPC8ucIFBsqk3wnz+g9Cv60hkfp97Le3M5yAfQDPdZWp0L470 X-Received: by 2002:a05:6402:ca:b0:45c:dbdd:8143 with SMTP id i10-20020a05640200ca00b0045cdbdd8143mr6426312edu.213.1666170499412; Wed, 19 Oct 2022 02:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170499; cv=none; d=google.com; s=arc-20160816; b=YVY+JdPUn8WmkPgCye7xqHuNzYZKVXNB24L/jgcYb1DEKDCUzqE7LomZlb/3ZzyfmW nu28m98YLddO+ulBZN+PF3+G3uJ7OSBAPiZYnhvInjCRh4iWTheOM5ByNS4UX5A1Tz7C diF47gM0M/3M/6xt2z/zqrshjYperwSpBC8bQbvmSN+/kc+MRqehNXW0iB6nd02xnzQG YvCfE3TZKkNqU+Uz6C66kM//6uUYG2pxhaB0ufecimOAIhV8iQ4t6IvJN96T4pvzXe/C 0bK+nkctNshhq1oNPYJPHGITjgV5BL4Z8H9MGXWLCjRow13K8KYosFeO6SIwXv8h1qAd Yh/w== 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=p2X3a8beoo1d9rtCVEG9ZSA5U7hTVPkKBawke6CJGAU=; b=F/UdoRMPkL8rx+J5Bldcy73c9ZPfnb2c1ZxCVvL25dt67Mm8smO+tTCN2XHmXgMqHs gvtCV1Goy0LT8qjqiy74o7vIUeYP65m9n+dBhY8ccwDd9vHaCCSswG6jfuyNDlpx7Dcl NDDGXwL6eyC3wXtkn3Mes4f6y8GUH97CV09/GFIl2V13UQo8DlZyzvn5I4zJiEFqqcwT uCiUaGsoho7E5lQeDAtxdBzdcxiIQpKxzq4Bcvj8h/dw7TBiCaxjQZ+ntjm3FxffzZK/ w/t6rBMceGOhfK/mS/ZUyhr7NwJ8oeO61fpqIYhjq84iiq2yUjirQovZT1B+E3LqqCBT z0Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kt3rKgZ6; 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 d25-20020a056402001900b0045c26f0050esi12015053edu.238.2022.10.19.02.07.47; Wed, 19 Oct 2022 02:08:19 -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=kt3rKgZ6; 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 S232174AbiJSJCP (ORCPT + 99 others); Wed, 19 Oct 2022 05:02:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232318AbiJSI72 (ORCPT ); Wed, 19 Oct 2022 04:59:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 943D01F9CE; Wed, 19 Oct 2022 01:54:44 -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 616F4617E2; Wed, 19 Oct 2022 08:52:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73BA1C433D6; Wed, 19 Oct 2022 08:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169565; bh=5u3kOrzXDHW67/4WydkJbp5+FsobPaSHWftOVuCCVsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kt3rKgZ6AFc3jlW97jCzZe4DNWRyzQ2Pil3TtOYaN8rDWtzSjN8uV3uuQpJ/0n1RU JuvZ0X9tdEv+MB76wVVDrmZniMwD7hrTgMSA2dxU5iPiXFhS+FZM/fpRTyDEBMPcJl czxjlIH94QlRDFVyK5IJXczamWj202Cmchyzmfw4= 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 6.0 324/862] spi: s3c64xx: Fix large transfers with DMA Date: Wed, 19 Oct 2022 10:26:51 +0200 Message-Id: <20221019083304.335658021@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747106397709070132?= X-GMAIL-MSGID: =?utf-8?q?1747106397709070132?= 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 651c35dd9124..71d324ec9a70 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) @@ -711,6 +712,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) @@ -1152,6 +1160,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) master->unprepare_transfer_hardware = s3c64xx_spi_unprepare_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;