Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3793294pxu; Wed, 9 Dec 2020 00:08:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2Y4kXA6elpJaumnikpEMB7f0+29dVA2IATq8w/K6PMJlPCHA+8beYfTWk1XVU+ux77sjx X-Received: by 2002:a17:906:518a:: with SMTP id y10mr1078987ejk.323.1607501310475; Wed, 09 Dec 2020 00:08:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607501310; cv=none; d=google.com; s=arc-20160816; b=lhKV6gkqwjgs6h44RfUyDMtxqc18hk+ktXTcBcUkNP4ZUbxJuXpHSYXN8fJ7DIkAAP ggESCesOau4dhzl6R16+9HA52dlTfyKamb/nZyMpIBkRob3s/WuzcrrVz3dMmv/xJG3I U6xneQb/CPZMUywmhos9phhDnpI6Ect7GnVpvOgvTQovqzCP5g7cjbc1Zb/Gdcl0dPFE hxOZSHnOb/NFG89MbX4i4XUWK8IeIkfpfMXhv+xiaoPQFKILZhJd6BEIrhrcLjBujS1h +Wor+U/VZ0EEU/oYBlDarVKFDHMxzgxNfX+BhlMzct5p3dJRegQrDu7flRFHo6Rh4qOl G8Pw== 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=UyOIO2Gq6lZDawcYMrNXNV0xIIycVL2Qb7BY+4T1Rwk=; b=foitK93dW5wXvnAGCg4YgLpB864SBnqiz6YPJ7pgX5tm2R5BXhb0WNJK7cgJhNILjk ixROzi901fUxNmNhYdCm6/lf5rmj7DpbmiA7+gZtad642ss6/qFevxx8xRxdXdUmSEB/ cO9g+fzPqCmdh1qYVNZR0zY7CYe0/rQSoaXFwHNefpATQoNLd8h+nnKaeifSqV8Zi/UJ DPom+npQuZhbM3EIQCECj6GZ1qUf6Ir3g7Mx63LZ+S9pvBjm+F+IG2FGI/kmjLaMvRqy vJNWUeojRKHEg6WmpvXMPX8384o+nkGxOYhb7HBPgatABGZ4izX+bRPBhezCOxjDA9vK 1TiQ== 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 d16si435020edp.251.2020.12.09.00.08.07; Wed, 09 Dec 2020 00:08:30 -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 S1728591AbgLIIDp (ORCPT + 99 others); Wed, 9 Dec 2020 03:03:45 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:50636 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728571AbgLIIDg (ORCPT ); Wed, 9 Dec 2020 03:03:36 -0500 X-UUID: 81760ef3b36b48f9a0aef2430849446a-20201209 X-UUID: 81760ef3b36b48f9a0aef2430849446a-20201209 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 1044443157; Wed, 09 Dec 2020 16:02:59 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 9 Dec 2020 16:02:54 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 9 Dec 2020 16:02:57 +0800 From: Yong Wu To: Joerg Roedel , Matthias Brugger , Rob Herring , Will Deacon , Robin Murphy CC: Krzysztof Kozlowski , Evan Green , Tomasz Figa , , , , , , , , , Nicolas Boichat , , Subject: [PATCH v5 10/27] iommu/io-pgtable-arm-v7s: Clarify LVL_SHIFT/BITS macro Date: Wed, 9 Dec 2020 16:00:45 +0800 Message-ID: <20201209080102.26626-11-yong.wu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201209080102.26626-1-yong.wu@mediatek.com> References: <20201209080102.26626-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 The current _ARM_V7S_LVL_BITS/ARM_V7S_LVL_SHIFT use a formula to calculate the corresponding value for level1 and level2 to pretend the code sane. Actually their level1 and level2 values are different from each other. This patch only clarify the two macro. No functional change. Suggested-by: Robin Murphy Signed-off-by: Yong Wu Reviewed-by: Robin Murphy --- drivers/iommu/io-pgtable-arm-v7s.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c index 4d0aa079470f..58cc201c10a3 100644 --- a/drivers/iommu/io-pgtable-arm-v7s.c +++ b/drivers/iommu/io-pgtable-arm-v7s.c @@ -44,13 +44,11 @@ /* * We have 32 bits total; 12 bits resolved at level 1, 8 bits at level 2, - * and 12 bits in a page. With some carefully-chosen coefficients we can - * hide the ugly inconsistencies behind these macros and at least let the - * rest of the code pretend to be somewhat sane. + * and 12 bits in a page. */ #define ARM_V7S_ADDR_BITS 32 -#define _ARM_V7S_LVL_BITS(lvl) (16 - (lvl) * 4) -#define ARM_V7S_LVL_SHIFT(lvl) (ARM_V7S_ADDR_BITS - (4 + 8 * (lvl))) +#define _ARM_V7S_LVL_BITS(lvl) ((lvl) == 1 ? 12 : 8) +#define ARM_V7S_LVL_SHIFT(lvl) ((lvl) == 1 ? 20 : 12) #define ARM_V7S_TABLE_SHIFT 10 #define ARM_V7S_PTES_PER_LVL(lvl) (1 << _ARM_V7S_LVL_BITS(lvl)) -- 2.18.0