From patchwork Thu Apr 19 14:06:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 133769 Delivered-To: patch@linaro.org Received: by 10.46.66.142 with SMTP id h14csp678492ljf; Thu, 19 Apr 2018 07:06:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx48hHBtrS/bDe4MHSqvIaueoZmT1I7uKyqQjdipTC47aIL21RKr7FSR61GT+/SKVKbqXIdnn X-Received: by 2002:adf:8ab7:: with SMTP id y52-v6mr5000542wry.98.1524146786213; Thu, 19 Apr 2018 07:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524146786; cv=none; d=google.com; s=arc-20160816; b=NZxdMdb1A6s0DPCYDdxkqJYfO7ZTu1jNLsh7Ada5dH2KnQCXjSSgstQH5GgNDx+1Vg KS2RsLTKObq93IFvIJZxpnJTNoJlyitzahoUXJcnzVldIqBDkopK6Sqrlr9eN1IBwFYz U1kLDkLSxZxrz+WrMCeuzK0UAKP1vR2NIY3Zm/eGPU7UInq1Jqn/r48C4tmdmtEYc4N5 UyNugD8kCsWWTgkBv5UScdiFyu+vdS/5Bf+u/CIFRof+gOYqhqv1rorwMXUkTd0j4LzG XDSyJu7CQWr0Z5ijVJzKfmKsazyXiSvj6hPDlasl8MrgUVjHho+XXwbshA1adxVY9LuQ jvPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=YFvLgtpLxSOXXZYJkolgDU9kpcs+t03MzaAbzMF02LQ=; b=mWTl+ZNTr7741NS2d/Xr29Xv4bXi68mvDrpHlnekrChFxUxp7e7ota/vZcgHjjfIAP d9aXjXlzp5HdesI7TuO/5OR3xxrKOxnBY17qEbnAUn1wPBEObQyBEYA2Z5OQXPFawkxD GWUXae0lWSd79og3AHqFWYlK00BWnftBYO/izW+9pLesRWkkEA/WbyyskblLAfGhDdxw Wd3fLNqcflxjkzWxw/7a827r4ZQePjmBX1fjAk23wDg/oa4QI2GwPi7YZVKilfKrxn94 3FTPJJTtQE5meBS1d++2aVMO8UsAh1Y2CQm/oCStngx5+qX6Yu1ZZCperdrGOkbE+wSy fwUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=c4TAw3gN; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id u81si2880163wme.164.2018.04.19.07.06.26; Thu, 19 Apr 2018 07:06:26 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=c4TAw3gN; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 085B2267235; Thu, 19 Apr 2018 16:06:24 +0200 (CEST) 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 E504E267265; Thu, 19 Apr 2018 16:06:20 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: * X-Spam-Status: No, score=2.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, PRX_BODY_30, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_SOFTFAIL, T_DKIMWL_WL_MED autolearn=disabled version=3.4.0 Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by alsa0.perex.cz (Postfix) with ESMTP id 3BFF6267140 for ; Thu, 19 Apr 2018 16:06:17 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id u4-v6so14400611wrg.10 for ; Thu, 19 Apr 2018 07:06:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=RnBDE1ts73ISFkPUGdp03eVrzogxnDhxAwvxi6sMdcU=; b=c4TAw3gNEJwLRwvkuZVx1vmgF9WHvwdh0MIloS+6qTuPC9k+eGohD86UBm0bE13P+8 UFcHIzMqnshGOvlKow5nF+WCqB0Vl4mRZ+KbT1KIi4EhNGehJqIZbmg9xskjIswWkQaz vYniii8YiBtiAzIafdZBwtvKC44OOxUkFsNaKarHHvfTIXIe72410DdwDmXGDPGZLaT6 uaDUIqngQjYxXVsdxuUFNx9LpE+u1G0xzx9CTu38fEUdBqmrIURYVy4Qh2VPz3Axy9Kb dKhCAonE4YHuzxMkvMQQPD4XdthA/8X4ktMSYoseh1jNB6q6D5Vs8wfJJ+uQEfaTTguw 84Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RnBDE1ts73ISFkPUGdp03eVrzogxnDhxAwvxi6sMdcU=; b=L8Y9BLQdwj4LYYiO5PvtiWSuiaiArFVTsNA5pIuOXuJdIgoBWyzTsRRRWVliZ/IEog lfLL1cBh+iVgGYnbINBrpB3oLDONpLhA5qcNJSIaL7Z9HUlGcGX9T8202vu7dI5IrhJ6 6aa1E+AP37ZG8W2r9pMVSTZ5wTMyBx8FIj81UqyRpEhPvZo5yAi/kIuC7JmdpbmJCpRa MGM918J/nyR//hngNZxPnxB34jcAKfbsT1kg/E4j3GYzE9SKz+G1ViGUDMBHmhk6S7Fi LGCiqTE0toto3okjHixToujHWIH3WdT1aOCZSAKX7Xq1RcBQfUwBg4RrLT1u5Sl9Wu8D HQtA== X-Gm-Message-State: ALQs6tBPOjf/MbWQZNvggf2GZlYsN+pVovJrwaTmb58BzEkeSK7MI6FD BOiA3L/5kCikXg+mCvucGjefjg== X-Received: by 10.28.114.15 with SMTP id n15mr4988889wmc.88.1524146777357; Thu, 19 Apr 2018 07:06:17 -0700 (PDT) Received: from localhost.localdomain (cag06-6-78-235-100-105.fbx.proxad.net. [78.235.100.105]) by smtp.googlemail.com with ESMTPSA id k30-v6sm9164738wrf.1.2018.04.19.07.06.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Apr 2018 07:06:16 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Date: Thu, 19 Apr 2018 16:06:12 +0200 Message-Id: <20180419140612.11049-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 Cc: Kevin Hilman , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jerome Brunet Subject: [alsa-devel] [PATCH RFC] ASoC: dai playback_active and capture_active may be greater than 1 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org At the moment playback_active and capture_active are using only 1 bit so the maximum active count is 1. However, snd_soc_runtime_activate() may be called several time on the same dai. This happens when a dai is part of several dai_links. It is often the case for "snd-soc-dummy-dai". This is a problem if snd_soc_runtime_activate() is called an even number of times on a dai. In this case the active count overflow back to 0. As consequence, ASoC functions, such as soc_dpcm_runtime_update(), won't run correctly. Storing these usage counts on plain 'unsigned int' solves the problem. Fixes: f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support") Signed-off-by: Jerome Brunet --- Hi, I found this problem while working on ASoC support for a new platform. During a playback, using DPCM, if I changed the backend dai, nothing happened, old backend path was not pruned, new backend path was not added. Here is how it goes: 1 FE and 2 BE, all 3 using snd-soc-dummy-dai for the codec_dai (ATM). On playback start: - BE #1 activates and increments snd-soc-dummy-dai's playback_active - FE activates and increments snd-soc-dummy-dai's playback_active The playback works but snd-soc-dummy-dai's playback_active value is now 0. Through a mux kcontrol, change BE client of FE, from BE #1 to BE #2. -> trigger soc_dpcm_runtime_update(). -> checks fe's codec_dai playback_active which is zero so playback path processing is skipped, keeping the old invalid path. include/sound/soc-dai.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.14.3 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel Reviewed-by: Charles Keepax diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 8ad11669e4d8..35ebb0be5114 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -294,8 +294,8 @@ struct snd_soc_dai { struct snd_soc_dai_driver *driver; /* DAI runtime info */ - unsigned int capture_active:1; /* stream is in use */ - unsigned int playback_active:1; /* stream is in use */ + unsigned int capture_active; /* stream usage count */ + unsigned int playback_active; /* stream usage count */ unsigned int probed:1; unsigned int active;