Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2189518pxb; Mon, 11 Jan 2021 03:27:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvhZnZR0kXmZZ6qZOlFD+o38Opg14GVZdqDGWZRd6iGeRofyGJrkClEMimthUGdak/Ii6J X-Received: by 2002:a17:906:c45:: with SMTP id t5mr10312083ejf.370.1610364428878; Mon, 11 Jan 2021 03:27:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610364428; cv=none; d=google.com; s=arc-20160816; b=A4h93DlXdDqWA+cLgv6UbOcTBbN/LpEm2YoisD2COb7uebbsLzPY2Fv7ROTVRqs1yw WIW9jdAuBvapo+nOAfNyDtdYSlJTal9bv+wzR8cQSi0UtPVVIHl3hGB5DOOrx2aIT5a5 Ouuni67WbXlcxWb56KRjTS295OVOGDo13j5801enHwPXh060SlI4L8zpwO6ROCZX0A3H zMCxdpHayy/Gr2NpckoE5xUW0T/3E2yJHK5zbpM746y5mWl7EKExv+9Cb2RKkdcJIc39 lRDoU4Jd4qUTITk7JRcu6pQKx0kFK09VzpHw8/XEuHix4p1mHZcmXYnOKcNJwSd6B1lW t1LA== 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=NuNacw66kpjuDS85YeKpfIM7u/JWdz8IxzIFSm0JFKc=; b=MmLaAWdG9Tc7uGBGEGDflEfPyb8s195cfIlfckT11ZEUkWqhJpZ90hna0bAxUqm326 CT/99UdJTMwACNSwlservRrhintu4Cq1DGkoRU4zft6jt+c9EXTTfRjkNDx8JpXURJYH FYuNPV850EJUL9LwQHGj+OZjVragui/CE9uNk7rMOhvuOpB0xpSwKYrkZnw3tRUyUET1 OiNzn4PorwrrQMyF8Kj1OxMIaXmLMMAkX81k3uMAMmHq6DhkkX7vLDSPu7tXPo9sneGh uLt6iHFp6d2u/BgoI9sxwJloXxrCSahFyWHhfb6Vm28ToGojDNmZj+m/DZ1VBmAxwVfL 17Aw== 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 y21si6501889ejp.340.2021.01.11.03.26.45; Mon, 11 Jan 2021 03:27:08 -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 S1729947AbhAKLXY (ORCPT + 99 others); Mon, 11 Jan 2021 06:23:24 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:60479 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729650AbhAKLXX (ORCPT ); Mon, 11 Jan 2021 06:23:23 -0500 X-UUID: c266d31348794a5c8ecfce1cd1868076-20210111 X-UUID: c266d31348794a5c8ecfce1cd1868076-20210111 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.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 1104988850; Mon, 11 Jan 2021 19:22:52 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 11 Jan 2021 19:22:51 +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:50 +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 21/33] iommu/mediatek: Support up to 34bit iova in tlb flush Date: Mon, 11 Jan 2021 19:19:02 +0800 Message-ID: <20210111111914.22211-22-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 34bit, the iova[32][33] is the bit0/1 in the tlb flush register. Add a new macro for this. In the macro, since (iova + size - 1) may be end with 0xfff, then the bit0/1 always is 1, thus add a mask. Signed-off-by: Yong Wu --- drivers/iommu/mtk_iommu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index b9c63c8de33e..468be7ca62e4 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -129,6 +129,11 @@ static const struct iommu_ops mtk_iommu_ops; static int mtk_iommu_hw_init(const struct mtk_iommu_data *data); +#define MTK_IOMMU_TLB_ADDR(iova) ({ \ + dma_addr_t _addr = iova; \ + ((lower_32_bits(_addr) & GENMASK(31, 12)) | upper_32_bits(_addr));\ +}) + /* * In M4U 4GB mode, the physical address is remapped as below: * @@ -213,8 +218,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_TLB_ADDR(iova), + data->base + REG_MMU_INVLD_START_A); + writel_relaxed(MTK_IOMMU_TLB_ADDR(iova + size - 1), data->base + REG_MMU_INVLD_END_A); writel_relaxed(F_MMU_INV_RANGE, data->base + REG_MMU_INVALIDATE); -- 2.18.0