From patchwork Thu Feb 2 17:10:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 9552607 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 644EA602F0 for ; Thu, 2 Feb 2017 17:11:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56E4628411 for ; Thu, 2 Feb 2017 17:11:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47D882849B; Thu, 2 Feb 2017 17:11:27 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 EF70028411 for ; Thu, 2 Feb 2017 17:11:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cZKur-0007nE-Cw; Thu, 02 Feb 2017 17:11:25 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cZKuU-00078k-5P for linux-arm-kernel@lists.infradead.org; Thu, 02 Feb 2017 17:11:08 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 81FDB60C4F; Thu, 2 Feb 2017 17:10:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486055446; bh=AlQtMflak3q7gkMtc7Wvzd45a7ELX6ALQhEco/GlL5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SDNvsEzRwT9Rw6QsuJ9MEVmr3GKbWiqoB3sVhHs9i4z1/HJ6CRFCYugWXQOqvydo3 ciw24XJU6GDrIEVlScZFO3F7u80yDOnn1duB5mDjtiumkx+6OaaR9GOmh0vscwu2Ie Gm9LDQf1D6PNdvsCStCU8gc5D6YVNG+pm8GM2Em8= Received: from blr-ubuntu-32.ap.qualcomm.com (unknown [202.46.23.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sricharan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5D33F60BF6; Thu, 2 Feb 2017 17:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1486055444; bh=AlQtMflak3q7gkMtc7Wvzd45a7ELX6ALQhEco/GlL5U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z2AbstWpMehzSGO8gEU0PYxoFwyuhbfvctC0/IOizM2lU1CyiPCXzC+rws4CFxB2v RnZTTK+IkjxyMH9kJKcOwhDf0xDI273pdoSDekHdCsIb5aiuCsnatrbBAv3YwginHR 9rR2mlwdqfdJjDIrDf6+36z80L1AMt65qRxY6His= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5D33F60BF6 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=sricharan@codeaurora.org From: Sricharan R To: robin.murphy@arm.com, will.deacon@arm.com, joro@8bytes.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, m.szyprowski@samsung.com, sboyd@codeaurora.org, devicetree@vger.kernel.org, robh+dt@kernel.org, mathieu.poirier@linaro.org Subject: [PATCH V2 3/3] iommu/arm-smmu: Add the device_link between masters and smmu Date: Thu, 2 Feb 2017 22:40:20 +0530 Message-Id: <1486055420-19671-4-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1486055420-19671-1-git-send-email-sricharan@codeaurora.org> References: <1486055420-19671-1-git-send-email-sricharan@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170202_091102_493724_08924033 X-CRM114-Status: GOOD ( 11.97 ) 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: sricharan@codeaurora.org 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 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 --- drivers/iommu/arm-smmu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 5170523..db4bb3c 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1475,6 +1475,7 @@ static int arm_smmu_add_device(struct device *dev) struct arm_smmu_device *smmu; struct arm_smmu_master_cfg *cfg; struct iommu_fwspec *fwspec = dev->iommu_fwspec; + struct device_link *link = NULL; int i, ret; if (using_legacy_binding) { @@ -1528,6 +1529,16 @@ static int arm_smmu_add_device(struct device *dev) if (ret) goto out_free; + /* + * 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 create device link between %s and %s\n", + dev_name(smmu->dev), dev_name(dev)); + return 0; out_free: