Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4007749imu; Mon, 28 Jan 2019 15:16:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN7faWWKi7vpl7Ee9CE7P8GooK0RPy854NXbL7/2ySeZDeXSCsVlAxm7u+H2N+6Uud51o0X6 X-Received: by 2002:a62:76cc:: with SMTP id r195mr23625225pfc.38.1548717382128; Mon, 28 Jan 2019 15:16:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548717382; cv=none; d=google.com; s=arc-20160816; b=ZaIG3sMNWoLdBHtRunMPqfsRJ7QnDuXQPISLUJj+JHOH4DaSrTskdngLChgP+U+Oop orYEH3JHDlwXw2S+p5TwPCIRBZoFYrMAjDXDTqibvxbeVz8qRFyNYKz8CHSJgr8AOyYW PzY8WDJ5AnPkBsEQnL5AKfVhFg4oc2KFkAgzZgNuRay1vzogtNnaD6+e4M6RgeGlP/uV qnLJxW+sAvU3jdQN89R+C4ygsUL7LFU9NxH8OTaX8HHXBk5wTUSCXk3B4AniWoOGIE62 0+OCTz3U6e2CXUVgbBGKWynAaUt848bh+O2pgHc0yhM4GQxQG5ZgkRH9BEejy6g7Nc0D p8lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xQjdcdDB/b56DbGhoFdnvmavlRWJn831/2GA3kljyDI=; b=ZIZa0tHgez8g0cHNntmfaVQNBgdpgq9hDRv31BHw3py4guj4RuZF7d/Y8MCJwzlyBt tWOtVorBDc9rFGQatwtpVUGe/uoQoUz+00JodaR0A+t69O3P8pXv2571qYTfUiiFPKum lZqW/kErBJ9vsP+ryolaM1RSJ8hwXuW2gfjJgEgAtnQDl20rcQcGjskxYj4LKxcgataY 2GvySWbcVAj/mwlfK7+qBEdNulyKpfEKS46/G6rXp2lRJXH+59ysKS9u6xhOQLeKnEg0 3zKYdVo15sstTHBv/onVu/DaIRgl9tJOGPMidewwojtifOjUMNwR7Hn5i/PX5g0LHW62 j1gQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 91si11711249ply.222.2019.01.28.15.16.06; Mon, 28 Jan 2019 15:16:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbfA1XOD (ORCPT + 99 others); Mon, 28 Jan 2019 18:14:03 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:64962 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726678AbfA1XOD (ORCPT ); Mon, 28 Jan 2019 18:14:03 -0500 Received: from 79.184.255.169.ipv4.supernova.orange.pl (79.184.255.169) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id 2dcb95696e597b9e; Tue, 29 Jan 2019 00:14:00 +0100 From: "Rafael J. Wysocki" To: Greg Kroah-Hartman Cc: LKML , Linux PM , Ulf Hansson , Daniel Vetter , Lukas Wunner , Andrzej Hajda , Russell King - ARM Linux , Lucas Stach , Linus Walleij , Thierry Reding , Laurent Pinchart , Joerg Roedel Subject: [PATCH 4/4] driver core: Do not call rpm_put_suppliers() in pm_runtime_drop_link() Date: Tue, 29 Jan 2019 00:08:36 +0100 Message-ID: <9744885.kWxcYK6YUu@aspire.rjw.lan> In-Reply-To: <2405639.4es7pRLqn0@aspire.rjw.lan> References: <2405639.4es7pRLqn0@aspire.rjw.lan> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki Calling rpm_put_suppliers() from pm_runtime_drop_link() is excessive as it affects all suppliers of the consumer device and not just the one pointed to by the device link being dropped. Worst case it may cause the consumer device to stop working unexpectedly. Moreover, in principle it is racy with respect to runtime PM of the consumer device. To avoid these problems drop runtime PM references on the particular supplier pointed to by the link in question only and do that after the link has been dropped from the consumer device's list of links to suppliers, which is in device_link_free(). Fixes: a0504aecba76 ("PM / runtime: Drop usage count for suppliers at device link removal") Signed-off-by: Rafael J. Wysocki --- drivers/base/core.c | 3 +++ drivers/base/power/runtime.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) Index: linux-pm/drivers/base/core.c =================================================================== --- linux-pm.orig/drivers/base/core.c +++ linux-pm/drivers/base/core.c @@ -375,6 +375,9 @@ EXPORT_SYMBOL_GPL(device_link_add); static void device_link_free(struct device_link *link) { + while (refcount_dec_not_one(&link->rpm_active)) + pm_runtime_put(link->supplier); + put_device(link->consumer); put_device(link->supplier); kfree(link); Index: linux-pm/drivers/base/power/runtime.c =================================================================== --- linux-pm.orig/drivers/base/power/runtime.c +++ linux-pm/drivers/base/power/runtime.c @@ -1623,8 +1623,6 @@ void pm_runtime_new_link(struct device * void pm_runtime_drop_link(struct device *dev) { - rpm_put_suppliers(dev); - spin_lock_irq(&dev->power.lock); WARN_ON(dev->power.links_count == 0); dev->power.links_count--;