Received: by 10.213.65.68 with SMTP id h4csp202653imn; Thu, 15 Mar 2018 23:43:07 -0700 (PDT) X-Google-Smtp-Source: AG47ELsicJnJ/KZT4zosapdAZCoSuOAPshE7FUV2D4/WY79w9H30r4jV0xgDNY0twMA6zLB+rly2 X-Received: by 10.98.73.89 with SMTP id w86mr614473pfa.227.1521182587474; Thu, 15 Mar 2018 23:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521182587; cv=none; d=google.com; s=arc-20160816; b=RNtP6ZBbNKF1mJl93iUedzDTIQx9Ea8spw7VZZ5Mrw0Mg9eN6nL0tcYmdXBwVprlay qZUNLlHusoLMy0NlV7B1YT+Yd+y3JxhAtQHvjSOGUCk94ySwn+A9DrjgHC4PTiFadpBd JPvTl8OrtfqS2lkni1tsEaca1FnaBkuShBeVZkFz/c0S9uR3wLWn2lBhvKJhqzdxAfK3 gS25uuCic+O84qnUueN8w6L/nHDK3N34N5eUWOqk5KZza6+P8V1/BxEEpfNKASM4pM97 xMA88OIUOVy2hd6DWOD2ReQlSWEpi3m0JP+Behd+PPpdIzvituVq6aS6ndw3MocbwljU APRQ== 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=s8XXk33lPc2ATi2UH0KsjKV5p/VM6+o41kTj3qg13Oc=; b=pRlsZftsd6fhOjvzimkQ+ADiVwZgbyP9i9rI5le4lsffbpKJu/pSc965gb6X+r5t0C D3Ymn+c7adbAYKYencxhK0ZgLYdCUEaDD2QmHQJ7g/HOEyIaYq+63fmeF0xkNJNhs3dP HPp6DaWJXNVrDEHGqC+kjsQsi7Gt4D9HwRGlYvBfyNFkudadYEEBQc88XpHFV3b+If0z qJya27zcOi8liyp9ET1jAAvo9R4QZ+1tbt+3mFdsrhwSU70Wonr3v+sV/x+BK41TA9aT Sww1idu9crKgpJ6/MlDkctviPpxTmHyxYq3Epnycap/JOUlkLbS0GV1ag55opY6FLUcU 1BPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nGWGjjr0; 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 d12-v6si1420695plm.88.2018.03.15.23.42.53; Thu, 15 Mar 2018 23:43:07 -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=@chromium.org header.s=google header.b=nGWGjjr0; 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 S1752887AbeCPGl5 (ORCPT + 99 others); Fri, 16 Mar 2018 02:41:57 -0400 Received: from mail-ua0-f196.google.com ([209.85.217.196]:46083 "EHLO mail-ua0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752658AbeCPGly (ORCPT ); Fri, 16 Mar 2018 02:41:54 -0400 Received: by mail-ua0-f196.google.com with SMTP id d1so5935669ual.13 for ; Thu, 15 Mar 2018 23:41:54 -0700 (PDT) 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=s8XXk33lPc2ATi2UH0KsjKV5p/VM6+o41kTj3qg13Oc=; b=nGWGjjr0RErTEjmLR3Cyt1+7XJhGxOaeQEqe5zfxnRbEOTkkAoBTEGzfI2xRJb1q+N zumdFMPwUFqI1OVyf71nuDZwjOlrzEH56id/D6cMc0i1SxkR8OdMzNPwEORg10EDTeqF IEFQDR2AmbJ3gsDL5Pm6/hmPL0QGu3jhmLtUs= 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=s8XXk33lPc2ATi2UH0KsjKV5p/VM6+o41kTj3qg13Oc=; b=qY1Y2T8bdZrLknfcwTJSQ28pvcRxPI6XEPuZ5XTE+PD2xcC0HgTjZ5uK5Gph30WGb3 KPur1rTHaheLntiwtX8JiRL3rHGiixYr7y3J8hqsASNyYaoO2iGCMfPhuE+SYNm0/jLM wdO1rXVWpjdfxAmsNj9VA8hk4xMVGX0GewzL848QGNdQ7UZuLWnEpZa2xxGs4D8FtW5R +MPCb8aTdJx16HSaYEWDnqtZJ6jtQSenpQ6G0kdIE+vdTx7uM9nFsggeCM/dJUQbfKtQ aUol/NvNPLZ5xwMXvfZLsGxP+ZwsLN4vB7znQ2PzbSZmIRIwYMCTvc/dmLmU0o6CpRy0 YCxA== X-Gm-Message-State: AElRT7GU6DtOyP8Dobk8wweSISyINCkr+P0R/F0E4cjjp+EJDO6MXMWF IQ+uj+nRCnyYrHFRzSvRXiUIX090Hng= X-Received: by 10.176.80.20 with SMTP id b20mr388814uaa.92.1521182513228; Thu, 15 Mar 2018 23:41:53 -0700 (PDT) Received: from mail-ua0-f170.google.com (mail-ua0-f170.google.com. [209.85.217.170]) by smtp.gmail.com with ESMTPSA id o14sm1157142vkb.53.2018.03.15.23.41.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 23:41:51 -0700 (PDT) Received: by mail-ua0-f170.google.com with SMTP id q12so5958567uae.4 for ; Thu, 15 Mar 2018 23:41:51 -0700 (PDT) X-Received: by 10.176.69.182 with SMTP id u51mr369402uau.93.1521182510568; Thu, 15 Mar 2018 23:41:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.0.99 with HTTP; Thu, 15 Mar 2018 23:41:29 -0700 (PDT) In-Reply-To: <20180314081434.30875-5-vivek.gautam@codeaurora.org> References: <20180314081434.30875-1-vivek.gautam@codeaurora.org> <20180314081434.30875-5-vivek.gautam@codeaurora.org> From: Tomasz Figa Date: Fri, 16 Mar 2018 15:41:29 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v10 4/5] iommu/arm-smmu: Add the device_link between masters and smmu To: Vivek Gautam Cc: Joerg Roedel , Rob Herring , rafael.j.wysocki@intel.com, Robin Murphy , "open list:IOMMU DRIVERS" , devicetree@vger.kernel.org, Linux Kernel Mailing List , Mark Rutland , Will Deacon , Rob Clark , Sricharan R , Marek Szyprowski , Archit Taneja , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , 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 Vivek, On Wed, Mar 14, 2018 at 5:14 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 > Reviewed-by: Tomasz Figa > --- > > Changes since v9: > - Using device_link_del_dev() to delete the device link, instead of > doing it in two steps - device_link_find() to first find the link, and > then calling device_link_del(). > > drivers/iommu/arm-smmu.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > index 56a04ae80bf3..4cf270ffd449 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) { > + dev_warn(smmu->dev, > + "Unable to add link to the consumer %s\n", > + dev_name(dev)); > + ret = -ENODEV; > + goto out_unlink; > + } > + } If it's an error, we should use dev_err(). Also, as per Robin's comment for v9 could we make it as follows? if (pm_runtime_enabled(smmu->dev) && !device_link_add(dev, smmu->dev, DL_FLAG_PM_RUNTIME)) { dev_err(smmu->dev, "Unable to add link to the consumer %s\n", dev_name(dev)); ret = -ENODEV; goto out_unlink; } Best regards, Tomasz