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: 10423099 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 DE0076019D for ; Thu, 24 May 2018 08:34:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBFB929003 for ; Thu, 24 May 2018 08:34:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0A8729343; Thu, 24 May 2018 08:34:07 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 48A2429003 for ; Thu, 24 May 2018 08:34:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=wHIFAuu0fFdAkgqJuKJEdkY3Dd/965rJ7u6PET1cd78=; b=RK8 kQJXL93RfssyZmrC/8Tu4o4xTknEsWQyeoQD3HrohxOrQvYJ/GLYtTOS+b621Pt2Ysj8chTKMWnrh I2X5YncM5PQLrO2NisqB78KuwFXyjpwEjWKuaymcdCWJdhksraJhkUddK2W3zDckFhnrJT7l2SfUa SVm0NfWJWOEd/wUTc3lK9vxqT5qLPcviljKnDshFpe5+s+hEUEiBK05ciVzG6S840V/nw0dplwLoD qn+vZFZts9zeLP06wmUR84v+45w15dfodY2DDCW02k5jbQlrDKMN19AYS45dax6taDbKgZubTF8JC Lm8FYGjv0egmd55Q9RAF6DaFK7tzpow==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fLlhC-0006nZ-KG; Thu, 24 May 2018 08:34:02 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fLlh8-0006m9-Sp for linux-arm-kernel@lists.infradead.org; Thu, 24 May 2018 08:34:00 +0000 Received: by mail-wr0-x242.google.com with SMTP id a15-v6so1502272wrm.0 for ; Thu, 24 May 2018 01:33:47 -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=NXbZRzmzGs7wCg/XrQNfkvg0IOqLO5YVLNLR6trCbhDO9KAhbpWiRRu/qa4jotwdGb VhaXFTq0VZEFMf2zRzOH7cVTL2kOAd0f6Mnq6PFZuCsoyWAPVsDgCLNOTRu6F5fuSxa4 BUVPwCK8tBF/HpkK//XPEcJcacmSmw/R1Q6v60QGEroSHvzYs4J2TSm21KXIxdxu6L2a 2ijZMmhPP1dAqok1TkZOXCFEUiPM6ls4CDCggmAtjY7nVh+6JU06i160kQd5dI+NGP8L UGYK2wEnBALabFTC3HN6jCIK3eYcfJwWPMMi7YHDJQxWpL4Okb39HO0ysFFVaoqPJIyP fjWA== X-Gm-Message-State: ALKqPwcqB0krTgVN2nnln1gLQVzqUm1Ss2U7dy8GCk6/QV7Xs0bn46z1 xMjXClINymn1iD5Yr0NpX5sVdQ== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180524_013358_936345_1F763A3F X-CRM114-Status: GOOD ( 13.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ulf Hansson , Rajendra Nayak , Viresh Kumar , linux-kernel@vger.kernel.org, Jon Hunter , Todor Tomov , Vincent Guittot , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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--;