From patchwork Mon Aug 2 14:54:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 490359 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:1185:0:0:0:0 with SMTP id f5csp1999233jas; Mon, 2 Aug 2021 07:54:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy47GHM76PBnWXlHZvQta8/zHDxF+E6McPOlCOGi3TnVfrDPS6HvTM6ZfxPu/CmAOBuIGtI X-Received: by 2002:aa7:da02:: with SMTP id r2mr19849598eds.249.1627916099868; Mon, 02 Aug 2021 07:54:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627916099; cv=none; d=google.com; s=arc-20160816; b=fZQ9cJjGyNt4xhBxCIwEednpZyF+ggBPsVyhDUutdh48x1wBc9q26lKSphUqVQCc9u qT6cyxc/F1ZbglCcrBIDAp0GMhk+ogXkyipHCH86X/aF5gnl6iXj5d3cHuM8zRRTPRgb zQmZ6uoMnXSwikx+VT4yjYVqa+VmGiXpSs+wxppKQvJDOMDpLzkfdWHMQ6G7XHnY0qbh V7AZRhN75uEctmmzdjWgihB8obS9RIfIvIW35uLz+YyxgHI15CQyKwtq/XwylmbHncaW Pnu2tVz92CFVolHqPP2c73YADLMuNdkuaFpe+C48KHVcnmxiJ1EzTLJRdaJMZvVNGafn pJ0Q== 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=Vo3e4t1XvXuEwogy+sEck+zWBsS0gjB/utr3v06rEok=; b=swhcuOjF6OzMwgkBgQLf/XzltTV6+C0mrIEnsgzNAwu2PjO0U5O4ocLJ+MNgamdfpI eQGt15jVgE8PvsdezcZfJ9W9mNWgyZk+cwrXTMJjchewRovAp6mlMudfX9fhFrrV5/Re Ja4ZnD5Oi3O+gxFVVB6gAeZ0le5+J/4AtacAi7t83uaf7kh2P4023qfBz0FtblgIKVqc LRVr7dNN6D0hEVzmA8dnrCOvy79vVLTbtMG3HS75DAEeI6vvRY7iPwRCa1PjYT/B+NAt GYVd8fm9sozbE2RAAV88Z/Oa8vF6IADCudW/2dFQhSaqyP7cYAtu1wtHRjPtZ1CkDBse Jn3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=d6TyXtee; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 c12si13111201eja.232.2021.08.02.07.54.59; Mon, 02 Aug 2021 07:54:59 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=d6TyXtee; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-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 S234378AbhHBOzE (ORCPT + 8 others); Mon, 2 Aug 2021 10:55:04 -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 Precedence: bulk List-ID: X-Mailing-List: netdev@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(-) -- 2.29.2 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