Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp825225rwb; Tue, 27 Sep 2022 05:17:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6u5kJtih5EvbGGcn1JyD+t2zIBPk6DpR8h2Ao40ZTmGIQ5X8TTr52EM/kN+lkgq3rkIJeX X-Received: by 2002:a17:906:99c1:b0:6fe:b01d:134 with SMTP id s1-20020a17090699c100b006feb01d0134mr22188620ejn.598.1664281067039; Tue, 27 Sep 2022 05:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664281067; cv=none; d=google.com; s=arc-20160816; b=ZPIxio2tdAtx9aWGq1H2wYW2W6hPjgUxZC0pk7d295U2zIKZGYMU38BWaY2XgOb5G2 U8ZGFBmcfciEoWQYvqSRzr25zinDyKqGaai/z8aEXGi0CcybDQb6uZ/ZSGtshmA3K9Qb uZnjnqqZ/TODB3kvq6S1LtDtVf+TruxF4D8UAtOwi3SjTq7IVUpwqscb3A4uKZFqb7YW LhYRmlTGtmrPReGHgYTm7vHdL+1VsR/TOnSRxafMg80Ysp17igMENyyBrGZjNfZbYewL kYEw3cWhw/xjT/oUzM6hBk0/3n5JNWE5gLo2VqUXnTuLfix214t67l2NS0AbUFEkrtuM L0mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=FUKUzwHmRfNLiY0NPzyc3tn/CTu6dcDHzrfQc+oavds=; b=chxRXTo9ECZcXZgontFTtLnpOPizVxjR1vkSgMg8fAkK1v/TvkOOqpCCoyL8cojNXJ RhXevCnFfiiGqMDmdqWW2n8OLworFXBvnRSHhmvXM+eAZqUuI8jkXoqgPSt6zrpsiGGX TnYyHgbhXD7g4THP618H1a+mAS6CAmMAoPbEndIbOUv6fUWEa7jw4AO5pNjyr3PFKXyC hO6xY2Yf0lx5/H6EgH7l5w7dljqteDHylZsY9QR+/nJw9QEajYyyFGe86rcisCNzyrSP Xe2tHsTBRPx+QuVDMfDFEVXM8XfguD7sizWhTUjJDsJ/su6J1gFk6kHLtrjc0loIdMSQ aCaw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht21-20020a170907609500b0074172ed562dsi1084408ejc.813.2022.09.27.05.17.18; Tue, 27 Sep 2022 05:17:47 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232037AbiI0LRu (ORCPT + 99 others); Tue, 27 Sep 2022 07:17:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231448AbiI0LR1 (ORCPT ); Tue, 27 Sep 2022 07:17:27 -0400 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 693EA647E4; Tue, 27 Sep 2022 04:16:44 -0700 (PDT) Received: by mail-qt1-f177.google.com with SMTP id r20so5739559qtn.12; Tue, 27 Sep 2022 04:16:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=FUKUzwHmRfNLiY0NPzyc3tn/CTu6dcDHzrfQc+oavds=; b=P2vwIehLml7xk7K4P9Br5smkdU2acViSAl+noQlc+mmgw89+/DjLCTomPRlzgu0M3Z YMPROhrZq6XO8IoRUvhZ7a9yp34foYGmrM+K6pILJvRgn2bt1rAaEemInVbq6OLkPJrE 8EB4gPPnIchZ/2q2MB2wbDk9JTYbw1Z8Llkr4F6h4UjL8ioSvZpkuc2c8YPMD0+NmhkI KEDhM2H60N9lUOTtQTFcZFxvaU+yYjhCMJFoZR6BeYxhQGlD6DCd+E2KRyF8gngbVtHR y36LRFTqOtvMPwzYKzSMJubrm9O6PKQ4gyu7gR876Pp+YtnPcYQvJ1KAVQJUs3VVMMal 7onA== X-Gm-Message-State: ACrzQf2IhiMVZB3Kn5URJs/3KO5kxRBBHVhaUB6IrBUbSN97s28esMJ0 RYVjhZlky1NWcRQTYKkbXIKAXGlAYgbdhcD7F4JBiB6q X-Received: by 2002:a05:622a:620a:b0:35c:bf9e:8748 with SMTP id hj10-20020a05622a620a00b0035cbf9e8748mr22068048qtb.494.1664277402949; Tue, 27 Sep 2022 04:16:42 -0700 (PDT) MIME-Version: 1.0 References: <20220923124904.1373936-1-victor.liu@nxp.com> <75366bfac9fcd4f8c35309193705f0277a164ae4.camel@nxp.com> <1b1aa20aa3b8f8255fa05d61c7fa094650dee319.camel@nxp.com> In-Reply-To: <1b1aa20aa3b8f8255fa05d61c7fa094650dee319.camel@nxp.com> From: "Rafael J. Wysocki" Date: Tue, 27 Sep 2022 13:16:31 +0200 Message-ID: Subject: Re: [PATCH v2] PM: runtime: Return properly from rpm_resume() if dev->power.needs_force_resume flag is set To: Liu Ying Cc: Ulf Hansson , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-imx@nxp.com, "Rafael J . Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no 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 Tue, Sep 27, 2022 at 9:47 AM Liu Ying wrote: > > On Mon, 2022-09-26 at 11:47 +0200, Ulf Hansson wrote: > > On Fri, 23 Sept 2022 at 17:23, Liu Ying wrote: > > > On Fri, 2022-09-23 at 15:48 +0200, Ulf Hansson wrote: > > > > On Fri, 23 Sept 2022 at 14:47, Liu Ying wrote: > > > > > After a device transitions to sleep state through it's system > > > > > suspend > > > > > callback pm_runtime_force_suspend(), the device's driver may still > > > > > try > > > > > to do runtime PM for the device(runtime suspend first and then > > > > > runtime > > > > > resume) although runtime PM is disabled by that callback. The > > > > > runtime > > > > > PM operations would not touch the device effectively and the device > > > > > is > > > > > assumed to be resumed through it's system resume callback > > > > > pm_runtime_force_resume(). > > > > > > > > This sounds like a fragile use case to me. In principle you want to > > > > allow the device to be runtime resumed/suspended, after the device > > > > has > > > > already been put into a low power state through the regular system > > > > suspend callback. Normally it seems better to prevent this from > > > > happening, completely. > > > > > > Not sure if we really may prevent this from happening completely. > > > > > > > That said, in this case, I wonder if a better option would be to > > > > point > > > > ->suspend_late() to pm_runtime_force_suspend() and ->resume_early() > > > > to > > > > pm_runtime_force_resume(), rather than using the regular > > > > ->suspend|resume() callbacks. This should avoid the problem, I think, > > > > no? > > > > > > I thought about this and it actually works for my particular > > > panel-simple case. What worries me is that the device(DRM device in my > > > case) which triggers the runtime PM operations may also use > > > ->suspend_late/resume_early() callbacks for whatever reasons, hence no > > > fixed order to suspend/resume the two devices(like panel device and DRM > > > device). > > > > > > Also, not sure if there is any sequence issue by using the > > > ->suspend_late/resume_early() callbacks in the panel-simple driver, > > > since it's written for quite a few display panels which may work with > > > various DRM devices - don't want to break any of them. > > > > What you are describing here, is the classical problem we have with > > suspend/resume ordering of devices. > > > > There are in principle two ways to solve this. > > 1. If it makes sense, the devices might be assigned as parent/child. > > 2. If it's more a consumer/supplier thing, we can add a device-link > > between them. > > I thought about the two ways for my particular panel-simple case and > the first impression is that it's not straightforward to use them. For > DSI panels(with DRM_MODE_CONNECTOR_DSI connector type), it looks like > panel device's parent is DSI host device(set in mipi_dsi_device_alloc() > ). For other types of panels, like DPI panels, many show up in device > tree as child-node of root node and connect a display controller or a > display bridge through OF graph. Seems that DRM architecture level > lacks some sort of glue code to use the two ways. Well, apparently, the ordering of power management operations regarding the components in question cannot be arbitrary, but without any information on the correct ordering in place, there is no way to guarantee that ordering in every possible code path. Addressing one of them is generally insufficient and you will see problems sooner or later.