From patchwork Mon Nov 5 11:19:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 10667947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDFD7175A for ; Mon, 5 Nov 2018 11:57:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8E6D29142 for ; Mon, 5 Nov 2018 11:57:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA44E29628; Mon, 5 Nov 2018 11:57:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7133E29142 for ; Mon, 5 Nov 2018 11:57:12 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 260742678DA; Mon, 5 Nov 2018 12:19:46 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3D65C2678DD; Mon, 5 Nov 2018 12:19:44 +0100 (CET) Received: from mail-ot1-f73.google.com (mail-ot1-f73.google.com [209.85.210.73]) by alsa0.perex.cz (Postfix) with ESMTP id C2BBB267692 for ; Mon, 5 Nov 2018 12:19:41 +0100 (CET) Received: by mail-ot1-f73.google.com with SMTP id v4so6225928otb.0 for ; Mon, 05 Nov 2018 03:19:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=pVRFOCIJhUNg3kvVAeMUv5Uofy8fSnnEx7REz6BYyGM=; b=mjJJHoIPjQR6ksCdtyjYAyxwB2rg9z8jnDkg7GqQkr8cDqljyZtDCoS7KN07o+tbc9 tIhUkS4iaVEebEhE3wOPN5gk3B9Atya8VQOwSYuiBwZPTC1szv4lgJKvE3tKPGcU2ceL UQ8jORLyxDN8VhQjUDU+UX2eC+Wl031FYaRST7xb+pv/1vjw52Y7HJNq624hvhB8MGZi tdTbjPscVHkqmITQrZU0FfhbvOmxEQWTo8L+JIk244ndoK1qBtBm5AxprTAchchwdPT4 zEFGzQjNrLdJspJqcLevlt0IdnmtUofmDYiBfqRXy2wCGxId8bzf627q8AXOVJFSFPR9 2cqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=pVRFOCIJhUNg3kvVAeMUv5Uofy8fSnnEx7REz6BYyGM=; b=liMnhDP+sBom6DeuXgrbEtII+8JizrOfL4Bmppg7WslOTQ5DzpBpZqocVs22RzActH sPeNUFatQTuRxpeAb848a/LYDys74mnDKwJXU6+FLbCpVUTjAYOuxCFOTGtB6/Opb5Bp 03dNzoZXPKixFFZN7na7dc/fTObZDdJ/YwuFg4XOAOoGdI9t/lcZSov6dcziu6cS0/fB L/RapXLjfCoLx22Hib8N7gzuIYSBnd8eS4IrWg+ql7uoWduixHZlKWR8mpN/tuR9rzJ+ Ix9sDRNGDOwG+Qm0ET/hgsmGlKU8RbSzRv5hClz6a7f0PtpESEmDQKtv57HXB8vhTo0N N30g== X-Gm-Message-State: AGRZ1gIRU7VqPWh1ixT7JtuXf+MAk5i+jDaEq06egZQ9JSa0eNljDcj1 xYp20jKcWSU3Q1XvRQCKhFdfQ/GiSkbb X-Google-Smtp-Source: AJdET5c9rus9e4VygZF3QGoYo6R+AreUb+4rKVs7hFx9K4PJb9A/qdNbFau4bQj/2qCyhh/n7QZKAWNpfI7W X-Received: by 2002:a9d:29f6:: with SMTP id g51mr1093437otd.15.1541416780061; Mon, 05 Nov 2018 03:19:40 -0800 (PST) Date: Mon, 5 Nov 2018 19:19:12 +0800 Message-Id: <20181105111912.14464-1-tzungbi@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog From: Tzung-Bi Shih To: broonie@kernel.org, lgirdwood@gmail.com, alsa-devel@alsa-project.org Cc: tzungbi@google.com, lars@metafoo.de, dgreid@google.com, cychiang@google.com Subject: [alsa-devel] [PATCH] ASoC: dapm: Use less aggressive caching to ensure correctness X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 92a99ea439c4 ("ASoC: dapm: Use more aggressive caching") only invalidates necessary caches to improve the cache hit rate. However, in snd_soc_dapm_add_path(), the cache is too aggressive which results in wrong state of the audio map. E.g. imaging the following examples during snd_soc_instantiate_card(): time 1: at the beginning in:-1 in:-1 in:-1 out:-1 out:-1 out:-1 A -----> B Spk time 2: after someone called snd_soc_dapm_new_widgets() (e.g. create_fill_widget_route_map() in sound/soc/codecs/hdac_hdmi.c) in:0 in:0 in:0 out:0 out:0 out:1 A ----> B Spk time 3: route added to Spk in:0 in:0 in:0 out:0 out:0 out:1 A ----> B ----> Spk time N: route added from SIGGEN in:1 in:0 in:0 in:0 out:0 out:0 out:0 out:1 SIGGEN ----> A ----> B ----> Spk In the end, the path will not power on but it should be. At time 2, the caches have been polluted. At time 3, it will not get the correct state if snd_soc_dapm_add_path() does not invalidate "out" of B and A. time 3 (expected result): in:0 in:0 in:0 out:1 out:1 out:1 A ----> B ----> Spk Signed-off-by: Tzung-Bi Shih --- sound/soc/soc-dapm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index a5178845065b..2914f3adb333 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2722,7 +2722,7 @@ static int snd_soc_dapm_add_path(struct snd_soc_dapm_context *dapm, dapm_mark_dirty(widgets[dir], "Route added"); } - if (dapm->card->instantiated && path->connect) + if (path->connect) dapm_path_invalidate(path); return 0;