From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Subject: dmaengine: at_xdmac: Fix wrongfull report of a channel as in use From: Vinod Koul Message-Id: <20190123121641.GN4635@vkoul-mobl> Date: Wed, 23 Jan 2019 17:46:41 +0530 To: Codrin.Ciubotariu@microchip.com Cc: Ludovic.Desroches@microchip.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org List-ID: T24gMjEtMDEtMTksIDE0OjM4LCBDb2RyaW4uQ2l1Ym90YXJpdUBtaWNyb2NoaXAuY29tIHdyb3Rl Ogo+IE9uIDIwLjAxLjIwMTkgMTM6MDQsIFZpbm9kIEtvdWwgd3JvdGU6Cj4gPiBIaSBDb2RyaW4s Cj4gPiAKPiA+IE9uIDE3LTAxLTE5LCAxNjoxMCwgQ29kcmluLkNpdWJvdGFyaXVAbWljcm9jaGlw LmNvbSB3cm90ZToKPiA+PiBGcm9tOiBDb2RyaW4gQ2l1Ym90YXJpdSA8Y29kcmluLmNpdWJvdGFy aXVAbWljcm9jaGlwLmNvbT4KPiA+Pgo+ID4+IGF0Y2hhbi0+c3RhdHVzIGlzIHVzZWQgZm9yIHR3 byB0aGluZ3M6Cj4gPj4gICAtIHBhc3MgY2hhbm5lbCBpbnRlcnJ1cHRzIHN0YXR1cyBmcm9tIGlu dGVycnVwdCBoYW5kbGVyIHRvIHRhc2tsZXQ7Cj4gPj4gICAtIGNoYW5uZWwgaW5mb3JtYXRpb24g bGlrZSB3aGV0aGVyIGl0IGlzIGN5Y2xpYyBvciBwYXVzZWQ7Cj4gPj4KPiA+PiBTaW5jZSB0aGVz ZSBvcGVyYXRpb25zIGhhdmUgbm90aGluZyBpbiBjb21tb24sIHRoaXMgcGF0Y2ggYWRkcyBhCj4g Pj4gZGlmZmVyZW50IHN0cnVjdCBtZW1iZXIgdG8ga2VlcCB0aGUgaW50ZXJydXB0cyBzdGF0dXMu C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N0YXR1cykgYW5kIHRo ZW4gYSBsYXRlIEVuZCAKPiBvZiBCbG9jayBpbnRlcnJ1cHQgYXJyaXZlcyAoQVRfWERNQUNfQ0lT X0JJUyksIHdoaWNoIHNldHMgYml0IDAgb2YgCj4gYXRjaGFuLT5zdGF0dXMuIEJpdCAwIGlzIGFs c28gdXNlZCBmb3IgQVRfWERNQUNfQ0hBTl9JU19DWUNMSUMsIHNvIHdoZW4gCj4gYSBuZXcgZGVz Y3JpcHRvciBmb3IgYSBjeWNsaWMgdHJhbnNmZXIgaXMgY3JlYXRlZCwgdGhlIGRyaXZlciByZXBv cnRzIAo+IHRoZSBjaGFubmVsIGFzIGluIHVzZToKPiAKPiBpZiAodGVzdF9hbmRfc2V0X2JpdChB VF9YRE1BQ19DSEFOX0lTX0NZQ0xJQywgJmF0Y2hhbi0+c3RhdHVzKSkgewo+IAlkZXZfZXJyKGNo YW4yZGV2KGNoYW4pLCAiY2hhbm5lbCBjdXJyZW50bHkgdXNlZFxuIik7Cj4gCXJldHVybiBOVUxM Owo+IH0KPiAKPiBJIGNhbiBzZW5kIHYyIGlmIHlvdSBjb25zaWRlciB0aGUgY29tbWl0IG1lc3Nh Z2UgbWlzbGVhZGluZy4KClllcyBwbGVhc2UsIHRoYXQgd291bGQgYmUgYmV0dGVyIGFuZCBwbHMg YWRkIGZpeGVzIGFzIHN1Z2dlc3RlZCBieQpMdWRvdmljIGFsb25nIHdpdGggaGlzIGFjawo= From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 188CCC282C0 for ; Wed, 23 Jan 2019 12:18:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB9F520861 for ; Wed, 23 Jan 2019 12:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548245895; bh=NeuDsS0OVy3+Ri+RiplV7k5Lp6RvyBQuzJB+RSICNRI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=j7JxXvghSdVhEHMK6OEtOIpDaJiMTF8Bs+ZIkfrvjJN/EInOboeXUhplmIQsw/Z9T idKWEOV7beIHZiFVuikL4JoXnPF3fDd/SgL/M+TWhiY1FCPA32xeQQXplU5hFTXI/W 0GB8w3+/Ea0L9E3gBZuhCbS6sL2P7sJ7aeK4XSo4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727131AbfAWMSO (ORCPT ); Wed, 23 Jan 2019 07:18:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:47690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726057AbfAWMSO (ORCPT ); Wed, 23 Jan 2019 07:18:14 -0500 Received: from localhost (unknown [106.200.229.238]) (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 CF31720861; Wed, 23 Jan 2019 12:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548245893; bh=NeuDsS0OVy3+Ri+RiplV7k5Lp6RvyBQuzJB+RSICNRI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2LLZhpUqgwWX5T3ieq4dqEoHObIm3jwhGgEzxIjATPfClNAAMvmKMFcFTffiX5+ee oW/+NuTuMUV/X9qJUCQ0om8QZX9I4wD//zQZIqGU1ttcmInQCJ9I9jmSPJrVGIW/Hr 7VBK2c1JThgeLyXNP/KXB+PpCWwrQr9lnB0xEyeM= Date: Wed, 23 Jan 2019 17:46:41 +0530 From: Vinod Koul To: Codrin.Ciubotariu@microchip.com Cc: Ludovic.Desroches@microchip.com, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dmaengine: at_xdmac: Fix wrongfull report of a channel as in use Message-ID: <20190123121641.GN4635@vkoul-mobl> References: <20190117160957.13175-1-codrin.ciubotariu@microchip.com> <20190120110417.GS4635@vkoul-mobl> <450ee975-a603-cf89-0000-13156c1cb5e8@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <450ee975-a603-cf89-0000-13156c1cb5e8@microchip.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-01-19, 14:38, Codrin.Ciubotariu@microchip.com wrote: > On 20.01.2019 13:04, Vinod Koul wrote: > > Hi Codrin, > > > > On 17-01-19, 16:10, Codrin.Ciubotariu@microchip.com wrote: > >> From: Codrin Ciubotariu > >> > >> atchan->status is used for two things: > >> - pass channel interrupts status from interrupt handler to tasklet; > >> - channel information like whether it is cyclic or paused; > >> > >> Since these operations have nothing in common, this patch adds a > >> different struct member to keep the interrupts status. > >> > >> Fixes a bug in which a channel is wrongfully reported as in use when > >> trying to obtain a new descriptior for a previously used cyclic channel. > > > > This looks reasonable but am unable to see how the bug is fixed. Perhaps > > would be great to split the bug part (which can go to fixes) and remove > > the reuse of variable as a subsequent patch.. > > Hi Vinod, > > This patch is the fix, since it moves the operations on atchan->status, > in which the interrupt status register is saved, to a different member > (irq_status). The AT_XDMAC_CHAN_IS_CYCLIC and AT_XDMAC_CHAN_IS_PAUSED > bits have nothing in common with the interrupt status register. > > The bug reproduces when a 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; > } > > I can send v2 if you consider the commit message misleading. Yes please, that would be better and pls add fixes as suggested by Ludovic along with his ack -- ~Vinod From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78109C282C0 for ; Wed, 23 Jan 2019 12:18:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 33BE120861 for ; Wed, 23 Jan 2019 12:18:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ogEThNOx"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="2LLZhpUq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33BE120861 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GGFQhh4I2qNWLRx4JMO7heW3dZEJwpc2gbtqPqjicAM=; b=ogEThNOxLyQy2+ vt4as50PwNgRXQTxqaUWzLURTb+jgxUv5AAkeCOjj1w8hUzp9JpFosyR9EcDGRaz6kl5x7scstYHV lQlo3YpJzwDGT2CEG582CGA3fvs4RffVEzQNcXaRj0XxL1j6YZooNTIUKcWi+PIPZepQ1vifk9BKC lICY93iDmu0Ecs2hNc8Ug5h2IQ2LhKKhB7WvR6y59UGVqTp7hxlziq7A7gVGrOdmubuN16YA77bKC gQ+vLOV0axpZyZ2acwOJ8bI0Io1/cbhZdzI04S61Lx+gk9nD7/YNZ/jDPiGYoFA8e+1pP+JeE+QF9 9sBdNz2xy1jz1ssq2L2A==; 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 1gmHU0-0006uO-QI; Wed, 23 Jan 2019 12:18:16 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gmHTy-0006tv-1o for linux-arm-kernel@lists.infradead.org; Wed, 23 Jan 2019 12:18:15 +0000 Received: from localhost (unknown [106.200.229.238]) (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 CF31720861; Wed, 23 Jan 2019 12:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548245893; bh=NeuDsS0OVy3+Ri+RiplV7k5Lp6RvyBQuzJB+RSICNRI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2LLZhpUqgwWX5T3ieq4dqEoHObIm3jwhGgEzxIjATPfClNAAMvmKMFcFTffiX5+ee oW/+NuTuMUV/X9qJUCQ0om8QZX9I4wD//zQZIqGU1ttcmInQCJ9I9jmSPJrVGIW/Hr 7VBK2c1JThgeLyXNP/KXB+PpCWwrQr9lnB0xEyeM= Date: Wed, 23 Jan 2019 17:46:41 +0530 From: Vinod Koul To: Codrin.Ciubotariu@microchip.com Subject: Re: [PATCH] dmaengine: at_xdmac: Fix wrongfull report of a channel as in use Message-ID: <20190123121641.GN4635@vkoul-mobl> References: <20190117160957.13175-1-codrin.ciubotariu@microchip.com> <20190120110417.GS4635@vkoul-mobl> <450ee975-a603-cf89-0000-13156c1cb5e8@microchip.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <450ee975-a603-cf89-0000-13156c1cb5e8@microchip.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190123_041814_112776_E9E3B27F X-CRM114-Status: GOOD ( 20.13 ) 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: dmaengine@vger.kernel.org, Ludovic.Desroches@microchip.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 21-01-19, 14:38, Codrin.Ciubotariu@microchip.com wrote: > On 20.01.2019 13:04, Vinod Koul wrote: > > Hi Codrin, > > > > On 17-01-19, 16:10, Codrin.Ciubotariu@microchip.com wrote: > >> From: Codrin Ciubotariu > >> > >> atchan->status is used for two things: > >> - pass channel interrupts status from interrupt handler to tasklet; > >> - channel information like whether it is cyclic or paused; > >> > >> Since these operations have nothing in common, this patch adds a > >> different struct member to keep the interrupts status. > >> > >> Fixes a bug in which a channel is wrongfully reported as in use when > >> trying to obtain a new descriptior for a previously used cyclic channel. > > > > This looks reasonable but am unable to see how the bug is fixed. Perhaps > > would be great to split the bug part (which can go to fixes) and remove > > the reuse of variable as a subsequent patch.. > > Hi Vinod, > > This patch is the fix, since it moves the operations on atchan->status, > in which the interrupt status register is saved, to a different member > (irq_status). The AT_XDMAC_CHAN_IS_CYCLIC and AT_XDMAC_CHAN_IS_PAUSED > bits have nothing in common with the interrupt status register. > > The bug reproduces when a 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; > } > > I can send v2 if you consider the commit message misleading. Yes please, that would be better and pls add fixes as suggested by Ludovic along with his ack -- ~Vinod _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel