Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4262608rwl; Mon, 3 Apr 2023 02:17:49 -0700 (PDT) X-Google-Smtp-Source: AKy350biaHLHR8F8uvrFuarXGuA85LCmcM8cPzLlRy2JsirdTlKE6zYHmSGcFKipLhWt23+sm6iH X-Received: by 2002:a17:906:578c:b0:88f:a236:69e6 with SMTP id k12-20020a170906578c00b0088fa23669e6mr35640550ejq.7.1680513469456; Mon, 03 Apr 2023 02:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680513469; cv=none; d=google.com; s=arc-20160816; b=ifNGToaN7Rq5VuLId06ZILgzclLdfblW1iPRjdPCFQZX9odr5ni+K2i97v9Q66eimi coOlx3hasSjx9zZdJeNXGdRR9VGkZl965CV7tus60FwTo1XABf1VIx6X3N4Wr2/vuL/q D4I8tWPbz1GcJM+tYtPMFmenfp8JhMuRuMJ1267QAOpWUbj0/hXS4PKRlhqr+dUqBQvT drXu/AKRToJE09PI6UDtt47jI5JIgshxhhHXUmaBR0q/YXg+aEPSxlep2YZ3nAXr3a4H gBtLiogK2ZZNFGVKwIYEV3g1Rtp0uWNq7LCe3mbJubFU8vaYglBypW2x/G/fB2gZ/JvR D92g== 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=ikbJp6d90IXVw0sxspdPpFbtjqXNe1M7Eau6Eu2D3DM=; b=wERd5oG1174Y8URxe6F/Q2o84/HIp2njb4cbhbVxM9n5bLyLII1gS7szORe1WNSMjv noEfs/BWzzEw2qSz1tTowDqXts6+tw7qkt63R2FD/ntGTGIdyaCSwy5eD98me6UpMoZ6 jDZzOsvc2rifPiFHp0OOsFTVuqbVBBzawm/MfUR6AypQql7Gg+OgT2hW8/36cDUTUtha XwFuG6CLFGxe8zaldNy6dHdLGU3FpeMu2PnSPSloLOOTyT0umqITnJ6/3tO9sA7zoOps w9zBQ1QC6Aj5qxBJO5rJM1BjuxdjBbUsl21HWfVf9x/RiRk58coNk81PuKtfy2LEUE6o rEHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="anu/e93v"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r18-20020aa7da12000000b005026895f258si7236222eds.398.2023.04.03.02.17.24; Mon, 03 Apr 2023 02:17:49 -0700 (PDT) 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="anu/e93v"; 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 S231553AbjDCJQU (ORCPT + 99 others); Mon, 3 Apr 2023 05:16:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231426AbjDCJQM (ORCPT ); Mon, 3 Apr 2023 05:16:12 -0400 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88C1810264; Mon, 3 Apr 2023 02:15:50 -0700 (PDT) X-UUID: 1cdeff98d20011eda9a90f0bb45854f4-20230403 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=ikbJp6d90IXVw0sxspdPpFbtjqXNe1M7Eau6Eu2D3DM=; b=anu/e93vtTmVrExRX0KTvCV0YMOuu8AH9hwJmUqaOQHvqMiscCbfJmxHGlo7H8Lsp2QiMK57zrGk1Na3Pu4pxGTqkvNoswWvL/eRaXrJv2qnULSGtL1R0FiTt/TObxHsg7Jqv1EDPort2Je9sDrgwHzvCSxVwJdGRJhYvYwonh0=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.22,REQID:37b1632b-69aa-4127-ba58-959018233d05,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.22,REQID:37b1632b-69aa-4127-ba58-959018233d05,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:120426c,CLOUDID:f2db23b5-beed-4dfc-bd9c-e1b22fa6ccc4,B ulkID:230403171547O6H131CU,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-CID-BAS: 0,_,0,_ X-UUID: 1cdeff98d20011eda9a90f0bb45854f4-20230403 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 319230404; Mon, 03 Apr 2023 17:15:44 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.25; Mon, 3 Apr 2023 17:15:43 +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.1118.25 via Frontend Transport; Mon, 3 Apr 2023 17:15:42 +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 v6 09/14] iommu/mediatek: Set dma_mask for the master devices Date: Mon, 3 Apr 2023 17:13:32 +0800 Message-ID: <20230403091337.26745-10-yong.wu@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230403091337.26745-1-yong.wu@mediatek.com> References: <20230403091337.26745-1-yong.wu@mediatek.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable 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 MediaTek iommu arranges dma ranges for all the masters, this patch is to help them set dma mask. This is to avoid each master setting their own mask, but also to avoid a real issue, such as JPEG uses "mediatek,mtk-jpgenc" for 2701/8183/8186/8188, then JPEG could ignore its different dma_mask in different SoC to achieve common code. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 0e104bb27010..f58b970dccf2 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -738,6 +738,14 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, } mutex_unlock(&data->mutex); + if (region_id > 0) { + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(34)); + if (ret) { + dev_err(m4udev, "Failed to set dma_mask for %s(%d).\n", dev_name(dev), ret); + return ret; + } + } + return mtk_iommu_config(data, dev, true, region_id); err_unlock: -- 2.25.1