From patchwork Tue Mar 7 02:35:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wu X-Patchwork-Id: 65202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2202532wrd; Mon, 6 Mar 2023 18:47:09 -0800 (PST) X-Google-Smtp-Source: AK7set918ynjyVHN/KGyobY2Yk4wKkvywyoLjQbUWOWy0S72HYXy4SoBnj8O6qfhu3UmAE5IUGx0 X-Received: by 2002:a17:903:22cc:b0:19c:d5a5:1f52 with SMTP id y12-20020a17090322cc00b0019cd5a51f52mr15807615plg.18.1678157229152; Mon, 06 Mar 2023 18:47:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678157229; cv=none; d=google.com; s=arc-20160816; b=s/+7LahcX0d3FGg4tMBsMY5jE16+AFOzZSeV3VXnf8aDQeoCjCph6tYnbEoJAWMN+n yCqJmPBAmdd+sMaqAQCXa/7yKhTXRujh8nVO11cjExH2CD0P/Y288HkU0FykORmif9U9 g63on/cfKnenAQjKhaYjpFWGWLSTkSnGuSV2GnUsQZFJPooKKNma1zuhY1KuXY7amzhD dkkFkcX9Wmd007wvM68hfZL3Ry16ONRMgVZRwtArrCCVZTzmkdD1A1t+PFX6mLjLkQL5 JRj6dGZAehHPXyjRuHKkgLOvWbTvBMwUtuQNtecKQAtrRikUE+hNSYUuW7qL2XGSnDEO YHFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=N8HHskHnbAsCetHxm/xOX28+0QYD3OrWrhd9Jvdcg2M=; b=z6HGZK+EQCWTTThIFXJCWRCH2hOI+KpgcJzAAx081MTOpmyCKz4uM9zaa2pvLE0eAW O5sCavICdNKAGMDp4xn+kuS4ITvcPMjRfhUOzyZUE6UUnjWcPJ5AEPnit0rpju3tACqP sHHEvM7SwPHujJCzDgVEmgIPdWTYYt7DCovs0NwXwPJsef2TmS/hzBA91ODmxU/SpZQL h5tkYbxkMOFexQt0pgaJ3+OQaN6QpqCxJzUredvrsn6RmoYygHRKudw9AnAmW1G8rCUr 5F1ze/KLdW1yAH4rQ1OFBmm0zh0eVPAZ5p/cVlAhrZ06wI9xI3uQtW3VhPOsYL4JK1x7 y0tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="In4SElv/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kx12-20020a170902f94c00b0019e88c42997si10384291plb.104.2023.03.06.18.46.55; Mon, 06 Mar 2023 18:47:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="In4SElv/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230089AbjCGCiY (ORCPT + 99 others); Mon, 6 Mar 2023 21:38:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbjCGCiW (ORCPT ); Mon, 6 Mar 2023 21:38:22 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CEB37202A; Mon, 6 Mar 2023 18:37:45 -0800 (PST) X-UUID: f634106abc9011ed945fc101203acc17-20230307 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=N8HHskHnbAsCetHxm/xOX28+0QYD3OrWrhd9Jvdcg2M=; b=In4SElv/daDGeYna4G5VHRKWj6ccN9TJiZcgGaTu667a9cRezubLTFxj0rP/vu/JLHCuqhloWaheNBdDO39N+9cwu49oOS/DswMmUJ6CXYnhWHiQ/ZqOiOG2+AZMRmwhuWoWBBnlgUBpWE/Gf0AScVfzCxKIZPhdIWDFtyDOdck=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:31939b65-4ccc-4035-b18a-0f395204a1ea,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.20,REQID:31939b65-4ccc-4035-b18a-0f395204a1ea,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:25b5999,CLOUDID:308169b2-beed-4dfc-bd9c-e1b22fa6ccc4,B ulkID:230307103711ERS66U0K,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-UUID: f634106abc9011ed945fc101203acc17-20230307 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 894860727; Tue, 07 Mar 2023 10:37:11 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Tue, 7 Mar 2023 10:37:09 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.25 via Frontend Transport; Tue, 7 Mar 2023 10:37:08 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Mauro Carvalho Chehab , Rob Herring CC: Will Deacon , Robin Murphy , Krzysztof Kozlowski , Hans Verkuil , , , , , , , , "AngeloGioacchino Del Regno" , , , , Yunfei Dong , kyrie wu , , , , Yong Wu Subject: [PATCH v5 08/11] iommu/mediatek: Add a gap for the iova regions Date: Tue, 7 Mar 2023 10:35:04 +0800 Message-ID: <20230307023507.13306-9-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230307023507.13306-1-yong.wu@mediatek.com> References: <20230307023507.13306-1-yong.wu@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759675394703342551?= X-GMAIL-MSGID: =?utf-8?q?1759675394703342551?= As the removed property in the vcodec dt-binding, the property is: dma-ranges = <0x1 0x0 0x0 0x40000000 0x0 0xfff00000>; The length is 0xfff0_0000 rather than 0x1_0000_0000, this means it requires 1M as a gap. This is because the end address for some vcodec HW is (address + size). If the size is 4G, the end address may be 0x2_0000_0000, and the width for vcodec register only is 32, then the HW may get the ZERO address. Currently the consumer's dma-ranges property doesn't work, IOMMU has to consider this case. Add a bigger gap(8M) for all the regions to avoid it. Signed-off-by: Yong Wu Reviewed-by: AngeloGioacchino Del Regno --- drivers/iommu/mtk_iommu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index fbfc5e4e56a8..e0264d5f1c9a 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -332,8 +332,10 @@ static LIST_HEAD(m4ulist); /* List all the M4U HWs */ #define for_each_m4u(data, head) list_for_each_entry(data, head, list) +#define MTK_IOMMU_IOVA_SZ_4G (SZ_4G - SZ_8M) /* 8M as gap */ + static const struct mtk_iommu_iova_region single_domain[] = { - {.iova_base = 0, .size = SZ_4G}, + {.iova_base = 0, .size = MTK_IOMMU_IOVA_SZ_4G}, }; #define MT8192_MULTI_REGION_NR_MAX 6 @@ -342,11 +344,11 @@ static const struct mtk_iommu_iova_region single_domain[] = { MT8192_MULTI_REGION_NR_MAX : 1) static const struct mtk_iommu_iova_region mt8192_multi_dom[MT8192_MULTI_REGION_NR] = { - { .iova_base = 0x0, .size = SZ_4G}, /* 0 ~ 4G */ + { .iova_base = 0x0, .size = MTK_IOMMU_IOVA_SZ_4G}, /* 0 ~ 4G, */ #if IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT) - { .iova_base = SZ_4G, .size = SZ_4G}, /* 4G ~ 8G */ - { .iova_base = SZ_4G * 2, .size = SZ_4G}, /* 8G ~ 12G */ - { .iova_base = SZ_4G * 3, .size = SZ_4G}, /* 12G ~ 16G */ + { .iova_base = SZ_4G, .size = MTK_IOMMU_IOVA_SZ_4G}, /* 4G ~ 8G */ + { .iova_base = SZ_4G * 2, .size = MTK_IOMMU_IOVA_SZ_4G}, /* 8G ~ 12G */ + { .iova_base = SZ_4G * 3, .size = MTK_IOMMU_IOVA_SZ_4G}, /* 12G ~ 16G */ { .iova_base = 0x240000000ULL, .size = 0x4000000}, /* CCU0 */ { .iova_base = 0x244000000ULL, .size = 0x4000000}, /* CCU1 */