Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2227615pxa; Mon, 17 Aug 2020 04:39:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQxL4ik4Oy0IhaEzBG/5hEsdnbo7E0yeU/QR1jcUqr4F683zi2TS0t538Z3x33SLeksBvR X-Received: by 2002:a17:906:3493:: with SMTP id g19mr15416500ejb.253.1597664359121; Mon, 17 Aug 2020 04:39:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597664359; cv=none; d=google.com; s=arc-20160816; b=bCMsQhcU7V0KhWteKOm7j3P3Gb9xKt4LOvyqrTx95J/hcO0XVOVWQbVCvjD6YGUnIL Qhvp5QHTkws4JYUoEmndRGOkW3kzKMkKUcophUA51sGpcBb6KrQkwoNFwfFdIpSQD+sh R/y3eTIFXayiqnt4joRIOKiDAA0eatTU4c6hfp0c3+OqL6+EQ2HudlYKMPHElpgkS+Fr +vLeFktEPuhV70fSQLs4VnxgsR0lExOyTyZQSI30pTMuAZZXrIBPc4TrRBv+Q2p1B+as f4ZUvzdD2LHI++UUgI88jvxRa2raEw53DiIXNPu9iu1GTDMAqXbE72se6i/FoVuNwsf3 Iibw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:ironport-sdr :dkim-signature; bh=qAiSySTl/y8QrdoOwS73hqC2vZPrIK22GvC7HIEK8Sw=; b=l4K3dz8ZEQUlQDJvKwLY+zGbR6MIvcypjH0ytEVJZg4fj40Knj2nR2DDvsOcNxMbfw /Dx2dE8o4bXf2X+v01KYneC2Yk5eWZHDvAkeHcxW6WRMgO1ecU0JmGbQRmyNZFXkEaxr h0dUw9kJlQMSN6kx1Pdy1GhyExc4F6bhEzuiLw2/C7C5G1W7E+hUrj9de2vrpeeZxZ+Y CgK2qcV39H50DvngBdzSe/mF5Fno0RmjG1rF37GM2508sq+a7KiEOGhnG803ZEC4SAHt 53m2tTifQEjDcipu+dNoUs75JFY9qErXvQQJ3KR6VquCDRW7B835+ghObYKPZus24U00 xZFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@skidata.com header.s=selector1 header.b=LP63tE3J; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=skidata.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si11148030edl.400.2020.08.17.04.38.56; Mon, 17 Aug 2020 04:39:19 -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; dkim=fail header.i=@skidata.com header.s=selector1 header.b=LP63tE3J; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=skidata.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726341AbgHQLiW (ORCPT + 99 others); Mon, 17 Aug 2020 07:38:22 -0400 Received: from mail2.skidata.com ([91.230.2.91]:5503 "EHLO mail2.skidata.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726161AbgHQLiQ (ORCPT ); Mon, 17 Aug 2020 07:38:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=skidata.com; i=@skidata.com; q=dns/txt; s=selector1; t=1597664295; x=1629200295; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=qAiSySTl/y8QrdoOwS73hqC2vZPrIK22GvC7HIEK8Sw=; b=LP63tE3J/JW2ErnnxJAehAh0T7+LeTm3GauBDpY8jJWSpOmTCkiomLNt xSxIHMFnQNyovd0/2aHVfx4HJGyc+QedBfLCAgswXz7VzO6mMQRdTtGs3 CHLHba95AO6BrIzEjGI1BwSgMTq11LnJi6zHCBbG3HVs33XolXG1MvgaG xNSPMxFp6O40rhqzgCJQtyxBBLCjqqnmMOH7w8prsfRyVSRGufSbKxP5c KB9HFM5hBOdG2S1GdZzsnitaBtSVzHif/HodY3OHO4mCuGzxLdaJnNiir NeKNBwCD4J4GYVz/0+uC3Z4yV9pgJ3k7Ov7SICIYFuVuJItxfJ3bhDllP Q==; IronPort-SDR: r14hO/kLklIsGQ2dnpEN7qM09P2f2aF1EjhAlxzmSMcuqfvXFBRe+N2g2GbNAQy6RBnH6mvub4 G9CzTCq5/0Xu34vgrQoODE4XvobffdAgUcNAoI/Wd3UL6Jq51FS5mK4HdyazyQntye83cu6C1d Utxs08P5rh1ovPmRJnbqt32sNVRq/vBpgr26ga+RPc5pxsLbfheQqpxpsN6+Av0kB6MiwftAt7 /fB6w62Tw9zJn1oFUf2wPuRXpstyhH7KMAs9dQhCYg8DlQFi2903uhUeTmOramaYOuZ2OpH0lA PAs= X-IronPort-AV: E=Sophos;i="5.76,322,1592863200"; d="scan'208";a="2642801" From: Benjamin Bara - SKIDATA To: Robin Gong CC: "timur@kernel.org" , "nicoleotsuka@gmail.com" , "vkoul@kernel.org" , "dan.j.williams@intel.com" , dl-linux-imx , "shawnguo@kernel.org" , "kernel@pengutronix.de" , "dmaengine@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "alsa-devel@alsa-project.org" , Richard Leitner - SKIDATA Subject: RE: pcm|dmaengine|imx-sdma race condition on i.MX6 Thread-Topic: pcm|dmaengine|imx-sdma race condition on i.MX6 Thread-Index: AQHWcWQZKYOChL0mPkuCFeZyDJy6mKk3KiiAgABS1/CABG6hAIAARo2Q Date: Mon, 17 Aug 2020 11:38:10 +0000 Message-ID: References: <20200813112258.GA327172@pcleri> <61498763c60e488a825e8dd270732b62@skidata.com> In-Reply-To: Accept-Language: en-US, de-AT Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.111.252] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Robin Gong > Sent: Montag, 17. August 2020 11:23 > busy_wait is not good I think, would you please have a try with the attac= hed patch > which is based on https://lkml.org/lkml/2020/8/11/111? The basic idea is > to keep the freed descriptor into another list for freeing in later termi= nate_worker > instead of freeing directly all in terminate_worker by vchan_get_all_desc= riptors > which may break next descriptor coming soon The idea sounds good, but with this attempt we are still not sure that the = 1ms (the ultimate reason why this is a problem) is awaited between DMA disablin= g and re-enabling. If we are allowed to leave the atomic PCM context on each trigger, synchron= ize the DMA and then enter it back again, everything is fine. This might be the most performant and elegant solution. However, since we are in an atomic context for a reason, it might not be wa= nted by the PCM system that the DMA termination completion of the previous context happens within = the next call, but we are not sure about that. In this case, a busy wait is not a good solution, but a necessary one, or at least the only valid solution we are aware of. Anyhow, based on my understanding, either the start or the stop trigger has= to wait the 1ms (or whats left of it).