From patchwork Sun Aug 5 12:46:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 10556131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0274613B4 for ; Sun, 5 Aug 2018 12:47:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3188298AA for ; Sun, 5 Aug 2018 12:46:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D300D298B7; Sun, 5 Aug 2018 12:46:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B04D298AA for ; Sun, 5 Aug 2018 12:46:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=3CcJDgNGULy4UEgt87BywU1nWV0rL/b2hVf3Q3QXAI4=; b=r9X WhSTNbezwshZg62HrCUqnBlYxnQ+uD3idy/OMlrHdydL9oBuC8gEco6sXs1V7Oihm0SNuPJVRvLT0 jOY7nDVUp7vW/eNRAQxhdbNE99K8a4AF6VGNXUFFWHQV4RI+vTZCKSc1lLRENPvksvfAf/AXTELO8 8rNXF/qtm9W2jcNx/QNKjjegF8VKBUYw3WeNGJ2AzheBHz6jgm/uEBo3Vb251+AGYLliBCvh9j2KE s0bOGafnidvj4DqYI9OsXgvnbTP0QIGnf/95Y+4ZOiGsy6U371rrDYR8p27lO+mRr7JO6cIQZUku5 +UGaD1A/PDafTzfVByRhsuFWY7XpRJA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmIQu-0000Bk-CZ; Sun, 05 Aug 2018 12:46:52 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmIQq-0000Ap-Gs for linux-arm-kernel@lists.infradead.org; Sun, 05 Aug 2018 12:46:49 +0000 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 8D0B418A; Sun, 5 Aug 2018 05:46:32 -0700 (PDT) Received: from why.lan (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5E6C23F2EA; Sun, 5 Aug 2018 05:46:31 -0700 (PDT) From: Marc Zyngier To: iommu@lists.linux-foundation.org Subject: [PATCH] iommu/rockchip: Handle errors returned from PM framework Date: Sun, 5 Aug 2018 13:46:16 +0100 Message-Id: <20180805124616.18020-1-marc.zyngier@arm.com> X-Mailer: git-send-email 2.14.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180805_054648_566761_C51A78D3 X-CRM114-Status: GOOD ( 13.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , Heiko Stuebner , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP pm_runtime_get_if_in_use can fail: either PM has been disabled altogether (-EINVAL), or the device hasn't been enabled yet (0). Sadly, we ignore the first case at the moment, and end up treating it as if we had received a valid interrupt. The first case could happen because the interrupt line is shared (with the VOP for example), and although that device hasn't been programmed yet, an interrupt may be pending (think kexec/kdump). The second case means that we've enabled the IOMMU, but it is not powered-on just yet. This could be another instance of the above, but as it deserves investigation, let's output a single warning (instead of flodding the console). In both cases, bail with an IRQ_NONE. Fixes: 0f181d3cf7d98 ("iommu/rockchip: Add runtime PM support") Signed-off-by: Marc Zyngier --- drivers/iommu/rockchip-iommu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 054cd2c8e9c8..9d21495a8433 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -521,10 +521,11 @@ static irqreturn_t rk_iommu_irq(int irq, void *dev_id) u32 int_status; dma_addr_t iova; irqreturn_t ret = IRQ_NONE; - int i; + int i, err; - if (WARN_ON(!pm_runtime_get_if_in_use(iommu->dev))) - return 0; + err = pm_runtime_get_if_in_use(iommu->dev); + if ((err < 0) || WARN_ON_ONCE(!err)) + return ret; if (WARN_ON(clk_bulk_enable(iommu->num_clocks, iommu->clocks))) goto out;