Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2189374pxb; Mon, 11 Jan 2021 03:26:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNrDm7YqDY7KojD8FpglrfBhj6TjEucBdGhmIrI23wpYmI1u9VM5MZ6XDxdX+mbQfXiEui X-Received: by 2002:a05:6402:c0b:: with SMTP id co11mr13436889edb.180.1610364414265; Mon, 11 Jan 2021 03:26:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610364414; cv=none; d=google.com; s=arc-20160816; b=Z1pzkYLU3ay6QWnSvlXTgBPDzEHfi3uY2tEOBUZ2zTag/ziWP0SLj9pQNlspachcP1 8wnPaCUEsSdaSu+8JGT29VxYelEFZJElYY1r06kYAxAu+AvO/59DjxGa4Cy+buLWha21 3udQqE7XbQyNmXlgas4XdwHhgK+kOURxdwRuk9eyOpjUPzqESzicljpLZ8/sdA7tdX3u 3H40cuMi9qX5+ucDc8hPrnJ7LRo3vy9aUulXKEdgf4rASiexWjaUA+KBaKCO05ebplJK xG6/79n9iezf23wqCv8HXSFpuRaB6ohqRaYXb4gZ9LfTzJdTuytoMftVhg//CCGjy6PN vzHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=OgFmZaGAChk+UAIK74DD5z6xRMx1LxOIh2V3PyJ4p94=; b=ie5vZSu56ON0I/+RNJbDp+VPvo8VO3BpwXZMECiFRooQBnCDirVimmZ9Xzb/FxzxbA cq+scmJ2ADr+C5E8y1pcun4J+YZajD2iQv2Oe4rrp4brGYyeJ1v8nOqgUVnh1Q4k7msj i+5B8sEvTvYF5KKxWWaoF5Nv6wUzFgJQnHsAnSFwwvhBnkVZeC2iCdGCxzLbS2k55EpZ GQRZd6Z9Hltwk77lRX1fkGiuFnsnPVKXpyE3iqsASO5QtITLSzTvT+gH4BvqcsRqYugN 64kxGxmO8ukphoFhctLYktZeCPvKcgkW3vYQ68kUZ0QIDTrC1hptpAjjoapUsWkxqNzy b6Tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p22si5752174edt.391.2021.01.11.03.26.31; Mon, 11 Jan 2021 03:26:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729987AbhAKLXo (ORCPT + 99 others); Mon, 11 Jan 2021 06:23:44 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:46248 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729877AbhAKLXm (ORCPT ); Mon, 11 Jan 2021 06:23:42 -0500 X-UUID: 26ab373ea52b45e3bf56b249e48262eb-20210111 X-UUID: 26ab373ea52b45e3bf56b249e48262eb-20210111 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1205887880; Mon, 11 Jan 2021 19:22:57 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 11 Jan 2021 19:22:56 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 11 Jan 2021 19:22:55 +0800 From: Yong Wu To: Joerg Roedel , Rob Herring , Matthias Brugger , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v6 22/33] iommu/mediatek: Support report iova 34bit translation fault in ISR Date: Mon, 11 Jan 2021 19:19:03 +0800 Message-ID: <20210111111914.22211-23-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210111111914.22211-1-yong.wu@mediatek.com> References: <20210111111914.22211-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the iova is over 32bit, the fault status register bit is a little different. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 468be7ca62e4..f3666b0d7577 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -3,6 +3,7 @@ * Copyright (c) 2015-2016 MediaTek Inc. * Author: Yong Wu */ +#include #include #include #include @@ -89,6 +90,9 @@ #define F_REG_MMU1_FAULT_MASK GENMASK(13, 7) #define REG_MMU0_FAULT_VA 0x13c +#define F_MMU_INVAL_VA_31_12_MASK GENMASK(31, 12) +#define F_MMU_INVAL_VA_34_32_MASK GENMASK(11, 9) +#define F_MMU_INVAL_PA_34_32_MASK GENMASK(8, 6) #define F_MMU_FAULT_VA_WRITE_BIT BIT(1) #define F_MMU_FAULT_VA_LAYER_BIT BIT(0) @@ -246,8 +250,9 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id) { struct mtk_iommu_data *data = dev_id; struct mtk_iommu_domain *dom = data->m4u_dom; - u32 int_state, regval, fault_iova, fault_pa; unsigned int fault_larb, fault_port, sub_comm = 0; + u32 int_state, regval, va34_32, pa34_32; + u64 fault_iova, fault_pa; bool layer, write; /* Read error info from registers */ @@ -263,6 +268,14 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id) } layer = fault_iova & F_MMU_FAULT_VA_LAYER_BIT; write = fault_iova & F_MMU_FAULT_VA_WRITE_BIT; + if (MTK_IOMMU_HAS_FLAG(data->plat_data, IOVA_34_EN)) { + va34_32 = FIELD_GET(F_MMU_INVAL_VA_34_32_MASK, fault_iova); + pa34_32 = FIELD_GET(F_MMU_INVAL_PA_34_32_MASK, fault_iova); + fault_iova = fault_iova & F_MMU_INVAL_VA_31_12_MASK; + fault_iova |= (u64)va34_32 << 32; + fault_pa |= (u64)pa34_32 << 32; + } + fault_port = F_MMU_INT_ID_PORT_ID(regval); if (MTK_IOMMU_HAS_FLAG(data->plat_data, HAS_SUB_COMM)) { fault_larb = F_MMU_INT_ID_COMM_ID(regval); @@ -276,7 +289,7 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id) write ? IOMMU_FAULT_WRITE : IOMMU_FAULT_READ)) { dev_err_ratelimited( data->dev, - "fault type=0x%x iova=0x%x pa=0x%x larb=%d port=%d layer=%d %s\n", + "fault type=0x%x iova=0x%llx pa=0x%llx larb=%d port=%d layer=%d %s\n", int_state, fault_iova, fault_pa, fault_larb, fault_port, layer, write ? "write" : "read"); } -- 2.18.0