From patchwork Thu Jul 13 09:52:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Suti X-Patchwork-Id: 119749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1716921vqm; Thu, 13 Jul 2023 03:09:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlGshXobxplBtYAUQMSxOYtc6ofoRcOvXfKv995cfGGC1yotAxTuEo5PVP0Ihd/q6pxwAyk2 X-Received: by 2002:aa7:d94a:0:b0:51d:a831:58e5 with SMTP id l10-20020aa7d94a000000b0051da83158e5mr1316368eds.30.1689242989168; Thu, 13 Jul 2023 03:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689242989; cv=none; d=google.com; s=arc-20160816; b=jh9mNxvB808ypt39Hs5UdBNIH3vqsuPyDtivacZT5hRR41XTY17aIfYWwlRNHHZ6FM tH+vL4zUqLaf0fspXeOBeLx4yNYaOkdyt8Kvz/ZGlqPmKMPJw4Ho2W8N68BcI0FskUp1 z9iyBv1p83F0lF56lMbZkkXMvY4cH16H9uw/bUqcyx1YQDrUWwfdUMrF/O+QfX4j+M8J lfS+P615FFYicLvdccnc0vH8vbudrDPMNb0PStsnXmd3P4ugB1/1YvGmmWeAhO5zaXhm e/faeoKmVtKfCX0jC2uAq7pNAhw4fLTDhiB2rjHOOoBuVdlMAdduH2A0blL+ZhEwzTM6 oOXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=LPqBHwbjNM+xoM+NHlMenvzhZG8Km0jadyqZX+XYIaI=; fh=xje8QTXtSZ/t0B2nMyn40OhHfmUWm6VxVf0AaKjFYbM=; b=f/x89y154MhmcikXcGH1fFIqd+cuWsMseMTmGFbcn85lUZMBpOu2LAcVmL3i9E1JWF c+GVIs1hXOJ//tfImUEHob86dVig13UfJAIx43dSr7s52zx6oCjXW0m7h6HUl3Zjz62D PAXHQEe9WzROJIDoCDvqMamHNh2QOlxGxNbLkpgkOzTg6/dTQrSrFw4T8oGHbhK7pZSd 2YUi5anyYPia3U2ImQIBWbzi/Kvhjtfn80DHLHrKeELwCmp4dhPJfAj6h/GRji3Ozmhl XZ+/QwbfDgmZCS8CGmj3aRTR4OGOVDwjpc2rwmImEuzRvtS5gLbquLOTPtYr3CctbPfK DHiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@streamunlimited.com header.s=google header.b="xyHCc+a/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=streamunlimited.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h25-20020a50ed99000000b0051e03b85e7dsi7143481edr.438.2023.07.13.03.09.25; Thu, 13 Jul 2023 03:09:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@streamunlimited.com header.s=google header.b="xyHCc+a/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=streamunlimited.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234265AbjGMJyH (ORCPT + 99 others); Thu, 13 Jul 2023 05:54:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233916AbjGMJxY (ORCPT ); Thu, 13 Jul 2023 05:53:24 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C78422689 for ; Thu, 13 Jul 2023 02:53:19 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3142a9ffa89so676551f8f.0 for ; Thu, 13 Jul 2023 02:53:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=streamunlimited.com; s=google; t=1689241998; x=1691833998; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LPqBHwbjNM+xoM+NHlMenvzhZG8Km0jadyqZX+XYIaI=; b=xyHCc+a/9Ay9QUMg/ti18Teyz1YDlkma1brdD/5tCneK+zBr7RWvV9iYJvA3kIo729 cRFl0g3AxqJFmVR6gFcMTIoyPWN46XGmSyJ2loXuywmlQHQOm8yQoS5ivn1XDEWVpxwq nYsBPgLRiSaA1sapaVk9T5BQDmKkAtiuEmVrM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689241998; x=1691833998; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LPqBHwbjNM+xoM+NHlMenvzhZG8Km0jadyqZX+XYIaI=; b=RvsrnupuDn55dpb8IGo4E7q1aIn+3WO5o3EvFmvlG4DfNYUNoePTmrFwunAPlwGv9Q brP9QPnC74+RLh7tdzT5vwBWr7B2deNjpQlwO9WouVPHT3IWqqD3KDzgdpFG3cqzqJPq evNCWfr9hSCuPA6zC8vpNu22ghModa77qvnn0FymNoc7uG+3UL9V0ty0w/nxV5yG+7FN V361lypzTsUXlCR5LM/9e2MblH5cvfJpDcTmDOgQbrAPKy684ILFadtTSH1SMmg4mEXY BFBbyOZignjoEMCBbFC4OySAMuZpe+wK/+sEo1HwMHjNxJ+mh2p3qVN7+NV1g+pWIq3i /c2A== X-Gm-Message-State: ABy/qLbTH7mmeU/WVkYmGhH9jKAo9tc6dryR57/ld1kzrtFRgngVQEpH kyW7j/aejWKLZPisCeleaV5+qpOzHCGqBpWz9iI= X-Received: by 2002:adf:cd87:0:b0:313:fa0f:3a05 with SMTP id q7-20020adfcd87000000b00313fa0f3a05mr1081570wrj.14.1689241998235; Thu, 13 Jul 2023 02:53:18 -0700 (PDT) Received: from localhost.localdomain (vpn.streamunlimited.com. [91.114.0.140]) by smtp.gmail.com with ESMTPSA id t12-20020a5d6a4c000000b00314329f7d8asm7439711wrw.29.2023.07.13.02.53.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jul 2023 02:53:17 -0700 (PDT) From: Peter Suti To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: pierre-louis.bossart@linux.intel.com, Peter Suti , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH] ASoC: soc-dai: don't call PCM audio ops if the stream is not supported Date: Thu, 13 Jul 2023 11:52:58 +0200 Message-Id: <20230713095258.3393827-1-peter.suti@streamunlimited.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771299656740037488 X-GMAIL-MSGID: 1771299656740037488 PCM audio ops may be called when the stream is not supported. We should not call the ops in that case to avoid unexpected behavior. hw_params is handled already in soc-pcm.c [0] https://lore.kernel.org/alsa-devel/ae06b00a-f3f7-f9d1-0b58-4d71f3394416@linux.intel.com/T/#t Signed-off-by: Peter Suti --- Tested on 6.1 Compile tested on next/master sound/soc/soc-dai.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index 02dd64dea179..73a97ac6ccb8 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -424,6 +424,9 @@ int snd_soc_dai_startup(struct snd_soc_dai *dai, { int ret = 0; + if (!snd_soc_dai_stream_valid(dai, substream->stream)) + return 0; + if (dai->driver->ops && dai->driver->ops->startup) ret = dai->driver->ops->startup(substream, dai); @@ -439,6 +442,9 @@ void snd_soc_dai_shutdown(struct snd_soc_dai *dai, struct snd_pcm_substream *substream, int rollback) { + if (!snd_soc_dai_stream_valid(dai, substream->stream)) + return; + if (rollback && !soc_dai_mark_match(dai, substream, startup)) return; @@ -603,6 +609,8 @@ int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream) int i, ret; for_each_rtd_dais(rtd, i, dai) { + if (!snd_soc_dai_stream_valid(dai, substream->stream)) + continue; if (dai->driver->ops && dai->driver->ops->prepare) { ret = dai->driver->ops->prepare(substream, dai); @@ -619,6 +627,9 @@ static int soc_dai_trigger(struct snd_soc_dai *dai, { int ret = 0; + if (!snd_soc_dai_stream_valid(dai, substream->stream)) + return 0; + if (dai->driver->ops && dai->driver->ops->trigger) ret = dai->driver->ops->trigger(substream, cmd, dai);