Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp321709pxb; Wed, 11 Nov 2020 04:44:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyykGZyJvnDnVk+XXSwWr0GZdNHkQJgi7xspAcYhnnmtKtWOgnuPZLNaEQ/8VAYq+e+rsUP X-Received: by 2002:a50:d74c:: with SMTP id i12mr2071168edj.236.1605098663318; Wed, 11 Nov 2020 04:44:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605098663; cv=none; d=google.com; s=arc-20160816; b=mBHszGt/u80vauMzhg7lI6/lVksWOiV2yCx8T64x1mp9M7oRx2ur/7PybWgl6FNe4H iJdEqD8cOWR/v8ePJE/eMWQtzHGlQdkOFr89RDwV6Ldp6Cg/eYREfe25rtyiU6FoNZXX aOfTiW0BukomaFxnpijNblNF4/pdPLEgc7x31pdUtul6r8X3gcMud0nYlUapCLljGvnr qmfM93u14JGAvwwxsvywje52FhcgUcmvvhXyKjNNNRTYVgyd3pm9yzEXr+m4x7hq6vNG kOEJUAoo6upLQDuqhj0AKnY1ST1/npYIV5MYMp6RJ+migVDEDrYrtpqmFiDMIOa3UyCO CglA== 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=AhJDyMGFHSTs8k3FPx4eOsAW4Jx3OJrC3Jpqw8zEtkg=; b=gsvgtQ1M6rSjbSGk9ZpI4Iv0n4+nueaCTXj89GRrIvpm6YjC8vDe4+6W6X5hKMNvOP pYJH2BAxMgZUqkAwPAGsqa3bRKeixMtwFOX4D513ZKa4ozP8jdc1oiSLuc4wxhLUJ3N3 5CN0y53jIWByiwbuGa2xUU1OgV9MkahmfC27HWSE+t/OmFljvl6+GHWbOjIu8gM9ebA6 05JUL5+fM8q+ERmAr7eOrVrm01dotn1BtQi8Tw3q9EY0FXRWMxEl5jtMr9xzXfmKkbop ACHQ1OvQgBIbHcTquupF2CVQ6A7v4snFQjpNWxUzik7c9WPcVfM2JIzxa8SIIRqMEZ7Q 2FZg== 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 bm13si1395877edb.281.2020.11.11.04.44.00; Wed, 11 Nov 2020 04:44:23 -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 S1726953AbgKKMlt (ORCPT + 99 others); Wed, 11 Nov 2020 07:41:49 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:58497 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726958AbgKKMli (ORCPT ); Wed, 11 Nov 2020 07:41:38 -0500 X-UUID: b00b21ee1fa24059895ce7a2b2514d04-20201111 X-UUID: b00b21ee1fa24059895ce7a2b2514d04-20201111 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] 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 904370944; Wed, 11 Nov 2020 20:41:37 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 11 Nov 2020 20:41:34 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 11 Nov 2020 20:41:34 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , , Greg Kroah-Hartman , Subject: [PATCH v4 19/24] iommu/mediatek: Support up to 34bit iova in tlb flush Date: Wed, 11 Nov 2020 20:38:33 +0800 Message-ID: <20201111123838.15682-20-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201111123838.15682-1-yong.wu@mediatek.com> References: <20201111123838.15682-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 34bit, the iova[32][33] is the bit0/1 in the tlb flush register. Add a new macro for this. there is a minor change unrelated with this patch. it also use the new macro. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 46c9143703a9..11af0780e4dd 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -128,6 +128,9 @@ static const struct iommu_ops mtk_iommu_ops; static int mtk_iommu_hw_init(const struct mtk_iommu_data *data); +#define MTK_IOMMU_ADDR(addr) ({unsigned long _addr = addr; \ + (lower_32_bits(_addr) | upper_32_bits(_addr)); }) + /* * In M4U 4GB mode, the physical address is remapped as below: * @@ -218,8 +221,9 @@ static void mtk_iommu_tlb_flush_range_sync(unsigned long iova, size_t size, writel_relaxed(F_INVLD_EN1 | F_INVLD_EN0, data->base + data->plat_data->inv_sel_reg); - writel_relaxed(iova, data->base + REG_MMU_INVLD_START_A); - writel_relaxed(iova + size - 1, + writel_relaxed(MTK_IOMMU_ADDR(iova), + data->base + REG_MMU_INVLD_START_A); + writel_relaxed(MTK_IOMMU_ADDR(iova + size - 1), data->base + REG_MMU_INVLD_END_A); writel_relaxed(F_MMU_INV_RANGE, data->base + REG_MMU_INVALIDATE); @@ -639,8 +643,7 @@ static int mtk_iommu_hw_init(const struct mtk_iommu_data *data) if (MTK_IOMMU_HAS_FLAG(data->plat_data, HAS_LEGACY_IVRP_PADDR)) regval = (data->protect_base >> 1) | (data->enable_4GB << 31); else - regval = lower_32_bits(data->protect_base) | - upper_32_bits(data->protect_base); + regval = MTK_IOMMU_ADDR(data->protect_base); writel_relaxed(regval, data->base + REG_MMU_IVRP_PADDR); if (data->enable_4GB && -- 2.18.0