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.93.194.3 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796121343; b=mZ8YnMixrxUnhyUmzOsryxeJONqcbPhdBhnaiKDP9VQ0esH3AcCozdcjG1qFKaA9l5KA pUisiTqe8XA5c2iR7iNKAWy78AihLRgjo3q7SX9PbawGiKq31rfDoE53pmi3X4Xj6spi1 oSHrtkuDhezVoauMLFXxlUHB9SIyOv8hK3IKNz+t0bu5gxM50VP8VdCPIuyDN3s9daTbD MdBeMvlro/SuAEuz1AKo86m54tlzmS7UccRWU8teuAoq5sxmPEMVttYGjmyhbnBUEkroU sxkUXEYSzOSVl5zsh+QYsc2HrHx+Ll/R7sRe/a39u7M2wfLWTYPIWFiQjRRS44jTHXg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796121343; 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=MCHSvfWJL8X/46Lw+7J6iESQWgXdWwqKZ3Uq3xCdxEQ=; b=0BMif3/nGMcvA4FKIA6L6VFUOPfVxgrLS56GBrllHf4W7KLpQ+uPzBeLXPhRfcS/Y90n uAWRGfjljkEwVEh80odzuL/WHiLsowBNUcKAUlVcfYhhZTIvExLukZhJffydjaGblwOrC 3t2e++lxz5Q+ybcUampagZ8DTjdd7MVeZEAoRJoJPtjYXwT2OPqIc0WX6PfaUuh3/Ud/J xDRBXFktpi6+qvr/2/yJHWJ31gLPDsGDZvGlZkHiRBrVX8tv8QDUKaag72JrdAb7go03s pb7APVoJe8RbXNW82DwWyaAOGlQC05yBIdEy8NXQSU1YXsFmlx9Hno74+32H2zKHTIw== 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=J92e6Nrk; arc=pass header.oldest-pass=0 smtp.remote-ip=40.93.194.3 Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011003.outbound.protection.outlook.com [40.93.194.3]) (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 2E803606A320; Tue, 1 Dec 2026 10:35:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2E803606A320 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=J92e6Nrk ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qAbbHZAPA5LNOlaJRlYL8AAW1lVGF5o1sMZcscsX3fIXGhxXiX537jJoTerHS1ceWrSI+MaF2K5oDTKXEBCg7LuT6gIsKjXYNGzNTxy+CKOLZdY+tY/qC/w7JXDEGUTFdCZu1eQ5N1D66TuwbeAoPd+xjWG/TOtw4pJnqwa35afFsAwVdBItH2atdMcGsBZ8m/dDWsTFh7XrtbTumR7LUZkcSbuIXCkPxF7lcAFRwBvkMDm9d+KCvS42iAlVumpAOpSfeYbTtCLNEwUF6NSd8pJ3Bbt19oC3JJdj3UqBUlM/pGFyqnthkOCslcn6uHy0dR/9SiDfH1vrYsvGsCOp8Q== 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=MCHSvfWJL8X/46Lw+7J6iESQWgXdWwqKZ3Uq3xCdxEQ=; b=eb/fum91DoBNKzv2OJs0Tbopvz2XxgUaOi0wnzC78nmikoEdWg7TfRB0Ll+3ioxGm7FMYMkIU5WLLSJ98bz33E7uQQXHYScQP8sbti1QJdTnqWjLMNHRDA5f1RHQiFdKVa3YpcPDL3yUD2kkRe8NfE2ziC/qLQOa8UwSq2cA6EqNcce62/B/suMCVtuILSU18DHHlb5tiIlsbPrad8/jJ4h0UiydTrBkhBnsKSxM5M8PQdvvylnRtDhJA7Esns/TNJQYmhLqOkgya6UbVonqnG0TX2P8B6nq0ulPNTTkQmZZr+QjRroQUBY6/wmDqjRKUHLn+cjtGGQqMlGD8JRnmA== 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=MCHSvfWJL8X/46Lw+7J6iESQWgXdWwqKZ3Uq3xCdxEQ=; b=J92e6NrkTZ7n/qg1qUR4lkrwdx2F0so6od0wEH7TfsDPCw78FVgepXpWpPsh+MDIcjYI1qkk3UuHnIpG6mTHeyyvbDVsnQjAeRezXr/k3uC/f7ksXv7OPK30//hnWb2x9cwAY0dS9hzk/vPRK5RO0nnzp0K2IHyRKiyVUp8iZH4= 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 MN0PR12MB6271.namprd12.prod.outlook.com (2603:10b6:208:3c1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Tue, 1 Dec 2026 10:35:39 +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.0662.007; Tue, 1 Dec 2026 10:35:39 +0000 Message-ID: Date: Tue, 1 Dec 2026 16:04:25 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] soundwire: bus: use pm_runtime_get_if_active() in sdw_handle_slave_alerts() To: vkoul@kernel.org Cc: broonie@kernel.org, yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev, Sunil-kumar.Dommati@amd.com, venkataprasad.potturu@amd.com, Syed.SabaKareem@amd.com, Mario.Limonciello@amd.com, Richard.Gong@amd.com, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, srini@kernel.org References: <20261201082651.3700713-1-Vijendar.Mukunda@amd.com> Content-Language: en-US From: "Mukunda,Vijendar" In-Reply-To: <20261201082651.3700713-1-Vijendar.Mukunda@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MA5PR01CA0092.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:1a8::13) To CY5PR12MB6252.namprd12.prod.outlook.com (2603:10b6:930:20::17) X-Mailing-List: linux-kernel@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_|MN0PR12MB6271:EE_ X-MS-Office365-Filtering-Correlation-Id: 0fa8f205-bb1d-41a3-80fa-08df4f96d7af X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|23010399003|261028144727099003|10067099003|56012099006|11063799006|261021121427099003|261022105027099003|261026121527099003|261009221227099003|261009223027099003|261026140227099003|261022075727099003|261102123227099003|261021123027099003|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: wkfk9+fEoT/ElUYaWsLQgE4KlNE9EkKwiLc30SNTYt1Xxg6t0Gc6eZw3Cs1fExyU1UnYqMXhe+enmuD8bdXUy9sqZ4uUJ/SN9srViQVdbsqcJSTiUbCNjNvJdAPd94sHBQyKf9BDZxdY6aZCYM8qujcOZ7Q3TLkd5hekH213LRiXw96G9TpDvXxdJPQVq7jsZnGm6KY8aZjx0t4tkbTRMhgLEFSFT9l3xOVLFD/4GzjYErIrCzIzpTmZhCQUrZeRuqpUY0sIL4eU+g9RB2Dpv6HKRMIBYRfWoJYqUdDQ/ww6fdpclp5UgkKoZnODVvDRxv9qrG3sOFgMvc//gKBQ94tDqAMyJfZNOiHhszLXCUXSP02zaTLtGbie0uSMkJHzPxEumKa1GM5nQWeSQgfwItVqje8RGCHy2OBoGferkQjoPtcXnqcvayEMG4jnpGx25N0YBKah87z630ini1bdBmhSc3PgINrk8cZgjZjvVYH+sZT2jpIAY+tqN73sJY7X19DqaZYm4BynrYv3UqHkarius68/Zd1czGcibPbqYHB2chN/C+zB4e1onmaqPERy2//aTcuWJroUv7n1Wt9/qKqLt8bjLBvXkNk4K/D1DCNGlyYl2e8tmuWaeK9R9oUcffDV0tBvLxv0kGMissXZqq44ZOtei00oka87978f1+E= 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)(366016)(1800799024)(376014)(23010399003)(261028144727099003)(10067099003)(56012099006)(11063799006)(261021121427099003)(261022105027099003)(261026121527099003)(261009221227099003)(261009223027099003)(261026140227099003)(261022075727099003)(261102123227099003)(261021123027099003)(22082099003)(18002099003)(6133799003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MmVDQmZZbGx4TmxCY3RxRGdRMFl4dUI0VzNzMFRzQlZ0R0llUS9VVCt0dzNm?= =?utf-8?B?YUVYc2FCNTdmc3F4UFRldzJHcnRJb3BITzVoeThpS2xjYnZ2a2FrRUQvc095?= =?utf-8?B?TXFERHMrM01DVjZzbTJOSlM2VEJHMWVkWGZtU3gzZG82bVB0N2RrU1BRMWF3?= =?utf-8?B?K3dIWkJHNTNVOFUxZFZvekM2TDU3R1FQS2FuaVBFdlgxdHhwdjBLSVppWlZa?= =?utf-8?B?ejhqUFJXVTJkMHVBR0F4MEtOK3RXekVQOEswKzRWNXZCbHR0TVdUdFA3Ynp5?= =?utf-8?B?TEMxUi9jeUNsb3E4UnBCOU02VTk0SE8xRHpFT2VabVVWVTJKS3VOZVBhZ3JY?= =?utf-8?B?aTU2L21NQ3JrekVaNG1nalRINU9HeDZ0ZjVLTURNNjM2SVRodS9VbmR4a1FK?= =?utf-8?B?dnpodVo0R2RPUlY5YXFRb0Y2R1QvWHpEZzVvK2NQenVEd3Nt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VST2ZhMUhPcDdLR3FrdXZaeFA4TzZwdTE3ejB6UkdtY2NI?= =?utf-8?B?aU9TRVl5dVd2OWJtNHdSWWl4elN5QWdBSHQzQmxhMGhOWEVJQTBpdz09?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0fa8f205-bb1d-41a3-80fa-08df4f96d7af X-MS-Exchange-CrossTenant-AuthSource: CY5PR12MB6252.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 10:35:39.5403 (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: enoA0eZHhya0S3vnfurhI4jURW2GYsEcE5XXS53jGI72kogx+xdGGep/1RnvA+02Yvos8AYAz0JjqNlxi8dW6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6271 + Srinivas On 12/1/26 13:56, Vijendar Mukunda wrote: > sdw_handle_slave_alerts() calls pm_runtime_get_sync(&slave->dev) which, > when slave->dev is not in RPM_ACTIVE, calls rpm_resume() on the slave. > rpm_resume() propagates synchronously up the parent chain: slave->dev -> > bus->dev -> manager->dev. If manager->dev is in RPM_SUSPENDING at that > point, rpm_resume() blocks on dev->power.wait_queue waiting for the > suspend to complete. > > This creates a deadlock: the manager's runtime_suspend callback is blocked > in cancel_work_sync() waiting for the alert work to finish, while the alert > work is blocked in pm_runtime_get_sync() waiting for the manager's > runtime_suspend to complete. > > Fix this by first checking the manager device state using > pm_runtime_get_if_active() on slave->bus->dev->parent (the physical > manager device). This is an atomic check: if it returns 1 the usage > counter is incremented in the same operation and the manager cannot > transition to RPM_SUSPENDING while the reference is held. > > - If the manager reference cannot be taken (ret == 0, manager not > RPM_ACTIVE): request an async resume via pm_request_resume(mgr_dev) > and return early. This avoids I/O on potentially inaccessible hardware > and breaks the cancel_work_sync() deadlock. After the manager resumes, > the peripheral re-asserts the alert via the first PING frame. > > - If the manager reference is taken (ret > 0, manager is RPM_ACTIVE): > proceed with pm_runtime_resume_and_get(&slave->dev) to resume the > slave. Holding the manager reference prevents the manager from > entering RPM_SUSPENDING while the slave resumes, closing the deadlock > window for all slave PM states. > > - If ret < 0 (-EINVAL, PM disabled on manager): fall through without a > manager reference. PM being disabled means no suspend/resume callbacks > run, so no deadlock risk. This is consistent with the original -EACCES > exemption for the slave. > > pm_runtime_resume_and_get() is used for the slave (instead of > pm_runtime_get_sync()) because it does not increment the usage counter > on error, simplifying the error-path accounting. Introduce have_pm_ref > and have_mgr_ref booleans to guard the pm_runtime_put calls at io_err: > so they are only reached when a reference was actually taken. The > manager reference is released at the new mgr_put: label after io_err:. > > Fixes: aa79293517b3 ("soundwire: bus: fix io error when processing alert event") > Signed-off-by: Vijendar Mukunda > --- > drivers/soundwire/bus.c | 60 +++++++++++++++++++++++++++++++++++++---- > 1 file changed, 55 insertions(+), 5 deletions(-) > > diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c > index 15c66effbf4f..5dc3598eb85f 100644 > --- a/drivers/soundwire/bus.c > +++ b/drivers/soundwire/bus.c > @@ -1667,15 +1667,60 @@ 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) { > + /* > + * Manager is not RPM_ACTIVE (RPM_SUSPENDED, RPM_SUSPENDING, or > + * RPM_RESUMING). Return early to avoid I/O on potentially > + * inaccessible hardware and to prevent a deadlock: if the manager > + * is in RPM_SUSPENDING, its runtime_suspend callback may be blocked > + * in cancel_work_sync() waiting for this work, while this work > + * would block in pm_runtime_resume_and_get() waiting for the > + * manager to complete its suspend. > + * > + * Request an async resume so the deferred alert is re-serviced: > + * - RPM_SUSPENDING: pm_request_resume() sets deferred_resume so > + * the manager resumes immediately after its suspend completes; > + * on resume the peripheral re-asserts the alert via the first > + * PING frame and the interrupt fires again. > + * - RPM_RESUMING: pm_request_resume() is a no-op (device already > + * resuming); after the manager reaches RPM_ACTIVE, the peripheral > + * re-asserts the alert via the first PING frame. > + * - RPM_SUSPENDED: pm_request_resume() triggers an async resume; > + * after resume the peripheral re-asserts via PING. > + * > + * When the SoundWire link fully powers off (e.g. D3 or equivalent), > + * the peripheral loses power and its alert state does not survive; > + * pm_request_resume() is unnecessary but harmless. > + */ > + pm_request_resume(mgr_dev); > + dev_dbg(&slave->dev, "Alert deferred: manager not active\n"); > + return 0; > + } > + if (ret > 0) > + have_mgr_ref = true; > + /* > + * ret < 0 (-EINVAL): PM is disabled (CONFIG_PM=n or disable_depth > 0). > + * Proceed without a manager reference. > + */ > + > + ret = pm_runtime_resume_and_get(&slave->dev); > if (ret < 0 && ret != -EACCES) { > dev_err(&slave->dev, "Failed to resume device: %d\n", ret); > - pm_runtime_put_noidle(&slave->dev); > - return ret; > + goto mgr_put; > } > + if (ret >= 0) > + have_pm_ref = true; > + /* > + * ret == -EACCES: PM is disabled on slave; proceed without a > + * slave reference, consistent with the original -EACCES exemption. > + */ > > /* Read Intstat 1, Intstat 2 and Intstat 3 registers */ > ret = sdw_read_no_pm(slave, SDW_SCP_INT1); > @@ -1861,8 +1906,13 @@ static int sdw_handle_slave_alerts(struct sdw_slave *slave) > dev_warn(&slave->dev, "Reached MAX_RETRY on alert read\n"); > > io_err: > - pm_runtime_mark_last_busy(&slave->dev); > - pm_runtime_put_autosuspend(&slave->dev); > + if (have_pm_ref) { > + pm_runtime_mark_last_busy(&slave->dev); > + pm_runtime_put_autosuspend(&slave->dev); > + } > +mgr_put: > + if (have_mgr_ref) > + pm_runtime_put(mgr_dev); > > return ret; > }