Received: by 10.223.185.116 with SMTP id b49csp135523wrg; Tue, 13 Feb 2018 18:14:48 -0800 (PST) X-Google-Smtp-Source: AH8x227o3YDJrZOtys+jR5kgpT7ULjeRWb/xrSxFJ+mr4Okl+cdnd2t8hYOBaYktk5+bRgfckrAR X-Received: by 10.99.189.1 with SMTP id a1mr2566469pgf.189.1518574488037; Tue, 13 Feb 2018 18:14:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518574488; cv=none; d=google.com; s=arc-20160816; b=JClj2Tle99vK7uAEtIFHX+AnJxBRIZIAFYgTBTYcfgb/B/e3A2RodPLqkdVG8BGaoS dE9ZwBqVqea5YeMM9Wp08nLR8TA8vYh7yBK6eCRu9wb/LBCt6B4GcmDdEA0trv3mzIvD B7OPZIjuQP4/us8bTqvoWCxkizxtWIkZSv4jZkMk1WvjyPGsGZ3PYoW5FamKz/6Y0D59 EwIXU2Bn/CrsQ6RfeejObF02UMEFZuNZ7DDvTA1pK2DmERZ3Licsg13vQxsXaAc/n5Ku eDj5tgrY5n4Q6Uoe0koZyTcnQi/RLK5JHOIsaNyBcjlmJLLfqR/jso6Dss71eq/IgLxE 8dCA== 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=PxaIeIL6ZrWAHt7eiS0Xs81ua87bStkHMYo9DI3iCQg=; b=YKNweG62jlV0Pzoz9YEroXZpdJt2U9xcfFSByckvikqqlTGgvTO61d5PPuq8mxVbh9 XstBMuTRCU+Kzp1K59zv/O1ln5Gqsktkx0RKXc/F2PQuJARed2Suv94CCJ9uefXYSGGO RUx9uS7msr+XQ0tmgP13bVYbUc37O32eUVBH8YyDwC3gPN4k5apjTsOZvNJZv9GnU3qc X+FTWV4QeAmY0uC4Ud9Bgi9O5siiEUj6qNV9wqbcKsOwI00fiU8l14/TnfrZ5XqfSLUq wLLyQ5aIhBmIbjoYWYQTc7cITCrnj0mEy/mCFFmpoR0shSji7R/dOQ8QmUYwwGDG0D/J s0cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CgTlNn/P; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c11-v6si2173840pls.801.2018.02.13.18.14.33; Tue, 13 Feb 2018 18:14:47 -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=@gmail.com header.s=20161025 header.b=CgTlNn/P; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966507AbeBNCN4 (ORCPT + 99 others); Tue, 13 Feb 2018 21:13:56 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:34599 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966429AbeBNCNx (ORCPT ); Tue, 13 Feb 2018 21:13:53 -0500 Received: by mail-it0-f68.google.com with SMTP id j21so11413263ita.1; Tue, 13 Feb 2018 18:13:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=PxaIeIL6ZrWAHt7eiS0Xs81ua87bStkHMYo9DI3iCQg=; b=CgTlNn/Pe3cC9dCRXRN4xDQndEKdgIFyB2JpRJmnCdB4rUDfnap2GQLxIA5qqyL/nD giLcsfCJASGfbOs0NHDNmAzO8Cus8AvAXwH1JJpBUhWQZac8y4Hkep5oPKgP5bmFiF63 gonulhr6VT25AJEjrXwGJ+iimffL46q2X1o9f0AX/uY4FU8ezOmBQWKRCOq6go5D4Z29 L1Ovp7cTuR/PpqYee2qaYZWnhcol0mFp4qKhRbOmLJLFqd9Z8sOCW1i/yj4U+HuHvwKj QpPCrun3tBCEPb07zpB5QWJ5mbFju2a3bAHrMws6otsQccizwLp4fSAmzQ81hKR6wjCh 0XVw== 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=PxaIeIL6ZrWAHt7eiS0Xs81ua87bStkHMYo9DI3iCQg=; b=Gk1vlflFVZVEOEV3dCigXNQaQHAODUIJocIEUWRKDWPXK7vLB0opbmeVQE+HQv3uRB zhy+bQ8VLHGoojVEEAidOni+WvVwvaSUS7YvMOc/6PgQofSyVL/srt06P2wThna+w64I 8a8PW/IfWEloOZRC+czmfExXCcL9lyGlG0HqX/jpyOzccBzFxF6ZswO/6Czk0UDjCZ73 ilEtAPHjeQW7xXTUEEAEs/2umOJPTlhJCwkAZ/kk5zEwZ7Zrnrr7Xii/QoiFzAAuiCN4 KDlTGo3DgkFfvQfnVoNhDkWGeRu4DnxJcN5UMmnphJh/n+YyIp3bZLu4D5ilw+yTXJq6 3nCg== X-Gm-Message-State: APf1xPBDonTUMlQo6Og24wml6askYSBgUoBAXdnUxO8+bUA0r6rI/Ler Ix+nAwWzd7Yvlhn2bI5HUaB/lPli2cTIj8Msd/4= X-Received: by 10.36.236.134 with SMTP id g128mr4176878ith.38.1518574432614; Tue, 13 Feb 2018 18:13:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.111.93 with HTTP; Tue, 13 Feb 2018 18:13:51 -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: Rob Clark Date: Tue, 13 Feb 2018 21:13:51 -0500 Message-ID: Subject: Re: [PATCH v7 6/6] drm/msm: iommu: Replace runtime calls with runtime suppliers To: Tomasz Figa Cc: Vivek Gautam , "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@vger.kernel.org, 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 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. 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. There has already been some discussion about this on various earlier permutations of this patchset. I think we have exhausted all other options. BR, -R