From patchwork Thu May 24 08:33:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10423101 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 80F386019D for ; Thu, 24 May 2018 08:34:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F91629003 for ; Thu, 24 May 2018 08:34:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62CEF29343; Thu, 24 May 2018 08:34:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D57BA29003 for ; Thu, 24 May 2018 08:34:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965242AbeEXIdu (ORCPT ); Thu, 24 May 2018 04:33:50 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:34009 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965219AbeEXIdr (ORCPT ); Thu, 24 May 2018 04:33:47 -0400 Received: by mail-wr0-f194.google.com with SMTP id j1-v6so1504772wrm.1 for ; Thu, 24 May 2018 01:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=tRd75Ro7KAnq5vLrEM/PtLPi7L85Jit7GBlL7cfTkX4=; b=MYduOAdNDlg8Y14IvnMxdehmVhcrALNZPWMfysgNpw88Ix/YgmQZvEN3shuBFs3k/T I0oY5/BmJdzu+u11/0M0/uQU0AC5/eLYxmKAszlFk4y7Ru/nQWV02N/FXu+zeMdHNLCE iKxJ6WhQ5cYUlpMoBhVE424m6nYvSqVv+Q/eg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tRd75Ro7KAnq5vLrEM/PtLPi7L85Jit7GBlL7cfTkX4=; b=eOl3Brq6GQPkbX/DdqWnmK5BfLYgtpK2vH8bBxCZmRruq45pdix9MmDTQ96HifXDSt n0I3EV84EkBB9FDGFdq2tMMrn0xMIea3SPH+DkSd8prHHFJEB8SVYd0C7JATfuGlTVaZ 7B53NNail8sfEeFE+INRawA9CkmKmTKlBV993tNwmMO1eYyTEbNji+ztHlhE7/JRua42 Lami9DoU5y4SIuBIHoK/FsR+KKHdabPjHX5rCxgJPqyNfAOEYNvccVXlN4Tm6IHWsGlc Y9AFZgNL9YPqnKaathFVcsjbcVq+yDG9QzTv/T+uweGORumWoZ2csYGmSTu/ePcHDk9s k0vQ== X-Gm-Message-State: ALKqPweStrECFu15aF2svquTDtG66n9XkuPrPA6AwM6EXqfR/y5eQYLm 2LINrOOWKGxb/zIPCKF8wB43Yg== X-Google-Smtp-Source: AB8JxZpwmu0zB7dZwEZhRK7YAEM7jbVfmifj+Q0m8MpJDd25aN+yGcXWk8WTfnJa7l/ZNigJ3c1VCw== X-Received: by 2002:a19:c9d1:: with SMTP id z200-v6mr3701198lff.0.1527150826223; Thu, 24 May 2018 01:33:46 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id u8-v6sm3904641ljg.40.2018.05.24.01.33.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 May 2018 01:33:45 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Greg Kroah-Hartman , linux-pm@vger.kernel.org Cc: Ulf Hansson , Viresh Kumar , Vincent Guittot , Todor Tomov , Rajendra Nayak , Jon Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] PM / runtime: Drop usage count for suppliers at device link removal Date: Thu, 24 May 2018 10:33:36 +0200 Message-Id: <1527150816-8459-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In the case consumer device is runtime resumed, while the link to the supplier is removed, the earlier call to pm_runtime_get_sync() made from rpm_get_suppliers() does not get properly balanced with a corresponding call to pm_runtime_put(). This leads to that suppliers remains to be runtime resumed forever, while they don't need to. Let's fix the behaviour by calling rpm_put_suppliers() when dropping a device link. Not that, since rpm_put_suppliers() checks the link->rpm_active flag, we can correctly avoid to call pm_runtime_put() in cases when we shouldn't. Reported-by: Todor Tomov Fixes: 21d5c57b3726 ("PM / runtime: Use device links") Signed-off-by: Ulf Hansson --- Rafael, I am not sure if this is safe from locking point of view. The device link write lock has been taken when pm_runtime_drop_link() is called, hence I assume calling rpm_put_suppliers() should be fine!? If not, can you please advise how to change? Kind regards Uffe --- drivers/base/power/runtime.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 8bef3cb..beb85c3 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1607,6 +1607,8 @@ void pm_runtime_new_link(struct device *dev) 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--;