Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp281260imm; Tue, 12 Jun 2018 23:43:51 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLZbX+w8998+qWQ1E05IHBjaW+lYg+CRCW/d/TIB4NpuM2Dce5rptJGLrbwhvSBAl6Dkjwc X-Received: by 2002:a65:6252:: with SMTP id q18-v6mr3084910pgv.106.1528872231848; Tue, 12 Jun 2018 23:43:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528872231; cv=none; d=google.com; s=arc-20160816; b=pSh6Cs4xICd6WdqW+SpyHBWleNuWZvONtqtUYIb0Nu25YbJ1nmaGV5KtCfN3K1rvjQ rzwK+W/uddN1khz+9UqTDHUJfDFGk4d4E1Si1wCEajoS+QBrRg/QnKluo/OD6j008KnC NeZbZMJX/rFCbLvpUrKbWbNfl8K5VA5W4cIJ0eYUMnSqWqpfM22fY0d0WrX9N4aBRH5Z +Tecs77B6tIQjvjpsaJQkBntpbjbrJyzqU21XaCr8IqrZqIW9THzaHmM9EpXcG/bAqXG +QpKtbtBbkBWp15K43qZ89INcKxCMXMtEPTbtcV9GtntHbtjQhhITQjeNJYNv0BrgBOR Pdhw== 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=o8rM6JMlglZKcv5JAQSa0NGumcPFnZB83Km0pdXo+yA=; b=mnnEFuCtanNUxZMYp5A/tP9MVcKHsH9inm3NShsRiIXMfKqF/C/6Ok13ysc2/J3tDj 4QeVXbsBx9fh6T/+FbfSpBaRxPyWVXYbhT6XCKV4YyK//pTBtoqwFjEurc1ff1xkUU0J 4egqVqiTAGniR6ybFAPHIia0TEyl/pK2GfQ0bqZPWvHQnxOsVWDzOolhp6IGBIN+xFvS 1jjFdXfYaFec3WMpKXFTM7+o1CgZ1U/g81+EV3YaMPpU+IApjZWVrpOohhnAjRgPCoqh 0FxaYByFq9tcePqwiJbXWOAPwM4N0yr+jMV+CH2X1PqcE0QwoJBXfcJQ38AGaJ4nghkk 1Huw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=dPcSdxJc; 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 o1-v6si2039916plb.279.2018.06.12.23.43.37; Tue, 12 Jun 2018 23:43:51 -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=dPcSdxJc; 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 S1754500AbeFMGnG (ORCPT + 99 others); Wed, 13 Jun 2018 02:43:06 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:35472 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754398AbeFMGnE (ORCPT ); Wed, 13 Jun 2018 02:43:04 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180613064302euoutp0105a52b7626546d8a4ec3d0354ffabd33~3pSY61l-g0757907579euoutp01B for ; Wed, 13 Jun 2018 06:43:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180613064302euoutp0105a52b7626546d8a4ec3d0354ffabd33~3pSY61l-g0757907579euoutp01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1528872182; bh=o8rM6JMlglZKcv5JAQSa0NGumcPFnZB83Km0pdXo+yA=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=dPcSdxJckDtjTz13SIvBY3aotO+FAyBVEQSdliN9NnQeGAEP3rzSbVyz0WP0uPfp2 dD6lSNnweH7gHNjY2et8JBM9e09nII2YSfOzlU/OANZnSyXxJASrSKCZ3aPNze7YxX P9uU67D6BEJ1F9N6OmY/5nS1gog5O4x6/9CWCGUI= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180613064300eucas1p1f0d1539a22fec9b753cc9c0f2e438d60~3pSXgpBH32024620246eucas1p14; Wed, 13 Jun 2018 06:43:00 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 4A.6D.17380.3FCB02B5; Wed, 13 Jun 2018 07:42:59 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20180613064258eucas1p2f8a082548d80bbc02f26aaa8773383b9~3pSVbThtx0723907239eucas1p2l; Wed, 13 Jun 2018 06:42:58 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20180613064257eusmtrp255c81a7808632f34e9a0f25f6b157218~3pSUoXxUe0870908709eusmtrp20; Wed, 13 Jun 2018 06:42:57 +0000 (GMT) X-AuditID: cbfec7f4-713ff700000043e4-94-5b20bcf34c9e Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 4F.E6.04178.1FCB02B5; Wed, 13 Jun 2018 07:42:57 +0100 (BST) Received: from [106.116.147.30] (unknown [106.116.147.30]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180613064257eusmtip210eb8f61bab1791951409a85e4670b02~3pSUP050Y2941129411eusmtip2C; Wed, 13 Jun 2018 06:42:57 +0000 (GMT) Subject: Re: [PATCH] PM / core: Fix supplier device runtime PM usage counter imbalance To: Ulf Hansson Cc: "Rafael J. Wysocki" , Linux PM , LKML , Greg Kroah-Hartman , Lukas Wunner , Bartlomiej Zolnierkiewicz , Jon Hunter From: Marek Szyprowski Date: Wed, 13 Jun 2018 08:42:55 +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: Content-Transfer-Encoding: 7bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA01Sa0hTYRjm29k5O1qT49R8maI2KzRLnQkd0CIhaBRpF6Nwlq48qeSmbGpp EILhdKiYYtoyiwUq3pa2lpfRRc3lBU1HoiGkJWqSis1+CF23M8t/z/tcvvd54SMxQScuJFMV mYxSIUsTEc5cY//GyH6ryU8aqhsNoNuq9Tid/1hP0Le1Oi5t6aohaGtJH6IXF7zo4aFxnDa3 nD9CSqYnTITk5YNmnqQkf4WQGN6ruZJSQyOSWNt9JNVqI36KF+ccmcSkpWYzypDDic4pA282 OBkW0Q31agGWhyq8NciJBCocdLV3eBrkTAqoBgQTxfdxdlhHMPL5iUOxIvhoqOVsRgaaphyu egR1P1sdrlUEb3urcJvLjboAed++Iht2pwLANDtqT2BUPQesiyauTSAoMWiWNYQGkSSX2g3W PrGN9qDiwWiZsVv4lCsM3JuzYyfqNBQZR+0tMMoXni/XYCz2hA9zDzm294Ea5MHKcLkjnA3V hRUYW/sojHUbcRa7wZLZwGOxN/zu3AznI1BXa3nsUIzgWU0HwboioNc8htuaYlQg6LtCWDoK 5luqeDYaKBeYXHZlC7lAubEKY2k+FBYIWPce0Jpb/619/W4cK0Mi7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dMr Pk1UylE+5fE/zHUb/yJZkXcNAl4Ma2bz/2Ducjwq+XOy2tc9bLfdDurofTnwef/Wa1aSxw+f Vjtecq1vFdv0JqFXjQf8JV2eeQWd6V306YeFqGfU+4Nlt/0UNHdHi0zc0nE4Qni5eMQ69V3N i+4wvurbPz9rZkfX1rRIJZbijERDLeai4kQAhMOAwt0CAAA= Message-Id: <20180613064258eucas1p2f8a082548d80bbc02f26aaa8773383b9~3pSVbThtx0723907239eucas1p2l@eucas1p2.samsung.com> X-CMS-MailID: 20180613064258eucas1p2f8a082548d80bbc02f26aaa8773383b9 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> <20180612124424eucas1p101e61369a42132234d103ce52918b08e~3akoRUwbQ3138731387eucas1p17@eucas1p1.samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ulf, On 2018-06-12 21:43, Ulf Hansson wrote: > On 12 June 2018 at 14:44, Marek Szyprowski wrote: >> 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? Wasted power. IOMMU device is left enabled until first use of JPEG device, what means that respective power domain is also turned on unnecessarily. > When does the IOMMU device needs to be > runtime resumed? I would like to have IOMMU (supplier) runtime active all the time the JPEG (consumer) device is runtime active AND all the time between probe() and remove() if JPEG (consumer) doesn't support runtime PM (if it doesn't enable runtime PM at all). >> 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? s5p_jpeg_probe() doesn't touch hardware at all and only calls pm_runtime_enable(), see drivers/media/platform/s5p-jpeg/jpeg-core.c >> 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? Yes >> 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. I also agree that the old behavior is sub-optimal and there are use cases for the new (corrected) approach. I see no problems to add DL_FLAG_RPM_ACTIVE to exynos-iommu driver (and probably the 5 other drivers, which create links with DL_FLAG_PM_RUNTIME flag set to avoid regressions). The question is what else should be changed/fixed to get old behavior now. Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland