From patchwork Mon Oct 24 11:28:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9731 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp548089wru; Mon, 24 Oct 2022 09:40:48 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5tBr5FmunN6TkU/xSHG55ECJ1yCHc35JZQaKc+8ZNAf1g+66ofCD3ACvGP+D/RMp7UzCvM X-Received: by 2002:a17:907:1623:b0:78d:9e8b:171d with SMTP id hb35-20020a170907162300b0078d9e8b171dmr28327532ejc.309.1666629637196; Mon, 24 Oct 2022 09:40:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666629637; cv=none; d=google.com; s=arc-20160816; b=oGEc7QqdplVqjbre/6QgVSDJDiKuflCRuftHobBxmTp6gmtEn61QsD1wbD8DewbQ33 s/rZzxeerrHy5cRuzptNMcpAp0Lmsce9UVhJuXjD0mLSh3LNCYWg0IzOQ9sThObHjMZM Sazuv9wHZG2aFTcVqAjpZeM6tjBnneMvyVL25LJEWLgNIEUPe7u2WpeFWqUnOjgu/tBe yajW0806FaTpCAstGfepRXKguxM/RyYGZXq+6N4XihzxpVgKyb7eq12a1xKJymbbjC7b RtKYgKj0MjwEeV2K6CY9anYSDAZ8hbKt/I1dx6JpIj4TEiuNR7AM1Fp+2Oa2eItxj/e0 VMwg== 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=daxKrFAu4XXqg89Oi4bu7V+sOEdEXLRqNg8DBsHwvvA=; b=KP37Ep4U/+Gs8OWmPWO5ZghlOgikrrQRJXVgfOg35YK6r+LyqfaSMmjx+AZtVOOmvt 6VpHwdtBVy2WRWNsC//XuciCY+8dhF68vNxOyJQZdZ7kwApl9MqP7+y0FztPcpSuXDpP 0ZxqXtFl8N3tyH6dkNPdKfDroldeJH1FbcZ2HDdJrWP2swZSVKpB5yLuIwzR+cZ8MlA7 d1fiE07xE/KYBFhQSW6Q0xmt++Mrl+5OUY2mjb7+1Zii4WUnU3qOc4ygRSVlnYA0YAJU DHNQ5xlvdj6ShYYEgONIOLIM8/ijknhMIY9n8zStJNWRycLeirVvG0qoWNiN3MChzSK7 bAMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MGVYzLDD; 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 ne27-20020a1709077b9b00b0078341b2e269si231957ejc.886.2022.10.24.09.40.13; Mon, 24 Oct 2022 09:40:37 -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=MGVYzLDD; 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 S234412AbiJXQjY (ORCPT + 99 others); Mon, 24 Oct 2022 12:39:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234516AbiJXQjC (ORCPT ); Mon, 24 Oct 2022 12:39:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AD87192B88; Mon, 24 Oct 2022 08:26:23 -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 ams.source.kernel.org (Postfix) with ESMTPS id BD986B81981; Mon, 24 Oct 2022 12:41:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15B6BC433D6; Mon, 24 Oct 2022 12:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615290; bh=tR1Vw8yGULqRNjjnN8SN66mQXN/N8hhYvrowv+pMP60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MGVYzLDDXZBleVGPZ3aulm1M2bW6bTgLJZ6hAIKoVVuuNGbtFlpBzYlyyXkpPkSj+ NVOkwueNvhZnDjkKMag35EiurPJCVumkKsO4kEtnpccBiQlzBhten/DMoqNx8CXkXf UELsUfLNzZRrDUozHmIf0Ps4Ik0GMTD1KOu19cR8= 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.15 193/530] spi: s3c64xx: Fix large transfers with DMA Date: Mon, 24 Oct 2022 13:28:57 +0200 Message-Id: <20221024113053.786994648@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747587838867928792?= X-GMAIL-MSGID: =?utf-8?q?1747587838867928792?= 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 8755cd85e83c..90c70d53e85e 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -85,6 +85,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) @@ -661,6 +662,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) @@ -1130,6 +1138,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) |