From patchwork Sat May 13 22:13:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Sverdlin X-Patchwork-Id: 9725449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7102660146 for ; Sat, 13 May 2017 22:15:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63D08288F3 for ; Sat, 13 May 2017 22:15:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57AC1288F9; Sat, 13 May 2017 22:15:41 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE008288F3 for ; Sat, 13 May 2017 22:15:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756939AbdEMWPj (ORCPT ); Sat, 13 May 2017 18:15:39 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:35437 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755053AbdEMWPi (ORCPT ); Sat, 13 May 2017 18:15:38 -0400 Received: by mail-lf0-f65.google.com with SMTP id 99so2683365lfu.2; Sat, 13 May 2017 15:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aztsYLHJhFFO+f4Ln40T17lQzcd8fYyKPIk82jR4QVc=; b=cdhq3afmP8gYTigBDp0v9jNkiRPOwgkSjVgjGW1MKePaaevjOdAgkLVxmSnmq+9zW2 AkRcgHWmbSXUkb4hOfpnjzlaXfflLxThm7f4VPQFz0WM2PyMsPL3Qh+1hlRQbU6ahzpQ DIR/9958hvxLGMnDk2enf2wPucLNNOBS0204P0KvkPVl3ofoAQMMjzbpW2v0Crgr46dA EbFrbNYZRUdfoUNd/+nSf/RTbozP01dxz1QtznpULycSjiJSLdk5id3Y10kIA/ri/lV4 FybKMvEGje9gj3VnPX3AP/Wyfi6djYoNdEuros3vhziYcETUCqsL6vHwf40V6VTDlV+6 yuMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aztsYLHJhFFO+f4Ln40T17lQzcd8fYyKPIk82jR4QVc=; b=kz+D9Q+nabm2DYq/Ic9Ed8cOflqgwnubKbDcTd8qtqYFGj52Z1o3ty8PfBVvE+cQjz +RXvPGT8QSdiNrxX9i7fB1B6T2H+OBJeLglyZqhSHVxU9mrQBD+x8+n7GfQtoe0b/wqs 5AJMAQ3IZ3ma+0MDH8I9+0VVZ4BT0ZkGnT59mbuQa5DPUKp7pXWwl/t7oR1ajbLxieMd kDukUKzj6IR9MELhQWAvrx19UpbpenhHyO9GdfJv4ykvlot8XWOUnK4PIGrp3I2eCIdk 5UCucCUyZvsw+zaFHx4BNIlkr1/Vdvq8GU80t3GBq5MW2fti0UEztbcLgg9v0rFBCkiU WcZA== X-Gm-Message-State: AODbwcBevu1SylwBTl7+CWODQ14RkSGufDgHrKYKzCDdC2Vx6Aqr4m1c c7YvXX7UThV/INlB X-Received: by 10.25.26.81 with SMTP id a78mr2508292lfa.5.1494713736490; Sat, 13 May 2017 15:15:36 -0700 (PDT) Received: from giga1.localdomain ([195.245.52.203]) by smtp.gmail.com with ESMTPSA id u24sm1301705ljd.34.2017.05.13.15.15.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 May 2017 15:15:35 -0700 (PDT) From: Alexander Sverdlin To: dmaengine@vger.kernel.org Cc: Alexander Sverdlin , Dan Williams , Vinod Koul , stable@vger.kernel.org Subject: [PATCH 1/2] dmaengine: ep93xx: Always start from BASE0 Date: Sun, 14 May 2017 00:13:26 +0200 Message-Id: <20170513221327.10114-2-alexander.sverdlin@gmail.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170513221327.10114-1-alexander.sverdlin@gmail.com> References: <20170513221327.10114-1-alexander.sverdlin@gmail.com> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The current buffer is being reset to zero on device_free_chan_resources() but not on device_terminate_all(). It could happen that HW is restarted and expects BASE0 to be used, but the driver is not synchronized and will start from BASE1. Therefore, it's better to reset the buffer explicitly in m2p_hw_setup(). While here, check that HW really starts from BASE0 and warn otherwise. Signed-off-by: Alexander Sverdlin Cc: stable@vger.kernel.org --- drivers/dma/ep93xx_dma.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c index d37e8dda8079..a3d946d2a8e1 100644 --- a/drivers/dma/ep93xx_dma.c +++ b/drivers/dma/ep93xx_dma.c @@ -45,6 +45,7 @@ #define M2P_PPALLOC 0x0008 #define M2P_STATUS 0x000c +#define M2P_STATUS_NEXTBUFFER BIT(6) #define M2P_MAXCNT0 0x0020 #define M2P_BASE0 0x0024 @@ -312,6 +313,13 @@ static void m2p_set_control(struct ep93xx_dma_chan *edmac, u32 control) readl(edmac->regs + M2P_CONTROL); } +static inline u32 m2p_channel_nextbuf(struct ep93xx_dma_chan *edmac) +{ + if (readl(edmac->regs + M2P_STATUS) & M2P_STATUS_NEXTBUFFER) + return 1; + return 0; +} + static int m2p_hw_setup(struct ep93xx_dma_chan *edmac) { struct ep93xx_dma_data *data = edmac->chan.private; @@ -323,6 +331,10 @@ static int m2p_hw_setup(struct ep93xx_dma_chan *edmac) | M2P_CONTROL_ENABLE; m2p_set_control(edmac, control); + if (m2p_channel_nextbuf(edmac) != 0) + dev_warn(chan2dev(edmac), "M2P: Starting from BASE1\n"); + edmac->buffer = 0; + return 0; }