Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp280845ybh; Tue, 21 Jul 2020 23:56:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBnIpfytrTz8yfzq5tgsEDvrXNudKFcXTRMnkZFW1bzU6+OhAPDAoYrz7SOrqN+TIJV8nz X-Received: by 2002:a50:9b5d:: with SMTP id a29mr29153615edj.68.1595400987469; Tue, 21 Jul 2020 23:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595400987; cv=none; d=google.com; s=arc-20160816; b=m7wqwSvHm3Bxicl9GtUSpLhvAlrK8AHTR6BPMvCxdOwy22Jp+PQE1o5PpCEX+LREB6 nNj5y6f1DFMer6r2z1eNEx6pU5f8TDt7v+Oov8BYB4ndJwn5VCYfZVY3VEf7iCWWTHWL wh9CLU880zbJjN/ccY6h9DQYxpNJhCOUeZ7tHzeWB7s6yT5oir0seABgud1btX8RRgEY FQzJOyxLpJoHhMiO8RTLXWpKSb5d3oxcQu10cbvySGuZ3F/XUy3DDJMzRgqb/Zw07UWP dbXFfKq3OpgbCj8+oIGQXKwKEhO/qVD1fJlOlJmZWpIodnXHBzBpZzfjJrn+tjQTBFwx Lqew== 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=pzvPXGxS42phPwnybgmfPYAzQgS38vi6blZwZm2Xd9xXNDnSmvwXLWYuU8KvjYsL4N aC2RtF6XaFPSHR9HU2jcAscxDdRPrv6Y8bYd8sghigbCl4yZdrDx7MuCeEewrQPglM/+ BF+/KwArpseh9IiYn4K3lGApfdPGPPZSgioRIk2tVrGS8lfLgyc8Rg4w7pLXnyG8A8hF 6T1muItKkwtVJ2ae4JvXMmDvQrqSoJ/M0b6AcX6tsDFkTo0THqnF+X95hcl4U7SWeZ+f Z2yl+WJ5xJLYh6fM9Or7J3tjlrLlc3zaZy/0KjqRuPN5kj6IIQfrR12osb76JgBa2/bx /ggw== 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 lm14si10615203ejb.335.2020.07.21.23.56.04; Tue, 21 Jul 2020 23:56:27 -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 S1730346AbgGVGxI (ORCPT + 99 others); Wed, 22 Jul 2020 02:53:08 -0400 Received: from lucky1.263xmail.com ([211.157.147.135]:43236 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727922AbgGVGxI (ORCPT ); Wed, 22 Jul 2020 02:53:08 -0400 Received: from localhost (unknown [192.168.167.16]) by lucky1.263xmail.com (Postfix) with ESMTP id 12E65A186D; Wed, 22 Jul 2020 14:53:00 +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 P18585T140686821160704S1595400779440716_; Wed, 22 Jul 2020 14:53:00 +0800 (CST) X-IP-DOMAINF: 1 X-UNIQUE-TAG: 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 v1 1/3] spi: rockchip: Config spi rx dma burst size depend on xfer length Date: Wed, 22 Jul 2020 14:52:55 +0800 Message-Id: <20200722065257.17943-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