Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp335633ybh; Wed, 22 Jul 2020 01:44:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf4pbgvU7g9PyvHmn49k6IHZsPSU33alCz2g6HZoZIEsceh6zojJC2FySFuS2go8N+fEHS X-Received: by 2002:a05:6402:542:: with SMTP id i2mr30638605edx.318.1595407449094; Wed, 22 Jul 2020 01:44:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595407449; cv=none; d=google.com; s=arc-20160816; b=OayEwu7Eu9xL+WjgPIKvUxG0ZVa9cbIZztcoV3rgRVtggV1CCnU6iH7WQX4k2ROy2F NWSzhBKMSJ1ZCcSFWXWqzKZZ0/MBoAxW/tcz5J013Kcg03UN41R45x7x+BZDFeO8ch46 jMQUMc8NSgVhAx6xqCzSX9EQ5S9UEpFlQ2LEop6UTPzMYEYfL2VD9FKzOD/v0cJHHAWC SmQDdcpOrnAtVHaiTUSN7fVjCyzYj+ufOw+4T0yW2E6lB6kP8tERaLy2BiepNaWfu01V wpbq9pl929vRbxI5yeTwvBSgVD9qFl7rCo5tCH4mORa+euaQKVKFlG8qkDKs+ff9wo1s s2Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=quHWesxfpjwuG7V7saYbkYG3MxDiCKJ4HKFpaOw7hSQ=; b=OgSwaYd0MZhpUC8ZF+8JVR7mcWu3KLLqxzHcJROKhJ+lXTIydIrqHIMrbxVOJNy4SL pPRYX+PKlKoki3uv+hPGM8p534o9gq9RIWsqh5MVG+JEH8VxCOs229NO5blhIgrtibf1 dZEhUrvj8XXHZrJOFsoYmp/nRjy7Hk3dbG7OuWgxOc35jzswzqIlq0M9kmQG+npsCBxa 0YLxldet0qi+zuw9d18lLqm1I1rsSDo8Y4GmB8d5ACOEQ8V63NRQruUHuUyDMNABig4w sArKERy+lMR57kFp8sg10wPa6teNFEd8e/IV/Y/XoybjKkZcUUSYzUoy7ykV5n3ay+64 Anjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw16si13836255ejb.274.2020.07.22.01.43.44; Wed, 22 Jul 2020 01:44:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728856AbgGVIl1 (ORCPT + 99 others); Wed, 22 Jul 2020 04:41:27 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:36208 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726638AbgGVIl1 (ORCPT ); Wed, 22 Jul 2020 04:41:27 -0400 Received: from localhost (unknown [192.168.167.69]) by lucky1.263xmail.com (Postfix) with ESMTP id 3F84AC1209; Wed, 22 Jul 2020 16:37:43 +0800 (CST) X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-ABS-CHECKED: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (postfix) whith ESMTP id P18496T139713711163136S1595407061138531_; Wed, 22 Jul 2020 16:37:42 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: <82baf5b43f5d54575472d2b82e280558> X-RL-SENDER: jon.lin@rock-chips.com X-SENDER: jon.lin@rock-chips.com X-LOGIN-NAME: jon.lin@rock-chips.com X-FST-TO: broonie@kernel.org X-SENDER-IP: 58.22.7.114 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 X-System-Flag: 0 From: Jon Lin To: broonie@kernel.org Cc: heiko@sntech.de, linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Jon Lin Subject: [PATCH v2 1/3] spi: rockchip: Config spi rx dma burst size depend on xfer length Date: Wed, 22 Jul 2020 16:37:35 +0800 Message-Id: <20200722083737.8820-1-jon.lin@rock-chips.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The burst length can be adjusted according to the transmission length to improve the transmission rate Signed-off-by: Jon Lin --- drivers/spi/spi-rockchip.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 9b8a5e1233c0..63593a5b87fa 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -384,6 +384,19 @@ static void rockchip_spi_dma_txcb(void *data) spi_finalize_current_transfer(ctlr); } +static u32 rockchip_spi_calc_burst_size(u32 data_len) +{ + u32 i; + + /* burst size: 1, 2, 4, 8 */ + for (i = 1; i < 8; i <<= 1) { + if (data_len & i) + break; + } + + return i; +} + static int rockchip_spi_prepare_dma(struct rockchip_spi *rs, struct spi_controller *ctlr, struct spi_transfer *xfer) { @@ -397,7 +410,8 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs, .direction = DMA_DEV_TO_MEM, .src_addr = rs->dma_addr_rx, .src_addr_width = rs->n_bytes, - .src_maxburst = 1, + .src_maxburst = rockchip_spi_calc_burst_size(xfer->len / + rs->n_bytes), }; dmaengine_slave_config(ctlr->dma_rx, &rxconf); @@ -525,7 +539,8 @@ static void rockchip_spi_config(struct rockchip_spi *rs, writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR); writel_relaxed(rs->fifo_len / 2, rs->regs + ROCKCHIP_SPI_DMATDLR); - writel_relaxed(0, rs->regs + ROCKCHIP_SPI_DMARDLR); + writel_relaxed(rockchip_spi_calc_burst_size(xfer->len / rs->n_bytes) - 1, + rs->regs + ROCKCHIP_SPI_DMARDLR); writel_relaxed(dmacr, rs->regs + ROCKCHIP_SPI_DMACR); /* the hardware only supports an even clock divisor, so -- 2.17.1