Received: by 10.223.185.116 with SMTP id b49csp7241009wrg; Thu, 1 Mar 2018 02:11:11 -0800 (PST) X-Google-Smtp-Source: AG47ELuUsM/SfOdr5nXRfR2Ko84VdHxRVwN10LzgcwEz9KgE2MzsvbG68jc2GfbQuaU9EZr6TVkj X-Received: by 2002:a17:902:9693:: with SMTP id n19-v6mr1416814plp.69.1519899071804; Thu, 01 Mar 2018 02:11:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519899071; cv=none; d=google.com; s=arc-20160816; b=u2YemHRG65+23Hl8Kwq3Ep3n33+Q8o3OBxO1wNJtUFAheANbNGR/vthW3u+upqs+BE /Doo9JzHWK6rj/P3ELzZwR0Og/G6G0aA8o9hbhydBb3Mg8DKB7tdfHjdk68PM5HO9c0p OIZhrN5j0Bj1QNh3HWYLTRKVOePC1T0gjZFZk/WoFsziZvTeme3x2xBTNe2K2FTwR92Z DgVrYTdq/QgSxUtH9kQrysu+nxxOniUl7u5g6ZYjPlkMTduEHsqqUJufVEcfGmrPwZVm DU3fb5dibSNMHCV4JVTpvSNz6QptCRA7iu83z01j8oybEmVqk94tk4XPUSeDnPmlMhLp l9oQ== 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:arc-authentication-results; bh=kPCDMfTxlnDdYKZx9X14JHc0Y8DPVOqai8/KrxXSCng=; b=RxgD/xKNImxZxo4knLADVAhNhgDMWm9EMYNWO+4lCvQ/60Rk3D+96BHNXceZCErbx2 /6PzbUXuc4/MR52s47D96dDmi+4kTZPhKsCcw2BB26pKoHooTOnXtX2InCiGiQ7kwj+c WKqUsZb4u51me60wc1VTohdJ28H5ogzaR5a4TVJyz1vNql+S75wJrQ3SFMkczdNJS0ZC 6NQXNAaQWBLM7PAxB2nlQbe7aseN0xjxXiG8oaJKJLJbYzCiwWrN/GqLLs0UcnBMUEuM ow5YAw1l7Iv0xjg/bx+Fg1hbXIMhaHcrXQxobZoFs9mVBydIwLjXINqmg57FZ/mcWlbY mUCw== 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 z22si2289789pgc.398.2018.03.01.02.10.57; Thu, 01 Mar 2018 02:11:11 -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; 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 S967453AbeCAKJa (ORCPT + 99 others); Thu, 1 Mar 2018 05:09:30 -0500 Received: from regular1.263xmail.com ([211.150.99.131]:52084 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030242AbeCAKJX (ORCPT ); Thu, 1 Mar 2018 05:09:23 -0500 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.129]) by regular1.263xmail.com (Postfix) with ESMTP id 762EA624C; Thu, 1 Mar 2018 18:09:19 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTPA id 0AF23376; Thu, 1 Mar 2018 18:09:15 +0800 (CST) X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <05b4643cd4b245cd6eea1c99bb5e8d2a> X-ATTACHMENT-NUM: 0 X-SENDER: cjf@rock-chips.com X-DNS-TYPE: 0 Received: from localhost (unknown [103.29.142.67]) by smtp.263.net (Postfix) whith ESMTP id 69177PEWWG; Thu, 01 Mar 2018 18:09:20 +0800 (CST) From: Jeffy Chen To: linux-kernel@vger.kernel.org Cc: jcliang@chromium.org, robin.murphy@arm.com, xxm@rock-chips.com, tfiga@chromium.org, Jeffy Chen , Heiko Stuebner , linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, Joerg Roedel , linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 04/14] iommu/rockchip: Fix error handling in attach Date: Thu, 1 Mar 2018 18:08:14 +0800 Message-Id: <20180301100824.14887-5-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180301100824.14887-1-jeffy.chen@rock-chips.com> References: <20180301100824.14887-1-jeffy.chen@rock-chips.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tomasz Figa Currently if the driver encounters an error while attaching device, it will leave the IOMMU in an inconsistent state. Even though it shouldn't really happen in reality, let's just add proper error path to keep things consistent. Signed-off-by: Tomasz Figa Signed-off-by: Jeffy Chen Reviewed-by: Robin Murphy --- Changes in v6: None Changes in v5: Use out labels to save the duplication between the error and success paths. Changes in v4: None Changes in v3: None Changes in v2: Move irq request to probe(in patch[0]) drivers/iommu/rockchip-iommu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index b743d82e6fe1..f7ff3a3645ea 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -824,7 +824,7 @@ static int rk_iommu_attach_device(struct iommu_domain *domain, ret = rk_iommu_force_reset(iommu); if (ret) - return ret; + goto out_disable_stall; iommu->domain = domain; @@ -837,7 +837,7 @@ static int rk_iommu_attach_device(struct iommu_domain *domain, ret = rk_iommu_enable_paging(iommu); if (ret) - return ret; + goto out_disable_stall; spin_lock_irqsave(&rk_domain->iommus_lock, flags); list_add_tail(&iommu->node, &rk_domain->iommus); @@ -845,9 +845,9 @@ static int rk_iommu_attach_device(struct iommu_domain *domain, dev_dbg(dev, "Attached to iommu domain\n"); +out_disable_stall: rk_iommu_disable_stall(iommu); - - return 0; + return ret; } static void rk_iommu_detach_device(struct iommu_domain *domain, -- 2.11.0