Received: by 10.223.185.116 with SMTP id b49csp219709wrg; Tue, 13 Feb 2018 20:19:18 -0800 (PST) X-Google-Smtp-Source: AH8x226wC9Q26/YnGvVBwKRnt7rSOXMxWkO2hYOkX3fZFb/dFo94Qhk8IKm/o6J6f8RIYIlAGdwx X-Received: by 10.101.66.193 with SMTP id l1mr2845593pgp.149.1518581958804; Tue, 13 Feb 2018 20:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518581958; cv=none; d=google.com; s=arc-20160816; b=zwzUbYd0zchYh+n/jVvkyoCxqaIaWVTTOScOg0dpZk5ZCLyL7LvwAe3H+niXdXrLXr DOmXcvPsdDw5af4SR8/r94Dmogkhobh1sAw6cLjMBUVBWOZPRoKzbkltBDM3Mj4/B9oF U+G2KhjIngOuwxB14yPI3lzm0lRoe1zrgqm1yISG3HTkZisgtD+1Z1ZTEjDYN8L4MhyM gC++XvOJY59jNgAAuMPtkgkFYcru8DP7b4/lS6GMz0UqRPx4VpOu2hpflSmsUq0h37Zx zpYl3fO8DDwn77B92LpwnLrARtsktL3Vrq3mIgiXbX0oBgufuZc1rGiyxeTRZ5vJCQNs F/QQ== 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:dmarc-filter:dkim-signature :dkim-signature:arc-authentication-results; bh=OiwsRH+FBu0XJueJ6zSpcBZa3WXUPLeqxQRUnK8/hHw=; b=P11P4HP4bfJE6Ix/wQbzmf3fy04JgTb/9zTcQX4CNjTmSoTJIwRpsPiC/tJOc655TT DFdSpjhFMm30viNjtDrxmwjAf3aU0/UERafvms0zcSMq7gghgRf5eq90WogtbRo+7CXN 9S97QSsZmMuFL2MMvaKw8K9Rwoq2S1RXeUJMKzXJMnYfDp1MzdOpUPW8ErovnO0wvmbc Ce/2cbGFLvlXiYIOt+7yy8DpgPpzkNyqqbTyPtXeIPht7l2a+W2BYFHGNLpV7S0RwXFT Q7nKh2Ht4qh+pE9+04K0mRve5LEeddZi9H26NwuVdnJVMaIwKVX+TTYsYqIAN8NwzDN/ mmhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=TEkY0PG2; dkim=pass header.i=@codeaurora.org header.s=default header.b=WK44fmPN; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si2925147pgp.222.2018.02.13.20.19.03; Tue, 13 Feb 2018 20:19:18 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=TEkY0PG2; dkim=pass header.i=@codeaurora.org header.s=default header.b=WK44fmPN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966796AbeBNERK (ORCPT + 99 others); Tue, 13 Feb 2018 23:17:10 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:54976 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966705AbeBNERI (ORCPT ); Tue, 13 Feb 2018 23:17:08 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6C7A360F90; Wed, 14 Feb 2018 04:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518581827; bh=+e8hc8PTHUGHlho6DBVDjhBPPYr34tZaj9xpnh9zQB0=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=TEkY0PG2l+96Kw3hxdUXCPBasW7sxoBNdY8wVL2c/Sue8TeACUC5M2/BN3KDbij9M 2rWWJo9dO148dvr0TvUVFq29WzIOIIJ5JRqRRuLBSRc/dfdG6oFXYo9knjsR919M4b pJ1d5XXq6BiMRnYr9CaWzRsxCTswb6C8Lfu0x8xU= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail-qt0-f176.google.com (mail-qt0-f176.google.com [209.85.216.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E3EE360F92; Wed, 14 Feb 2018 04:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1518581826; bh=+e8hc8PTHUGHlho6DBVDjhBPPYr34tZaj9xpnh9zQB0=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=WK44fmPNsQjVS8IbvfMM1N3lmFwdFUqbFQknybINwv95uKLW6oMoIZUT7xMWyRp9M gkxzuYR8ns8ZPnpMiqIPBORfRepTX8tkdKkAb2PddKL0HeFlJAZ3+AD821UtnRf19Z 2aeYsejvuXyxapeuegSqAIfA/PIh0E0Ye2Z+tXsE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E3EE360F92 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org Received: by mail-qt0-f176.google.com with SMTP id g14so6282716qti.2; Tue, 13 Feb 2018 20:17:05 -0800 (PST) X-Gm-Message-State: APf1xPDOyz4DrFxNz+sLhZVhRGucLlJFR+b2WFg3JoAz3b3/9MS3TlKp cVxToJP5tdDGMuF7w9Wr1WbbiPLMT9lCyI1JkvE= X-Received: by 10.200.61.90 with SMTP id u26mr5572110qtf.168.1518581824973; Tue, 13 Feb 2018 20:17:04 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.8.227 with HTTP; Tue, 13 Feb 2018 20:17:04 -0800 (PST) In-Reply-To: References: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> <1517999482-17317-7-git-send-email-vivek.gautam@codeaurora.org> From: Vivek Gautam Date: Wed, 14 Feb 2018 09:47:04 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 6/6] drm/msm: iommu: Replace runtime calls with runtime suppliers To: Tomasz Figa Cc: Rob Clark , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Rob Herring , Mark Rutland , "Rafael J. Wysocki" , Robin Murphy , Will Deacon , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , devicetree@vger.kernel.org, Linux Kernel Mailing List , Linux PM , dri-devel , freedreno , David Airlie , Greg KH , Stephen Boyd , linux-arm-msm 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 Hi Tomasz, On Wed, Feb 14, 2018 at 8:31 AM, Tomasz Figa wrote: > On Wed, Feb 14, 2018 at 11:13 AM, Rob Clark wrote: >> On Tue, Feb 13, 2018 at 8:59 PM, Tomasz Figa wrote: >>> On Wed, Feb 14, 2018 at 3:03 AM, Rob Clark wrote: >>>> On Tue, Feb 13, 2018 at 4:10 AM, Tomasz Figa wrote: >>>>> Hi Vivek, >>>>> >>>>> Thanks for the patch. Please see my comments inline. >>>>> >>>>> On Wed, Feb 7, 2018 at 7:31 PM, Vivek Gautam >>>>> wrote: >>>>>> While handling the concerned iommu, there should not be a >>>>>> need to power control the drm devices from iommu interface. >>>>>> If these drm devices need to be powered around this time, >>>>>> the respective drivers should take care of this. >>>>>> >>>>>> Replace the pm_runtime_get/put_sync() with >>>>>> pm_runtime_get/put_suppliers() calls, to power-up >>>>>> the connected iommu through the device link interface. >>>>>> In case the device link is not setup these get/put_suppliers() >>>>>> calls will be a no-op, and the iommu driver should take care of >>>>>> powering on its devices accordingly. >>>>>> >>>>>> Signed-off-by: Vivek Gautam >>>>>> --- >>>>>> drivers/gpu/drm/msm/msm_iommu.c | 16 ++++++++-------- >>>>>> 1 file changed, 8 insertions(+), 8 deletions(-) >>>>>> >>>>>> diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c >>>>>> index b23d33622f37..1ab629bbee69 100644 >>>>>> --- a/drivers/gpu/drm/msm/msm_iommu.c >>>>>> +++ b/drivers/gpu/drm/msm/msm_iommu.c >>>>>> @@ -40,9 +40,9 @@ static int msm_iommu_attach(struct msm_mmu *mmu, const char * const *names, >>>>>> struct msm_iommu *iommu = to_msm_iommu(mmu); >>>>>> int ret; >>>>>> >>>>>> - pm_runtime_get_sync(mmu->dev); >>>>>> + pm_runtime_get_suppliers(mmu->dev); >>>>>> ret = iommu_attach_device(iommu->domain, mmu->dev); >>>>>> - pm_runtime_put_sync(mmu->dev); >>>>>> + pm_runtime_put_suppliers(mmu->dev); >>>>> >>>>> For me, it looks like a wrong place to handle runtime PM of IOMMU >>>>> here. iommu_attach_device() calls into IOMMU driver's attach_device() >>>>> callback and that's where necessary runtime PM gets should happen, if >>>>> any. In other words, driver A (MSM DRM driver) shouldn't be dealing >>>>> with power state of device controlled by driver B (ARM SMMU). >>>> >>>> Note that we end up having to do the same, because of iommu_unmap() >>>> while DRM driver is powered off.. it might be cleaner if it was all >>>> self contained in the iommu driver, but that would make it so other >>>> drivers couldn't call iommu_unmap() from an irq handler, which is >>>> apparently something that some of them want to do.. >>> >>> I'd assume that runtime PM status is already guaranteed to be active >>> when the IRQ handler is running, by some other means (e.g. >>> pm_runtime_get_sync() called earlier, when queuing some work to the >>> hardware). Otherwise, I'm not sure how a powered down device could >>> trigger an IRQ. >>> >>> So, if the master device power is already on, suppliers should be >>> powered on as well, thanks to device links. >>> >> >> umm, that is kindof the inverse of the problem.. the problem is >> things like gpu driver (and v4l2 drivers that import dma-buf's, >> afaict).. they will potentially call iommu->unmap() when device is not >> active (due to userspace or things beyond the control of the driver).. >> so *they* would want iommu to do pm get/put calls. > > Which is fine and which is actually already done by one of the patches > in this series, not for map/unmap, but probe, add_device, > remove_device. Having parts of the API doing it inside the callback > and other parts outside sounds at least inconsistent. > >> But other drivers >> trying to unmap from irq ctx would not. Which is the contradictory >> requirement that lead to the idea of iommu user powering up iommu for >> unmap. > > Sorry, maybe I wasn't clear. My last message was supposed to show that > it's not contradictory at all, because "other drivers trying to unmap > from irq ctx" would already have called pm_runtime_get_*() earlier > from a non-irq ctx, which would have also done the same on all the > linked suppliers, including the IOMMU. The ultimate result would be > that the map/unmap() of the IOMMU driver calling pm_runtime_get_sync() > would do nothing besides incrementing the reference count. The entire point was to avoid the slowpath that pm_runtime_get/put_sync() would add in map/unmap. It would not be correct to add a slowpath in irq_ctx for taking care of non-irq_ctx and for the situations where master is already powered-off. > >> >> There has already been some discussion about this on various earlier >> permutations of this patchset. I think we have exhausted all other >> options. > > I guess I should have read those. Let me do that now. Yea, i point to the thread in cover letter and [PATCH 1/6]. Thanks. regards Vivek > > Best regards, > Tomasz > -- > To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation