Received: by 10.223.185.116 with SMTP id b49csp29035wrg; Thu, 22 Feb 2018 15:53:56 -0800 (PST) X-Google-Smtp-Source: AH8x224qdJsT9A97ljCFesENJeU+Fb2SRMWgrjwhkcctM945CAFCbDJADKz60qfSHTSRLrzSRkWr X-Received: by 2002:a17:902:684a:: with SMTP id f10-v6mr8371168pln.129.1519343635905; Thu, 22 Feb 2018 15:53:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519343635; cv=none; d=google.com; s=arc-20160816; b=gdLQ/bHQVFxsnycf3VTt077HjnkJFeHwjnh0V2+tG5sMgBIniiQfr8h+tSVW8hOIWR +8zBZVB/uBeJqdH3kJcdCzJ06fdwujbgQb5vdGkuv3lzz6C76dv1VsYA4iIx6q420M2h CT+nrzhM1K04W4zTcs90x7uy+Fh1Q68cwfb70uNsJJTZqY7GGQ6S915XGDi3To3StkLM yH5+7qIl8xT0tK0Fo/YN4BRFz9dCOvOXLSuwO0X5/F/AnP+RvAU/E8rAprCpUv4nz5tZ H2rTghYdksPv09STkAabsEH8lCNlua69qJ3XQhu/sx4kPj5MZc53KBd6wl517QDKGsvX Lqow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dmarc-filter:dkim-signature :dkim-signature:arc-authentication-results; bh=AhNeCVaWoPArUjcEK4nHJHm3xlXnaG7f39vsag9YQ0o=; b=RGzLrwVHNVraSTUsWNoFEWwX5tvRPtox6KHHMmAZJjP/Kjufq1a16kRaE00p3uq2Jy YcwdGCus6acVxvqK0QleDO9S+Qs4tS2ebmIWwzVpX9L1tDiPZ1vNfiMqad+3hwMGcQ20 rfektxvoVITB4WqzLyIZVN2YLTN4EsEWCysojoj6Evmf2jb690V9ZQe+vptORdm3bwKx W5CZsiF3sOKavZoZxB9LKQ8PUHy3ieZaGh5kBkrV1bJwl+0cXFgUeBrRewhdzs9DBcOp 1ko2MW3Zm5Hu2DUE12shcZILA6c5orZJfIsyRJ38xRp16nF0UgFGI+BNBuRcocAhaONT 29/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=aRNqJyCs; dkim=pass header.i=@codeaurora.org header.s=default header.b=XKCij5hO; 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 q2si664347pgp.627.2018.02.22.15.53.40; Thu, 22 Feb 2018 15:53:55 -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=aRNqJyCs; dkim=pass header.i=@codeaurora.org header.s=default header.b=XKCij5hO; 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 S1752169AbeBVXwI (ORCPT + 99 others); Thu, 22 Feb 2018 18:52:08 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:59966 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751841AbeBVXwF (ORCPT ); Thu, 22 Feb 2018 18:52:05 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 261AA60A05; Thu, 22 Feb 2018 23:52:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519343525; bh=c2PeSR4wXzxlHQuPsq09G1pE62cR7kqYghMmhBQjz5U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aRNqJyCs437MjcxqCmV6dOyOCcrci17VwtLMYmJLxBH2bN44aE3l3kNKgiEmmAOdv Hs8X7Et13XsLfz9crjwrg9iw/g8/wzB8qo4V32t8JavlTFwsVLVOcVMHpbWbXQM5+7 Zgyq8zAc7LZLwsop2fK3dk4Pz8oSFMKFirCSi4s4= 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 jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B6B1660712; Thu, 22 Feb 2018 23:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519343524; bh=c2PeSR4wXzxlHQuPsq09G1pE62cR7kqYghMmhBQjz5U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XKCij5hOMZQyt242MR51CcxhVLfpbywEBIHnoLBHOqMeDuJWH4jTHnWouYMWXvd4Y pE+a0R9lX3b5RL13/KVj2gmd8Adkui7utO9Qc85/bjyoDEbox/DV9Drb+0uNQuPWob G4p7N+awxNSfKCaMM1+K2p+yG60v2w59uZlXylEU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B6B1660712 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=jcrouse@codeaurora.org Date: Thu, 22 Feb 2018 16:52:00 -0700 From: Jordan Crouse To: Vivek Gautam Cc: joro@8bytes.org, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net, robin.murphy@arm.com, will.deacon@arm.com, robdclark@gmail.com, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, airlied@linux.ie, gregkh@linuxfoundation.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH v7 3/6] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device Message-ID: <20180222235200.GA18743@jcrouse-lnx.qualcomm.com> Mail-Followup-To: Vivek Gautam , joro@8bytes.org, robh+dt@kernel.org, mark.rutland@arm.com, rjw@rjwysocki.net, robin.murphy@arm.com, will.deacon@arm.com, robdclark@gmail.com, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, airlied@linux.ie, gregkh@linuxfoundation.org, sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org References: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> <1517999482-17317-4-git-send-email-vivek.gautam@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1517999482-17317-4-git-send-email-vivek.gautam@codeaurora.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 07, 2018 at 04:01:19PM +0530, Vivek Gautam wrote: > From: Sricharan R > > The smmu device probe/remove and add/remove master device callbacks > gets called when the smmu is not linked to its master, that is without > the context of the master device. So calling runtime apis in those places > separately. > > Signed-off-by: Sricharan R > [vivek: Cleanup pm runtime calls] > Signed-off-by: Vivek Gautam > --- > drivers/iommu/arm-smmu.c | 42 ++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 38 insertions(+), 4 deletions(-) > > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > index 9e2f917e16c2..c024f69c1682 100644 > --- a/drivers/iommu/arm-smmu.c > +++ b/drivers/iommu/arm-smmu.c > @@ -913,11 +913,15 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain) > struct arm_smmu_domain *smmu_domain = to_smmu_domain(domain); > struct arm_smmu_device *smmu = smmu_domain->smmu; > struct arm_smmu_cfg *cfg = &smmu_domain->cfg; > - int irq; > + int ret, irq; > > if (!smmu || domain->type == IOMMU_DOMAIN_IDENTITY) > return; > > + ret = pm_runtime_get_sync(smmu->dev); > + if (ret) > + return; > + > /* > * Disable the context bank and free the page tables before freeing > * it. > @@ -932,6 +936,8 @@ static void arm_smmu_destroy_domain_context(struct iommu_domain *domain) > > free_io_pgtable_ops(smmu_domain->pgtbl_ops); > __arm_smmu_free_bitmap(smmu->context_map, cfg->cbndx); > + > + pm_runtime_put_sync(smmu->dev); > } > > static struct iommu_domain *arm_smmu_domain_alloc(unsigned type) > @@ -1407,14 +1413,22 @@ static int arm_smmu_add_device(struct device *dev) > while (i--) > cfg->smendx[i] = INVALID_SMENDX; > > - ret = arm_smmu_master_alloc_smes(dev); > + ret = pm_runtime_get_sync(smmu->dev); > if (ret) > goto out_cfg_free; Hey Vivek, I just hit a problem with this on sdm845. It turns out that pm_runtime_get_sync() returns a positive 1 if the device is already active. I hit this in the GPU code. The a6xx has two platform devices that each use a different sid on the iommu. The GPU is probed normally from a platform driver and it in turn initializes the GMU device by way of a phandle. Because the GMU isn't probed with a platform driver we need to call of_dma_configure() on the device to set up the IOMMU for the device which ends up calling through this path and we discover that the smmu->dev is already powered (pm_runtime_get_sync returns 1). I'm not immediately sure if this is a bug on sdm845 or not because a cursory inspection says that the SMMU device shouldn't be powered at this time but there might be a connection that I'm not seeing. Obviously if the SMMU was left powered thats a bad thing. But putting that aside it is obvious that this code should be accommodating of the possibility that the device is already powered, and so this should be if (ret < 0) goto out_cfg_free; With that the GPU/GMU successfully comes up on Sean Paul's display testing branch. Jordan -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project