Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2955967imm; Fri, 24 Aug 2018 08:08:57 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda4344o3M5PQdTe5VLL0vkZdMS/0pQMoBQAltXQreDkuz4YCY84O9N2lv5fm1HoafBZZuj2 X-Received: by 2002:aa7:83cd:: with SMTP id j13-v6mr2407545pfn.236.1535123337768; Fri, 24 Aug 2018 08:08:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535123337; cv=none; d=google.com; s=arc-20160816; b=cJi4LGbi8VEiIa4k7soD5NbOZ9sc2JWUIIZLKn5nQ10TvWPOMXUoFqz8najiDFmEo3 2xNNbOcvmEl2UdMI1YZDyuzD6N8wXtbTxbA6+7ju7awflPokS73Q4shIFFnVeP0Ssmlw Q7j4+B64k25RPlwtGCqA+z4QUcjF0dXPwzbhZWbV6N0DFpkPjoWu9lI6Q/AWw/FXWABy NkRbvcjDw28GSSGw1A2PKIugOT86Qo7aPOmdJcnmDJ9HN2hf6ASUz+haKWeoIkZWXKqh b+R+N2LE629I+95W97xWXGoXUBZwQW4Rt2aRJ6izqW6B3QKu5AabcNQpCMGc14mJrdSk 014w== 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=IYeWGLfuBkC1/7vTJuhMZIFNXutTYiBYT7CwSlKJISk=; b=JbMKXgej9RGkCH2vN5993+uFrfgwWv8/3kS4CZWGNuKNbbe9kS6eIFrs4JMgVf7Iy6 WWreAZ49A6+pXiLxZNaidH7LBDg8h8CuJq3Tr4O1umqpafH8+S1wOKMgDBFdeNq/yxxt xNRseHiiWt0kCI/c97luyG6PQnz9B8BHi3fBUqTDfYZ5hsdePdZqWdyKOuhSCeVtDT5B uPB+pw0VPt6UPyAgnSmWc1d5jhv3j1MTUfZw9RrC1srqIYQMf2IzLORPirnxkeT0YzER nWqoyBH3/f0Rb6gecdGbGRxiI4eb1u+12R+ZSWlAmYGAq9gsomwfP5GbyXCn/eFkjlW2 MGNg== 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 ay10-v6si6928934plb.293.2018.08.24.08.08.42; Fri, 24 Aug 2018 08:08:57 -0700 (PDT) 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 S1728016AbeHXSmb (ORCPT + 99 others); Fri, 24 Aug 2018 14:42:31 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:60084 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbeHXSma (ORCPT ); Fri, 24 Aug 2018 14:42:30 -0400 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 CD0CF1688; Fri, 24 Aug 2018 08:07:27 -0700 (PDT) Received: from approximate.Emea.Arm.com (approximate.emea.arm.com [10.4.13.119]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 54F5F3F5BC; Fri, 24 Aug 2018 08:07:26 -0700 (PDT) From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: Joerg Roedel , Heiko Stuebner , Jeffy Chen , arm@kernel.org Subject: [PATCH v2 4/4] iommu/rockchip: Move irq request past pm_runtime_enable Date: Fri, 24 Aug 2018 16:06:37 +0100 Message-Id: <20180824150637.15316-5-marc.zyngier@arm.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180824150637.15316-1-marc.zyngier@arm.com> References: <20180824150637.15316-1-marc.zyngier@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enabling the interrupt early, before power has been applied to the device, can result in an interrupt being delivered too early if: - the IOMMU shares an interrupt with a VOP - the VOP has a pending interrupt (after a kexec, for example) In these conditions, we end-up taking the interrupt without the IOMMU being ready to handle the interrupt (not powered on). Moving the interrupt request past the pm_runtime_enable() call makes sure we can at least access the IOMMU registers. Note that this is only a partial fix, and that the VOP interrupt will still be screaming until the VOP driver kicks in, which advocates for a more synchronized interrupt enabling/disabling approach. Fixes: 0f181d3cf7d98 ("iommu/rockchip: Add runtime PM support") Reviewed-by: Heiko Stuebner Signed-off-by: Marc Zyngier --- drivers/iommu/rockchip-iommu.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 4e0f9b61cd7f..2b1724e8d307 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1161,17 +1161,6 @@ static int rk_iommu_probe(struct platform_device *pdev) if (iommu->num_mmu == 0) return PTR_ERR(iommu->bases[0]); - i = 0; - while ((irq = platform_get_irq(pdev, i++)) != -ENXIO) { - if (irq < 0) - return irq; - - 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, "rockchip,disable-mmu-reset"); @@ -1228,6 +1217,19 @@ static int rk_iommu_probe(struct platform_device *pdev) pm_runtime_enable(dev); + i = 0; + while ((irq = platform_get_irq(pdev, i++)) != -ENXIO) { + if (irq < 0) + return irq; + + err = devm_request_irq(iommu->dev, irq, rk_iommu_irq, + IRQF_SHARED, dev_name(dev), iommu); + if (err) { + pm_runtime_disable(dev); + goto err_remove_sysfs; + } + } + return 0; err_remove_sysfs: iommu_device_sysfs_remove(&iommu->iommu); -- 2.18.0