Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp232072pxm; Tue, 22 Feb 2022 22:01:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkliSHsqje1n1qPyjZXIYgrQtqp7fhIVt5g1WRJngUYD/vR7d/Zd2zF1iWPkGBnL0dy7Lq X-Received: by 2002:a17:906:7e52:b0:6cf:cf1a:17f with SMTP id z18-20020a1709067e5200b006cfcf1a017fmr21268835ejr.251.1645596110583; Tue, 22 Feb 2022 22:01:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645596110; cv=none; d=google.com; s=arc-20160816; b=v55AGkGI15LWISN7C3r+BKNBsMoE+9F92UlD5t6hVnhD6A6zNatShEvf1DUmALcd2G D1kyh1FAWxe0cdFIb+fN8DnIFfP2sZmHUJnRWymeOxIsr/dCotYSqYpvYQc2zqMv7tVZ pJNm2D5YU3f7DEVnJDst1BVwlAtQDnttcuBWWHygGATwbPyVDIZmwPhVhD4yKEecU2qi 7xdUs0u6LqbvDI6aAbJf2iRxQtf2p8EDmiDGZCOv9AXe6e9JX87fJnwr7DuvQgolEdt2 Z3LG9AgQUa8RfrDj3aEicR/2N/X+DJd6v7pPMHyabfYemq9B+nmrkPbpmygXPQitfVDH bSzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=H638T03iwLO+Yr/KEMXZAOv3ZOkFA0UkKzpUqJeGI1g=; b=r6UTnWlDjL2rXLH9dsGLaT9tvogtO4Rsj3FEg/HH+tG5HCvvfuvy9TRWrRDdGneNoa FoG/LtCxGVl0KDcEZMKWK3lmayMbLHo/xH/S8anPbxRedOHKbVlHJdH8rnj/dnlbv73e pztdvRdxdVzGAnmC1K5bccljpSdhppBlrYbre5Z047s9uTQdzNXqIhFuDHvWn1oSOirP nFgYDp/NoPbPfna3s4KUWiWNV8cJOlMFif+uhTrJBwUBDS0Bqzel48qAV/hE6CVbbjpv nRMNWnVqUCv/OFxk3o9AgG29YwrKxXFTniHrJ7xE4BEBCjKSjnvTEBnV3JfvOKe5TMu7 S5ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gfInyjZx; 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 kw22si10257876ejc.169.2022.02.22.22.01.24; Tue, 22 Feb 2022 22:01:50 -0800 (PST) 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=gfInyjZx; 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 S235327AbiBWAcE (ORCPT + 99 others); Tue, 22 Feb 2022 19:32:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234017AbiBWAcC (ORCPT ); Tue, 22 Feb 2022 19:32:02 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8187926563; Tue, 22 Feb 2022 16:31:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645576294; x=1677112294; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=9nLGmFa4SonpF2qf8NgANpNkiWR11udF8i0fGALAavU=; b=gfInyjZxWRp27tVE7gxbSkW3f9r+XAT+hhKnJ9C+sr3l8tB9eVWMjuNv fOgRWFcf6iTTvxcaLLmA7bPkgwsaK+TWQ6iOCZTB2zCXlIf8ehLhTtqtn lVUBCuNcf/TWJ3T9i+T3tvJhfPnL8KJ5G+irXMZzorl6p5ASJsnSbdlA8 e09HIYuC6fdLPD47vNS0fV9jN0mY+GT86yKTGOXODBVPEPxWyhO5B9Jiu x/Eg46Obs7JoOVlifVdn5SmkUBuQV4BOoE0+vVPp/3MDtV6RCkKCdAnw8 GoYXdeUOSyvNUS+d/ykrQhu8X9UNYxN4xMv7rT6cksUx+vk986mkIWhm5 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10266"; a="315076994" X-IronPort-AV: E=Sophos;i="5.88,389,1635231600"; d="scan'208";a="315076994" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 16:31:33 -0800 X-IronPort-AV: E=Sophos;i="5.88,389,1635231600"; d="scan'208";a="639110296" Received: from mjpatel-mobl.amr.corp.intel.com (HELO [10.212.37.223]) ([10.212.37.223]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 16:31:32 -0800 Message-ID: <49099bcb-35e9-0bea-9658-006caed3ab33@linux.intel.com> Date: Tue, 22 Feb 2022 18:31:32 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.5.0 Subject: Re: [PATCH 3/3] soundwire: qcom: add wake up interrupt support Content-Language: en-US To: Srinivas Kandagatla , robh+dt@kernel.org, vkoul@kernel.org, yung-chuan.liao@linux.intel.com Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, quic_srivasam@quicinc.com References: <20220221104127.15670-1-srinivas.kandagatla@linaro.org> <20220221104127.15670-4-srinivas.kandagatla@linaro.org> <5e050d4c-e3d2-35fb-ca49-7be53579bc31@linux.intel.com> <1cb4e02f-f040-23bd-44d0-0675429332bd@linaro.org> From: Pierre-Louis Bossart In-Reply-To: <1cb4e02f-f040-23bd-44d0-0675429332bd@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, 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 On 2/22/22 16:52, Srinivas Kandagatla wrote: > > > On 22/02/2022 19:26, Pierre-Louis Bossart wrote: >> >> >> >>> +static irqreturn_t qcom_swrm_wake_irq_handler(int irq, void *dev_id) >>> +{ >>> +    struct qcom_swrm_ctrl *swrm = dev_id; >>> +    int ret = IRQ_HANDLED; >>> +    struct sdw_slave *slave; >>> + >>> +    clk_prepare_enable(swrm->hclk); >>> + >>> +    if (swrm->wake_irq > 0) { >>> +        if (!irqd_irq_disabled(irq_get_irq_data(swrm->wake_irq))) >>> +            disable_irq_nosync(swrm->wake_irq); >>> +    } >>> + >>> +    /* >>> +     * resume all the slaves which must have potentially generated this >>> +     * interrupt, this should also wake the controller at the same >>> time. >>> +     * this is much safer than waking controller directly that will >>> deadlock! >>> +     */ >> There should be no difference if you first resume the controller and >> then attached peripherals, or do a loop where you rely on the pm_runtime >> framework. >> >> The notion that there might be a dead-lock is surprising, you would need >> to elaborate here.Issue is, if wakeup interrupt resumes the controller >> first which can > trigger an slave pending interrupt (ex: Button press event) in the > middle of resume that will try to wake the slave device which in turn > will try to wake parent in the middle of resume resulting in a dead lock. > > This was the best way to avoid dead lock. Not following, sorry. if you use pm_runtime functions and it so happens that the resume already started, then those routines would wait for the resume to complete. In other words, there can be multiple requests to resume, but only the *first* request will trigger a transition and others will just increase a refcount. In addition, the pm_runtime framework guarantees that the peripheral device can only start resuming when the parent controller device is fully resumed. While I am at it, one thing that kept us busy as well is the relationship between system suspend and pm_runtime suspend. In the generic case a system suspend will cause a pm_runtime resume before you can actually start the system suspend, but you might be able to skip this step. In the Intel case when the controller and its parent device were suspended we had to pm_runtime resume everything because some registers were no longer accessible.