Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2187783pxb; Mon, 11 Jan 2021 03:24:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyswU5lxoqg7TMaMS1jM3O/qNzsOqUMbcPywSlgkKcG+6Xc/Mgy/p6wB7pqLKDiJcbV5E1r X-Received: by 2002:a17:906:c82c:: with SMTP id dd12mr10568745ejb.66.1610364244154; Mon, 11 Jan 2021 03:24:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610364244; cv=none; d=google.com; s=arc-20160816; b=W05qU5EUuGhaCVaf7nIhHO17Unx8KzFTAM6M9f66wAP+7Ar+oUksJF1WmQRSXWkB67 oxscXDh1qB8HWZon0ggIpirhFe7rR0gbIFUjx2fQZUBkQb9Hf7/qn+kLTgW2OCegwJg+ ORv346swNv4Huyv+ShJdN4JYHZgydA0bzzOAN+J2abR8OofUCC8p+RItIv8bPhdoM40q lYYgdcRrgThVAOEN+9AyOYkNkVbSBhTmx34ZiElzzv69e6JEDVrVjD+xZV8F+pCu5upK bzZ7i9t+e6ja5DOPCoCQuUxz+EPJ+Q4QOWlLeZVTZ1bGAW48YsPsb0uIOtuhQF5sWddW qEFA== 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=YjxbKb5FmMl4qCc53iinOYTvJUznwRKM+iZqJ0kQoag=; b=aj/liOFidljulWDF45JY7XA7TboMI7lf5+4n9go5sHg1JuAVLywQtiwQbWYsJSoM5s Ekv8fn/bRrTNfpxgncytZ4XDPRK8xSGSb/5JMBsHB+3+gvIN5Au41ZurbgIO4fsTI2A9 fzzLL4O81IeZmEFpg1edf9pr1De/dUjhQt9aoA/HJ8NNXaPM3FmDXQSz2wxv4BXJE5u0 OivktoDpCgzt4HURSJn/ulkjRn0Cs4EQPGvTybBvqYTP9ovy+kUAUXwK9Lu/gfIuFgtk 06Qwch8WXAU1ykbeLheDeQMzYAb4vI5q3mag7yGapHXzyR0DCgLipkV4n8sPSWdZ/5j0 24kA== 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 g5si6928180edj.194.2021.01.11.03.23.40; Mon, 11 Jan 2021 03:24:04 -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 S1729773AbhAKLVn (ORCPT + 99 others); Mon, 11 Jan 2021 06:21:43 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:44552 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729444AbhAKLVk (ORCPT ); Mon, 11 Jan 2021 06:21:40 -0500 X-UUID: 89f0f3dca0b94213af97a01860504737-20210111 X-UUID: 89f0f3dca0b94213af97a01860504737-20210111 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] 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 1298534697; Mon, 11 Jan 2021 19:21:20 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 11 Jan 2021 19:21:19 +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:21:19 +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 11/33] iommu/io-pgtable-arm-v7s: Clarify LVL_SHIFT/BITS macro Date: Mon, 11 Jan 2021 19:18:52 +0800 Message-ID: <20210111111914.22211-12-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 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 acfdb0163af8..0ce9a14300e9 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