Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1564666imm; Fri, 7 Sep 2018 02:25:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZBY4PgoAAr1+TcllLfHSJg9mRKomaKR5GniXXH+1PR+YBDY9R4xNO+wtaYT4rWWrCnv0oI X-Received: by 2002:a63:c912:: with SMTP id o18-v6mr6995526pgg.331.1536312340518; Fri, 07 Sep 2018 02:25:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536312340; cv=none; d=google.com; s=arc-20160816; b=yNBu8QdHoJLDzc2xDTJ0t0rhSMTXMNebwI2mmBtfDdw8jG3ZejWCpSXyq//OqwxQ+D k6KFdYOLxE1WSWIYz67HQxNhzHfSPBgbxbGQw+OrEuNnQ75ipbsGYd+jPiYjPoqj7WVs pc4Nqr5NP92ojW/7dN1odYfzWVkXga7guJkaoeznBUIpw4bxS63eH9mI0wwnnwvRkkYm HYv/vSCCp84+qj5tP2v+BGaYeUXdBTwxwpX5FtnMxkXhVPZKcLkUcmKD79jeDINzzFIE dDQTx0DkuC4BAqoAtjiBHFuEyDdU47UMLsG7v44jdImCLO0Ic5I2Y3mDHe281FcELRak +sHg== 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 :in-reply-to:references:mime-version:dkim-signature; bh=CPMX2U/+GDmuntzdpi16LobMjhTM3x3EDMSFlNOCPmI=; b=AURZkqVSfYbSSr0mmTl7slMncyXYR1hLqjxMovZI5OEzjZoNbaTAD3zMWkgAsuxYgS oGdt0f4XGahGup+dzSnEVgYQt6GudA3I8zjxw3EuMek7iwO/y863VrIU+hzJTbg86OVQ 2+WNshjSnkWmufM5eInOO4mjkhauPxnyb7gCstNYdkH9scAkTkZtcG3Llpj0JXtLwNpR bhR1zf4dWYVvzi1glncErTwGJoSp08Jd1BBWDYUK2+njtOQYW6FL517yogpAlVoUi0kl Z3LV+DoKn4vdtEwz1PdSMveJpngrKAT5xahLsnst/XA3IueOQS7sZqJSaod9zmNLogwt j8bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Z69EaHtr; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11-v6si7299532plg.453.2018.09.07.02.25.13; Fri, 07 Sep 2018 02:25:40 -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=@chromium.org header.s=google header.b=Z69EaHtr; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728291AbeIGODh (ORCPT + 99 others); Fri, 7 Sep 2018 10:03:37 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:35662 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725843AbeIGODg (ORCPT ); Fri, 7 Sep 2018 10:03:36 -0400 Received: by mail-yw1-f65.google.com with SMTP id 14-v6so5165996ywe.2 for ; Fri, 07 Sep 2018 02:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CPMX2U/+GDmuntzdpi16LobMjhTM3x3EDMSFlNOCPmI=; b=Z69EaHtr1C4HiEmd6XGQPnqrgi2tb6Jyy3RHxWbcYZv7LC0MUHKt+MWFYMmrLFdXmq YSF5EF9KKiQ75rJIRGVLYTrdIDt1k/oabsRUB97A6hFQ4ujJ+scpYNl3AmMNigXS+Ev/ +Smedr4L0Ob83lP20SwsIU+Mk0c7JoEBHtZsg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CPMX2U/+GDmuntzdpi16LobMjhTM3x3EDMSFlNOCPmI=; b=rtcr4uGThhx07XO81zvpZcejOxlTDZQ1Qcq46BgMcpmWOEGNiQnqImIWjcFvWMGFs/ ahSGVcARf1Q2AjrCZGqUnaqx6moIKKxB/O8S5tesiuVaXNX1WdBCmw0dJ5E9SuGgDhdN sF5xuq8HCjuVDBLFmCsKvyvFVscrTHPsyZxDneTeKHKLNfhy7aiBanGeBGkBDfskc6jI FTJnrB/3e4F+jk4+u4JBHvOf5ksdxlYduGJQ7EB5wHh7Wlr6+Cl3vdDFIE7ro3NLw04u 57H1wgYt+5b3Da+vV4f8foUz0k7n6pD7lrGCJ9jJUcHX4OVPqMLM3SPId9l4+lyHLq96 qDUg== X-Gm-Message-State: APzg51Bz8tnv21JV9EgLPGRxgrQ23GLuzv07Ha2Jbbg+aPVZ8LZ6D/93 uFbnO41gXPpWLC9GNvOFBwN1s/q3tdN5+w== X-Received: by 2002:a81:5dc1:: with SMTP id r184-v6mr3438697ywb.122.1536312213113; Fri, 07 Sep 2018 02:23:33 -0700 (PDT) Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com. [209.85.219.178]) by smtp.gmail.com with ESMTPSA id q194-v6sm2605936ywg.91.2018.09.07.02.23.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 02:23:32 -0700 (PDT) Received: by mail-yb1-f178.google.com with SMTP id o17-v6so5228022yba.2 for ; Fri, 07 Sep 2018 02:23:32 -0700 (PDT) X-Received: by 2002:a25:acc6:: with SMTP id x6-v6mr441205ybd.293.1536311808369; Fri, 07 Sep 2018 02:16:48 -0700 (PDT) MIME-Version: 1.0 References: <20180830144541.17740-1-vivek.gautam@codeaurora.org> <20180830144541.17740-3-vivek.gautam@codeaurora.org> In-Reply-To: <20180830144541.17740-3-vivek.gautam@codeaurora.org> From: Tomasz Figa Date: Fri, 7 Sep 2018 18:16:37 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v16 2/5] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device To: Vivek Gautam Cc: "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Rob Herring , Robin Murphy , Will Deacon , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , devicetree@vger.kernel.org, Linux Kernel Mailing List , Alex Williamson , Mark Rutland , "Rafael J. Wysocki" , Rob Clark , Linux PM , freedreno , sboyd@kernel.org, jcrouse@codeaurora.org, Sricharan R , Marek Szyprowski , Archit Taneja , 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 Vivek, On Thu, Aug 30, 2018 at 11:46 PM 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. > Global locks are also initialized before enabling runtime pm as the > runtime_resume() calls device_reset() which does tlb_sync_global() > that ultimately requires locks to be initialized. > > Signed-off-by: Sricharan R > [vivek: Cleanup pm runtime calls] > Signed-off-by: Vivek Gautam > Reviewed-by: Tomasz Figa > Tested-by: Srinivas Kandagatla > --- > drivers/iommu/arm-smmu.c | 89 +++++++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 81 insertions(+), 8 deletions(-) [snip] > @@ -2215,10 +2281,17 @@ static int arm_smmu_device_remove(struct platform_device *pdev) > if (!bitmap_empty(smmu->context_map, ARM_SMMU_MAX_CBS)) > dev_err(&pdev->dev, "removing device with active domains!\n"); > > + arm_smmu_rpm_get(smmu); > /* Turn the thing off */ > writel(sCR0_CLIENTPD, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0); > + arm_smmu_rpm_put(smmu); > + > + if (pm_runtime_enabled(smmu->dev)) > + pm_runtime_force_suspend(smmu->dev); > + else > + clk_bulk_disable(smmu->num_clks, smmu->clks); > > - clk_bulk_disable_unprepare(smmu->num_clks, smmu->clks); > + clk_bulk_unprepare(smmu->num_clks, smmu->clks); Aren't we missing pm_runtime_disable() here? We'll have the enable count unbalanced if the driver is removed and probed again. Also, if we add pm_runtime_disable(), we can reorder things a bit and simplify into: arm_smmu_rpm_get(smmu); /* Turn the thing off */ writel(sCR0_CLIENTPD, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0); if (pm_runtime_enabled()) pm_runtime_disable(); arm_smmu_rpm_put(smmu); clk_bulk_disable_unprepare(smmu->num_clks, smmu->clks); Best regards, Tomasz