Received: by 10.223.185.116 with SMTP id b49csp3319197wrg; Tue, 13 Feb 2018 00:33:16 -0800 (PST) X-Google-Smtp-Source: AH8x227Owkg2yrZaGr8BT4d72xCl6H1+HbBjjTkIgcbTKl2UZfZMUgiIjahDkV7+wFMMnRe1x09w X-Received: by 10.98.33.199 with SMTP id o68mr493785pfj.78.1518510796676; Tue, 13 Feb 2018 00:33:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518510796; cv=none; d=google.com; s=arc-20160816; b=ix1mckIiUlQmEiF61ZnMyijJFuGE5BKcJbPiniAvoVxOcnkz9XWaWF/rMlv5GS5eHU iAX8vMHqzmdOS5ibr1cw5LlWUDg9iIKPXwwnQ+4kw+xWlxWyhj9kLAavYgy17PmQuHYh L0Njvy1Gfs4H9ijPjt5v8r37AEj4/x6Nrhz349hy/jUBfSOS3QWwe+NxJS2F6PmhUpI1 PS2r+FRukjZX01dIy7f3TpfahXMoq4NfVKjpIn2P7yvtjGqqWDfsC3MyZixkl2Qg4FCR doEcIyVC7YSLicabDZyZIVcnbOgSTvcJZXwoLcEplJrBcxGvNLRlLp12CgPxjfcWwaiM TD0Q== 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:dkim-signature :arc-authentication-results; bh=MaechsA5XcwsMkh6AvJdZRDthLwnkQdJptK7LZebCRk=; b=0ayk0rGXfApKcwxnqVfEjcQrQpmvyIajJw462uZvsLnUCBFi2pcgujRgbNl6NITZQw 2KssiAs5ijDZHgxxhvziImlHCxZILiRlGJsA4ekZRw9H4kgEC8pXfBQCbV0fFDudhHPU O5PcDP0Y1TlRQdVktsKJTHojH7HJItfGt0LigKct/WniFWsafaO7PgSnsVMnvIknQMHg UvNLfW71SCa0EPts+pghMMB+HBZ3/TIAZ6HEHrkmWpiCbWyncOFR7swAOOU5m6ACBiaJ GW9xIDLUO9Sw4eeUGbnIi92BKwEZXVHnlnWJzgU1ztk0DkaD0UZotSwR1StouRYMpEcx hINQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=QHgZeKVr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m186si1366121pfm.25.2018.02.13.00.33.01; Tue, 13 Feb 2018 00:33:16 -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=@chromium.org header.s=google header.b=QHgZeKVr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933752AbeBMIcX (ORCPT + 99 others); Tue, 13 Feb 2018 03:32:23 -0500 Received: from mail-ua0-f196.google.com ([209.85.217.196]:42567 "EHLO mail-ua0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933631AbeBMIcV (ORCPT ); Tue, 13 Feb 2018 03:32:21 -0500 Received: by mail-ua0-f196.google.com with SMTP id 47so11111159uau.9 for ; Tue, 13 Feb 2018 00:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=MaechsA5XcwsMkh6AvJdZRDthLwnkQdJptK7LZebCRk=; b=QHgZeKVrTI7Hu+l104QRtNvqr/sf1xnHTernI6PUjEGuaobVKiADjRRvkOQNUcaYFM /MRttJ90NVqxZrPshpKGSPjEFXE9f1E309CkvhBAux9dZBFYOQsHuIkWH+ggOCsZFctc 4hHJay6sdxdyTOUrLiXAoDL96kZ9Ojfov+7O8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=MaechsA5XcwsMkh6AvJdZRDthLwnkQdJptK7LZebCRk=; b=UTwAjjl6/4VLwkp/Qe3td9ClIR+0HljQ1xp5UdgWkoxCJb1662+X9LWkiZnio1KPFm UXPwDVtSQEZxf2IcQtik8BxmCzIGZi0w8ygAQILZxtcHDCVPsOQBQLKETh1sAOLKudov LyS0S84r8K58X1M97vOqoZgCNXTi0XPOSGFVnvMwTzGtIYgoI3ImsJ8x1seERCAch8ht ChEWR61f+SKsAWmNWk2jqxRAoKSLwEYEqohXAMEfyhm15AipqSH92bMUm+KzZVNE74uB P0X/kjSa/kT975mTWjP9dfiJc4uJsHvEtonhh7HQu2FzaSZkaUYCcDE1yLabKPKjWxWb EOww== X-Gm-Message-State: APf1xPC8T8eMnD1PLfb7gosE0YnLbByGannHIjRgj9U3M6QZiX9Vzqny Ngwm9GOSQk/t1vLETIwFGKeyKc/cPoc= X-Received: by 10.176.0.105 with SMTP id 96mr412532uai.66.1518510740747; Tue, 13 Feb 2018 00:32:20 -0800 (PST) Received: from mail-vk0-f54.google.com (mail-vk0-f54.google.com. [209.85.213.54]) by smtp.gmail.com with ESMTPSA id x14sm7136600uab.38.2018.02.13.00.32.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 00:32:19 -0800 (PST) Received: by mail-vk0-f54.google.com with SMTP id w201so10391134vkw.0 for ; Tue, 13 Feb 2018 00:32:18 -0800 (PST) X-Received: by 10.31.95.84 with SMTP id t81mr370303vkb.173.1518510737860; Tue, 13 Feb 2018 00:32:17 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.0.68 with HTTP; Tue, 13 Feb 2018 00:31:57 -0800 (PST) In-Reply-To: <1517999482-17317-5-git-send-email-vivek.gautam@codeaurora.org> References: <1517999482-17317-1-git-send-email-vivek.gautam@codeaurora.org> <1517999482-17317-5-git-send-email-vivek.gautam@codeaurora.org> From: Tomasz Figa Date: Tue, 13 Feb 2018 17:31:57 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 4/6] iommu/arm-smmu: Add the device_link between masters and smmu To: Vivek Gautam Cc: "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Rob Herring , Mark Rutland , "Rafael J. Wysocki" , Robin Murphy , Will Deacon , Rob Clark , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, dri-devel , freedreno@lists.freedesktop.org, David Airlie , Greg KH , sboyd@codeaurora.org, linux-arm-msm@vger.kernel.org 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 Vivek, Thanks for the patch. Please see my comments inline. On Wed, Feb 7, 2018 at 7:31 PM, 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 > --- > 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)); How likely it is that the master can work normally even if the link add fails? Perhaps we should just return an error here? > + > 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); We allowed smmu->link in arm_smmu_add_device(), but here we don't check it. Looking at the code, device_link_del() doesn't seem to check either. Note that this problem would go away if we fail add_device on device_link_add() failure, as I suggested above, so no change would be necessary. Best regards, Tomasz