mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Jeffy Chen <jeffy.chen@rock-chips.com>, linux-kernel@vger.kernel.org
Cc: jcliang@chromium.org, tfiga@chromium.org,
	Heiko Stuebner <heiko@sntech.de>,
	linux-rockchip@lists.infradead.org,
	iommu@lists.linux-foundation.org, Joerg Roedel <joro@8bytes.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/9] iommu/rockchip: Fix error handling in attach
Date: Thu, 11 Jan 2018 15:47:27 +0000	[thread overview]
Message-ID: <427ecf29-2024-b746-c567-903c1ce02e75@arm.com> (raw)
In-Reply-To: <20180111082229.24011-3-jeffy.chen@rock-chips.com>

On 11/01/18 08:22, Jeffy Chen wrote:
> From: Tomasz Figa <tfiga@chromium.org>
> 
> 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 <tfiga@chromium.org>
> Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
> ---
> 
>   drivers/iommu/rockchip-iommu.c | 26 +++++++++++++++++---------
>   1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
> index 9d991c2d8767..ee805e1dfba7 100644
> --- a/drivers/iommu/rockchip-iommu.c
> +++ b/drivers/iommu/rockchip-iommu.c
> @@ -826,17 +826,10 @@ 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;
>   
> -	for (i = 0; i < iommu->num_irq; i++) {
> -		ret = devm_request_irq(iommu->dev, iommu->irq[i], rk_iommu_irq,
> -				       IRQF_SHARED, dev_name(dev), iommu);
> -		if (ret)
> -			return ret;
> -	}
> -
>   	for (i = 0; i < iommu->num_mmu; i++) {
>   		rk_iommu_write(iommu->bases[i], RK_MMU_DTE_ADDR,
>   			       rk_domain->dt_dma);
> @@ -844,9 +837,16 @@ static int rk_iommu_attach_device(struct iommu_domain *domain,
>   		rk_iommu_write(iommu->bases[i], RK_MMU_INT_MASK, RK_MMU_IRQ_MASK);
>   	}
>   
> +	for (i = 0; i < iommu->num_irq; i++) {
> +		ret = devm_request_irq(iommu->dev, iommu->irq[i], rk_iommu_irq,
> +				       IRQF_SHARED, dev_name(dev), iommu);

Why aren't we simply requesting the IRQ once in rk_iommu_probe()? Given 
that the hardware doesn't handle multiple translation contexts, there 
doesn't seem to be much point in being this dynamic about it.

Robin.

> +		if (ret)
> +			goto err_free_irq;
> +	}
> +
>   	ret = rk_iommu_enable_paging(iommu);
>   	if (ret)
> -		return ret;
> +		goto err_free_irq;
>   
>   	spin_lock_irqsave(&rk_domain->iommus_lock, flags);
>   	list_add_tail(&iommu->node, &rk_domain->iommus);
> @@ -857,6 +857,14 @@ static int rk_iommu_attach_device(struct iommu_domain *domain,
>   	rk_iommu_disable_stall(iommu);
>   
>   	return 0;
> +
> +err_free_irq:
> +	while (i--)
> +		devm_free_irq(iommu->dev, iommu->irq[i], iommu);
> +err_disable_stall:
> +	rk_iommu_disable_stall(iommu);
> +
> +	return ret;
>   }
>   
>   static void rk_iommu_detach_device(struct iommu_domain *domain,
> 

  reply	other threads:[~2018-01-11 15:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11  8:22 [PATCH 0/9] iommu/rockchip: Use OF_IOMMU Jeffy Chen
2018-01-11  8:22 ` [PATCH 1/9] iommu/of: Drop early initialisation hooks Jeffy Chen
2018-01-11  9:40   ` Marek Szyprowski
2018-01-11 11:14     ` JeffyChen
2018-01-11 12:24       ` Robin Murphy
2018-01-12  1:22         ` JeffyChen
2018-01-11 12:26       ` Marek Szyprowski
2018-01-11  8:22 ` [PATCH 2/9] iommu/rockchip: Fix error handling in attach Jeffy Chen
2018-01-11 15:47   ` Robin Murphy [this message]
2018-01-12  0:33     ` JeffyChen
2018-01-11  8:22 ` [PATCH 3/9] iommu/rockchip: Fix error handling in probe Jeffy Chen
2018-01-11  8:22 ` [PATCH 4/9] iommu/rockchip: Fix error handling in init Jeffy Chen
2018-01-11  8:22 ` [PATCH 5/9] iommu/rockchip: Use iopoll helpers to wait for hardware Jeffy Chen
2018-01-11  8:22 ` [PATCH 6/9] iommu/rockchip: Fix TLB flush of secondary IOMMUs Jeffy Chen
2018-01-11  8:22 ` [PATCH 7/9] iommu/rockchip: Use iommu_group_get_for_dev() for add_device Jeffy Chen
2018-01-11  8:22 ` [PATCH 8/9] iommu/rockchip: Use IOMMU device for dma mapping operations Jeffy Chen
2018-01-11  8:22 ` [PATCH 9/9] iommu/rockchip: Use OF_IOMMU to attach devices automatically Jeffy Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=427ecf29-2024-b746-c567-903c1ce02e75@arm.com \
    --to=robin.murphy@arm.com \
    --cc=heiko@sntech.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jcliang@chromium.org \
    --cc=jeffy.chen@rock-chips.com \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=tfiga@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®