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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D229ECA9ED3 for ; Sun, 11 Oct 2026 22:22:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OXZ1UsR/jsdDknoGUcyYR4VW8gmQlVsH7nZcsEdE/Yo=; b=VzKC+K6N23aQZMhLU9MIRu3lq4 SUAf2BHbf2F3qczY7V2r1nsa5eALbaIYnNf6TN+LD0xbHDrwoeTx8/NQHmWMalUhlL0DdDIPSCDmv FRqqralVp/WL6xFoOC4UIVFeR7pHalm+a3TFgauscqWom1P0fzO0HdZaan3NJJVqOw0RypkFYOSNh +ke9kzdM6iUTNewsQoGNxqT7jfk+MjnxBWpEpjdxONY9oVu3ZRAHMmPUW48O189BMopsnP6zon1Iv RixJzVxUyj9U8y9tG/ODAK4qnOzqgUOc89VhVuPndPUUU/jMATnrzPEGRE7sdQoW/h+wlRCZVVkeC CTQhARfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xG1wQ-00000009SFA-2tH3; Sun, 11 Oct 2026 22:22:50 +0000 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xG1wO-00000009SCL-1pZs for linux-mediatek@lists.infradead.org; Sun, 11 Oct 2026 22:22:49 +0000 Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-5350c1b9e0dso19231551cf.0 for ; Sun, 11 Oct 2026 15:22:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791757367; x=1792362167; darn=lists.infradead.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=OXZ1UsR/jsdDknoGUcyYR4VW8gmQlVsH7nZcsEdE/Yo=; b=K61oPN8NSiVGjEepnUNDoNLtFPypfws/Nr62ERTZbZTcgetJ/iFK7xCHl4BdzTmou4 w0GqWjFSztkOhzI2FKk+/EqWnPZ7OQ5buaQHTFWOHMrxAyLROOtH/ovKKBODRMiqFom7 JYFxy6zURJyrqbnB7v3pypBlzUUFdiTXPKCjz8ah4HXpMtAAeJuQvbijmEddyP2soTzd Tf+Sfp9GJMvfx2dx0IrzPuB/zUePIRxubBuStj6tGS0nDcawLMyQnnoJQhx2adBNOWye 0aelqJUQDnZdYQ1bSo8LBbUNaT9AQCKnPsd7zmaE5yjRa/zDod92m45+ghlEnO+uvV6X Sd/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791757367; x=1792362167; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=OXZ1UsR/jsdDknoGUcyYR4VW8gmQlVsH7nZcsEdE/Yo=; b=UYorzxd6AZmI9yAYchqjiTjxJ1Fqz4yxuI0wTbUO9QnIBvxqrACllWH67FDlC80iNC /Y53TmRVIq9D75UGD5YDqI5aGv61NMlKfAfR3ci859ZNnNPXfuzwrqiJdO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mAM9J7KqUzXEfehA6wMWmDbyU= X-Received: by 2002:a05:622a:260b:b0:533:32f3:1db9 with SMTP id d75a77b69052e-5359f46f5ccmr130647001cf.11.1791757367164; Sun, 11 Oct 2026 15:22:47 -0700 (PDT) Received: from i4-gl-tmk5904-1.ad.psu.edu ([130.203.156.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5359b7ecccdsm66288831cf.30.2026.10.11.15.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Oct 2026 15:22:45 -0700 (PDT) From: Myeonghun Pak To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Matthias Brugger , AngeloGioacchino Del Regno Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Ijae Kim Subject: [PATCH 3/3] ASoC: mediatek: mt8196: Keep the AFE IRQ within its resource lifetime Date: Sun, 11 Oct 2026 18:22:34 -0400 Message-ID: <20261011222234.2098904-4-mhun512@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261011222234.2098904-1-mhun512@gmail.com> References: <20261011222234.2098904-1-mhun512@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261011_152248_497736_7A4F6A4C X-CRM114-Status: GOOD ( 16.91 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org The managed AFE IRQ is requested before the regmap is allocated. The handler can therefore run before its regmap exists, and devres releases the regmap before joining the IRQ. The remove callback also suspends the AFE and disables its clocks before devres releases the IRQ. Request the IRQ after initializing the regmap and before enabling MCU IRQ routing. A failed request then takes the existing runtime PM unwind without enabling that routing. Release the IRQ at the start of removal before the explicit clock shutdown, using the IRQ number saved at probe. The regmap's managed lifetime also encloses the IRQ on probe errors. This issue was found by static analysis. Fixes: 57513aabfe5b ("ASoC: mediatek: mt8196: add platform driver") Assisted-by: LLM Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak --- Compile-tested with Clang 22.1.2, W=1 (arm64). sound/soc/mediatek/mt8196/mt8196-afe-common.h | 1 + sound/soc/mediatek/mt8196/mt8196-afe-pcm.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/sound/soc/mediatek/mt8196/mt8196-afe-common.h b/sound/soc/mediatek/mt8196/mt8196-afe-common.h index 4951a6f32abb..ce5d586721db 100644 --- a/sound/soc/mediatek/mt8196/mt8196-afe-common.h +++ b/sound/soc/mediatek/mt8196/mt8196-afe-common.h @@ -186,6 +186,7 @@ struct clk; struct mtk_base_afe; struct mt8196_afe_private { + int irq_id; struct clk **clk; /* dai */ void *dai_priv[MT8196_DAI_NUM]; diff --git a/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c b/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c index a1ae8322d8b6..39d9103bd5e7 100644 --- a/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c +++ b/sound/soc/mediatek/mt8196/mt8196-afe-pcm.c @@ -2393,12 +2393,7 @@ static int mt8196_afe_pcm_dev_probe(struct platform_device *pdev) irq_id = platform_get_irq(pdev, 0); if (irq_id < 0) return dev_err_probe(dev, irq_id, "no irq found"); - - ret = devm_request_irq(dev, irq_id, mt8196_afe_irq_handler, - IRQF_TRIGGER_NONE, - "Afe_ISR_Handle", afe); - if (ret) - return dev_err_probe(dev, ret, "could not request_irq for Afe_ISR_Handle\n"); + afe_priv->irq_id = irq_id; /* init sub_dais */ INIT_LIST_HEAD(&afe->sub_dais); @@ -2453,6 +2448,14 @@ static int mt8196_afe_pcm_dev_probe(struct platform_device *pdev) goto err_pm_put; } + ret = devm_request_irq(dev, irq_id, mt8196_afe_irq_handler, + IRQF_TRIGGER_NONE, + "Afe_ISR_Handle", afe); + if (ret) { + dev_err_probe(dev, ret, "could not request_irq for Afe_ISR_Handle\n"); + goto err_pm_put; + } + regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &tmp_reg); regmap_write(afe->regmap, AFE_IRQ_MCU_EN, 0xffffffff); regmap_read(afe->regmap, AFE_IRQ_MCU_EN, &tmp_reg); @@ -2482,8 +2485,11 @@ err_pm_put: static void mt8196_afe_pcm_dev_remove(struct platform_device *pdev) { struct mtk_base_afe *afe = platform_get_drvdata(pdev); + struct mt8196_afe_private *afe_priv = afe->platform_priv; struct device *dev = &pdev->dev; + devm_free_irq(dev, afe_priv->irq_id, afe); + if (!pm_runtime_status_suspended(dev)) mt8196_afe_runtime_suspend(dev);