Received: by 10.223.148.5 with SMTP id 5csp7424046wrq; Thu, 18 Jan 2018 05:23:44 -0800 (PST) X-Google-Smtp-Source: ACJfBotYHw00u1mUF/O4DMU9P5OYAw14Rbwac2CrYSL4El6zBpm/dgZAZlp1CzSxpmyokTjxZLVm X-Received: by 10.101.99.211 with SMTP id n19mr22696729pgv.147.1516281824449; Thu, 18 Jan 2018 05:23:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516281824; cv=none; d=google.com; s=arc-20160816; b=JHTF7x8psI9HR3lOVEG/VwNt9T+xY/Zxq2YsOklfyx8sBU8v1FwIeogdEaNKsQ43MS Gdl/UnyG2W/sIDOE2XHE0DYrAymkPHafNgPwgB1w8kK+kfVAS/rY1jihYeJOXfQm1gtF q1ULLcBQcam9c3C5JJYEhv/vS8ny6xZcIibDPLtPdYlD6UuTKXPmdNdCRqGNQ+JY3OXJ CD/YIS1Xd7F2LuMM8ERiKqpE31amRihMef/IkPSptXp7OU31HmFN9zdSXIICkUAUoreF hpb2XDSE7JDWoOqnjyDUEZDk7D32R0axUQf4mPAPJhDVunbtjY3ESEnlf/g/28go6WEP h1uw== 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=85HoDtFALIyr+MqpI7jkAo9vJXk7cBoyBiRGiPm5PQ0=; b=dsFtLRk7LrNUrhuJbsj1echlDm2CwFfKrnFKUJDK+tz7/ho3aOd3/6o/+ERxGbP3rn UwWFlj3cq3Syee22aVTKz/tBSYCXKXvFWtbR7tMrf814gz2IYWgtUMSd6bxm7uDxC23A hWE4x5bxxQAoLwZC1GqwHdPyGJM9y4S70gMpUp4fJuP9C4tG7Ijwz5DhAIo6vEQAkya5 /W18q/P1urof4Y84NfuOI/B6tN3XdCTkxWKVzTvuAa3zTAAAA6aTlwB7k1HYslNnrgLW WbfE/Hj1EKx8LAAaxqsoXAMW3cw/HW9pLd+zd/4UwtjSeUkMaN8/JEUKwaxOofpLWpBO 5Q4g== 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 z90si6716758pfl.204.2018.01.18.05.23.30; Thu, 18 Jan 2018 05:23:44 -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 S1756143AbeARNXF (ORCPT + 99 others); Thu, 18 Jan 2018 08:23:05 -0500 Received: from foss.arm.com ([217.140.101.70]:55360 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755874AbeARNXE (ORCPT ); Thu, 18 Jan 2018 08:23:04 -0500 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 EB4B61529; Thu, 18 Jan 2018 05:23:03 -0800 (PST) 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 43B9E3F487; Thu, 18 Jan 2018 05:23:02 -0800 (PST) Subject: Re: [PATCH v4 04/13] iommu/rockchip: Fix error handling in attach To: Jeffy Chen , linux-kernel@vger.kernel.org Cc: jcliang@chromium.org, xxm@rock-chips.com, tfiga@chromium.org, Heiko Stuebner , linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, Joerg Roedel , linux-arm-kernel@lists.infradead.org References: <20180118115251.5542-1-jeffy.chen@rock-chips.com> <20180118115251.5542-5-jeffy.chen@rock-chips.com> From: Robin Murphy Message-ID: Date: Thu, 18 Jan 2018 13:23:00 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20180118115251.5542-5-jeffy.chen@rock-chips.com> 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 18/01/18 11:52, Jeffy Chen wrote: > 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; Nit: if you like, it looks reasonable to name the label "out_disable_stall" and remove these lines above here, to save the duplication between the error and success paths (since ret will already be 0 on the latter). Either way, Reviewed-by: Robin Murphy > + > +err_disable_stall: > + rk_iommu_disable_stall(iommu); > + > + return ret; > } > > static void rk_iommu_detach_device(struct iommu_domain *domain, >