Received: by 10.223.176.46 with SMTP id f43csp569568wra; Wed, 24 Jan 2018 02:38:11 -0800 (PST) X-Google-Smtp-Source: AH8x225O1xH6pATST+ivbqMVGGEwCQXg3z7C9YxQ/2CdXNuLuglEFoGMdh4ywOFQtvVGuccDHvIo X-Received: by 10.99.161.26 with SMTP id b26mr1411411pgf.322.1516790291745; Wed, 24 Jan 2018 02:38:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516790291; cv=none; d=google.com; s=arc-20160816; b=l2soVp3EANJlWJ2oSxlQ/2qTF8n2D7GETVDdjDDRw6TKn5gBHxQsIdqQCKLb5AlyFQ In15h/VS/mDUBtQVI6RIXJ9Jhi7qLmC8RNGdheK1gLzFA95Ld8v0/15TWjscow43i45M XZzfcSY1WRbQR5I0WB5tHtaLndVdoe5fh3KpaoMw+k2HPIaKoWDyxYnMFNozTwQq0iUs FbhZgnMiKMmdhKKux3HiKMUsVideakdaUoqs6SNqC5z5ITgcBKiqEQCI+JKJMvoiQPDA Drgkuius213jn77n5dTrGCD9Htf2Oj7Q2tXExy6da2LoT8JDywhMLlZqk40k54VWpRBq c9xg== 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=jiEkd8yEd0ZSmGcoB24xRnPPsOIuKn6N5POhSghE42w=; b=v3ltW1/mQ/1MNP0eVyIX4YtBB346MI3DgWXEQWyeKghUkkgq792jEJOHvK+JMNZW/A a6GqQr1w0TUIrIUR4io5HEcPVhFvfeTQIHFBo5lnoTR5ZTFc7cB+e+alj5CvtN0j7fRy AW32m9QXTEndZT7slgYSwksSjM2e/YQZj67Jx/s4Pxl5jPNG2Yh7alqPPQBu6resE1BC TCOKfnaHJyaXB3Qy2aDNqqJm3Spjy3sSnlul/aAoBMRsM0jv7Ec44dvJ+REc296nntdP BWF0+lAGamhIQZ1/TE3behzL+o4wN3gcAcLFjH0JHyKtx6pe2QEsidgUA4cMpw9bYU7K Ttdw== 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 77si2714579pfz.87.2018.01.24.02.37.58; Wed, 24 Jan 2018 02:38: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 S933164AbeAXKgI (ORCPT + 99 others); Wed, 24 Jan 2018 05:36:08 -0500 Received: from regular1.263xmail.com ([211.150.99.140]:35505 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932884AbeAXKgG (ORCPT ); Wed, 24 Jan 2018 05:36:06 -0500 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.139]) by regular1.263xmail.com (Postfix) with ESMTP id AA15B4A36; Wed, 24 Jan 2018 18:36:01 +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 A4BE2622; Wed, 24 Jan 2018 18:35:57 +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: <9d901ef41b5ca916920e646ba85913dd> 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 15797A557S0; Wed, 24 Jan 2018 18:36:02 +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 v5 04/13] iommu/rockchip: Fix error handling in attach Date: Wed, 24 Jan 2018 18:35:07 +0800 Message-Id: <20180124103516.2571-5-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180124103516.2571-1-jeffy.chen@rock-chips.com> References: <20180124103516.2571-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 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