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=-0.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no 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 0D7E4C432C3 for ; Fri, 22 Nov 2019 18:15:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 8DD812067D for ; Fri, 22 Nov 2019 18:15:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="Op7T5yWL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DD812067D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mentor.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CE54E1816; Fri, 22 Nov 2019 18:57:58 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CE54E1816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1574445528; bh=0Wx/iA/CbR5gDbqV7qAaHZdTtW108jfTI2+1cg/l5qU=; h=From:To:References:In-Reply-To:Date:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Op7T5yWLWWY7t3t3+OpqEokUslTvhgl4I8k3GcX2l0YezYKZeZKQJqJrWR3x3Fhpc USJtKOKBkRmZwquGMKW5pU9mG4b6fun3eRvlv4H4Nz4RtkwwAbSsViONjfwV60rZqV VyB32ZaD5OoVag2oPP32cj+KKoE2wDz1VbpoWHV8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5C3E3F8013F; Fri, 22 Nov 2019 18:57:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3B28AF80140; Fri, 22 Nov 2019 18:57:57 +0100 (CET) Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 62AA4F800EF for ; Fri, 22 Nov 2019 18:57:52 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 62AA4F800EF IronPort-SDR: W6goTO94ykNvLWI1XUpfn6cgC8HkjyjS+acPdhN+uSkHRVOWztqxZW9UstCGOXEwFlYSAIwm2D PAaQYQ26YAxWxowANKPZATvnQC53ZU2x53jvuV+Q0aFm6o/WuxN0VFbn/ffG3Gr4F+SwmQZQLC 5QSDWM8b7h5FdYRq2IfpyfEx2Jsi4osEL4TwUG7trA3M8fE8WhWK4dlWqCfaI14+Fq93I1uQoq vUd4O0Tc7YvCwLaKF9fLSDdTODlzHrKpyzVXL4azcbH/0WWdwJR467k6wZQEna4rmhyvFXnUbL 9xI= X-IronPort-AV: E=Sophos;i="5.69,230,1571731200"; d="scan'208";a="45307818" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 22 Nov 2019 09:57:49 -0800 IronPort-SDR: lqQfW2r8D2WklT+Wja549BGc5dY5HXVZ5gKTGsCblkSa1szwOnIRCy9N+EZNGXMgqEfCY6Eyt5 z7o2QNP/yY2YH26Xvbvr4jaSN/LqY/2Gbmy5W83WVgNG53vYh162eAGRzU4Iqx68qJCsLLUQQw Q7zNPbO3MbpaJYmCjua7/TUNusOTdkSmMGbtSwDyT+F/ITjIoWXpk7UqBt6fLYGMC/I88IYGPv SIPQMdmPQRZpfzp4n9iJZ2U3ml50HRjTa7xdNPo087ZwMTUx4FDsLoRCyEMP6biYGIBqtZ0VBZ JSQ= From: Andrew Gabbasov To: 'Takashi Iwai' References: <20191120174955.6410-1-andrew_gabbasov@mentor.com> In-Reply-To: Date: Fri, 22 Nov 2019 20:56:42 +0300 Organization: Mentor Graphics Corporation Message-ID: <000001d5a15e$3dc81c20$b9585460$@mentor.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQHVn8sGSSfaGACQHE2XYQ6MReKZVqeUZruAgAKrbqA= Content-Language: en-us X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) To svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) Cc: Timo Wischer , alsa-devel@alsa-project.org, Takashi Iwai , linux-kernel@vger.kernel.org Subject: Re: [alsa-devel] [PATCH v5 0/7] ALSA: aloop: Support sound timer as clock source instead of jiffies X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hello Takashi, > -----Original Message----- > From: Takashi Iwai [mailto:tiwai@suse.de] > Sent: Wednesday, November 20, 2019 9:49 PM > To: Gabbasov, Andrew > Cc: alsa-devel@alsa-project.org; linux-kernel@vger.kernel.org; Jaroslav > Kysela; Takashi Iwai; Timo Wischer > Subject: Re: [PATCH v5 0/7] ALSA: aloop: Support sound timer as clock > source instead of jiffies > > On Wed, 20 Nov 2019 18:49:48 +0100, > Andrew Gabbasov wrote: > > > > This patch set is an updated version of patches by Timo Wischer: > > https://mailman.alsa-project.org/pipermail/alsa-devel/2019- > March/146871.html > > > > This patch set is required for forwarding audio data between a HW sound > > card and an aloop device without the usage of an asynchronous sample rate > > converter. > > > > Most of sound and timers related code is kept the same as in previous > set. > > The code, related to snd_pcm_link() functionality and its using for > > timer source setting, is removed (as rejected earlier). The changes in > this > > update are mainly related to the parameters handling and some cleanup. > > > > The timer source can be initially selected by "timer_source" kernel > module > > parameter. It is supposed to have the following format: > > [:](|)[{.,}[{.,}]] > > For example: "hw:I82801AAICH.1.0", or "1.1", or just "I82801AAICH". > > (Prefix is ignored, just allowed here to be able to use the strings, > > the user got used to). > > Although the parsing function recognizes both '.' and ',' as a separator, > > module parameters handling routines use ',' to separate parameters for > > different module instances (array elements), so we have to use '.' > > to separate device and subdevice numbers from the card name or number > > in module parameters. > > Empty string indicates using jiffies as a timer source. > > > > Besides "static" selection of timer source at module load time, > > it is possible to dynamically change it via sound "info" interface > > (using "/proc/asound//timer_source" file in read-write mode. > > The contents of this file is used as a timer source string for > > a particular loopback card, e.g. "hw:0,0,0" (and here ',' can be used > > as a separator). > > > > The timer source string value can be changed at any time, but it is > > latched by PCM substream open callback "loopback_open()" (the first > > one for a particular cable). At this point it is actually used, > > that is the string is parsed, and the timer is looked up and opened. > > This seems to be a good trade-off between flexibility of updates and > > synchronizations or racing complexity. > > > > The timer source is set for a loopback card (the same as initial setting > > by module parameter), but every cable uses the value, current at the > moment > > of opening. Theoretically, it's possible to set the timer source for each > > cable independently (via separate files), but it would be inconsistent > > with the initial setting via module parameters on a per-card basis. > > > > v2: > > https://mailman.alsa-project.org/pipermail/alsa-devel/2019- > November/157961.html > > > > v3: > > https://mailman.alsa-project.org/pipermail/alsa-devel/2019- > November/158312.html > > - Change sound card lookup to use snd_card_ref() and avoid direct access > > to sound cards array > > - Squash commits on returning error codes for timer start and stop > > - Some locking related fixes > > - Some code cleanup > > > > v4: > > https://mailman.alsa-project.org/pipermail/alsa-devel/2019- > November/158896.html > > - Change to use updated API for snd_timer_open() (separate timer > instance) > > - Change to use snd_timer_close() returning void > > - Some code cleanup > > > > v5: > > - Change to initialize timer event tasklet before calling > snd_timer_open() > > > > > > Andrew Gabbasov (1): > > ALSA: aloop: Support runtime change of snd_timer via info interface > > > > Timo Wischer (6): > > ALSA: aloop: Describe units of variables > > ALSA: aloop: Support return of error code for timer start and stop > > ALSA: aloop: Use callback functions for timer specific implementations > > ALSA: aloop: Rename all jiffies timer specific functions > > ALSA: aloop: Move CABLE_VALID_BOTH to the top of file > > ALSA: aloop: Support selection of snd_timer instead of jiffies > > Now applied all patches. Thanks. Thank you very much! Unfortunately, I found some issue with locking in patch 6 (sorry for late finding): loopback_parse_timer_id() uses snd_card_ref(), that can lock on mutex, also snd_timer_instance_new() uses non-atomic allocation, that can sleep. So, both functions can not be called from loopback_snd_timer_open() with cable->lock spinlock locked. Also, most part of loopback_snd_timer_open() function body works when the opposite stream of the same cable does not yet exist, and the current stream is not yet completely open and can't be running, so existing locking of loopback->cable_lock mutex is enough to protect from conflicts with simultaneous opening or closing. So, it looks like locking of cable->lock spinlock is not needed in loopback_snd_timer_open() at all (similarly to loopback_snd_timer_close_cable()). I'm sending a separate patch to fix this: https://mailman.alsa-project.org/pipermail/alsa-devel/2019-November/159087.h tml Also, when you requested to move tasklet_init() call to before snd_timer_open() call, I should have guessed to look into the reverse closing side too ;-) Now, I have to add one more patch to move tasklet_kill() call to after snd_timer_close(). https://mailman.alsa-project.org/pipermail/alsa-devel/2019-November/159088.h tml Please, take a look at the patches. Thanks! Best regards, Andrew _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel