From patchwork Wed Mar 14 08:14:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 10281623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5CE19602C2 for ; Wed, 14 Mar 2018 08:19:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AC3A281DB for ; Wed, 14 Mar 2018 08:19:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CCD62876D; Wed, 14 Mar 2018 08:19:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C4923281DB for ; Wed, 14 Mar 2018 08:19:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Fe1O5WGEjfii/oILQQxDPkM2PS+hb51y5ONtrLy7L08=; b=LA4PUSOY0bTMse5W6mrqGH4GjD I9kBWCbL7c6vdzfGCNbt4zLcvIvT+wmu/MMPgCetWZzdyS3+HElAYAp/vS4muvSyp0mVi9dvQeGv+ 5juRfKwjCHfQhkwE6OszzrKsZ/LidqxVVLk2QpqchTVK9EdxTbIyULXRnJFGdSUCcp6zPtnezZiM7 kPwwtyZrCLLH9GzS4yRxE0Ekr7YNF0UvRYQuvtxWUBhY3mNAw6WG4UBEakTr1nVT5iMEbESDOO+be 0XQsRzNIt7MgmTj5vE5/YfmOhHfJVmPKWlwh1LnE+piflBF/zhqJw1OYtF3MaGOoZr7Oj0jyExSYn 8/hw3bdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ew1cy-00075v-69; Wed, 14 Mar 2018 08:19:16 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ew1ZD-0004Zi-RS for linux-arm-kernel@lists.infradead.org; Wed, 14 Mar 2018 08:15:31 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 22DF760B1E; Wed, 14 Mar 2018 08:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521015318; bh=2ZKbi6jJOLuT7Rz050AP8qbd2LxQcfAcqkqJnorcgSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ReziFnvhuh4vgaYRFptpOCiHsrDxdpz/My27EcAObQkGA+XlL+NbYApYrnmXSRsde nkvYaBD0k63PTD8uuYZ8ivQJNKD4/L0vo9RYfvAHgYjncj+O4ZgQl1nHxr/f2GMj8n vjar5k5UUURhXZFdjMet9H7lavKMVcvAqaDX8WYE= 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 845226081A; Wed, 14 Mar 2018 08:15:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521015310; bh=2ZKbi6jJOLuT7Rz050AP8qbd2LxQcfAcqkqJnorcgSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FUsCn88nRLNiYLVHqP3JaXuf+Hgy3tNQv2tUU0PHebAC4UrYDxceENkE8cYPnmL+B /bWejohnje6fTjn3jzGXeb7T/ikffmuY/fsM3/Y7vuItVPkTUgtBVw6rzL3cWaAjvR wo9tOqpEjj9IrcQJA69oCwcQQVU7vPjwRCqPRgLM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 845226081A 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, rafael.j.wysocki@intel.com, robin.murphy@arm.com, iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 4/5] iommu/arm-smmu: Add the device_link between masters and smmu Date: Wed, 14 Mar 2018 13:44:33 +0530 Message-Id: <20180314081434.30875-5-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 2.16.1.72.g5be1f00a9a70 In-Reply-To: <20180314081434.30875-1-vivek.gautam@codeaurora.org> References: <20180314081434.30875-1-vivek.gautam@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180314_011524_504239_9C928968 X-CRM114-Status: GOOD ( 14.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, architt@codeaurora.org, linux-arm-msm@vger.kernel.org, will.deacon@arm.com, tfiga@chromium.org, robdclark@gmail.com, vivek.gautam@codeaurora.org, sricharan@codeaurora.org, linux-arm-kernel@lists.infradead.org, m.szyprowski@samsung.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sricharan R Finally add the device link between the master device and smmu, so that the smmu gets runtime enabled/disabled only when the master needs it. This is done from add_device callback which gets called once when the master is added to the smmu. Signed-off-by: Sricharan R Signed-off-by: Vivek Gautam Reviewed-by: Tomasz Figa --- Changes since v9: - Using device_link_del_dev() to delete the device link, instead of doing it in two steps - device_link_find() to first find the link, and then calling device_link_del(). drivers/iommu/arm-smmu.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 56a04ae80bf3..4cf270ffd449 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1460,10 +1460,31 @@ static int arm_smmu_add_device(struct device *dev) iommu_device_link(&smmu->iommu, dev); + if (pm_runtime_enabled(smmu->dev)) { + struct device_link *link; + + /* + * Establish the link between smmu and master, so that the + * smmu gets runtime enabled/disabled as per the master's + * needs. + */ + link = device_link_add(dev, smmu->dev, DL_FLAG_PM_RUNTIME); + if (!link) { + dev_warn(smmu->dev, + "Unable to add link to the consumer %s\n", + dev_name(dev)); + ret = -ENODEV; + goto out_unlink; + } + } + arm_smmu_rpm_put(smmu); return 0; +out_unlink: + iommu_device_unlink(&smmu->iommu, dev); + arm_smmu_master_free_smes(fwspec); out_rpm_put: arm_smmu_rpm_put(smmu); out_cfg_free: @@ -1486,6 +1507,9 @@ static void arm_smmu_remove_device(struct device *dev) cfg = fwspec->iommu_priv; smmu = cfg->smmu; + if (pm_runtime_enabled(smmu->dev)) + device_link_del_dev(dev, smmu->dev); + ret = arm_smmu_rpm_get(smmu); if (ret < 0) return;