Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3902024pxb; Mon, 27 Sep 2021 05:20:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfsgsxaKy66oyaYoCarFYiY1x55u/9NLTyriL81wlL6+Fd1CfnELpdmHTkn7GgQn6MTBV5 X-Received: by 2002:a05:6402:42d5:: with SMTP id i21mr22958708edc.14.1632745245489; Mon, 27 Sep 2021 05:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632745245; cv=none; d=google.com; s=arc-20160816; b=yoyJR94mMLCImhVxdgyMXg3n72xSfoAOQB9ZdRCsvcqlpLem23CYNayhGMMMpUjOwQ N6kQ1ucvp98w+D3ujSMEDg90E5khcvZsjYhEqiNJcoNPO/9rCLt6tln0DX3iUDi9vOcx Guxx3FN2l23ARCIeNEdjumstKFTvd+hWV3d3jVF3+B/Vm+YH7ZSs1IGEeQmnpBmG/lo/ fyj0fKNio9Y4iuyrOftLT5hP0MtwxtcdfaKhHUwi4T08Q+RPJxeylCzNzaJIBg12L7uQ afYMHKXUb2bOPwzTiXswmeYit8uqIaO/AG7puaGKanpfrtlznjm1EqivjpzgcxbKhzK7 NOdQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=G+X6fQvAWpY9Alu9l4wMSenr1gxNa2oZNl91rguTZBg=; b=WDaa37bDUxISBhmCEF6HTCqh3cuE+IylDM7KqvYRxLGT+gOnn5ANIwqz/myRxaJ+NP Kxy8YZAbftUY3sfyZrh37aCe0pMoZhKNt5zWyedBRwDgKn3+cUgdHMgytgmT9bHhl3Gt BvtaydUe59tn8mKwaLAyP+BjMhKPXS+rDg6KzMPdBsLNqE7nal+VvREP3aDIbG+ecUmc zkO6M5WHPiKZZhUdbCF00dTO/1h8onM4w7gdlE9RH3GChcKhttUCBIcDuTo8dZ9phrj/ ZpwjDFoHDv8TWA0jf4rUJezpnkVeiNlsrzMcMtFcPhlJcaobXhTiL++X72qX4fq1XxzT 5IGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iQ1cVnEt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si16869158edm.70.2021.09.27.05.20.20; Mon, 27 Sep 2021 05:20:45 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=iQ1cVnEt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234239AbhI0MUn (ORCPT + 99 others); Mon, 27 Sep 2021 08:20:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:43926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234223AbhI0MUk (ORCPT ); Mon, 27 Sep 2021 08:20:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C105F6103B; Mon, 27 Sep 2021 12:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632745142; bh=F9/Tr9COtm4Stj4bhDIokvzMkSf99FLpUsv9Um0t5FI=; h=From:To:Cc:Subject:Date:From; b=iQ1cVnEtOm5m5/2kAdPUnsn+F/m6UMiVUTNVuuJVHQzqfCTB37Wh92MSJMucsKtLS hE6EEfH26Y7f55flpw2XxZbTXZOaSqx5aWlljUGX/puBub5sCl6FwV6KHrALTMS0fj fXJcasgF8W/8SdTAezOjWsJAoAYktTuihAPRjRFtFdXLoXXkfgGk3Sgu1u/jaHthW5 2L+vEP9AaPWCp8njdVAzDZLerxAtaI/Cv5lOJ4OTkc1gIyZiiuNgwrdLQCd4QP6O89 3HeumoPYO5S/iEZyMKOr9XjdjDictDEY86eIyVDUKsZ2B+AZKZPoYfjJRhaeLjgBbJ 5JrGQXrIaY2Fg== From: Arnd Bergmann To: Yong Wu , Joerg Roedel , Will Deacon , Matthias Brugger Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Tomasz Figa , Robin Murphy , iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] iommu/mediatek: fix out-of-range warning with clang Date: Mon, 27 Sep 2021 14:18:44 +0200 Message-Id: <20210927121857.941160-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann clang-14 notices that a comparison is never true when CONFIG_PHYS_ADDR_T_64BIT is disabled: drivers/iommu/mtk_iommu.c:553:34: error: result of comparison of constant 5368709120 with expression of type 'phys_addr_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (dom->data->enable_4GB && pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE) ~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Add an explicit check for the type of the variable to skip the check and the warning in that case. Fixes: b4dad40e4f35 ("iommu/mediatek: Adjust the PA for the 4GB Mode") Signed-off-by: Arnd Bergmann --- drivers/iommu/mtk_iommu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index d837adfd1da5..25b834104790 100644 --- a/drivers/iommu/mtk_iommu.c +++ b/drivers/iommu/mtk_iommu.c @@ -550,7 +550,9 @@ static phys_addr_t mtk_iommu_iova_to_phys(struct iommu_domain *domain, phys_addr_t pa; pa = dom->iop->iova_to_phys(dom->iop, iova); - if (dom->data->enable_4GB && pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE) + if (IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT) && + dom->data->enable_4GB && + pa >= MTK_IOMMU_4GB_MODE_REMAP_BASE) pa &= ~BIT_ULL(32); return pa; -- 2.29.2