Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2268156imc; Tue, 12 Mar 2019 10:14:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwggiioyfqfWgN1WvVpEHqpmPq1mp0aGDA5uv23rPh1UQVfMx5agBpxL7/8wTO1ppvMTxjB X-Received: by 2002:a17:902:6b47:: with SMTP id g7mr41713100plt.100.1552410897154; Tue, 12 Mar 2019 10:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552410897; cv=none; d=google.com; s=arc-20160816; b=Pga9VtDms7YvFtzgRC8BeD7T2gNBDH1bCFStZXY7PT3w0JkQZ26Zy7dN8J5uhfv0B4 jxe13EiDqGjudCp5nEt0QcjZRFopynGX7/EnIV1dtSVkpCLaux2gUw7KGSNMNVz1MLAI JQKzJru9yoKKvHKkw4Ntsi5mb29zNoE/xf+1Z9JNLJeDZyf4IQToKv0a86d3fowIqcnS MPZBbLMqJdm5/c9+ncuMoowclzqDbHCy4SE5PBFETwDRD6ztP531Z+ljaoKGylHkz0bS 6LmkbvuB2UJKOxs7oad5gJPiwjMLlYc4JpVE4SPzJ2CHRe2JFu8MN8UGF1NQr0zORmdE WLsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KFuWOOfwWGqGqt20MnE5ORLdlaNCauEWCw6TA+y1IvA=; b=UcCXaKIOd8UpyYBR4fZGGzO7/AJHIuhMHRzUdzhdeSAOKH/CS3XbPIxRliO8v6jX7t EJbICntyjZPM+0+0O5KpANYc+4jbLufuHJwgxz5sX/5xI3WR/qAzmiOhXxYYgEnfRNxD 6S/QommzAEdzDxTx7cuFCPEQqPL+mdX+f+SXCHO78wW369B9D9wpivPoLaoFrfE5vn+o 0UALrWJbnz9IcqxS0eI3jOXcIPW7hKaoqubZe59K0ccUR8vFLqAKn64EejfDPRYXNbfK 4ydxXMEaShGxJX34dIOXlueaYIy4r82fsQRIY74nCwbitGc9KV1JxiAZff9FTea+98Jj CsYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iR+aOU6P; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d25si7857172pgv.468.2019.03.12.10.14.41; Tue, 12 Mar 2019 10:14:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iR+aOU6P; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727988AbfCLRNg (ORCPT + 99 others); Tue, 12 Mar 2019 13:13:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:49126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727725AbfCLRM7 (ORCPT ); Tue, 12 Mar 2019 13:12:59 -0400 Received: from localhost (unknown [104.133.8.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AE131217D4; Tue, 12 Mar 2019 17:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552410778; bh=XxuUbZsz7VTvVZyCUF8PA7i5ndaKkaD4MoaZInej/HU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iR+aOU6P06O1iE/q6T05xnCZ6SKnOovcKK14GhA3J3UD3CN5/23tZ9EJGM2MYpaBC 3yqZqiLgiImLIm+/F6pGbJoT7oHpwnyXPSfQLRBe2EuqrvnGWZ+IybSt3wplYZLX6k 81zMiXWzKl3j0bB9uvlVA91uP9awgJREDPfYv39I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Codrin Ciubotariu , Ludovic Desroches , Vinod Koul , Sasha Levin Subject: [PATCH 4.20 118/171] dmaengine: at_xdmac: Fix wrongfull report of a channel as in use Date: Tue, 12 Mar 2019 10:08:18 -0700 Message-Id: <20190312170358.027167167@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190312170347.868927101@linuxfoundation.org> References: <20190312170347.868927101@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit dc3f595b6617ebc0307e0ce151e8f2f2b2489b95 ] atchan->status variable is used to store two different information: - pass channel interrupts status from interrupt handler to tasklet; - channel information like whether it is cyclic or paused; This causes a bug when device_terminate_all() is called, (AT_XDMAC_CHAN_IS_CYCLIC cleared on atchan->status) and then a late End of Block interrupt arrives (AT_XDMAC_CIS_BIS), which sets bit 0 of atchan->status. Bit 0 is also used for AT_XDMAC_CHAN_IS_CYCLIC, so when a new descriptor for a cyclic transfer is created, the driver reports the channel as in use: if (test_and_set_bit(AT_XDMAC_CHAN_IS_CYCLIC, &atchan->status)) { dev_err(chan2dev(chan), "channel currently used\n"); return NULL; } This patch fixes the bug by adding a different struct member to keep the interrupts status separated from the channel status bits. Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver") Signed-off-by: Codrin Ciubotariu Acked-by: Ludovic Desroches Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/at_xdmac.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c index 4e557684f792..fe69dccfa0c0 100644 --- a/drivers/dma/at_xdmac.c +++ b/drivers/dma/at_xdmac.c @@ -203,6 +203,7 @@ struct at_xdmac_chan { u32 save_cim; u32 save_cnda; u32 save_cndc; + u32 irq_status; unsigned long status; struct tasklet_struct tasklet; struct dma_slave_config sconfig; @@ -1580,8 +1581,8 @@ static void at_xdmac_tasklet(unsigned long data) struct at_xdmac_desc *desc; u32 error_mask; - dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08lx\n", - __func__, atchan->status); + dev_dbg(chan2dev(&atchan->chan), "%s: status=0x%08x\n", + __func__, atchan->irq_status); error_mask = AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS @@ -1589,15 +1590,15 @@ static void at_xdmac_tasklet(unsigned long data) if (at_xdmac_chan_is_cyclic(atchan)) { at_xdmac_handle_cyclic(atchan); - } else if ((atchan->status & AT_XDMAC_CIS_LIS) - || (atchan->status & error_mask)) { + } else if ((atchan->irq_status & AT_XDMAC_CIS_LIS) + || (atchan->irq_status & error_mask)) { struct dma_async_tx_descriptor *txd; - if (atchan->status & AT_XDMAC_CIS_RBEIS) + if (atchan->irq_status & AT_XDMAC_CIS_RBEIS) dev_err(chan2dev(&atchan->chan), "read bus error!!!"); - if (atchan->status & AT_XDMAC_CIS_WBEIS) + if (atchan->irq_status & AT_XDMAC_CIS_WBEIS) dev_err(chan2dev(&atchan->chan), "write bus error!!!"); - if (atchan->status & AT_XDMAC_CIS_ROIS) + if (atchan->irq_status & AT_XDMAC_CIS_ROIS) dev_err(chan2dev(&atchan->chan), "request overflow error!!!"); spin_lock(&atchan->lock); @@ -1652,7 +1653,7 @@ static irqreturn_t at_xdmac_interrupt(int irq, void *dev_id) atchan = &atxdmac->chan[i]; chan_imr = at_xdmac_chan_read(atchan, AT_XDMAC_CIM); chan_status = at_xdmac_chan_read(atchan, AT_XDMAC_CIS); - atchan->status = chan_status & chan_imr; + atchan->irq_status = chan_status & chan_imr; dev_vdbg(atxdmac->dma.dev, "%s: chan%d: imr=0x%x, status=0x%x\n", __func__, i, chan_imr, chan_status); @@ -1666,7 +1667,7 @@ static irqreturn_t at_xdmac_interrupt(int irq, void *dev_id) at_xdmac_chan_read(atchan, AT_XDMAC_CDA), at_xdmac_chan_read(atchan, AT_XDMAC_CUBC)); - if (atchan->status & (AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS)) + if (atchan->irq_status & (AT_XDMAC_CIS_RBEIS | AT_XDMAC_CIS_WBEIS)) at_xdmac_write(atxdmac, AT_XDMAC_GD, atchan->mask); tasklet_schedule(&atchan->tasklet); -- 2.19.1