From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.201.68 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796305927; b=yyWcZtVIT2FEr2VRNPg3CA1Bxtnz74EQ4c3YcL8CcZCSo0HF8m2aVellp8FcPSyzBNc9 tD2JEmKRObLe1JHzT5BrefojUGwYOLQo7TQxEdOsdWgYfEm6PREUGo3tttMza7FbQpw9o NGG/ySb7fRyeVo7JL3Kiz7W+PW4+1/jhVTSuAeUoPzS6RqZg7axaaOXSey11VtghCe719 M3aMhMzBGh5Ive03oL6fibEWMHwInetT0jsDK/j2uNspTJ0LqHpNTzKL86m8+dHI8gH76 0NxMwBINYTgr1Rq+dAj3bwXiJIVzS3VBRbkd5YL2U8fBCbWTCFJWi+N4n1TXiFjcx5w== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796305927; h=DMARC-Filter:DKIM-Signature:Received:Received:Message-ID:Date: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-ClientProxiedBy:MIME-Version: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=dDotVdZUhrurmABWUaPWmarozdn47wqyiZIP1RtqGm0=; b=17yXE+7bkB9NIqibyyfOHEbx57ui7FXoZY+RvF0weVqjEleqHrib1guci9odNbdsPHix XzdrAnB5VrHonE6mbJ3RFU14dzaBf344Oc8OctPt6NBJLTU0rhizcVhwmAS5yw445RGKF IgkVsY8iHwrxt2ayVDzkpF4IEOInrMAhxO5s3lz5/ku6MwyTMd3H8EpMoDb9xQbQrxWe+ s7Pt3wsbzYR6T6MVo1nkGCAMDNYWcIcxqX5u+CjsTXfuJqnKhF5QUSAitQDpDqRkaoK8a 8Mvkv6YkUmFQUjppEgL0QAJ6Oa3ZtzqCYcaAdU4qfYz77/r5qhaJL0FsNKE7w8BCJ6A== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=PHwWVjnk; arc=pass header.oldest-pass=0 smtp.remote-ip=40.107.201.68 Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013068.outbound.protection.outlook.com [40.107.201.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 143F3606A322 for ; Thu, 3 Dec 2026 13:52:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 143F3606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=PHwWVjnk ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KHHsu6sQJ3cEglEzlc/OSrc7RA7Im5ROGcMrooXTbzwNkQZbxnOhX4cAoq+LH28zafeW27UPYe6UjbkRgnae7y+7aBUcpvaGUduzkB+G/dBIYi1Y8Uvtccyk/2IInqADcjpZrJs49dGzEeX2XJ3GSnqcUI8WFr5j8ckTvUhMYyL8IzxX5vnW3UMo7MRJyZmhXO9EejgMLYWQqrcHZBYC58EGsexDc9fyu7kOrOOmDy9O4PHfepEMoY+cVdUWXa6t3jF+3jU2/4WbN3JGPVIpxWQWF5cDqCIjzv62BrCQ6QxD8SOewwAcxWEvmA8QHIQLR2Csl2LRcjebxDc9CNTDQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dDotVdZUhrurmABWUaPWmarozdn47wqyiZIP1RtqGm0=; b=qFTmQTjmhlC7OzyYRSNEcDoFXQPDXhw/g74hKqw/6E+gjsSus0PAyqERK27qhignsdCkOUdoRqE6EMhVN1m4LS2IywUJigeZVWzegdbuzy5T1ACQKRFu5jI7nC6dlceyRwKm1x9U4QnXwHuGgQb4fpAIC2vo2TNh5FLOw2E4Sm3f66+lxLlivPj4R/H8TSxt1OF20YinPyMECEb7n/jauoX/2UBi7p4pmZ/z6ujJXbqy8azE0U6dxoG19g+TOquQZea+RVQnA7/Jwtcze4fj0hMlyk54wYXJVioIVGtbQwRejIXL4iCx2LtgcJ8aoqd+c/x5/SwnB5ileJ11x0smCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dDotVdZUhrurmABWUaPWmarozdn47wqyiZIP1RtqGm0=; b=PHwWVjnkWxomjDmVkY6qlwxQ4fBkX9UmB1mvg3jVexa6zkPMNtf+TNtC0iYuPSV1ZsryucYlPA9Wf6sWwpefVbzp+GTggHTdarJpHFetTFODQropjRkFMLlfH+X2n6UHOW3irWYU2HuogS2mT8upstl4WQ6qYUTFmdXzEFrVH5k= Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CY5PR12MB6252.namprd12.prod.outlook.com (2603:10b6:930:20::17) by PH7PR12MB7235.namprd12.prod.outlook.com (2603:10b6:510:206::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Thu, 3 Dec 2026 13:52:02 +0000 Received: from CY5PR12MB6252.namprd12.prod.outlook.com ([fe80::ab00:d77:6014:64a2]) by CY5PR12MB6252.namprd12.prod.outlook.com ([fe80::ab00:d77:6014:64a2%4]) with mapi id 15.21.0688.009; Thu, 3 Dec 2026 13:52:01 +0000 Message-ID: <47b75028-5574-4a26-aee2-080a653760fc@amd.com> Date: Thu, 3 Dec 2026 19:20:46 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] soundwire: bus: use pm_runtime_get_if_active() in sdw_handle_slave_alerts() To: Pierre-Louis Bossart , sashiko-reviews@lists.linux.dev, Bard Liao , "Liao, Bard" , Vinod Koul , srini@kernel.org Cc: linux-sound@vger.kernel.org, "Dommati, Sunil-kumar" , Mario Limonciello References: <20261203114833.3096517-1-Vijendar.Mukunda@amd.com> <3cdb895d-bb14-4925-92b8-0f267eb124cf@linux.dev> Content-Language: en-US From: "Mukunda,Vijendar" In-Reply-To: <3cdb895d-bb14-4925-92b8-0f267eb124cf@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MA5PR01CA0264.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:21c::12) To CY5PR12MB6252.namprd12.prod.outlook.com (2603:10b6:930:20::17) X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY5PR12MB6252:EE_|PH7PR12MB7235:EE_ X-MS-Office365-Filtering-Correlation-Id: 67093282-1e2d-4234-a2a4-08df51449b3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016|23010399003|11063799006|5023799004|4143699003|6133799003|18002099003|22082099003|10067099003|56012099006|261102123227099003|261022113327099003|261021121427099003|261022105027099003|261022075727099003|261026140227099003|261026121527099003|261028144727099003|261009223027099003; X-Microsoft-Antispam-Message-Info: iypScwHXMiUylIJc44hidmphEI6EgL+uNs1lp1NwiWdTyyi+HKtVgYeUUss+PE5/KJ1AQaZOPcQqoAr6t/774+2OwMX35jXglIVpHaWbFENnomIH0IF7Su7qMhHbskKfa/Dymui1SL3zoicqUvtdR9XN8raDMcRVYKtz6GUS/UgXJ/mYIMQeZlgMH8+52/LxgtQLMMLEAtcFtLCRaGaz1Bty31Z73+youIUPvuFJ17eUdBjwB71FVwPR26PkdcbeJcKCnr7Zd0HeodB1rCCI/imHyM/N3DZKl+vpoqO/8x5JurufIZ51jspzmQv7Cjtq7omC+tmlAeqSaxwe/VSHJqJIRub0F/7GS7AlQedfpFqSsQ3VYBQt+qKt8iEI6HqP8uJTYcAKsVwKC5ZfoCHskGJ0D3V7naAouPobGdq7OojqvYVjJk3WTCmKKVUo4J4hoY2SLLhSYE8bIObw1/ZzKTDVd1vUBHjZxf1Oo7kfVioEeA50Q5vRlcnvtetyWa3L8PPBV2767CDqzlOl4+gDyfFjvGIk3brUH+zHfh8mve3ScAmFn8FMartPYWpUqf11F0BotKKUlKklUIfpe02qp8p9apDcSSckcJ47ygumRKKX69SLV5PDiz4VrmeBH35tCRtqpkfoPzYRrA/+Ya9OMcVsg4W5bE/HYmgOBt8QIBE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY5PR12MB6252.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016)(23010399003)(11063799006)(5023799004)(4143699003)(6133799003)(18002099003)(22082099003)(10067099003)(56012099006)(261102123227099003)(261022113327099003)(261021121427099003)(261022105027099003)(261022075727099003)(261026140227099003)(261026121527099003)(261028144727099003)(261009223027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bXhkVzJJMEVmN25QaW84QU5zdEtPQW9ONDZPUlR6YWQvd01mSEZXMHEzbGNN?= =?utf-8?B?VStmdHlxb25RTXdJdW1ETTdEZVRQdWRKZHBGVjBraENER0xsdDM3cFBkMklq?= =?utf-8?B?c0Q5cStqUzR0MThCUnAzVWliUlFReW9DWWJXMTgrWlRIUDZZNjBrbDRIN21m?= =?utf-8?B?NjRPL2dqNzNOczhJanVxU3IvK2dka3Zld25LaXV5T0ZRTURINWYxRTJ1OFdk?= =?utf-8?B?ZjdkblZuYzcxMFZkbjU4ZEkzZytzbHVONFFhR2pUblhmK2ExY3VZQklna0xU?= =?utf-8?B?NHdVVVdhYlhZVy9wWGpXOXIzcG1qTjJFNWFsRmp6UXJyMVROQThUNUswUGJu?= =?utf-8?B?VkRKRVlaRlY0SjQveWgyV29DVlJnSXFRdEkwemRHRGdBUjJ6K2hnVmNxdXhw?= =?utf-8?B?M25uL3d0SWIrVUNxMktDU2FWMmhObzg3bUJ4Y1FBNFhxcXJIY0dyZ3RKTFM4?= =?utf-8?B?Ky8zWW8zN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jRHTFM2UFlpREczWWRpRGdS?= =?utf-8?B?bStqMG1JSGRtS09QWTc0clpuNWhwSmszZVBlVGRjK0V6cm11TEZWZz09?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67093282-1e2d-4234-a2a4-08df51449b3c X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6252.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 13:52:01.7529 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EthXh1jsQegekRL0FK56SsyRx6PpQj+SNzymkGJ/qoOHYqwTlHZp6UnnCkRPqgLRyzYVgibj7NLDaOEqa3f6qA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7235 On 12/3/26 18:32, Pierre-Louis Bossart wrote: > On 12/3/26 13:11, sashiko-bot@kernel.org wrote: >> Thank you for your contribution! Sashiko AI review found 2 potential >> issues to consider: >> - [High] soundwire: bus: early return in sdw_handle_slave_alerts() drops >> alerts >> - [High] soundwire: bus: early return in sdw_handle_slave_alerts() hangs >> qcom IRQ >> -- >> >> commit 1fc0f1d3eacfdbaa69b03883111cd2662e12323a >> Author: Vijendar Mukunda >> >> soundwire: bus: use pm_runtime_get_if_active() in sdw_handle_slave_alerts() >> >> This commit checks the manager device with pm_runtime_get_if_active() >> before calling pm_runtime_resume_and_get() on the slave in >> sdw_handle_slave_alerts(), requesting an async resume and returning 0 >> early when the manager is not RPM_ACTIVE. >> >>> diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c >>> index 15c66effbf4f4..82d4902be0c9e 100644 >>> --- a/drivers/soundwire/bus.c >>> +++ b/drivers/soundwire/bus.c >>> @@ -1667,15 +1667,55 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave) >>> u8 buf, buf2[2]; >>> bool parity_check; >>> bool parity_quirk; >>> + bool have_pm_ref = false; >>> + bool have_mgr_ref = false; >>> + struct device *mgr_dev = slave->bus->dev->parent; >>> >>> sdw_modify_slave_status(slave, SDW_SLAVE_ALERT); >>> >>> - ret = pm_runtime_get_sync(&slave->dev); >>> + ret = pm_runtime_get_if_active(mgr_dev); >>> + if (ret == 0) { >>> + /* >>> + * Paranoia check based on code analysis: this path is only >>> + * functionally significant when the manager is in RPM_SUSPENDING. >>> + * In that state, runtime_suspend() may be blocked in >>> + * cancel_work_sync() waiting for this work to finish, while this >>> + * work would block in pm_runtime_resume_and_get() waiting for the >>> + * manager to complete its suspend - a circular dependency that >>> + * neither side can break. Returning early breaks the deadlock. >>> + * >>> + * In RPM_RESUMING or RPM_SUSPENDED the early return is harmless. >>> + * This issue has not been observed in practice; it is identified >>> + * through code analysis. >>> + * >>> + * Request an async resume as a best-effort recovery: for >>> + * wake-capable CLK_STOP_MODE peripherals the clock-stop wake >>> + * mechanism re-asserts the alert after manager resumes; for other >>> + * peripherals pm_request_resume() ensures the manager does not >>> + * remain suspended after completing the ongoing suspend. >>> + */ >>> + pm_request_resume(mgr_dev); >>> + dev_warn(&slave->dev, "Alert deferred: manager not RPM_ACTIVE\n"); >>> + return 0; >>> + } >> [Severity: High] >> Can returning 0 here drop peripheral alerts during runtime resume and >> clock-stop suspend? >> >> pm_runtime_get_if_active(mgr_dev) returns 0 whenever mgr_dev is not >> RPM_ACTIVE, which includes RPM_RESUMING. In rpm_resume(), mgr_dev stays >> in RPM_RESUMING until the manager's runtime_resume callback returns, and >> calling pm_request_resume(mgr_dev) in that state is a no-op returning >> -EINPROGRESS. >> >> All three in-tree managers (AMD, Intel/Cadence, and Qualcomm) restart the >> SoundWire clock and have interrupts enabled while mgr_dev is still in >> RPM_RESUMING. On AMD, amd_resume_runtime() exits clock stop via >> amd_sdw_clock_stop_exit() while RPM_RESUMING; if a waking peripheral >> reports ALERT, amd_sdw_irq_thread() schedules amd_sdw_work and clears >> ACP_SW_STATE_CHANGE_STATUS_0TO7 and ACP_SW_STATE_CHANGE_STATUS_8TO11. >> >> Returning 0 without clearing SDW_SCP_INT1 drops the alert, and because >> AMD performs no post-resume status re-poll, the peripheral remains latched >> in SDW_SLAVE_ALERT with future state-change alerts suppressed. The same >> loss occurs on clock-stop-mode-0 managers when mgr_dev is RPM_SUSPENDING >> or RPM_SUSPENDED, as pm_request_resume() triggers a deferred resume >> without a wake pulse or post-resume alert re-dispatch. > I didn't realize that this seemingly harmless return 0 could get in the > way of interrupt handling... Ugh. > > It's possible the same problem reported above occurs on Intel hardware. > I vaguely remember that the Cadence IP will only throw an interrupt when > the peripheral status changes from ATTACHED to ALERT. If we return > without dealing with the interrupt registers, it's possible that the > alert is not handled a second time. > > Bard, do you happen to remember the details of the interrupt handling? I > no longer have access to the documentation. > Adding Vinod as well since the bot seems to drop people in To: and CC: ++ The concern is valid. The circular dependency only arises when the manager is in RPM_SUSPENDING: runtime_suspend blocks in cancel_work_sync() waiting for the alert work, while the alert work blocks in pm_runtime_resume_and_get() waiting for the manager's suspend to complete. For RPM_RESUMING no cancel_work_sync() is in flight, so there is no deadlock risk. The early return for RPM_RESUMING is therefore unnecessary. @Pierre-Louis :Would restricting the early return to RPM_SUSPENDING only be the right fix in your opinion? > >> [Severity: High] >> Does this early return deadlock swrm_runtime_suspend() and hang >> qcom_swrm_irq_handler() on Qualcomm managers? Adding Srinivas from Qualcomm to this thread for confirmation. Based on our code walkthrough of swrm_runtime_suspend(), when clock_stop_not_supported is set, we do not see a disable_irq(ctrl->irq) call. Instead the function calls clk_disable_unprepare(ctrl->hclk) followed by enable_irq(ctrl->wake_irq). Our understanding is that once clk_disable_unprepare() stops the hardware clock, register reads in qcom_swrm_irq_handler() return 0, intr_sts_masked becomes 0, and the do-while loop exits — so the hang and spin described above would not occur. This looks like a false positive. Srinivas, please correct us if our understanding of the Qualcomm code path is wrong. The unratelimited dev_warn() flooding concern raised above is valid regardless, and will be addressed in the next revision. >> >> kworker / PM qcom_swrm_irq_handler() >> swrm_runtime_suspend() [SWRM_INTERRUPT_STATUS_SLAVE_PEND_IRQ] >> /* ctrl->dev is RPM_SUSPENDING */ do { >> /* clock_stop_not_supported: */ sdw_handle_slave_status() >> /* skips sdw_bus_clk_stop() */ sdw_handle_slave_alerts() >> disable_irq(ctrl->irq) pm_runtime_get_if_active() == 0 >> <-- blocks forever dev_warn(...); return 0; >> /* SDW_SCP_INT1 never cleared */ >> clear & re-read INTERRUPT_STATUS >> } while (intr_sts_masked); >> <-- spins forever >> >> swrm_runtime_suspend() never masks SWRM_INTERRUPT_STATUS_SLAVE_PEND_IRQ >> and skips sdw_bus_clk_stop() when ctrl->clock_stop_not_supported is set >> (for any peripheral with clk_stop_mode1). With PING frames still running >> and SDW_SCP_INT1 left uncleared, SWRM_INTERRUPT_STATUS_SLAVE_PEND_IRQ >> stays asserted on every loop iteration, flooding unratelimited dev_warn() >> messages while disable_irq() blocks forever waiting for the IRQ thread. >>