Received: by 10.223.185.116 with SMTP id b49csp5008994wrg; Wed, 7 Mar 2018 05:02:00 -0800 (PST) X-Google-Smtp-Source: AG47ELuh3CkiTWNtJDm1cnQLuPGaM2TydmyXva7anraOkUG7zg6qZaVhJmSzg8mr1beYGsFNGPwe X-Received: by 10.99.60.8 with SMTP id j8mr18130168pga.209.1520427720027; Wed, 07 Mar 2018 05:02:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520427719; cv=none; d=google.com; s=arc-20160816; b=h0nZGU69TK2K/Me+5Wysb+Cg+kACgdBlp5NpE2IuvD7CNY31W1ty65pV6mjKeliT36 RR2msjmWFzDvLXAMQJasCrwlM1yAEWuTWo4fLIc+4pUW4tiWKlbH/gqUS6PV5fg7+YkZ 6lq071dCbFquNQ1eNpoinbO0j9Zeg35lEM32K3CWL/9tbHSaitNChGROstOD0twz9GM+ 1nvxXY0HEyC+jtLSwMN4cE6PC3wYTCq2XLC6mkIWcE7yyQ8pAjG8AEwWsOOTAgtUEVui 8QAm5nY6r6gGktSxLV2f+F9jI+qiqUGCUBGBhnuJzbCj7Rf9taRDcFh4B7Vebthwt+Ks Ykng== 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=HqetUW068iER1t5EtOUP1VjfgZxoI2Y75jh5T6MKLmY=; b=jkv04CO5qxLnu/hJDGb+uwqhrnyYRw40SF0pikllBAMK5JoGluFjDzewO4VE2/4AJq Nqo9Il04+E3Anygt6xVFZjf2sPCEel0LxFsktKZksO4dk0eDwO88BJO6DvWZmV2RuEOA eIJXN5UAPGp77de50ujTqky8c8wamuZmzE1TxQEqVRSaWzw2AisAS3wI8cG8d8qv1ExH z7DO/10S8/DiHm9Oe24iUyC7/EGSrX5O4kIhsMHGFyBncoKIIFk2osT3yJ7W0g8l+9VT 8OBpSoUtsqVNNcjKpOJkfN5RexwEqglVjmH7C6+lhikOzW6cperQAVV2SMsSddTsPs9q N0Nw== 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 h67si13883289pfj.11.2018.03.07.05.01.45; Wed, 07 Mar 2018 05:01:59 -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 S1754362AbeCGNAc (ORCPT + 99 others); Wed, 7 Mar 2018 08:00:32 -0500 Received: from foss.arm.com ([217.140.101.70]:50328 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933251AbeCGNA1 (ORCPT ); Wed, 7 Mar 2018 08:00:27 -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 5259F1435; Wed, 7 Mar 2018 05:00:27 -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 A20BC3F487; Wed, 7 Mar 2018 05:00:25 -0800 (PST) Subject: Re: [PATCH v7 03/14] iommu/rockchip: Request irqs in rk_iommu_probe() 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: <20180306030252.3197-1-jeffy.chen@rock-chips.com> <20180306030252.3197-4-jeffy.chen@rock-chips.com> From: Robin Murphy Message-ID: <3c3aa82e-2a06-4ced-fb7e-8e219b25b812@arm.com> Date: Wed, 7 Mar 2018 13:00:24 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180306030252.3197-4-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 06/03/18 03:02, Jeffy Chen wrote: > Move request_irq to the end of rk_iommu_probe(). Acked-by: Robin Murphy > Suggested-by: Robin Murphy > Signed-off-by: Jeffy Chen > Reviewed-by: Tomasz Figa > --- > > Changes in v7: None > Changes in v6: None > Changes in v5: None > Changes in v4: None > Changes in v3: > Loop platform_get_irq() as Robin suggested. > > Changes in v2: None > > drivers/iommu/rockchip-iommu.c | 38 +++++++++----------------------------- > 1 file changed, 9 insertions(+), 29 deletions(-) > > diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c > index c2ef3cbd4401..b743d82e6fe1 100644 > --- a/drivers/iommu/rockchip-iommu.c > +++ b/drivers/iommu/rockchip-iommu.c > @@ -90,8 +90,6 @@ struct rk_iommu { > struct device *dev; > void __iomem **bases; > int num_mmu; > - int *irq; > - int num_irq; > bool reset_disabled; > struct iommu_device iommu; > struct list_head node; /* entry in rk_iommu_domain.iommus */ > @@ -830,13 +828,6 @@ static int rk_iommu_attach_device(struct iommu_domain *domain, > > 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); > @@ -885,9 +876,6 @@ static void rk_iommu_detach_device(struct iommu_domain *domain, > } > rk_iommu_disable_stall(iommu); > > - for (i = 0; i < iommu->num_irq; i++) > - devm_free_irq(iommu->dev, iommu->irq[i], iommu); > - > iommu->domain = NULL; > > dev_dbg(dev, "Detached from iommu domain\n"); > @@ -1138,7 +1126,7 @@ static int rk_iommu_probe(struct platform_device *pdev) > struct rk_iommu *iommu; > struct resource *res; > int num_res = pdev->num_resources; > - int err, i; > + int err, i, irq; > > iommu = devm_kzalloc(dev, sizeof(*iommu), GFP_KERNEL); > if (!iommu) > @@ -1165,23 +1153,15 @@ static int rk_iommu_probe(struct platform_device *pdev) > if (iommu->num_mmu == 0) > return PTR_ERR(iommu->bases[0]); > > - iommu->num_irq = platform_irq_count(pdev); > - if (iommu->num_irq < 0) > - return iommu->num_irq; > - if (iommu->num_irq == 0) > - return -ENXIO; > + i = 0; > + while ((irq = platform_get_irq(pdev, i++)) != -ENXIO) { > + if (irq < 0) > + return irq; > > - iommu->irq = devm_kcalloc(dev, iommu->num_irq, sizeof(*iommu->irq), > - GFP_KERNEL); > - if (!iommu->irq) > - return -ENOMEM; > - > - for (i = 0; i < iommu->num_irq; i++) { > - iommu->irq[i] = platform_get_irq(pdev, i); > - if (iommu->irq[i] < 0) { > - dev_err(dev, "Failed to get IRQ, %d\n", iommu->irq[i]); > - return -ENXIO; > - } > + err = devm_request_irq(iommu->dev, irq, rk_iommu_irq, > + IRQF_SHARED, dev_name(dev), iommu); > + if (err) > + return err; > } > > iommu->reset_disabled = device_property_read_bool(dev, >