From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2B29C4338F for ; Mon, 2 Aug 2021 14:54:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C625C60F70 for ; Mon, 2 Aug 2021 14:54:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234563AbhHBOzF (ORCPT ); Mon, 2 Aug 2021 10:55:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:53474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233962AbhHBOzE (ORCPT ); Mon, 2 Aug 2021 10:55:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5FCAB603E9; Mon, 2 Aug 2021 14:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627916094; bh=gd6OQ4Zwz+1XcZxjkz5g5AcMnW2ndyrD0KHsCPTjG68=; h=From:To:Cc:Subject:Date:From; b=d6TyXtee1UNYvKa4NyfTbn9v8ArDxAZs9TEMf6TOKU6UFANyssy4+uO9AEH4hnE7g Z7XSy/gjLuNlLUczAPVgfLL1mQoEdwjfTZtoKUuqChgwPcF4WVpZ9I9oTkPs8+ChLH YAIb7/5m16kZEWF+FJkleGb/ZfjhqxNzfLNZjP46NDEDvfNTn/wh/am1/lv1dVc+Qa ZLD7uAZrVoGu5sVoa1uKVR5PmgNNN3Xli2ZXW1qIQkhrR0ez6isJhd8sMETzZ+AVOv HrScd/admooZDplS2Xn+n2nX7MxtiY4+QtuwjFA9zcHUwpYDBaXo2wk90NeeD72rqi WAfZbZXDSF6xQ== From: Arnd Bergmann To: "David S. Miller" , Jakub Kicinski , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Bjarni Jonasson Cc: Arnd Bergmann , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: sparx5: fix bitmask check Date: Mon, 2 Aug 2021 16:54:37 +0200 Message-Id: <20210802145449.1154565-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 Older compilers such as gcc-5.5 produce a warning in this driver when ifh_encode_bitfield() is not getting inlined: drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c: In function 'ifh_encode_bitfield': include/linux/compiler_types.h:333:38: error: call to '__compiletime_assert_545' declared with attribute error: Unsupported width, must be <= 40 drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c:28:2: note: in expansion of macro 'compiletime_assert' compiletime_assert(width <= 40, "Unsupported width, must be <= 40"); ^ Mark the function as __always_inline to make the check work correctly on all compilers. To make this also work on 32-bit architectures, change the GENMASK() to GENMASK_ULL(). Fixes: f3cad2611a77 ("net: sparx5: add hostmode with phylink support") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c index 9d485a9d1f1f..6f362f6708c6 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c @@ -13,14 +13,15 @@ */ #define VSTAX 73 -static void ifh_encode_bitfield(void *ifh, u64 value, u32 pos, u32 width) +static __always_inline void ifh_encode_bitfield(void *ifh, u64 value, + u32 pos, u32 width) { u8 *ifh_hdr = ifh; /* Calculate the Start IFH byte position of this IFH bit position */ u32 byte = (35 - (pos / 8)); /* Calculate the Start bit position in the Start IFH byte */ u32 bit = (pos % 8); - u64 encode = GENMASK(bit + width - 1, bit) & (value << bit); + u64 encode = GENMASK_ULL(bit + width - 1, bit) & (value << bit); /* Max width is 5 bytes - 40 bits. In worst case this will * spread over 6 bytes - 48 bits -- 2.29.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5231C432BE for ; Mon, 2 Aug 2021 14:57:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AEE7D60F9E for ; Mon, 2 Aug 2021 14:57:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AEE7D60F9E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=2ygkAVxezLrE4I9BtvG7PEtXuSIwynGLGSam1p8zPGw=; b=a1NZXH64kdQXEx mJeS105jZs6nWw6b3UAD/sCwNwSwOYAJScIGu7whZMWR52v0gRnna/Td8Yk2qHokL91j5Oa5UQZnc ebrDeyt4j03Q2Gwn/LOXITQpb+2iTNBhSouQQ6QKJ96p6u/feiru65tiUm69JyoKn2U1Xvxl28zRl jnkaavxMREjd41I5ZExTERSbAme38KtfWoc/X/XZrn7ODivc19XB6gGz0ZxyBjfTvkQEBlingRF9l ThdEDpsULGJxvmPJuhVIb+MrY7uW8n5Z/sHSvsRjWcX5L4GaHxnbL/IFO28Gyf9HMAatfN6YviEhH RB8yZaasSd0U4VtA4hXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAZLb-00Gm6M-Di; Mon, 02 Aug 2021 14:55:20 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mAZLD-00Glyu-1n for linux-arm-kernel@lists.infradead.org; Mon, 02 Aug 2021 14:54:56 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5FCAB603E9; Mon, 2 Aug 2021 14:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627916094; bh=gd6OQ4Zwz+1XcZxjkz5g5AcMnW2ndyrD0KHsCPTjG68=; h=From:To:Cc:Subject:Date:From; b=d6TyXtee1UNYvKa4NyfTbn9v8ArDxAZs9TEMf6TOKU6UFANyssy4+uO9AEH4hnE7g Z7XSy/gjLuNlLUczAPVgfLL1mQoEdwjfTZtoKUuqChgwPcF4WVpZ9I9oTkPs8+ChLH YAIb7/5m16kZEWF+FJkleGb/ZfjhqxNzfLNZjP46NDEDvfNTn/wh/am1/lv1dVc+Qa ZLD7uAZrVoGu5sVoa1uKVR5PmgNNN3Xli2ZXW1qIQkhrR0ez6isJhd8sMETzZ+AVOv HrScd/admooZDplS2Xn+n2nX7MxtiY4+QtuwjFA9zcHUwpYDBaXo2wk90NeeD72rqi WAfZbZXDSF6xQ== From: Arnd Bergmann To: "David S. Miller" , Jakub Kicinski , Lars Povlsen , Steen Hegelund , UNGLinuxDriver@microchip.com, Bjarni Jonasson Cc: Arnd Bergmann , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: sparx5: fix bitmask check Date: Mon, 2 Aug 2021 16:54:37 +0200 Message-Id: <20210802145449.1154565-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210802_075455_171275_6F5B2A7B X-CRM114-Status: GOOD ( 13.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann Older compilers such as gcc-5.5 produce a warning in this driver when ifh_encode_bitfield() is not getting inlined: drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c: In function 'ifh_encode_bitfield': include/linux/compiler_types.h:333:38: error: call to '__compiletime_assert_545' declared with attribute error: Unsupported width, must be <= 40 drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c:28:2: note: in expansion of macro 'compiletime_assert' compiletime_assert(width <= 40, "Unsupported width, must be <= 40"); ^ Mark the function as __always_inline to make the check work correctly on all compilers. To make this also work on 32-bit architectures, change the GENMASK() to GENMASK_ULL(). Fixes: f3cad2611a77 ("net: sparx5: add hostmode with phylink support") Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c index 9d485a9d1f1f..6f362f6708c6 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c @@ -13,14 +13,15 @@ */ #define VSTAX 73 -static void ifh_encode_bitfield(void *ifh, u64 value, u32 pos, u32 width) +static __always_inline void ifh_encode_bitfield(void *ifh, u64 value, + u32 pos, u32 width) { u8 *ifh_hdr = ifh; /* Calculate the Start IFH byte position of this IFH bit position */ u32 byte = (35 - (pos / 8)); /* Calculate the Start bit position in the Start IFH byte */ u32 bit = (pos % 8); - u64 encode = GENMASK(bit + width - 1, bit) & (value << bit); + u64 encode = GENMASK_ULL(bit + width - 1, bit) & (value << bit); /* Max width is 5 bytes - 40 bits. In worst case this will * spread over 6 bytes - 48 bits -- 2.29.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel