Received: by 10.213.65.68 with SMTP id h4csp1573725imn; Thu, 15 Mar 2018 03:45:53 -0700 (PDT) X-Google-Smtp-Source: AG47ELtTad7Ns6RDb2mnWALskH7VrGxrSbizsM4o3EV2UTvs5eGQQtl9fC/L06rYTZRqZILzXsFA X-Received: by 10.98.147.156 with SMTP id r28mr7367033pfk.204.1521110753758; Thu, 15 Mar 2018 03:45:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521110753; cv=none; d=google.com; s=arc-20160816; b=UYa2hbhVygjGGRTTl/x5UJO6oprrsoJyxHwLMN0kupuPLRtp5icyLHHU+uzvRKxwxe 1IAz/FvP9EHYvGHo+2m2kBHCbee5A7iRrZlpuTkP5A22q2I8o3Gnm2QmKk8TgjmvGKhU w000bqcPi2p/kXnJWCsXaXSnd3ifRcxgjYf3HqcsYUE2Ro/C4SgX3RzEjEt3INHm5qFs eknfErtsxnv1vfgVJfDbwjY8MYRxANTl4X/RnLBgf5dKSgGkHXxvLACQH4Y1n7sq0J5H +BWCE/jupDdZUTkzduWflpQuuyqmoMcDdi1XvA7TOXtIySbDVNobxScukmoHdenOaLbR Qbpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=328Fi077jsqtHTJebYiOUX+MhwScWGGWEEV8Syw9Ezw=; b=m7rDfF/Do3xQWQQ4nMD/FrIQetsiwclvAUKzIX/lL5HWoVpRkHVNSEju9eS1/xRBf1 GtKafiUNERoM9OQDKnLfL767zAGCm1GN467Pya3HKISP8E5gVNbTTlXpMsUZ6VgziaDS ixD/QBM8jm5r9mQJC6JjegTQUztVO79WqRfnlKLIIL6BkLmb1xzjakCtK3MaLHPiIQOn N2m8B91oRMg7wcSLSOszUgy4Wp1SsNQLiFoNvLwqDh7bMxGLdFBSdbFIli090hBCtq9O z/v6Fpj8W0azd2tFccRR5EmDT9nWXjifV5QWxKaDvdHlr7HnjxfgE+hrU5vuOguHIxi9 2vuw== ARC-Authentication-Results: i=1; mx.google.com; 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 d31-v6si3802034pld.495.2018.03.15.03.45.39; Thu, 15 Mar 2018 03:45:53 -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; 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 S1751880AbeCOKoi (ORCPT + 99 others); Thu, 15 Mar 2018 06:44:38 -0400 Received: from foss.arm.com ([217.140.101.70]:36790 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751541AbeCOKog (ORCPT ); Thu, 15 Mar 2018 06:44:36 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 71F1480D; Thu, 15 Mar 2018 03:44:36 -0700 (PDT) Received: from [10.1.210.88] (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 24DE93F24A; Thu, 15 Mar 2018 03:44:34 -0700 (PDT) Subject: Re: [PATCH v9 4/5] iommu/arm-smmu: Add the device_link between masters and smmu To: Tomasz Figa Cc: Vivek Gautam , Joerg Roedel , Rob Herring , "open list:IOMMU DRIVERS" , devicetree@vger.kernel.org, Linux Kernel Mailing List , Mark Rutland , Will Deacon , Rob Clark , Sricharan R , Marek Szyprowski , Archit Taneja , linux-arm-msm References: <20180313085534.11650-1-vivek.gautam@codeaurora.org> <20180313085534.11650-5-vivek.gautam@codeaurora.org> <8b427ea2-5c13-4712-13d1-e4c1aed0779e@arm.com> From: Robin Murphy Message-ID: <2cab6e92-c44c-edeb-bf50-946cec5cccac@arm.com> Date: Thu, 15 Mar 2018 10:44:32 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/03/18 06:18, Tomasz Figa wrote: > On Thu, Mar 15, 2018 at 2:50 AM, 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)) { >> >>> + 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?) > > I think we care whether adding the link succeeded. If it fails to be > added, we might end up with a complete system lockup on a system with > power domains. Well, yeah, that was implicit - the point is that we *only* care about whether it succeeded or not. Thus we may as well just check for NULL directly instead of assigning the value as if we were actually going to do anything with it. Robin.