Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3719803imj; Tue, 19 Feb 2019 08:17:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IYT6ymWQ/FYpHq465TO4fOkXSoeKZSDuzAJwLUhMK3QGOqW9GgDTqm3QuxCQMKrc60RUL0T X-Received: by 2002:aa7:8c8c:: with SMTP id p12mr31276048pfd.0.1550593057233; Tue, 19 Feb 2019 08:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550593057; cv=none; d=google.com; s=arc-20160816; b=ntYx4CJz0qGg52/kZgdOdAKJCV9BeSJjpMxLRx/onwMwt4qtF7dglHSQHFURL8krMR DFCuiwMbLYW/FSumZTXHBthJW2TVQbhIsbo0zwhaIF+MkOGoCgWqB6kJjVX6rn2KQ4Hm ZYbz+SXMmeDaMy72wUrUeyZX0UcMxB9++5/9ZQUXE+JBYG62vsTKtQgWc1kktnkfEwAJ qiOX/bkin3ypIn4yvOWD/OqEXXFUs4LiRL9xfcdAwbd9uV9noUBvkybsb4WS5f1BkHgy 6gkxFp516koi4wBuxAte9CTd66xJLmbgMscpTla3BkranUz6Hor0U+CJCTOLyU7uQV2C k21g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=7rBwqJIhj7nAqwKM6FOimUnzEHMkrOlGJ8xKKa4+T6g=; b=pHx32a2rsK7aDAQBg/nNov+zcJX8zD3Ia4QPTbx9fiOwBRXGbw8fYsfYHDYgAACSHD H61OaLQKipoVsrn04tHPzGzX3jZiW5u+7dsx6e24ZOssf9U2QxHa+ohkx8VrRPkZzMPq MIq3mdjZTsCE4jycub8oRImCtmPZSTgaRH5Nr1KrC3CzehZPqCcpNxY474noa+Xm5J7T s5FHdF34NFuCtbEBGUtf+f3WorTF8tR7HMyh2Odz7GnPIRHNF/proSpqoBfvuRSxRrV5 qVE89XAAovDrlIAIbGWzxtLlI7vDvSPLNGQul4DqkjuWBQv95px3XArL7fS/T+JN9e3x 8kfQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si17123474pla.335.2019.02.19.08.17.21; Tue, 19 Feb 2019 08:17:37 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728952AbfBSQQb (ORCPT + 99 others); Tue, 19 Feb 2019 11:16:31 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:41284 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725885AbfBSQQa (ORCPT ); Tue, 19 Feb 2019 11:16:30 -0500 Received: by mail-ot1-f65.google.com with SMTP id t7so18684671otk.8; Tue, 19 Feb 2019 08:16:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7rBwqJIhj7nAqwKM6FOimUnzEHMkrOlGJ8xKKa4+T6g=; b=b/H2RVTdChZo6mC/vbvXFzOJyPVuIvQF2V+he82cZNmueiYKFoGsMU+//RK9oBgpOY kbfjhvhaybAd5gQ2Kac2414qWRnCRY1d11JIjusBooEDqrQRy1T6Btwt0DPeAbjecTVT gXg/rGja3dbNm7t3Hd9CyKoDvLn+9jWGLFVdNitKi9/m4Bb7bJuu1YvoaLYEFlooMtsX 88SjmcHznS5hmNYothFlDMdlac+3Lb/hOg+u0Hoy6W2X21fi7vRpfv0f303YeA4dW+Y3 QsdYYhvuD64pwLF/WwBpGk+XGbpjsVJA7yZp1avfGgRN8yViW8CQ0MEiVIbqXTSVqPKw UkZg== X-Gm-Message-State: AHQUAubsKAXer9sccVBzHLae9L0jlyMwBx/bTQ0bo9EHHvGBhubCskvj tFlnwzfcVKImYIicuqC0gUQ5OZhCh5S6HmzCR84= X-Received: by 2002:a9d:5e8c:: with SMTP id f12mr18760036otl.343.1550592989931; Tue, 19 Feb 2019 08:16:29 -0800 (PST) MIME-Version: 1.0 References: <14371356.imFjPFOrCi@aspire.rjw.lan> In-Reply-To: From: "Rafael J. Wysocki" Date: Tue, 19 Feb 2019 17:16:18 +0100 Message-ID: Subject: Re: [RFT/RFC][PATCH] driver core: Fix PM-runtime for links added during consumer probe To: Ulf Hansson Cc: "Rafael J. Wysocki" , Jon Hunter , Greg Kroah-Hartman , LKML , Linux PM , Daniel Vetter , Lukas Wunner , Andrzej Hajda , Russell King - ARM Linux , Lucas Stach , Linus Walleij , Thierry Reding , Laurent Pinchart , Marek Szyprowski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 19, 2019 at 1:10 PM Ulf Hansson wrote: > > On Mon, 18 Feb 2019 at 23:09, Rafael J. Wysocki wrote: > > > > From: Rafael J. Wysocki > > > > Commit 4c06c4e6cf63 ("driver core: Fix possible supplier PM-usage > > counter imbalance") introduced a regression that causes suppliers > > to be suspended prematurely for device links added during consumer > > driver probe if the initial PM-runtime status of the consumer is > > "suspended" and the consumer is resumed after adding the link and > > before pm_runtime_put_suppliers() is called. In that case, > > pm_runtime_put_suppliers() will drop the rpm_active refcount for > > the link by one and (since rpm_active is equal to two after the > > preceding consumer resume) the supplier's PM-runtime usage counter > > will be decremented, which may cause the supplier to suspend even > > though the consumer's PM-runtime status is "active". > > Just to confirm, this is the behavior that I see as well. > > However, I am a bit a surprised on my side, that I did not run this > particular test sequence earlier. Sorry about that! > > > > > For this reason, partially revert commit 4c06c4e6cf63 as the problem > > it tried to fix needs to be addressed somewhat differently, and > > change pm_runtime_get_suppliers() and pm_runtime_put_suppliers() so > > that the latter only drops rpm_active references acquired by the > > former. [This requires adding a new field to struct device_link, > > but I coulnd't find a cleaner way to address the issue that would > > work in all cases.] > > > > Fixes: 4c06c4e6cf63 ("driver core: Fix possible supplier PM-usage counter imbalance") > > Reported-by: Jon Hunter > > Signed-off-by: Rafael J. Wysocki > > Besides validating the fix, I can confirm device link add/removal > during probe works fine, as before. > > I also tested the runtime PM autosuspend (several seconds timeout) > together with DL_FLAG_RPM_ACTIVE - it's working fine! During this > test, the rpm_active count reaches 3 after probe and the supplier's > usage count reaches 2. When the consumer becomes runtime suspended, > after the timeout, these "counts" becomes decremented to 1 and 0, so > the supplier also becomes runtime suspended. > > Tested-by: Ulf Hansson > Reviewed-by: Ulf Hansson Many thanks to you and Jon for verifying it!