From patchwork Wed Feb 8 05:36:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wu X-Patchwork-Id: 54197 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3271713wrn; Tue, 7 Feb 2023 21:39:15 -0800 (PST) X-Google-Smtp-Source: AK7set9ATNiieul1ShDG9uoPFa2fCR6uZFUMZk3fspwRjVg5QUG7TdbDhxm4hZNG2oNwyeaDXM1G X-Received: by 2002:a17:90a:19:b0:22c:4f41:bbc2 with SMTP id 25-20020a17090a001900b0022c4f41bbc2mr7366743pja.5.1675834755613; Tue, 07 Feb 2023 21:39:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675834755; cv=none; d=google.com; s=arc-20160816; b=TjIFoBVXJkAT3lth9aHPsc00yF2OvIElN1L6PtWJMkypkBpkWu7yfFmp0UwXIRux1Y Sy21kjBTZppD3WKHoOm3CUsZ1Hy2pTuVXuU8FSUNJm/4QYhhXatVa3VPUaYcujP9FEZ2 lv6YXotgSnDnURNLHmhnYzKUP9EkilW/Ljm6XrikE4ZPe2A+58z6dAN/gDujYpGemGZC 3aDBvqXWq5NMr2wOmSq7q5IKJKY7y+YzwR8n7OAAeklWcj865Mh/97ntnLLOazNg73ML uJGIugQsFOUBSyeWkdYkPAKiRkuhFTzXoZ3QmqeAqB39+bdc0ILP6AGcmUW2dTWB/Ny8 /g2w== 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:dkim-signature; bh=Xl1CilNBVbkJItVNSibY1tzmDqH8d48UMU079vqS8Mc=; b=uwFsD4gkKNjRA6BOXS9F6eA+ccNIojJaCEOYyI/xa7gwS3ITXKGq3pq5zJ2bvNCru0 af569ltVVm1Yn6pByycAd+PEpLw1loJ7Cf/fKxAEQCDTDIaho/ocdLUkFnAu3FYv67Yv /4C1bQtGT5vm/QBLi9lCw2Wb9ec2+dVWNgTr2zgUXbf5S76DUCg92Q4C6W27McrQM0vT xvO650P0pfnIn/US4/PFCyqqOKBMxuBHklx2Is3aq+ZE+QseHgFUGgyxd/vh8unt8tXS dp7hdxylrLUXkA6+mcDqfswy6Dvim8tYDxK9CIPnZfVJDPLu/BSkBJ7/Ih+DYMNyYSZd wQGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=iQsd76Mi; 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 m7-20020a17090a34c700b00230f6f58ba3si1324252pjf.17.2023.02.07.21.39.02; Tue, 07 Feb 2023 21:39:15 -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=iQsd76Mi; 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 S230377AbjBHFiq (ORCPT + 99 others); Wed, 8 Feb 2023 00:38:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230327AbjBHFim (ORCPT ); Wed, 8 Feb 2023 00:38:42 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 964D8442CF; Tue, 7 Feb 2023 21:38:30 -0800 (PST) X-UUID: ce5c8708a77211ed945fc101203acc17-20230208 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Xl1CilNBVbkJItVNSibY1tzmDqH8d48UMU079vqS8Mc=; b=iQsd76MiUJgqMXDqGzfwTXE8KD1mbOF5oR3HeiDsSmkwWqUP/z1Fhk9cyjMmOp5qU6BfuyPXCyFxolaYO3cPKRDxBTplDmYSpmZSHnBDEl4j3qEu11VOn3eNK8L/irfVEXS9ZLxf71deGGm9BePl55W19YCc5W98z/FwbTeDGdA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.19,REQID:cf94aeb0-a608-4e85-b7fd-c7ace1989842,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:885ddb2,CLOUDID:33163e8e-8530-4eff-9f77-222cf6e2895b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-UUID: ce5c8708a77211ed945fc101203acc17-20230208 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1227592973; Wed, 08 Feb 2023 13:38:24 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) 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.792.15; Wed, 8 Feb 2023 13:38:23 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 8 Feb 2023 13:38:22 +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 v2 07/10] iommu/mediatek: Add a gap for the iova regions Date: Wed, 8 Feb 2023 13:36:40 +0800 Message-ID: <20230208053643.28249-8-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20230208053643.28249-1-yong.wu@mediatek.com> References: <20230208053643.28249-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 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?1757240105064686669?= X-GMAIL-MSGID: =?utf-8?q?1757240105064686669?= 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 have to consider this problem. Add a bigger gap(8M) for all the regions to avoid it. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 7e8fd0a0536c..2e8ffcec35d9 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -304,15 +304,15 @@ static LIST_HEAD(m4ulist); /* List all the M4U HWs */ #define for_each_m4u(data, head) list_for_each_entry(data, head, list) static const struct mtk_iommu_iova_region single_domain[] = { - {.iova_base = 0, .size = SZ_4G}, + {.iova_base = 0, .size = SZ_4G - SZ_8M}, }; static const struct mtk_iommu_iova_region mt8192_multi_dom[] = { - { .iova_base = 0x0, .size = SZ_4G}, /* 0 ~ 4G */ + { .iova_base = 0x0, .size = SZ_4G - SZ_8M}, /* 0 ~ 4G, 8M as a gap. */ #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 = SZ_4G - SZ_8M}, /* 4G ~ 8G */ + { .iova_base = SZ_4G * 2, .size = SZ_4G - SZ_8M}, /* 8G ~ 12G */ + { .iova_base = SZ_4G * 3, .size = SZ_4G - SZ_8M}, /* 12G ~ 16G */ { .iova_base = 0x240000000ULL, .size = 0x4000000}, /* CCU0 */ { .iova_base = 0x244000000ULL, .size = 0x4000000}, /* CCU1 */