Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5368799pxu; Wed, 21 Oct 2020 23:40:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvYtyg44EbrvL5nzIME3HEPErwevBscPhMxcfjb08kaqVWq/DPXYAmlj+7pvgz+CpxWJbH X-Received: by 2002:aa7:d65a:: with SMTP id v26mr950200edr.82.1603348823278; Wed, 21 Oct 2020 23:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603348823; cv=none; d=google.com; s=arc-20160816; b=a2BrRFeE11HSOcTFtuevS9AOa+Wli4Uq59vztxey5oaTElEUQFJ0urAfs/ueZKDZ1h qB8xJyrTDOv9OSbyxzFro7o3+VPgTNKpJipOkouHma4Kxa/K/bGRCYOTRfDhyokV7ie/ 9vIeyNjONwMDbvO9n85bYvk8Oaqc3KUiqQS0OyawTbgkyG+b71G9fOf8Q1QZJmZNE9Sq LQyd0moqRXDjXgUaRJ6Buo2GjCwIg539NMGuPolioIIEabRXJ/kXpF7cD1gEA5jmNZCa BjNCLmiC95za7uVkJKeMr2VikW7HuUdKh6BMk8V5bJKe9LfQuNwzMGGvyvTJgIv5VK8X emQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=0RoGVmbdWCwvHrQ/NxTIVR5ZWcKZgcp0fta7cO66qXc=; b=fuh7DuOqwmISz2ZbQJ1Gul5jB/cDHNAGXUoOC6Go+aKc0LHrZUPSXuksDQKplDm1vR d/VNm31X/Yz6lZESG2fNdXYKQeFY4YNYcqJrpUvnRVPKCHG5kK3AxJSNLv+UtO6I50zm mr7KWpOtMJErKV1oefcNI+oPDnXlmSj+Ym634Tqyd2XcmOFVCc68Vs1vZIJckwCm+2oK lzJyo7cwS+5aEgGfWwji76KexwA5aVD87OqVgWp38eqeShsbD3+OsL2gt2tzYxF6Eeq3 GtfN615UZZZfAQVXEieAimN8Zv5yhVVgdanHRhpvP77Nh+Ti1T61KbF9FKbrmV+g6AUz Y+JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lr20si309016ejb.439.2020.10.21.23.40.01; Wed, 21 Oct 2020 23:40:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504831AbgJUTOk (ORCPT + 99 others); Wed, 21 Oct 2020 15:14:40 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:59714 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504800AbgJUTOg (ORCPT ); Wed, 21 Oct 2020 15:14:36 -0400 Received: from 89-77-60-66.dynamic.chello.pl (89.77.60.66) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.491) id 93d625418f3655fd; Wed, 21 Oct 2020 21:14:33 +0200 From: "Rafael J. Wysocki" To: Greg Kroah-Hartman Cc: Linux PM , LKML , Lukas Wunner , Saravana Kannan , Xiang Chen Subject: [PATCH 0/3] PM: runtime: Fixes related to device links management Date: Wed, 21 Oct 2020 21:10:08 +0200 Message-ID: <6543936.FbWAdBN1tG@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg & all, Commit d12544fb2aa9 ("PM: runtime: Remove link state checks in rpm_get/put_supplier()") merged recently introduced a weakness in the handling of device links in the runtime PM framework that may be confusing and even harmful. Namely, the checks removed by that commit prevented PM-runtime from getting or dropping references to the supplier device whose driver was going away via its links to consumers, which specifically allowed the pm_runtime_clean_up_links() called from __device_release_driver() to run without interfering with runtime suspend/resume of consumer devices (which still might happen even though the drivers had been unbound from them by that time). After the above commit, calling pm_runtime_clean_up_links() from __device_release_driver() makes a little sense and it may be interfering destructively with regular PM-runtime suspend/resume control flows, so it needs to be either fixed or dropped altogether. I prefer the latter, because among other things this removes an arbitrary difference in the handling of managed device links with respect to the stateless ones, so patch [2/3] is doing just that. However, in some rare cases pm_runtime_clean_up_links() may help to clean up leftover PM-runtime references, so if that function goes away, they need to be cleaned up elsewhere. That's why patch [1/3] modifies __device_link_del() to drop them upon device link removal (which also needs to be done for stateless device links and that's why I'm regarding this patch as a fix). Finally, to avoid pointless overhead related to suspending and resuming the target device for multiple times in a row in __device_release_driver(), it is better to resume it upfront before checking its links to consumers, which is done by patch [3/3]. While this series touches the driver core, it really is mostly related to runtime PM, so I can apply it if that's OK. Thanks!