Received: by 10.223.185.116 with SMTP id b49csp7249193wrg; Thu, 1 Mar 2018 02:21:25 -0800 (PST) X-Google-Smtp-Source: AG47ELv6p4f/gfl+2Ciprl+96xnwCjE2xXtY3Lqfk6zR4A6ip4YBYU5R/VUx2es3MP1m4JmEn1c3 X-Received: by 10.99.96.66 with SMTP id u63mr1152498pgb.49.1519899685781; Thu, 01 Mar 2018 02:21:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519899685; cv=none; d=google.com; s=arc-20160816; b=npD10878LNX/XoLyyqnQB/hLnbYo3GHmj0jJWrpAQpwPoeoMr6OGvuBiK6ZWOmszoB fmHdPmLsG7jq6Pi64UpVAY0FDqqkWrPhTL0jF0pSb1xi349vlTpvEDOBSreFczE83C2P whOuDbapZavb4rD/RwmmArQmEx469/7A58wN4VgkgB6IuYoJ5rU/NGxxAI6+YSpn3nUY wo+bfXgF8r948ub/gB16Ujg8TPChP5IJ+hVrmGCShiJG1/wbQ6NvEGrzrbJRoT4oNei2 Bx0I+txIoqdITsAVZ5CSYQBgMlOGr4hYjGXJGNbVeBgqgFswpnrKxQH5fsm4qbazKuC2 GcvQ== 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=MQNfT/wJKLrEKtV+U+Af9x9SIuYijm9l/TgCHg/HnZwBDn97FCPERK3HBn3paRLBIL X1T8yPVL+0rkzBNypeziuP7+Ppwzre2laNZrLDLx19+crXKiUPI7M2gELIahrU9qljB2 kmKHDodDceEPqMtfPSF379Tc2ZfN2nIxL9RGl7sQJYU8E2eUrNB0u6D1lZXZRndv2DYb 4UdCxSFOYpUaCZCRrdF/qLgusVQ+A+uzKzlQzpX6/Nft0WHsO32dF2rBxCAuXcEKCQJq J3C8Y0NMZbEH4LXhSvIElTCYVkjw5w9TbgsYj52/gcVzDTYbd/KcTDzR2Ba3INrC7sqA YAzA== 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 v10-v6si2883388plo.61.2018.03.01.02.21.11; Thu, 01 Mar 2018 02:21:25 -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 S966305AbeCAKTo (ORCPT + 99 others); Thu, 1 Mar 2018 05:19:44 -0500 Received: from regular1.263xmail.com ([211.150.99.130]:59360 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966066AbeCAKTj (ORCPT ); Thu, 1 Mar 2018 05:19:39 -0500 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.224]) by regular1.263xmail.com (Postfix) with ESMTP id DE554B256; Thu, 1 Mar 2018 18:19:34 +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 5C5A63AF; Thu, 1 Mar 2018 18:19:32 +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: <84572eb4f397141e4f3f94cbc39f9253> 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 150597SV0QD; Thu, 01 Mar 2018 18:19:35 +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: [RESEND PATCH v6 04/14] iommu/rockchip: Fix error handling in attach Date: Thu, 1 Mar 2018 18:18:27 +0800 Message-Id: <20180301101837.27969-5-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180301101837.27969-1-jeffy.chen@rock-chips.com> References: <20180301101837.27969-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