Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp348540pxb; Thu, 21 Apr 2022 00:39:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylQXA/32KoBHmganwYT7zZ5rTuOP5WmVJNFt77XC4Au/OTDTCZidvN1BIpMcu2jFHIQxfI X-Received: by 2002:a17:90a:2b0f:b0:1cb:a3e5:413b with SMTP id x15-20020a17090a2b0f00b001cba3e5413bmr8901501pjc.115.1650526750770; Thu, 21 Apr 2022 00:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650526750; cv=none; d=google.com; s=arc-20160816; b=Tit0dYzK0CbkI6AqAm190fcIr3VVkUTirV3psTFWeubyGbLl2B3CceJ2tnzb9o7nyi 2E1iqTRZKY0qZwOd+5O3bIV+WdWN86/nkybVgsAEkVSwc1blEgkPc/7RZgGFbAcw5FCA r+z0DtZ/nMhV4TRpXU1Sfh8S7HsjbPy5PrVsqnEv+A6Ejm4T7/hwO3xCp84p9fgyS5Zy 5BFy6jaNGuPui+ZlY4jkSvO+eLLon9AuEyBw0AZTBXyKuogiI1Rz8CW2hA0hySUiqsSp 23WFTSaoCYqqhVBkxy4tEYQn01ifHQhlXk/Zn7ij1ijZnYNqzIEauEeQ64sMPPZpd/Pw NjXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=XrucOQHCpH3vQrpK0v53Dmg6jxkXFbcmwO1aLgG7tRQ=; b=CDKfJ+TfGR0lUb0R8GSvXCbs4Qarxk8Y2erAC0XuMg+dtkHVLaF7WTMaiuKRtGGL2R +ZVQCik614+kBobVwOv141pfQuJnZ9d9vEHWW/BNpykMmkrilf9gBN2WnfdY3dRZd/bS BtAR4oAgGhaTmt7Ttx/vNwLFg2XGGASxAXLQY7G3r5zc5j/7rScaU2ZUck8KkUhLHW7D 1SFcYhXw4CZW0VZz+SfH3XgreDJS6/pBs09yoipWskUtcRpTGr/qnfLBKVg5hd83acG7 HMzPpCotkj4uzctkEZIN8nG0eefe1E7sQb895oAI0EDIhfM+VzMu2JeJe9z9SK5iwAOr k9Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="JxKLnr8/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020aa78889000000b0050594974188si4669169pfe.277.2022.04.21.00.38.54; Thu, 21 Apr 2022 00:39:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="JxKLnr8/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358962AbiDTCfv (ORCPT + 99 others); Tue, 19 Apr 2022 22:35:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358945AbiDTCfu (ORCPT ); Tue, 19 Apr 2022 22:35:50 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1266932995 for ; Tue, 19 Apr 2022 19:33:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650421986; x=1681957986; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=NhcIVk7RjAY/MIh/KHzpjrCZoNRYNyCEFEr4+HwwHNI=; b=JxKLnr8/BmAtwN1RDUsh53zy1q1dGnojInRKRN3i6tdnjh3/APNFQM/P YpFB+NOtB/jroWTZ7x+lB7/sx3Nz4pp7L0GpQYQiCWU+KT6gNKQSaGbJB gGmtlxyyFDH9kjTIZ8E9lKvLqoX3syz4mb43YYOaWYM6EXxIqJfVQGGmd 4SDVQ6wr03rgWbJdOPNsjBKkId/FQSWLLIHT5sCptbRdmL2DAeq4V7sz4 cB3pqzjSYbhb8bIfqbictIpO54ASCslqFHbhBewbbxw48e7F7hE1/4Rx7 fTG7sEKB4Iog+JAkz+LSgHftHnryAs0iJkUWyBxCmyNTJBUMlM737MJ2k g==; X-IronPort-AV: E=McAfee;i="6400,9594,10322"; a="261522464" X-IronPort-AV: E=Sophos;i="5.90,274,1643702400"; d="scan'208";a="261522464" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 19:33:05 -0700 X-IronPort-AV: E=Sophos;i="5.90,274,1643702400"; d="scan'208";a="529554582" Received: from bard-ubuntu.sh.intel.com ([10.239.185.57]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2022 19:33:03 -0700 From: Bard Liao To: alsa-devel@alsa-project.org, vkoul@kernel.org Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, srinivas.kandagatla@linaro.org, pierre-louis.bossart@linux.intel.com, sanyog.r.kale@intel.com, bard.liao@intel.com Subject: [PATCH 3/3] soundwire: bus: pm_runtime_request_resume on peripheral attachment Date: Wed, 20 Apr 2022 10:32:41 +0800 Message-Id: <20220420023241.14335-4-yung-chuan.liao@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220420023241.14335-1-yung-chuan.liao@linux.intel.com> References: <20220420023241.14335-1-yung-chuan.liao@linux.intel.com> X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart In typical use cases, the peripheral becomes pm_runtime active as a result of the ALSA/ASoC framework starting up a DAI. The parent/child hierarchy guarantees that the manager device will be fully resumed beforehand. There is however a corner case where the manager device may become pm_runtime active, but without ALSA/ASoC requesting any functionality from the peripherals. In this case, the hardware peripheral device will report as ATTACHED and its initialization routine will be executed. If this initialization routine initiates any sort of deferred processing, there is a possibility that the manager could suspend without the peripheral suspend sequence being invoked: from the pm_runtime framework perspective, the peripheral is *already* suspended. To avoid such disconnects between hardware state and pm_runtime state, this patch adds an asynchronous pm_request_resume() upon successful attach/initialization which will result in the proper resume/suspend sequence to be followed on the peripheral side. BugLink: https://github.com/thesofproject/linux/issues/3459 Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Rander Wang Signed-off-by: Bard Liao --- drivers/soundwire/bus.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index 354d3f89366f..8b7a680f388e 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -1838,6 +1838,18 @@ int sdw_handle_slave_status(struct sdw_bus *bus, __func__, slave->dev_num); complete(&slave->initialization_complete); + + /* + * If the manager became pm_runtime active, the peripherals will be + * restarted and attach, but their pm_runtime status may remain + * suspended. If the 'update_slave_status' callback initiates + * any sort of deferred processing, this processing would not be + * cancelled on pm_runtime suspend. + * To avoid such zombie states, we queue a request to resume. + * This would be a no-op in case the peripheral was being resumed + * by e.g. the ALSA/ASoC framework. + */ + pm_request_resume(&slave->dev); } } -- 2.17.1