Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5561918rwb; Mon, 5 Dec 2022 00:25:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf7chzj2wcpiCMB7tarz7wlXQe8m4gWxAE3OwNlP/KEpMdM3svwhF/UfJcxrt6rV1q2FF7bW X-Received: by 2002:a17:90b:2801:b0:200:2069:7702 with SMTP id qb1-20020a17090b280100b0020020697702mr6191088pjb.239.1670228735105; Mon, 05 Dec 2022 00:25:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670228735; cv=none; d=google.com; s=arc-20160816; b=vZcBxNW4dpMFCfyCMsznhb2SKE56ckVE2MNJRHPWj0FYq2bWtHBKWT8ZN1ggve2qRt RiSfauBX8nbKEOCNdVDR9eCLmUgn8kD4+4Pg6dPho4J4DypxgwlewqWqBq+2IEV59SZO nfXkYTrOfLApBDjAvpmkP/yiqkBRA8u1UUXYNhmb4Zp6gLk8siAPd79EyWkuWhzjA6he VJQndnCJbVgxnn67TUz0cuLVOMI2WOfnR3JOWg1t0OP88YPoovYhtSxHmS5JykjSWdFg TLsLNgEOlEudmSi2hguvQsPeCUxjcSFsW/2+PC2KbfoUS3kx+4jG10jRAtNfBl2/WPXy VX/Q== 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 :organization:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=aHZ3M9OGpd9Se20iIr19l39lVpyNjINarHtmmcKSG50=; b=UROL/L8a3yUVu9f0KJHap3MmROqq2PRDxjy8xflBKvP/AtUtZqgWOAfyPeLRoFtbkW NruC8F5bLtbg6L2jHYJAkd+EbKoG3efrviEsGBfcUl00+Ff0NJIvcHyLrRmVkdDLQmqs pZ5rlPKE8IhShXS7qPic3f2CKjPlpYPR/QWvgeY4+FrXgxiu3dVL/DtvPMvRQvgy3HcL wYZUD2XkffHQVnYEeqnmTHqhsd0UUyojJri6jnR/xddvkmtLaULIojaJduR8W0Iiy0h2 1Qq4oclV/ZLXWRyjSqlxzeLBuC4/D7+iau7VN2BZTjdRusGdeA0E3/3iBu6drdYlMj6F rH+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DCbReg8j; 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 x17-20020a1709027c1100b00188fead2329si12836561pll.135.2022.12.05.00.25.24; Mon, 05 Dec 2022 00:25:35 -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=DCbReg8j; 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 S230151AbiLEHpU (ORCPT + 83 others); Mon, 5 Dec 2022 02:45:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231528AbiLEHpO (ORCPT ); Mon, 5 Dec 2022 02:45:14 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA1FA13F22; Sun, 4 Dec 2022 23:45:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670226313; x=1701762313; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Dy6cUKU1bDtIuKsKSF9kSgG90krsYCMVDXa1HRQdkdE=; b=DCbReg8jdqWFedmuMCmgG8JWmozUbZIrAAClViDZTuAzyhLS724263lc nb5jUJbuTvxevszUOQwTrRBIqoWLewadDSJWLjsotSILpWTH0ApJGk7S6 ImXRvobF8wMeLlXk2ejsf7X6Gda1P1LhsZUD7BRxFK64dgpc4ApQ9ofx4 VSvxuH8ez5AKzlHg+AaAN/cUxGKl4WxhQvztWaF6xIvK+woELXBP4ZdSp dDW4RSAzB5fhzxNjWdhzxrlGU0UNd09QEmfD7sJv4mzX9VEYQKRWWXzF8 4b7MXEHl/toQh+nDtm9b2bGkiJe8WTufFO/F8p7LxRTiuhxM0UUyuRztW Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10551"; a="313933380" X-IronPort-AV: E=Sophos;i="5.96,218,1665471600"; d="scan'208";a="313933380" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2022 23:45:13 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10551"; a="645727543" X-IronPort-AV: E=Sophos;i="5.96,218,1665471600"; d="scan'208";a="645727543" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.55.104]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Dec 2022 23:45:10 -0800 Message-ID: Date: Mon, 5 Dec 2022 09:45:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.5.1 Subject: Re: [PATCH v1 1/2] PM: runtime: Do not call __rpm_callback() from rpm_idle() To: "Rafael J. Wysocki" , Linux PM Cc: LKML , Tushar Nimkar , Adrian Hunter , "Rafael J. Wysocki" , Nitin Rawat , Peter Wang , Alan Stern , Ulf Hansson References: <5627469.DvuYhMxLoT@kreacher> <4789678.31r3eYUQgx@kreacher> Content-Language: en-US From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: <4789678.31r3eYUQgx@kreacher> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE 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/12/22 16:30, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Calling __rpm_callback() from rpm_idle() after adding device links > support to the former is a clear mistake. > > Not only it causes rpm_idle() to carry out unnecessary actions, but it > is also against the assumption regarding the stability of PM-runtime > status accross __rpm_callback() invocations, because rpm_suspend() and accross -> across > rpm_resume() may run in parallel with __rpm_callback() when it is called > by rpm_idle() and the device's PM-runtime status can be updated by any > of them. > > Fixes: 21d5c57b3726 ("PM / runtime: Use device links") Reviewed-by: Adrian Hunter > Signed-off-by: Rafael J. Wysocki > --- > drivers/base/power/runtime.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > Index: linux-pm/drivers/base/power/runtime.c > =================================================================== > --- linux-pm.orig/drivers/base/power/runtime.c > +++ linux-pm/drivers/base/power/runtime.c > @@ -484,7 +484,17 @@ static int rpm_idle(struct device *dev, > > dev->power.idle_notification = true; > > - retval = __rpm_callback(callback, dev); > + if (dev->power.irq_safe) > + spin_unlock(&dev->power.lock); > + else > + spin_unlock_irq(&dev->power.lock); > + > + retval = callback(dev); > + > + if (dev->power.irq_safe) > + spin_lock(&dev->power.lock); > + else > + spin_lock_irq(&dev->power.lock); > > dev->power.idle_notification = false; > wake_up_all(&dev->power.wait_queue); > > >