Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp934201ybh; Wed, 22 Jul 2020 17:45:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDDmhGFAMnKYqZT9gk/HxIgTId4lW4XvohCDYSy9J0gBtCrrvM27UTspkbQkoHPDmdo/9G X-Received: by 2002:a17:906:57c5:: with SMTP id u5mr1955882ejr.311.1595465105594; Wed, 22 Jul 2020 17:45:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595465105; cv=none; d=google.com; s=arc-20160816; b=CIOsvJVSglLVUPhPGtQasdCiV2OpDmOPoD0p5UM+fytrJGEthTHPkldd8fbsWhIXU3 dTRJu8FBHGlCM3AHvnTOd+oPWNfuBCh79IJ1VGNukk2wD5RCXHtiePswFrFzBK8bAWUQ DjCLnbOBZA6QbDPMdMMvx/Na56gxzMcRhE3ZrEARb4y8wHlTgcASm6K0vwTfE2rj74+0 WEfF9g4cjzgm8QzhwWSjxscNw12ieQeC80XL7fPC4V8CXKvLfZrvdRuRnRgiv5u83u1a Rnr2ZKkyBLc88ozDxuoiVYk8j8LETjmP+uc21aEWb7Ye/M86RtyMz/k3b3EpO0FDuK+Z Ar2Q== 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=9GRkFv8qQAE+TJXYI4y8gfMTcLBmwvy8EcETSoWUEL0=; b=ygL9O9ZpDInvVoD2pID7HsoSM0CZWetMUoMYJJmjySBOhyoaDKXl8rRZbh1a55S5MQ kvnMr4okz4W0udwkf59JH+/9GMw9fqlqORcUfEpJXDGhwKrbAtQnhtsEr/BBp32qZ+mu ycLbf0F3Or7iQq4rzpFCHbFQywNP349QBgFPCinJ6sB1AnX0hSXnO+Pr7HtAe+zzNvff 4t6tpw/BENiPo5VwTwDQBEgHfcp7eYttCKjaRusPkt3OXtsMssCmtKPskKU7JQ1BbNS0 O8vlVa+1/1Qjxxfj1ifqel/yEJUc1b2qa1Oi3GGV6vP4i/qZozjGYQxxli7RDTexSrEt n++A== 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 a12si6139edf.185.2020.07.22.17.44.43; Wed, 22 Jul 2020 17:45:05 -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 S1733187AbgGWAoH (ORCPT + 99 others); Wed, 22 Jul 2020 20:44:07 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:58912 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733114AbgGWAoG (ORCPT ); Wed, 22 Jul 2020 20:44:06 -0400 Received: from localhost (unknown [192.168.167.209]) by lucky1.263xmail.com (Postfix) with ESMTP id E51F1C5AAA; Thu, 23 Jul 2020 08:44: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 P17009T140099499042560S1595465038112439_; Thu, 23 Jul 2020 08:44: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, kernel@esmil.dk, Jon Lin Subject: [PATCH v3 1/3] spi: rockchip: Config spi rx dma burst size depend on xfer length Date: Thu, 23 Jul 2020 08:43:54 +0800 Message-Id: <20200723004356.6390-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 Reviewed-by: Emil Renner Berthing Tested-by: Emil Renner Berthing --- 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