Received: by 10.213.65.68 with SMTP id h4csp1522843imn; Thu, 15 Mar 2018 01:58:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELvzT8tYxnYFWH5aSr1Sx52tWSdqvOeeh4Pw46bkxQ91B4B9ugzOPpUN/Ghbr+RGJ8kRGKxb X-Received: by 10.101.86.70 with SMTP id m6mr759111pgs.349.1521104330431; Thu, 15 Mar 2018 01:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521104330; cv=none; d=google.com; s=arc-20160816; b=nyLYZBof0fcsfYS++TY3JdgyWnNiyY8Ue0Mdtk6RsgcauTYcXrbhqFEzqzyN+dGQc3 G5XD9V9l8HwlZDIuJjcQeMTG/eABYoxeebXGXecNKefw6UN0gSQetwtWHDsHkowZFJtr ul8tYBe2B3P7QsVAjQSlJMDctP3pADTszzNQ6iVShSzBaNdUpyQEgWQBIjV1ICNFH6Tv 6ZlHY/gRiJTNBb58B6+00Ipa0iecG4dXvaCPybacf7XZ9dWBXH8yxJYMlkBfAtUF293z HjOPON+KSX8tPRWJZCuQop2Sb3y/2u0SgDSRFuT94nkDIOdcwxy+voa8/Ee4x69J8L9m dsHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter:dkim-signature :dkim-signature:arc-authentication-results; bh=lm0kpn9tjkLTLr5iffaZa3GOoQ+S47/myB3S4VUEZnU=; b=iYKbqUSNqfCZqLm9HAybn40qaBcuplJpow+RIV4g7uhDeEhiffdQ3G/8y7c9omVOeq aUPtRjxnHaEWLF7mzdOnjgiVNWMuQ/uPE9cf8xgVNTloJ/blczPj1j68cHiwQnDRGsNN jFiCwGEfEemeQa3WDUj3rwK+b6Dge3kortPyA3J6kiQWwZvOWd3JaPN4Gauv85TArTiR vtCFMBbYAfVN6u31dR+IrpqyRaWd1VyUjTeAHwm+I3/2aOt4brGs5c8FKGKTwNrO3ds9 NxW+6mBU366SuWiNTlUcux/FGALxKd0mqYCTjR+ywKKT7P+WRlAqBUdMkitmbRLIMpCd 64rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=fQ/BlPKm; dkim=pass header.i=@codeaurora.org header.s=default header.b=BKj2Ejlm; 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 f64-v6si3599347plb.377.2018.03.15.01.58.36; Thu, 15 Mar 2018 01:58:50 -0700 (PDT) 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=fQ/BlPKm; dkim=pass header.i=@codeaurora.org header.s=default header.b=BKj2Ejlm; 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 S1751571AbeCOI5b (ORCPT + 99 others); Thu, 15 Mar 2018 04:57:31 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43832 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751478AbeCOI52 (ORCPT ); Thu, 15 Mar 2018 04:57:28 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 437E960C64; Thu, 15 Mar 2018 08:57:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521104248; bh=z5bT9gg0+bkQ/mZhZXbMW6QlEnAciBy/QZ/JXNw/S8k=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=fQ/BlPKmBnRndK2oxgTLnGeltkd3dH11uecHzYiQwv8soEG/AAhaMxA2A0tbhWq7Q 352R5S7n9vHv2EZ/Yu79CZ9pZrREWlzx4XyV97X82RRwquq43jhKWB3gi3lg+Kno+i PLsq2CDUhS0rd5ukoVphqxSCSJRqoYJVmJKa7ZAE= 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 mail-qt0-f171.google.com (mail-qt0-f171.google.com [209.85.216.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vivek.gautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5AE5460AE0; Thu, 15 Mar 2018 08:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521104247; bh=z5bT9gg0+bkQ/mZhZXbMW6QlEnAciBy/QZ/JXNw/S8k=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=BKj2EjlmkRFwkFRE05S/Yj/JXAq/HYcHewzfi8lev7sh3RPaR/ur9vPpuEYSjcygC 4jiJm3KmW1rKBxGVDnVN3cctPMwQFaYCkrxM49SySRubBBiA5JtYJOY3uCE989IEcd Sn/cMpmQqdjVdZ0mYd/dyRtZv6qAwBL2+D2tFxrc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5AE5460AE0 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 Received: by mail-qt0-f171.google.com with SMTP id c7so6409009qtn.3; Thu, 15 Mar 2018 01:57:27 -0700 (PDT) X-Gm-Message-State: AElRT7GGTZOpvu+Zn92R1ZqNR7t6QzealODLxD4Fq0zMxLDt3g3I/IuV x5DV7PcWrL5NEBbtNnlOWHNT83JgxhDqvIZxfcs= X-Received: by 10.200.56.214 with SMTP id g22mr8870923qtc.245.1521104246536; Thu, 15 Mar 2018 01:57:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.83.10 with HTTP; Thu, 15 Mar 2018 01:57:26 -0700 (PDT) In-Reply-To: <8b427ea2-5c13-4712-13d1-e4c1aed0779e@arm.com> References: <20180313085534.11650-1-vivek.gautam@codeaurora.org> <20180313085534.11650-5-vivek.gautam@codeaurora.org> <8b427ea2-5c13-4712-13d1-e4c1aed0779e@arm.com> From: Vivek Gautam Date: Thu, 15 Mar 2018 14:27:26 +0530 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v9 4/5] iommu/arm-smmu: Add the device_link between masters and smmu To: Robin Murphy Cc: "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , "robh+dt" , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , devicetree@vger.kernel.org, open list , Mark Rutland , Will Deacon , Rob Clark , Tomasz Figa , Sricharan R , Marek Szyprowski , Archit Taneja , linux-arm-msm Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Robin, On Wed, Mar 14, 2018 at 11:20 PM, Robin Murphy wrote: > On 13/03/18 08:55, Vivek Gautam wrote: >> >> 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 >> --- >> drivers/iommu/arm-smmu.c | 29 +++++++++++++++++++++++++++++ >> 1 file changed, 29 insertions(+) >> >> diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c >> index 56a04ae80bf3..64953ff2281f 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) { > > > FWIW, given that we don't really care about link itself, I'd be quite happy > to simplify that lot down to: > > if (pm_runtime_enabled(smmu_dev) && > !device_link_add(dev, smmu->dev, DL_FLAG_PM_RUNTIME)) { Sure, will update this. > >> + dev_warn(smmu->dev, >> + "Unable to add link to the consumer >> %s\n", >> + dev_name(dev)); > > > (side note: since device_link_add() already prints a message on success, > maybe it could print its own failure message too?) Should we make device_link that verbose - to print failure messages at each step (there are atleast a couple where we return link as NULL), or we can let the users handle printing the message? regards Vivek > > Robin. > > >> + 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,14 @@ static void arm_smmu_remove_device(struct device >> *dev) >> cfg = fwspec->iommu_priv; >> smmu = cfg->smmu; >> + if (pm_runtime_enabled(smmu->dev)) { >> + struct device_link *link; >> + >> + link = device_link_find(dev, smmu->dev); >> + if (link) >> + device_link_del(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