Received: by 10.223.176.5 with SMTP id f5csp483440wra; Wed, 7 Feb 2018 02:34:17 -0800 (PST) X-Google-Smtp-Source: AH8x224CoSRBcasDgm5cEm4VDqe65uJFS483PluhYuIBvyFqB2u+HzCutCTn+p6cQPa0DLfRv9JM X-Received: by 10.98.12.144 with SMTP id 16mr5580223pfm.147.1517999657051; Wed, 07 Feb 2018 02:34:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517999657; cv=none; d=google.com; s=arc-20160816; b=ZmhWMoYKDzRtzPfnsvYP5NYtmvRQCMnSTx/Ow/TOdiUbCE3vH8snW8ZNi65etTtLgg 8zhl04PAKu5yW9fsLuFcKH97pvCVliRyc0RqR9NeJDZJ3kDaL7/2L1OCvbT6pvJilmn2 NrEdgE3xKbZjdduvQoouURBgTwhHUykdRCeSKsfb4nAbOrXRgvq6ekiUMViyza+B1wlI wKiVZuprtmzMnDC9RYbpCgKWd2dBZ3Egd8k0U1r9TF0QtzdZjvbSM9A7X/CYN6DabsB9 ePzAAIidH/jrQZwgUB/yQZJvbhmQghx4vh7rrBxLFtXpkLwSzsok1DTPGGpd9AJckiR8 YosA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=C+b6uNMG0xjr1YoTlOhk6oXGJd8pmwrHR6U/xtY6o30=; b=tOMGhHSBBsrFnVgkX4ejCO6ZTeCNE4bR55W/LDnq2eDPrpyJSIvWLqMsiFa/yJjVO4 Z1tsuWEymbEcDbeQyIqax4JbRV7YMGAFPSCnMLzhITqiH+DdwiQB218v6HDEPDcBRgyg G3EKeUWso+nVFR4g3uKb9mrmxAfZzns7OFD9+Xy3CqCYjC8LgJ4CjOGHfoNMz/a05kf6 LkFOjtv6QYVPqO46+at8c4CchhYxoMqwW6XSSuee35oOOiPHBIEuveXQVEKv7zI9Pd2/ kabzZ8CnLcGSkUOsP3lFykKQfa4UjFIi/USOXSQpVe1TwD7i6m9AbhCR/zkUrezybJD9 lmXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=gp/fuyOH; dkim=pass header.i=@codeaurora.org header.s=default header.b=WG2K7uMR; 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 m1-v6si898186plb.83.2018.02.07.02.34.03; Wed, 07 Feb 2018 02:34:17 -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=gp/fuyOH; dkim=pass header.i=@codeaurora.org header.s=default header.b=WG2K7uMR; 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 S1753938AbeBGKcF (ORCPT + 99 others); Wed, 7 Feb 2018 05:32:05 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:40938 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753794AbeBGKcA (ORCPT ); Wed, 7 Feb 2018 05:32:00 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id DB82060A66; Wed, 7 Feb 2018 10:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517999519; bh=3HZeGS2qD+Qgyq/9wCEp2e67DE77+ddOFIlnQTx2KUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gp/fuyOHVENFswtyls15s7Rla/XWtPM6V04CAz+bB8mzBAxeRjosTIRPACug6ZXPS bnsgRSP9Gzkpac65y/+wdfO65LpqztMORbdYqyAk3BW4X5skquSrDbnvrmoWxuNI3z FhMi2xpKrz9+FuabuiTsNfrTuFcOC9bL/THFg2rQ= 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 blr-ubuntu-41.ap.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A4B6360272; Wed, 7 Feb 2018 10:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517999518; bh=3HZeGS2qD+Qgyq/9wCEp2e67DE77+ddOFIlnQTx2KUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WG2K7uMRngQpTPim4KCBzMVn6ceQCgMIPhtn/LIDCc/LgHGVBTE6/aJu21DNuFXq4 KAEXjF8xj6z4obzecnKEkToIqcxCFDvXUaHNufDvMx3r1KEEWKjYegjz7FKpDTzi70 U97yK9MkFOcwN4vMFvgmszjCujF1/QcG9o56wWVo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A4B6360272 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 From: Vivek Gautam To: 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 Cc: alex.williamson@redhat.com, gregkh@linuxfoundation.org, airlied@linux.ie, sboyd@codeaurora.org, sricharan@codeaurora.org, m.szyprowski@samsung.com, architt@codeaurora.org, linux-arm-msm@vger.kernel.org, vivek.gautam@codeaurora.org Subject: [PATCH v7 3/6] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device Date: Wed, 7 Feb 2018 16:01:19 +0530 Message-Id: <1517999482-17317-4-git-send-email-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> References: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; + ret = arm_smmu_master_alloc_smes(dev); + if (ret) + goto out_rpm_put; + iommu_device_link(&smmu->iommu, dev); + pm_runtime_put_sync(smmu->dev); + return 0; +out_rpm_put: + pm_runtime_put_sync(smmu->dev); out_cfg_free: kfree(cfg); out_free: @@ -1427,7 +1441,7 @@ static void arm_smmu_remove_device(struct device *dev) struct iommu_fwspec *fwspec = dev->iommu_fwspec; struct arm_smmu_master_cfg *cfg; struct arm_smmu_device *smmu; - + int ret; if (!fwspec || fwspec->ops != &arm_smmu_ops) return; @@ -1435,8 +1449,15 @@ static void arm_smmu_remove_device(struct device *dev) cfg = fwspec->iommu_priv; smmu = cfg->smmu; + ret = pm_runtime_get_sync(smmu->dev); + if (ret) + return; + iommu_device_unlink(&smmu->iommu, dev); arm_smmu_master_free_smes(fwspec); + + pm_runtime_put_sync(smmu->dev); + iommu_group_remove_device(dev); kfree(fwspec->iommu_priv); iommu_fwspec_free(dev); @@ -2131,6 +2152,14 @@ static int arm_smmu_device_probe(struct platform_device *pdev) if (err) return err; + platform_set_drvdata(pdev, smmu); + + pm_runtime_enable(dev); + + err = pm_runtime_get_sync(dev); + if (err) + return err; + err = arm_smmu_device_cfg_probe(smmu); if (err) return err; @@ -2172,9 +2201,9 @@ static int arm_smmu_device_probe(struct platform_device *pdev) return err; } - platform_set_drvdata(pdev, smmu); arm_smmu_device_reset(smmu); arm_smmu_test_smr_masks(smmu); + pm_runtime_put_sync(dev); /* * For ACPI and generic DT bindings, an SMMU will be probed before @@ -2211,8 +2240,13 @@ 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"); + pm_runtime_get_sync(smmu->dev); /* Turn the thing off */ writel(sCR0_CLIENTPD, ARM_SMMU_GR0_NS(smmu) + ARM_SMMU_GR0_sCR0); + pm_runtime_put_sync(smmu->dev); + + pm_runtime_disable(smmu->dev); + return 0; } -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation