Received: by 10.223.185.116 with SMTP id b49csp8467090wrg; Fri, 2 Mar 2018 02:14:35 -0800 (PST) X-Google-Smtp-Source: AG47ELs0HvITQqOYCGbijW7jIl8R+bSx7/Xp3kqkEvSw0vxLlU598sZHyYcSy8lWlysHpiZ24Ixy X-Received: by 2002:a17:902:1:: with SMTP id 1-v6mr4839615pla.187.1519985675835; Fri, 02 Mar 2018 02:14:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519985675; cv=none; d=google.com; s=arc-20160816; b=08Y6mxT01dgUQiJOOR3gqCxy/YFXdxvQNlgTm3swjqZssxuRB+hyxQlrV9AbRb6rHs HTf1M4QL15I51ciuYFZH60bgQc7PKbDDqYye3QYf7tIs+7BgtepQu11GDTkywsoksGe6 7tvOVgGeKpNcw40APkc1vx8o49AjgWnGAeYtemBuxJpUgCwhVC6sUm1+OEsCcc2aexl6 FcQWYBmfRaPZ4IvFCDC4v3uwVlmzC2/ufRbit59KvRhMYs5msfuwKG2hUwCTcelpDi+r HEax/YAxaegooDSPma6BMA3Q1AzS7E9ApXNc+98gLl2tpJWC2mPyT93H4w8s2m4QnSq/ J2Og== 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=tUBL31c/94dw/rNFwDNWbaX5IAqPFgiQYlnbLy3xct8=; b=0flGH3O3DMdclwoH1hbZrshHo9igh2Asfl1MiNCg0juXmDYObDezsiUghB5WY6gcsu 8f18pDiX9gqIypfe7Z/HAJDmVjtlj8KJOO9OM4RWPisbq3H0dXcRujyO4jOTIMIqERs9 KyI3NjWMOZyEpdmYC2DYgiD+kw3v9dvasa0s8eCfevls/rb8nChtebd9ceSTwUMtuc5/ HmI16RGOmVLydeotxZayqVavz95ehOGsuam+qFCAJWdujZts0mS9fSX+MMQNG36c/B9Y 6ps3EwUDM8rRHLXXmOHN9GUg6yMeek0hFTNEUlkfHG0FuW/AEYFuYocRuh8JDxpeBuYR KZyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=IRIX5xkX; dkim=pass header.i=@codeaurora.org header.s=default header.b=kJ926qWi; 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 h127si3285474pgc.308.2018.03.02.02.14.21; Fri, 02 Mar 2018 02:14:35 -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=IRIX5xkX; dkim=pass header.i=@codeaurora.org header.s=default header.b=kJ926qWi; 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 S1426248AbeCBKMe (ORCPT + 99 others); Fri, 2 Mar 2018 05:12:34 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:47090 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1426176AbeCBKLY (ORCPT ); Fri, 2 Mar 2018 05:11:24 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C1B60607E5; Fri, 2 Mar 2018 10:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519985483; bh=ivrPxhiKg6YXONJHD3zN3ZCDR/9kqfknu3sRuEo8H/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IRIX5xkXF8k1kTHz68r3mjclp4sklAqVztFgPUmKQ5OvkyeU1Lhi/eNXh60YMlWKn g7uly8ZmtG32ExNvVvr7lwTSy4I4y+2hxmtXFLd3gW0QoCtmyAQCHa5ksdlReQi3vr K//x+P2TDVDge+Op89jUmPY0Njpv4F5RYcBVNlEo= 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 5F20F602B8; Fri, 2 Mar 2018 10:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519985482; bh=ivrPxhiKg6YXONJHD3zN3ZCDR/9kqfknu3sRuEo8H/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kJ926qWiTIwV2VED78te2Da0mYTlXAjlhDBHqtlRGkd4Z2Si4cUTajNMtbz1tM2i8 oJqzaFWTHIIN5LnCFNeLRoZ2cV+DDlJ/aVlcFe/DPDgA0pjvYAg2t/A4HVQ2KjMols shC4cjC0nXRC7mRP+po4cC5Y7ISw7SR6b3BxBFdQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5F20F602B8 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 Cc: tfiga@chromium.org, jcrouse@codeaurora.org, 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 v8 4/5] iommu/arm-smmu: Add the device_link between masters and smmu Date: Fri, 2 Mar 2018 15:40:49 +0530 Message-Id: <20180302101050.6191-5-vivek.gautam@codeaurora.org> X-Mailer: git-send-email 2.16.1.72.g5be1f00a9a70 In-Reply-To: <20180302101050.6191-1-vivek.gautam@codeaurora.org> References: <20180302101050.6191-1-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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 3d6a1875431f..bb1ea82c1003 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -217,6 +217,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 { @@ -1470,10 +1473,26 @@ static int arm_smmu_add_device(struct device *dev) iommu_device_link(&smmu->iommu, 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)); + 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: @@ -1496,6 +1515,8 @@ static void arm_smmu_remove_device(struct device *dev) cfg = fwspec->iommu_priv; smmu = cfg->smmu; + device_link_del(smmu->link); + ret = arm_smmu_rpm_get(smmu); if (ret < 0) return; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation