Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5288709imm; Tue, 12 Jun 2018 05:45:26 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKHuaKuHhuTxyoaHA4bN8LeFDc0vfvD9FKZWBT2EFuX12ead2Kce48zwU47ZIkaltrcdFk9 X-Received: by 2002:a17:902:bc44:: with SMTP id t4-v6mr243350plz.139.1528807526064; Tue, 12 Jun 2018 05:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528807526; cv=none; d=google.com; s=arc-20160816; b=sCIxrhJfYb1HL6DU+ghQKT9q4swqNIU1SH8QqH9RRA8Q/EHdbp/s1rckWcwbK298aZ 4u8j7GPmXhja1+jhzRfVS4VTm2l32LrtvSE9BMFOInLoOpi5RY2E3RJrv+SIISHoHpqr BGROGERbZF9JdmbOlVustkDAtBaJBftGgO0pGBh/TkTsDzukUnvdQRjJ2LfE5BCBwPMZ 4tARQ4cQ2VHQ/WgU80I44U+gT2vfIamSMTlZdQuYKtGcoOA0ncl+CBL+RorSGtvZHP6b CdEmR8Stdsn5uo93CvuqkonQhbLMjTtIjsplzGqc3m8pv+FWEQUgXuJW8wSLjOG9JwlP MXbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id :content-language:content-transfer-encoding:in-reply-to:mime-version :user-agent:date:from:cc:to:subject:dkim-signature:dkim-filter :arc-authentication-results; bh=5Cp+z7KyqdDLvd22Gzq1AMdd4Scj7rZQp7+rtXMJA3s=; b=vdjtRsAEVQqzb1X6DA6fB3oMlU6E8limiDyPO6Ys4nklZvQ4X2E1vEnZe4bZH++s/6 Mrr/RjEwtO+uZ2h9Ux647zF0hd+lxBiubdwYTICW9sY3+kRiLM8DSiC+jOKhwhM1DW0b DtPIbkAfinkll6rjThZs736ODaMJERGONn3SZjZcd4Yx5ZTXTw+RFQUW9uQoJwd30Ttz 6F0HpaGmfGSukO+N5JimRlIywYlVvSdpESFpldKZjQCwnpDugZhsq2FRQvxGKAed0EY4 XsPL92a86uj/XnS9EjYmh24uZ7F1mU5QH+aSWudk7hsNwamEA774+EAJxKvol9t+S20s HWLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=FZcSw0p7; 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=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8-v6si71390pfn.191.2018.06.12.05.45.11; Tue, 12 Jun 2018 05:45:26 -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=@samsung.com header.s=mail20170921 header.b=FZcSw0p7; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933666AbeFLMoa (ORCPT + 99 others); Tue, 12 Jun 2018 08:44:30 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:58535 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932976AbeFLMo2 (ORCPT ); Tue, 12 Jun 2018 08:44:28 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180612124426euoutp01872149b6578012d3930be4107703b77e~3akp5T4Gt0630506305euoutp01i for ; Tue, 12 Jun 2018 12:44:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180612124426euoutp01872149b6578012d3930be4107703b77e~3akp5T4Gt0630506305euoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1528807466; bh=5Cp+z7KyqdDLvd22Gzq1AMdd4Scj7rZQp7+rtXMJA3s=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=FZcSw0p7hLOvH2tghZ1Ct3LXiN9pQDUOh103EzFfO/+a4yH1IQg4J9xdLe++h5C5z eYmht82fhPOfHKbmQkSna9sbXslMXt2F5qY1nbJVwxt/NLoJBC3lq0mG/BqDIZ+mE+ JJsgv/nh3C0wHQ1Ht4z1hWde83IltFpPBul9qqHc= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180612124425eucas1p24f09df067254c32e75b322c4142e3aad~3akpL5cxA2650026500eucas1p2e; Tue, 12 Jun 2018 12:44:25 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 93.B1.17380.920CF1B5; Tue, 12 Jun 2018 13:44:25 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180612124424eucas1p101e61369a42132234d103ce52918b08e~3akoRUwbQ3138731387eucas1p17; Tue, 12 Jun 2018 12:44:24 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180612124424eusmtrp17f58fb2d892458ebcc6cfef147fd9be3~3akoAVFFn0306903069eusmtrp1-; Tue, 12 Jun 2018 12:44:24 +0000 (GMT) X-AuditID: cbfec7f4-713ff700000043e4-7c-5b1fc029f95c Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CA.AC.04183.820CF1B5; Tue, 12 Jun 2018 13:44:24 +0100 (BST) Received: from [106.116.147.30] (unknown [106.116.147.30]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180612124424eusmtip23e848e823f0be27f20b33e8e01db75e7~3aknoFPS01131011310eusmtip2P; Tue, 12 Jun 2018 12:44:24 +0000 (GMT) Subject: Re: [PATCH] PM / core: Fix supplier device runtime PM usage counter imbalance To: "Rafael J. Wysocki" , Linux PM Cc: LKML , Greg Kroah-Hartman , Ulf Hansson , Lukas Wunner , Bartlomiej Zolnierkiewicz , Jon Hunter From: Marek Szyprowski Date: Tue, 12 Jun 2018 14:44:23 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <10125310.W3e2TP0641@aspire.rjw.lan> Content-Transfer-Encoding: 7bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOKsWRmVeSWpSXmKPExsWy7djP87qaB+SjDT6vkrXYOGM9q0Xz4vVs Fi2zFrFYXN41h83ic+8RRosXz6Utzpy+xGpxfG24A4fHnWt72Dz2z13D7tHb/I7NY8vVdhaP vi2rGD0+b5LzmNG+jTWAPYrLJiU1J7MstUjfLoErY8LaSewFM+QqDr3pYWlgnCbRxcjBISFg InH6qUIXIxeHkMAKRokHhyYwQjhfGCWWnf/HAuF8ZpSY1bSarYuRE6xjXcNcJhBbSGA5o8TG 9iiIoveMEju3rGIGSQgLREg0fHrDCGKLCARJrJ07iw2kiFngL6PEv9YzYAk2AUOJrrddbCB3 sAioSvx55QgSFhWIkdh2+QELiM0rIChxcuYTMJsTqPzjlOesIDazgLzE9rdzmCFscYlbT+Yz gcyXEDjELjFrwXSo5jKJi78nMkNc7SJxueEiO4QtLPHq+BYoW0bi9OQeFojmZkaJ9hmz2CGc HkaJrXN2QP1sLXH4+EVWkEuZBTQl1u/Shwg7SjxbO50dEpB8EjfeCkIcxCcxadt0Zogwr0RH mxBEtZrErOPr4NYevHCJeQKj0iwkb85C8tosJK/NQti7g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y6h9eay5xGBi7FqFq/qaC3Zm mr1/9k4gTsTlRvSKu8YHp6Yem3LU9HGRe9beY++tru05t4h3X76F3Qnpj/utr+l9fr+vRTXd 9YdsG/vH7FLptu2xF5YX7eaLnxSW+OjrZkd9OZ6WwI+pB0K94/i2zrjl+2rn7PyyAPmAvCf+ Btxf5kwzYvmuxFKckWioxVxUnAgA3BPfodwCAAA= Message-Id: <20180612124424eucas1p101e61369a42132234d103ce52918b08e~3akoRUwbQ3138731387eucas1p17@eucas1p1.samsung.com> X-CMS-MailID: 20180612124424eucas1p101e61369a42132234d103ce52918b08e X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20180612110807epcas5p10e076681eac6f50b01840c0052748d12 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180612110807epcas5p10e076681eac6f50b01840c0052748d12 References: <10125310.W3e2TP0641@aspire.rjw.lan> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). 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. 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. 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. Is there any way to keep old behavior? > --- > drivers/base/core.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) > > Index: linux-pm/drivers/base/core.c > =================================================================== > --- linux-pm.orig/drivers/base/core.c > +++ linux-pm/drivers/base/core.c > @@ -216,6 +216,13 @@ struct device_link *device_link_add(stru > link->rpm_active = true; > } > pm_runtime_new_link(consumer); > + /* > + * If the link is being added by the consumer driver at probe > + * time, balance the decrementation of the supplier's runtime PM > + * usage counter after consumer probe in driver_probe_device(). > + */ > + if (consumer->links.status == DL_DEV_PROBING) > + pm_runtime_get_noresume(supplier); > } > get_device(supplier); > link->supplier = supplier; > @@ -234,14 +241,6 @@ struct device_link *device_link_add(stru > case DL_DEV_DRIVER_BOUND: > switch (consumer->links.status) { > case DL_DEV_PROBING: > - /* > - * Balance the decrementation of the supplier's > - * runtime PM usage counter after consumer probe > - * in driver_probe_device(). > - */ > - if (flags & DL_FLAG_PM_RUNTIME) > - pm_runtime_get_sync(supplier); > - > link->status = DL_STATE_CONSUMER_PROBE; > break; > case DL_DEV_DRIVER_BOUND: > > > > Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland