Received: by 10.223.176.5 with SMTP id f5csp483636wra; Wed, 7 Feb 2018 02:34:30 -0800 (PST) X-Google-Smtp-Source: AH8x226sOZt/3G68RgJK6Zy1sFg5Mf0RUO/YR060Xus/05NkIxNqNHbkawBua0xcpARzeiHNwyg9 X-Received: by 10.101.74.73 with SMTP id a9mr4623075pgu.32.1517999670559; Wed, 07 Feb 2018 02:34:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517999670; cv=none; d=google.com; s=arc-20160816; b=MUCapHpp8ndBHo8cnlyG+aRKHV5ixaE9elMxHhFj/hnLQ+JOeEwyHxCd80yIHc7t08 Sgs0qQe20NYJqdGxQ6IW+VA0AL5/Dd3YrwsXQWv8+Kf/UlerDb/FDdej8WkoCMhm4GLu 0zHmpQG8zsvhuC9jclgEpjRWzWZPjVl9nujtyn8osMqDCjYmeLwXByLWqLjR2w2Chr8V y7IAj2/SnwA1QGXBmsbfYE6VAizYAcyqXns4QefBUdLKn8IXIqay8XOZQtQr70HOlKAU ct5LdDuDv3rjtbVa/wzNCFfvevIMOfDFiOYYi7XgqSExfMn8ouaJpK9zoAdvErSZnXjK RQ3w== 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=8U+iN46xj9qrDvjJtqlGFYvqqkf3OR97hIwqHRczs8I=; b=bJB6oqp0H2ARfDZSQtRpzFxJUtAeZFyYX6J+7wCPqgIIzX8Z2Avhlie0dZtt5nGn6V Eo05vpOs7Jy9v8WUZhsm11dW+sQTAOBkiLvP2SgmZgEaHOWhds+40doqR+sPSplutTyk sjFaSh2xtQ/ctt9nvn6J8S2jABcXLHfuthBLuorGSNZ3mxJAtL/fijC6rxhTsgIoLPOC devqUP7psUqNwgWBJH7Q12SXOye+TG1BXkHWLFMMO2nneNnUyJkThzdqTROP/YddqV+1 0WgreN+MkQZgaU3S6kLG0noyWEu6phzdqHd71bIakH1bilvWGJZ9dF/welNTdoum6e+v PLTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=n3bXvP2F; dkim=pass header.i=@codeaurora.org header.s=default header.b=FhoM/swA; 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 g7-v6si890148plo.380.2018.02.07.02.34.16; Wed, 07 Feb 2018 02:34:30 -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=n3bXvP2F; dkim=pass header.i=@codeaurora.org header.s=default header.b=FhoM/swA; 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 S1754016AbeBGKc7 (ORCPT + 99 others); Wed, 7 Feb 2018 05:32:59 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:41208 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753945AbeBGKcH (ORCPT ); Wed, 7 Feb 2018 05:32:07 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B7D6060A66; Wed, 7 Feb 2018 10:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517999526; bh=RA9LbtiTU7cL5j6cuHkcjze61/0JLDCCyx1Q3xPcW2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n3bXvP2F22/GAG3FBISYpTv/mr0ZSXsgjsAxBxtB0kAUHXhEW5WU/hNRipUtX3DKl gmRCWvQppmocodI7Zh6LrcW/EwVzksw5ZLm8e22TvU9ojrk/fmCJT/Sr9vAJg3sJMp VnwoqqSCLKVzrJTHaqfVgbPSZmqe6nR+RBnQK6TQ= 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 D81F760767; Wed, 7 Feb 2018 10:31:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1517999525; bh=RA9LbtiTU7cL5j6cuHkcjze61/0JLDCCyx1Q3xPcW2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FhoM/swAsChR+UMMuUy3HqjvWAxdFCXQH65rUkRSegKbgV+Qb5qD5kfJcKz1lda74 tDeVb8zj7k23rH4Zl89yrk7kOrqW6f89P1LkvrrhNORcA9gp43V4DlHnDeCQTgy5hx aS+iIVaiDLCk4p0krzUD8urQMViUaqvqHT7lXXlY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D81F760767 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 4/6] iommu/arm-smmu: Add the device_link between masters and smmu Date: Wed, 7 Feb 2018 16:01:20 +0530 Message-Id: <1517999482-17317-5-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 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 --- drivers/iommu/arm-smmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index c024f69c1682..c7e924d553bd 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -215,6 +215,9 @@ struct arm_smmu_device { /* IOMMU core code handle */ struct iommu_device iommu; + + /* runtime PM link to master */ + struct device_link *link; }; enum arm_smmu_context_fmt { @@ -1425,6 +1428,17 @@ static int arm_smmu_add_device(struct device *dev) pm_runtime_put_sync(smmu->dev); + /* + * Establish the link between smmu and master, so that the + * smmu gets runtime enabled/disabled as per the master's + * needs. + */ + smmu->link = device_link_add(dev, smmu->dev, DL_FLAG_PM_RUNTIME); + if (!smmu->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_rpm_put: @@ -1449,6 +1463,8 @@ static void arm_smmu_remove_device(struct device *dev) cfg = fwspec->iommu_priv; smmu = cfg->smmu; + device_link_del(smmu->link); + ret = pm_runtime_get_sync(smmu->dev); if (ret) return; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation