Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5752612imm; Tue, 12 Jun 2018 12:44:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLsdazvqV2wiKngk/P1Hq//hdYWvkr9Z88kjO6+XV0LXadMwX6JMKk6GPQr/ZIjlMGhYqMw X-Received: by 2002:a17:902:9b92:: with SMTP id y18-v6mr1837541plp.57.1528832687954; Tue, 12 Jun 2018 12:44:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528832687; cv=none; d=google.com; s=arc-20160816; b=cSVra2/1M3ERaI2uw0Jxl6K5m30TKT4NY/Qrhve/eHe6mM35hrmV4uSj6e1Umws/Lj BV9zw8F4lmD9K/2otlCU0Z4FmLWFQcA1RkrBKHN6NjtHRKfBNPp/AsDAjfJ8NkjLmFk/ LpOO/tgIYMfQz71gSU8Kob8SEFwbG3bwnPaGPfvi6/XWwCA6Xh1JZLwjoCQaLWds6d+u v/o+F3pMlg3sifZs/841PMQBJCfS/CeOysHGshvkP0AWeKdfIdbLRRUYwldXHWIvFBPv D2JiBJmHdyCdrcgcQtnCGibSfC+kJJSEsSyXjenCVM/fLLG02y9OayldjhdliHuOzzXk oj9Q== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=K/1i4PQppEy6ckp9J9hJDoKmD2VBt+4PgWc9u6ykU4U=; b=N0kq0J5Z+ZtFYLW0uuSCimIaMb3I5fRHzCUWeCf0LJ5uNuPpyTJDT+GuFNrMyz6mVk TRgiyfuHEyt8QrvPxAjDjXJfsmly6ylppszgLdRfGbCOCIpiovqRZDB7Sf81iRGsZ+c+ ruk2AuYeGsBr5G2rnz2hBliGtShh6+RBKE9WDlNLfNQVwPESIKsn55NKcOR0fxyMLR// cyKuEKIjPJeSJHJn9KIyWWXE8kCOIsWadaL7LDoKwtuRrt+mbRpY4mmGj/N2DduPIr9w 8BzOW72ydTSb6gnVIm/+q0sXCZjezBHJFELF3Ygm5qonTBtKpkABiWVNxhWLIETEu61J ibAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IFREy+HM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c19-v6si861741pls.176.2018.06.12.12.44.33; Tue, 12 Jun 2018 12:44:47 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=IFREy+HM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933844AbeFLTnw (ORCPT + 99 others); Tue, 12 Jun 2018 15:43:52 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:55647 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933328AbeFLTnr (ORCPT ); Tue, 12 Jun 2018 15:43:47 -0400 Received: by mail-it0-f65.google.com with SMTP id 16-v6so801084itl.5 for ; Tue, 12 Jun 2018 12:43:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=K/1i4PQppEy6ckp9J9hJDoKmD2VBt+4PgWc9u6ykU4U=; b=IFREy+HMjSWQHkha6C+/055/c4zFDEzkgN1wtw+gtO4uq5b1XfSetee6NMuD+6Bw/g qIy8he+8oWA5GiNaYB0T50cOuayTO+EZid6x3/uZXI1NMJK+RDJdlsk7oCxxEZ5WPDBU N091DhgBzQ1FgOFHJRAM82sRKfb/fAVwP+YGA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=K/1i4PQppEy6ckp9J9hJDoKmD2VBt+4PgWc9u6ykU4U=; b=KZ/Er9kHkUQl7W46bI9lksVYcpkU8KnqJhvTWUGZTAZYnphdsy+A8SgdNVA3KGVu3C 3JpvxIfgEd9+G9Jg4XmPaWpdk5nUQN4UisPPQemkAyx/jZ4q5HuAzG/2lDRKyJ7h8G3M FAM3SjrqPoYIxWYXL2LTEcs5U50gXWqlmyC3gO1UfKb5KfcJuDjznyKGyLDAtwdYGNBc jbfff0+Vsl+HItdfWeQQKapM0WZYp2l2FtGqAHi6yw0l1v/TqPIfHYb5twpl9F+RsviO leX8ZsAX7H2lzwHBop1SZt8SyyUa5K7rtFG01DYkNNK5+rKRV25zFy1JTSI1BH2iMkLO CdUA== X-Gm-Message-State: APt69E3pE4KUaCuN2oGKQ1x9Sk0drggEZ9agJPGMre50c2I+Dj1r5apj rKqQ5f5p/Z+4a9qFxFr6MfUyexTn0TXdUCa3r++vbg== X-Received: by 2002:a24:308:: with SMTP id e8-v6mr1982899ite.102.1528832626651; Tue, 12 Jun 2018 12:43:46 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:c054:0:0:0:0:0 with HTTP; Tue, 12 Jun 2018 12:43:45 -0700 (PDT) In-Reply-To: <20180612124424eucas1p101e61369a42132234d103ce52918b08e~3akoRUwbQ3138731387eucas1p17@eucas1p1.samsung.com> References: <10125310.W3e2TP0641@aspire.rjw.lan> <20180612124424eucas1p101e61369a42132234d103ce52918b08e~3akoRUwbQ3138731387eucas1p17@eucas1p1.samsung.com> From: Ulf Hansson Date: Tue, 12 Jun 2018 21:43:45 +0200 Message-ID: Subject: Re: [PATCH] PM / core: Fix supplier device runtime PM usage counter imbalance To: Marek Szyprowski Cc: "Rafael J. Wysocki" , Linux PM , LKML , Greg Kroah-Hartman , Lukas Wunner , Bartlomiej Zolnierkiewicz , Jon Hunter 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 12 June 2018 at 14:44, Marek Szyprowski wrote: > Hi Rafael, > > On 2018-06-12 13:00, Rafael J. Wysocki wrote: >> From: Rafael J. Wysocki >> >> If a device link is added via device_link_add() by the driver of the >> link's consumer device, the supplier's runtime PM usage counter is >> going to be dropped by the pm_runtime_put_suppliers() call in >> driver_probe_device(). However, in that case it is not incremented >> unless the supplier driver is already present and the link is not >> stateless. That leads to a runtime PM usage counter imbalance for >> the supplier device in a few cases. >> >> To prevent that from happening, bump up the supplier runtime >> PM usage counter in device_link_add() for all links with the >> DL_FLAG_PM_RUNTIME flag set that are added at the consumer probe >> time. Use pm_runtime_get_noresume() for that as the callers of >> device_link_add() who want the supplier to be resumed by it should >> pass DL_FLAG_RPM_ACTIVE in flags to it anyway. >> >> Fixes: 21d5c57b3726 (PM / runtime: Use device links) >> Reported-by: Ulf Hansson >> Signed-off-by: Rafael J. Wysocki >> --- >> >> This is a replacement for commit 1e8378619841 (PM / runtime: Fixup >> reference counting of device link suppliers at probe) that is going >> to be reverted. > > Thanks Rafael for the patch. I've applied it and now I'm a bit puzzled. > Let's get back to my IOMMU and codec case, mentioned here: > https://marc.info/?l=linux-pm&m=152878741527962&w=2 > > Now, after applying your patch, when IOMMU creates a link with > DL_FLAG_PM_RUNTIME to the jpeg device (this happens when jpeg device is > being probed), it is not IOMMU is not runtime resumed anymore (that's > because the patch changes pm_runtime_get_sync to pm_runtime_get_noresume). According to your earlier replies, I thought this is what you wanted. No? > This means that until jpeg driver enables runtime pm for its device and > finally performs runtime pm suspends/resume cycle, the supplier won't be > resumed. What's the problem with that? When does the IOMMU device needs to be runtime resumed? > On the other hand, when I add DL_FLAG_RPM_ACTIVE flag to link > creation, the supplier is properly resumed, but then, once the jpeg > device probe finishes, the supplier is still in runtime active state > until a next runtime suspend/resume cycle of jpeg device. Could you elaborate on the what happens in jpeg driver during probe, in regards to runtime PM. Perhaps you can also point me to what driver it is? > If I understand > right, the DL_FLAG_RPM_ACTIVE flag should be there from the beginning, > but that time it runtime pm part of links worked in a bit different way > than now. Just to make sure, you also reverted 1e8378619841, before trying Rafael's change on top? > > Is there any way to keep old behavior? I think the old behavior is sub-optimal. I am sure there are users that really don't want the driver core to runtime resume the supplier unconditionally. I would rather go and fix the few users of device_link_add(), to use DL_FLAG_RPM_ACTIVE, in cases when they need it. Of course I am fine if we do these changes in a step by step basis as well. [...] Kind regards Uffe