Received: from mail-qk2-f12.google.com (mail-qk2-f12.google.com [74.125.230.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45F20280CD5 for ; Sun, 13 Sep 2026 02:14:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.230.204 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789265645; cv=none; b=nK8EIOR0dR5ynPFfHBWx9E30p6IGTKoDcXlRBKnpUbXfdwEZhT9YMxdCedZVSZHGg8s/CLPY1OE+qGgnGpH+IqKblQUSnh1w4zFRhTCceHLpgVSN+13Vyu0WVjIj6RoSN/Q7yusiBPN3OiiyGVCk37Ixho/LaU//GQ/qgpQ484c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789265645; c=relaxed/simple; bh=+0JcbwgDBAnCe37S1lbW1di/g8nThyfXp0uPh67aoJA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ou+fj/4bdCx5GK8v0n3d2uc2lhtVYLfEKTrBDGkrLBmmCMhCjipE5vpd0xS3TvyPpGz0o0D8RG+GSsJR92wD42Db5ZcKbjo1tw5L3r5gxMpUvRkAGM2nXCG5rP3jnm0TeeEY+AzW0R9Hundm/N3YrRoD1EXN6gIrEYFUTO4UM4A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ptsTaoOg; arc=none smtp.client-ip=74.125.230.204 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ptsTaoOg" Received: by mail-qk2-f12.google.com with SMTP id af79cd13be357-93a0fd41a7bso53796185a.1 for ; Sat, 12 Sep 2026 19:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789265643; x=1789870443; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=88ICzwtScsGBN29oTXuL8hAaTuiJVGtZYlaw6P8iREg=; b=ptsTaoOgWBFz21BIqyw2zsxvI+XBkXCYeB1zkpDXlZ87Uhv4zQJinlkUe/ReTPUYsU yo1mv/fDtq++xQ+G7cG7xkCfqYaEOf/TrFnUwjTow/tmlNvQ0JauY8ZqVDwEiCrpHoqw U8tK8dSwItuiutFGjU8nTLHN3wYYNWHrTtYHiHXLRkJ7hAbxzwbdVZTXX09j9H2yypU0 tNLs5OykV0qL+Bjvtz2FBsfmbLoxVHd3iR4RETuPMYJlinK/w07IF5WB7+Yoym/F48Gv DN+1DhBqew6V9aJbfu7SWZin3nshKS5VpqcvbmltIwrGx8NCX7H008H47weSdidA8AG0 D2zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789265643; x=1789870443; h=content-transfer-encoding:mime-version: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=88ICzwtScsGBN29oTXuL8hAaTuiJVGtZYlaw6P8iREg=; b=B8DbO4vaHa9y8iMLVJheT/phR1RH8gMIVZaEIwV2qlx5FwmuDGiuGYFYGMQ7ojegMH otJrt8SCVUcG6M0MySGlXWk9eEvPpe3mwsFdzsCE4YdHU7wyCdRFKujr768MQcpm4Cfa Uob2SyuF67RaJo8MHBW3ytI6KDcoKvYjbk93ONmtmQDLbKD6o54N+rB53Duu+gGpJ74M RK9EDWaA8eymDIZJ56JxZ8W0JvglryxCYYnmfV4czvKaFxknaBk7/65mJcdHSxak09dq YSX5z1yQ4g+6M3ahUU5lhI4ZLLepnAAjaG9YV2a192j2RyBSfcJ1L+fJT3M1Yz2Wlhr7 uJDw== X-Forwarded-Encrypted: i=1; AKwUvBzwWGz2b7lULD+JdS3ihsJsIfwb1SxTPTkzvGhj4o7ghW+aK+JVh2eYKAv/t4GbxkUe/4JolknGodSIDRDh@vger.kernel.org X-Gm-Message-State: AFuF++kPjmkHX1CFUaRk1yPzXq73vQGw9Sub0M68KnXs4HEstmcRyEvo zEtffDIv2hpbWPAyToYn02zxjjMa67HZWynQmVYmsKC5m0aI/5UZORQ= X-Gm-Gg: AYBFou2LJp9oUROZasPjFYyavAKk7fU7OfoLIJwfwceKkQXAOexSSJ03ztTBv08avSS f4YnlOh8GtHnyiF69SbAv3xDsWYGwhUYBQ1afWAOxVCFPik0DXcT4JGkRtqv6R+ozsToTM2xkwQ kyKzs49ASOtqk7LaLG59Z+gm8fC81aNUOaA6rIO+BKuTaiEuCoD5K/mJ6eleXyPSuXtCB37GWyt sarsquSJyAQJd7M2SEGengDb36uqUnjrONV29H9oprneTJsdGTW4zKfEDFOjTBdwTQorIzK4W/A 21ZpkdVcYn155rsPTohuXAe1dLAXnrC7wlaP7TYSJgNkWTd+c5uwaQniuNUpaJ3zUlHLyAyrT12 hMN2z7AC5lHHkcoWHtWTb7NbzFlgZghbNL1BbsHwg0jZpgl0gBFk6o4B2htJJKlBf4o0ClOzV5d 1muaDww1FrHnIvxOQEedvxo8pV394hp9D4g47E2I7lEVf+vBwQiQfgEMOHF+cxbnkMMvUreDt1Z zaQM0uNfZj7k7f9m9a/cCPpTgBEgqAl9A2BjOtcDY5M9U0FxGRRYtqJAL9ylDedtnswyNIhvfaF dlyKEQxCqFmSJCHiuG6YFT2Yy+/3Mdkjvw== X-Received: by 2002:a05:620a:838b:b0:939:9bcf:8d35 with SMTP id af79cd13be357-93a03886412mr757341585a.35.1789265643185; Sat, 12 Sep 2026 19:14:03 -0700 (PDT) Received: from localhost.localdomain ([104.39.73.78]) by smtp.gmail.com with ESMTPSA id af79cd13be357-939e8045d9fsm629778085a.19.2026.09.12.19.14.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 12 Sep 2026 19:14:01 -0700 (PDT) From: Myeonghun Pak To: Srinivas Kandagatla , Vinod Koul , Bard Liao Cc: Pierre-Louis Bossart , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Ijae Kim Subject: [PATCH] soundwire: qcom: quiesce runtime PM before removing bus Date: Sat, 12 Sep 2026 22:13:56 -0400 Message-ID: <20260913021356.60079-1-mhun512@gmail.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Qualcomm SoundWire controllers enable runtime PM after registering the bus, but remove tears down the bus and iface clock while runtime callbacks and the main or optional in-band wake IRQ handlers can still run. A controller that is already runtime-suspended also has its iface clock disabled, so the unconditional clock disable in remove unbalances that clock. Disable runtime PM first to cancel pending requests and drain any callback. Free both controller IRQs synchronously before deleting SoundWire children, then disable the iface clock only when runtime suspend has not already done so. Record the powered-down state for a later rebind. Bus deletion does not require a resume: the Qualcomm master has no put_device_num operation. The core disables slave runtime PM before unregistering each SoundWire child. A pending runtime resume can run while runtime PM is being disabled. Make its clock enable failure visible to the PM core and restore the wake IRQ in that case, so the runtime status continues to describe the clock state. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes: 74e79da9fd46 ("soundwire: qcom: add runtime pm support") Cc: stable@vger.kernel.org Assisted-by: OpenAI:GPT-5.6 Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak --- drivers/soundwire/qcom.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 55678a30c..35e552cc0 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -1713,23 +1713,42 @@ static int qcom_swrm_probe(struct platform_device *pdev) static void qcom_swrm_remove(struct platform_device *pdev) { - struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(&pdev->dev); + struct device *dev = &pdev->dev; + struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dev); + bool suspended; + + pm_runtime_disable(dev); + suspended = pm_runtime_status_suspended(dev); + + devm_free_irq(dev, ctrl->irq, ctrl); + if (ctrl->wake_irq > 0) + devm_free_irq(dev, ctrl->wake_irq, ctrl); sdw_bus_master_delete(&ctrl->bus); - clk_disable_unprepare(ctrl->hclk); + if (!suspended) + clk_disable_unprepare(ctrl->hclk); + pm_runtime_set_suspended(dev); } static int __maybe_unused swrm_runtime_resume(struct device *dev) { struct qcom_swrm_ctrl *ctrl = dev_get_drvdata(dev); + bool wake_irq_disabled = false; int ret; if (ctrl->wake_irq > 0) { - if (!irqd_irq_disabled(irq_get_irq_data(ctrl->wake_irq))) + if (!irqd_irq_disabled(irq_get_irq_data(ctrl->wake_irq))) { disable_irq_nosync(ctrl->wake_irq); + wake_irq_disabled = true; + } } - clk_prepare_enable(ctrl->hclk); + ret = clk_prepare_enable(ctrl->hclk); + if (ret) { + if (wake_irq_disabled) + enable_irq(ctrl->wake_irq); + return ret; + } if (ctrl->clock_stop_not_supported) { reinit_completion(&ctrl->enumeration);