Received: by 10.223.148.5 with SMTP id 5csp7307473wrq; Thu, 18 Jan 2018 03:58:41 -0800 (PST) X-Google-Smtp-Source: ACJfBouZC3mjbk3a2HAwfG4D+OzswWrJJutHq+z2wv0AskhlKQc1EwjEmK1wGm+T0+MmFnmfkVWb X-Received: by 10.101.74.71 with SMTP id a7mr19302151pgu.32.1516276721086; Thu, 18 Jan 2018 03:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516276721; cv=none; d=google.com; s=arc-20160816; b=JN7h/fjEySDSPjO7+3nCCcWw9/4Puo9GzQ5ylfe0hxf+ML4FUHfrBOPnG1lHmVNp8K 6o3MAqfKx920GPCQqY/SAZGp/gvI+xEBn7+/DNMPPkYJOFcl9YeBPebh74XRG6pS+6Dh NnCf1YlpoiiTptHoOdrlEUFupGaIK7x0mzvIiGFXpkALKss+yS2AUyuQXVzisAkBNYQi /h+g2wk3oHdAyJz/kBHFMjVsZRBOqbqIXFk+II2vTJpIpS6drTEuEtIp9JuVmhRUv+d1 Cz0RT43Yb1zqSs//qNza1STnc4SywOXlYawpNI/wkby3NxSPtb7q8QEM9J/BkBIpfbxt 85vA== 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=bkrLqapBWM4obRdo5UYfZvG+qOsC5qw2LdZJGcCEyYo=; b=HXlWHAj5lTaykn/Bz6qS6YcBJVPZ6+ZYs5v1bUKwN5fvA3qIByAzU3qbtsrirpD2oX WmPQ4G6dDY/ghuFP6EljSaio5k7hQGSl7kJFDBFkwh+xXVIF3sJr+CSXPXAG1KgWPeaT 2ruJ/JB8OsJGIJHbINx+guBA+xCyoMJzkh9OfNsywkrAvoQqnvSQ5z09C24j2uBKyl/A PWiGSVJ3Sm0g7Rzp5Oavp8BJxa1RjTQRqKrx8rhltjBvFMwke1U/5aQO8CA9mg/O3sfE 3r7tuCjr0IXekt+dPhtcyQa/d+wNU8Pu9I3uv8ErzOfSj2O1A5w9+jejT5AoI0r0mPKf KxPg== 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 c16si6776307pli.305.2018.01.18.03.58.27; Thu, 18 Jan 2018 03:58:41 -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 S1755989AbeARLxi (ORCPT + 99 others); Thu, 18 Jan 2018 06:53:38 -0500 Received: from regular1.263xmail.com ([211.150.99.134]:49465 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755898AbeARLxg (ORCPT ); Thu, 18 Jan 2018 06:53:36 -0500 Received: from jeffy.chen?rock-chips.com (unknown [192.168.167.140]) by regular1.263xmail.com (Postfix) with ESMTP id 366E98115; Thu, 18 Jan 2018 19:53:31 +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 01DB0359; Thu, 18 Jan 2018 19:53:26 +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: <359ac71d7a911aab844c6176ba78b6c6> 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 12255WA1DKC; Thu, 18 Jan 2018 19:53:33 +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 v4 04/13] iommu/rockchip: Fix error handling in attach Date: Thu, 18 Jan 2018 19:52:42 +0800 Message-Id: <20180118115251.5542-5-jeffy.chen@rock-chips.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180118115251.5542-1-jeffy.chen@rock-chips.com> References: <20180118115251.5542-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 --- Changes in v4: None Changes in v3: None Changes in v2: Move irq request to probe(in patch[0]) drivers/iommu/rockchip-iommu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index b743d82e6fe1..37065a7127c9 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 err_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 err_disable_stall; spin_lock_irqsave(&rk_domain->iommus_lock, flags); list_add_tail(&iommu->node, &rk_domain->iommus); @@ -848,6 +848,11 @@ static int rk_iommu_attach_device(struct iommu_domain *domain, rk_iommu_disable_stall(iommu); return 0; + +err_disable_stall: + rk_iommu_disable_stall(iommu); + + return ret; } static void rk_iommu_detach_device(struct iommu_domain *domain, -- 2.11.0