From patchwork Fri Apr 12 10:53:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 10897991 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9ED81390 for ; Fri, 12 Apr 2019 10:54:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C717F28B8C for ; Fri, 12 Apr 2019 10:54:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB31628E53; Fri, 12 Apr 2019 10:54:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 72A9528B8C for ; Fri, 12 Apr 2019 10:54:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wLHEg6PMiGgTpbtiMhnLRQRRvO4RE7Hl/puFjK33KaQ=; b=L0Jiw9A8FBXCf0 MxtpsraMeEhj/A4Y271APe4yp1m8AmTWF38Ki5fym9NJrtsLhSCMduDcNBt3/Nh8ON6MNB9fg9Khj 8PCu1W9wOPFJGiAh80erVg2mt3fNjI4f2ft+a8k6khbEG6i1I2vTIwvxbvzLPsrvEyQxY5ktBWRRU vr7Wnh387J82rNSY6sfz82BUPnqc7MHKlkvl667N930D/dSQZ++ayg5CgM2YUo5Y25B4/AOnudVPt bhIO/o4Is572a+zVGh1zxej5qSPxZenI4xWtb1Im978GHi2+DTsXBod2VbyCKDsopR0/E5I05gtBb LSROJE2cRlfDaWHqNASA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEtpA-0004be-8q; Fri, 12 Apr 2019 10:54:24 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hEtp5-0004Up-Nz; Fri, 12 Apr 2019 10:54:21 +0000 Received: by mail-ed1-x541.google.com with SMTP id d1so7910791edd.13; Fri, 12 Apr 2019 03:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xKIfWCxHbhwFJ1+b/MwpbnrM3F2wdwu1e4NkzCc5CUM=; b=b6kl5u4gCyhc3RlJhHnrlp0Ruz7qcDwYdEYS37U+BV0XzFWCCcXpovAw/CUAILObFk pTI2PARuYgVvelWMzAY4Ak9444kwJ5AkILEHBktWN+sEAETdd9eWnvcR/OVw1LjrZqYH hVxx/jupdVUuUHBvQdkCqMJIKd1Cx+qkUqg4T1S3DOBv9qclj7c13NWaKw5N2sh5RA+r ZyU4TYhxdjJJItlvDykMuluOhNFXRXssaVttuYTXQZeYlvKHaTXforCTvrW3EM6ISnvo 83h5Rul633cpgi1EnXhLeI2Ne74Lb0g+BSO5lnYM/jAp/RiXnRN38yi3r8R7hYpOYEeB s+dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=xKIfWCxHbhwFJ1+b/MwpbnrM3F2wdwu1e4NkzCc5CUM=; b=P1c84Xb1u4U1woVlpHW9pupXRdrtQqNpmsg9O/bFr2i9PubSzTeq94kHKpP7a/YZEm Xfyn+jsPUgkxgVYXzeBMxzQ4UXLUVBJA4DKuUyJSbvGrCBlPoBYioIfFrrADkCYjLKwm x91uun4cbbsBsDxqohUZRau+QjDQgGerlrCbBcbsODu2kATsX/fWpLmL9wjnoi/Nysg3 ZDO8ujTQg1yNjqhKOZ7AR6E01oWv/kTC12yEtuxrMLLKQztoJ8vBkcJn7lZyLOkCT1N+ J8dRAIEtb6Py3ParQziBjc1CMbDut6Lg/Libif5acXUi73y/Lw7RsN6BfZ/syHYWA5Gh NKow== X-Gm-Message-State: APjAAAXB1sNJ+3gN3wFynIiiFF0Gy9gDs3ZgSlzQZWg5RsagCYOEruhi n7MgtMUsmIGBYRCbdA3JLG4= X-Google-Smtp-Source: APXvYqxe6QhezhBCK+opbYcdALZLkgRza3g2v2TvYPzD8jEQ0r9PChlcheUh07eMQCr/Xr7fdkmk7g== X-Received: by 2002:a17:906:2f13:: with SMTP id v19mr30567233eji.17.1555066457744; Fri, 12 Apr 2019 03:54:17 -0700 (PDT) Received: from localhost.localdomain ([2a01:4262:1ab:e::10]) by smtp.gmail.com with ESMTPSA id y71sm2862750ede.21.2019.04.12.03.54.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 03:54:13 -0700 (PDT) From: Emil Renner Berthing To: linux-spi@vger.kernel.org Subject: [PATCH] spi: rockchip: turn down tx dma bursts Date: Fri, 12 Apr 2019 12:53:20 +0200 Message-Id: <20190412105320.2924-1-kernel@esmil.dk> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190412_035419_804851_0104D69F X-CRM114-Status: GOOD ( 12.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , linux-kernel@vger.kernel.org, Vicente Bergas , linux-rockchip@lists.infradead.org, Mark Brown , Robin Murphy , linux-arm-kernel@lists.infradead.org, Emil Renner Berthing Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This fixes tx and bi-directional dma transfers on rk3399-gru-kevin. It seems the SPI fifo must have room for 2 bursts when the dma_tx_req signal is generated or it might skip some words. This in turn makes the rx dma channel never complete for bi-directional transfers. Fix it by setting tx burst length to fifo_len / 4 and the dma watermark to fifo_len / 2. However the rk3399 TRM says (sic): "DMAC support incrementing-address burst and fixed-address burst. But in the case of access SPI and UART at byte or halfword size, DMAC only support fixed-address burst and the address must be aligned to word." So this relies on fifo_len being a multiple of 16 such that the burst length (= fifo_len / 4) is a multiple of 4 and the addresses will be word-aligned. Fixes: dcfc861d24ec ("spi: rockchip: adjust dma watermark and burstlen") Signed-off-by: Emil Renner Berthing --- drivers/spi/spi-rockchip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 3912526ead66..19f6a76f1c07 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -425,7 +425,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs, .direction = DMA_MEM_TO_DEV, .dst_addr = rs->dma_addr_tx, .dst_addr_width = rs->n_bytes, - .dst_maxburst = rs->fifo_len / 2, + .dst_maxburst = rs->fifo_len / 4, }; dmaengine_slave_config(master->dma_tx, &txconf); @@ -526,7 +526,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs, else writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_RXFTLR); - writel_relaxed(rs->fifo_len / 2 - 1, rs->regs + ROCKCHIP_SPI_DMATDLR); + writel_relaxed(rs->fifo_len / 2, rs->regs + ROCKCHIP_SPI_DMATDLR); writel_relaxed(0, rs->regs + ROCKCHIP_SPI_DMARDLR); writel_relaxed(dmacr, rs->regs + ROCKCHIP_SPI_DMACR);