From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.68 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796308888; b=twC0LLMmgCexaMin9Re6RUJF7ruLqzTqS9nHUsIh6s+k6Bxr/OTn/Xi/bD68SgAVfNBN 1eduB/Di6NIRBR7Omde6e2r8+Ogl/7xnAAhVOgKQpfxVggOLFHgWTcarbEhjV7VVHtD6Y r0N2PIHEIBWxlnfTE2E5ofvtKpfsIiD86OqgaDXPqEcFZelBYL3tgLxyxoNCQJyW2nkcH GKRwOSHCjz4vhL1msVu0LmbxdKO4bbztLnHb2Izzrz/QndAdMx+b6GJtwsMDLtEUsJBWK Ih11o+/H2DwHplb4D9zKdxk8NPgVQ5IOJUNCGBlARJaYWBA3MDVfiagQb+sg5DKhBtw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796308888; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=itfRMHoUOw/jz/FDyLalRdS/T8SqUfo1tEmeuO8+mMs=; b=uwHUhW3R/O83VSC03PyowbpBYUxEXNIRWQqUNpQTvks/F37pFBNbFIWaz7PElDV3/aHA dyyZLhRejUNs6BfEaCxr8LYDSduKr/cMyZoGil1lWjbZSvf/YCGZ3FBcRQ+cTKiuCXj1z VJTOOzv9BImwXjzzoE4duLh/paqxvk7wWuOzPZJ1HTGD7bovrrxG5r5Xl9+DpT3lxWVGn 1LW5Xf3dAE4A43ik3QJPHK1Q2XCyaP/D7ch/vOjO2Db/luuFRriwhUSnGmdKxMgPKSguz 9MhouEHfK7CyHD5WUbrvUJfADQhB0lqma7ggW9UUlt2LhWcXjsD/AgJHBKO5p57N1bw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=DYyjqu1x; arc=none smtp.remote-ip=91.218.175.68 Received: from mta0.migadu.com (out-68.mta0.migadu.com [91.218.175.68]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC7C1606A322 for ; Thu, 3 Dec 2026 14:41:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DC7C1606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=DYyjqu1x X-Envelope-To: linux-sound@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=bT0e4GPlI85/AvtV4PexXVuQvAj/k6XrbnhUZOceLZU=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796308886; v=1; x=1796913686; b=DYyjqu1x/iFJn/GkKduTv4G4v2DhrC8nlrX5yfE6DF/iSA580pGFxq8ygM5tEqwwW6KDjR83 s1xuaRqU+bF4qykZ9SH8VjxVrew2SEDwVPrDB0+IdUpN3MqUE+xoPzq3DMmJmFqP0wuVEjmpian raDibzIr8yeu1ECR+nJMsAJ8= X-Envelope-To: linux-sound@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 4e54e8b2dd3f838e; Thu, 03 Dec 2026 14:41:26 +0000 X-Mizu-Trace-ID: 4e54e8b2dd3f838e X-Migadu-Flow: FLOW_OUT Message-ID: Date: Thu, 3 Dec 2026 15:32:35 +0100 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] soundwire: bus: use pm_runtime_get_if_active() in sdw_handle_slave_alerts() To: "Mukunda,Vijendar" , 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> <47b75028-5574-4a26-aee2-080a653760fc@amd.com> Content-Language: en-US From: Pierre-Louis Bossart In-Reply-To: <47b75028-5574-4a26-aee2-080a653760fc@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit >>> 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? possibly, but I can't think of a race-proof way to do this?