From patchwork Tue Jun 1 08:17:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 12290681 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 DA5E3C47092 for ; Tue, 1 Jun 2021 08:19:54 +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 59391613AD for ; Tue, 1 Jun 2021 08:19:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59391613AD Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sakamocchi.jp 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 952471698; Tue, 1 Jun 2021 10:19:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 952471698 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1622535592; bh=TJQYc6g5T8oW2i7PmuYRFN60xpk8gy/sD6dfDNSEkeg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Cul1jGqOx1nuMAGdnbxoFgQeZm6RgAkJnWytiArsd3ItONZiLlCNgZy1CEsuuE5G2 sXnp+BqY0INRs6Y6OZgnjOmT3/ZrPG9EBR/We7KGNH8Eq83U0foru9ORFCG/23DmHA 2W24LVra3UvE2zl6KXnb5RwxVSwFcsa9KpfTkO/I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 884A5F804B0; Tue, 1 Jun 2021 10:18:13 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E4816F804B1; Tue, 1 Jun 2021 10:18:11 +0200 (CEST) Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 91A6AF800B2 for ; Tue, 1 Jun 2021 10:18:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 91A6AF800B2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=sakamocchi.jp header.i=@sakamocchi.jp header.b="2IvVffT0"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="qA7wUJy9" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 2575310D3; Tue, 1 Jun 2021 04:18:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 01 Jun 2021 04:18:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sakamocchi.jp; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=wY/w/UIXGVb1y +KyDya97gK1sT1t8Q9iFVV4XOs1wFw=; b=2IvVffT0qQD42lCKkyt88TwUWqYHP wyBO2hPo+Q/j3I8UtRAzAaSibzvj46nB9Q6xoUb/nOHO1rGCOpOUtNJySJAvVT9u 9bu9p3Ja3lGUnD0Vxj+gqPDfcp9dXms95wPXDZ2ID0S6OsSdM4RyWkuH1KWFsHhc z1/IWRk5ErvlOZKCFBoPKQKkCDXbhdVb1osteq2B1g4zzGBplHZVRei+lqQSkwzo uIAwn+xbLxqrf3LcuibTjRMyEEx6APgeELUEioRfqYGRfvP81EBA6ItJ38/SDwac 5CnMTY3yv2+o9gPEqycENh+VEeVE3cJPRKGZqAyXFnAitCFKa7cDCmhDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=wY/w/UIXGVb1y+KyDya97gK1sT1t8Q9iFVV4XOs1wFw=; b=qA7wUJy9 yRVthqLYgM0dPDWMyUMsGUaZANow6SBhE2U6HPdo7oaFNCPn1RbqhKb/atz5ufjr qNosGeCtiBOcj+B0/PwfEPy8dpPrW033wmcM/ucBxWs6n+QoSlDiMGO/BA8hVIDP A3nKCL8Tlwxaz6zB+/slCZvo6ICIhahZqaVrPUXREaDdX7OoMyy2ThZ4j9XY1ybc dFGURatdY+VbWgyKsQ3TPUfCrO++GM5C8EawteC1U8SAJRHDv7FzLcswukmnfbeB QfBIt8U1zowq5eE6bCSxYonlbC+ZMIgIhVdPno5vXxULs8FcIOyl6H4XREfOE46n utw7ojdPdHLoig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdelhedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepvfgrkhgrshhhihcuufgrkhgrmhhothhouceoohdqthgrkhgr shhhihesshgrkhgrmhhotggthhhirdhjpheqnecuggftrfgrthhtvghrnhepveefffefke etgfevgeefleehfffhueejtdejveethfekveektdejjedvtdejhfejnecuvehluhhsthgv rhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohdqthgrkhgrshhhihessh grkhgrmhhotggthhhirdhjph X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Jun 2021 04:18:00 -0400 (EDT) From: Takashi Sakamoto To: tiwai@suse.de Subject: [PATCH 1/3] ALSA: dice: wait just for NOTIFY_CLOCK_ACCEPTED after GLOBAL_CLOCK_SELECT operation Date: Tue, 1 Jun 2021 17:17:51 +0900 Message-Id: <20210601081753.9191-2-o-takashi@sakamocchi.jp> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210601081753.9191-1-o-takashi@sakamocchi.jp> References: <20210601081753.9191-1-o-takashi@sakamocchi.jp> MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, clemens@ladisch.de 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" NOTIFY_CLOCK_ACCEPTED notification is always generated as a result of GLOBAL_CLOCK_SELECT operation, however NOTIFY_LOCK_CHG notification doesn't, as long as the selected clock is already configured. In the case, ALSA dice driver waits so long. It's inconvenient for some devices to lock to the sequence of value in syt field of CIP header in rx packets. This commit wait just for NOTIFY_CLOCK_ACCEPTED notification by reverting changes partially done by two commits below: * commit fbeac84dbe9e ("ALSA: dice: old firmware optimization for Dice notification") * commit aec045b80d79 ("ALSA: dice: change notification mask to detect lock status change") I note that the successful lock to the sequence of value in syt field of CIP header in rx packets results in NOTIFY_EXT_STATUS notification, then EXT_STATUS_ARX1_LOCKED bit stands in GLOBAL_EXTENDED_STATUS register. The notification can occur enough after receiving the batch of rx packets. When the sequence doesn't include value in syt field of CIP header in rx packets adequate to the device, the notification occurs again and the bit is off. Signed-off-by: Takashi Sakamoto --- sound/firewire/dice/dice-stream.c | 29 +++++++------------------- sound/firewire/dice/dice-transaction.c | 2 +- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c index 0fb8b4ae6a0a..d7220160c778 100644 --- a/sound/firewire/dice/dice-stream.c +++ b/sound/firewire/dice/dice-stream.c @@ -9,7 +9,7 @@ #include "dice.h" #define READY_TIMEOUT_MS 200 -#define NOTIFICATION_TIMEOUT_MS (2 * MSEC_PER_SEC) +#define NOTIFICATION_TIMEOUT_MS 100 struct reg_params { unsigned int count; @@ -57,13 +57,9 @@ int snd_dice_stream_get_rate_mode(struct snd_dice *dice, unsigned int rate, return -EINVAL; } -/* - * This operation has an effect to synchronize GLOBAL_STATUS/GLOBAL_SAMPLE_RATE - * to GLOBAL_STATUS. Especially, just after powering on, these are different. - */ -static int ensure_phase_lock(struct snd_dice *dice, unsigned int rate) +static int select_clock(struct snd_dice *dice, unsigned int rate) { - __be32 reg, nominal; + __be32 reg; u32 data; int i; int err; @@ -94,19 +90,8 @@ static int ensure_phase_lock(struct snd_dice *dice, unsigned int rate) return err; if (wait_for_completion_timeout(&dice->clock_accepted, - msecs_to_jiffies(NOTIFICATION_TIMEOUT_MS)) == 0) { - /* - * Old versions of Dice firmware transfer no notification when - * the same clock status as current one is set. In this case, - * just check current clock status. - */ - err = snd_dice_transaction_read_global(dice, GLOBAL_STATUS, - &nominal, sizeof(nominal)); - if (err < 0) - return err; - if (!(be32_to_cpu(nominal) & STATUS_SOURCE_LOCKED)) - return -ETIMEDOUT; - } + msecs_to_jiffies(NOTIFICATION_TIMEOUT_MS)) == 0) + return -ETIMEDOUT; return 0; } @@ -304,7 +289,7 @@ int snd_dice_stream_reserve_duplex(struct snd_dice *dice, unsigned int rate, // Just after owning the unit (GLOBAL_OWNER), the unit can // return invalid stream formats. Selecting clock parameters // have an effect for the unit to refine it. - err = ensure_phase_lock(dice, rate); + err = select_clock(dice, rate); if (err < 0) return err; @@ -646,7 +631,7 @@ int snd_dice_stream_detect_current_formats(struct snd_dice *dice) * invalid stream formats. Selecting clock parameters have an effect * for the unit to refine it. */ - err = ensure_phase_lock(dice, rate); + err = select_clock(dice, rate); if (err < 0) return err; diff --git a/sound/firewire/dice/dice-transaction.c b/sound/firewire/dice/dice-transaction.c index 2c0dde29a024..92941ef83cd5 100644 --- a/sound/firewire/dice/dice-transaction.c +++ b/sound/firewire/dice/dice-transaction.c @@ -155,7 +155,7 @@ static void dice_notification(struct fw_card *card, struct fw_request *request, fw_send_response(card, request, RCODE_COMPLETE); - if (bits & NOTIFY_LOCK_CHG) + if (bits & NOTIFY_CLOCK_ACCEPTED) complete(&dice->clock_accepted); wake_up(&dice->hwdep_wait); }