From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751221AbdJDRmT (ORCPT ); Wed, 4 Oct 2017 13:42:19 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:46119 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751050AbdJDRmR (ORCPT ); Wed, 4 Oct 2017 13:42:17 -0400 X-Google-Smtp-Source: AOwi7QBluS9NGnIETvH0tmD+tvxpOsfl4wMTi3kBAKnwR7bRa7hT6I+la7J9v631eAnVRiW2Hm4RDg== Date: Wed, 4 Oct 2017 10:42:15 -0700 From: Matthias Kaehlcke To: Jakub Kicinski Cc: "David S . Miller" , Simon Horman , Dirk van der Merwe , oss-drivers@netronome.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Renato Golin , Manoj Gupta , Guenter Roeck , Doug Anderson Subject: Re: [PATCH] nfp: convert nfp_eth_set_bit_config() into a macro Message-ID: <20171004174215.GM173745@google.com> References: <20171003200546.165731-1-mka@chromium.org> <20171003145000.53683e21@cakuba> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20171003145000.53683e21@cakuba> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org El Tue, Oct 03, 2017 at 02:50:00PM -0700 Jakub Kicinski ha dit: > On Tue, 3 Oct 2017 13:05:46 -0700, Matthias Kaehlcke wrote: > > nfp_eth_set_bit_config() is marked as __always_inline to allow gcc to > > identify the 'mask' parameter as known to be constant at compile time, > > which is required to use the FIELD_GET() macro. > > > > The forced inlining does the trick for gcc, but for kernel builds with > > clang it results in undefined symbols: > > > > drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.o: In function > > `__nfp_eth_set_aneg': > > drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c:(.text+0x787): > > undefined reference to `__compiletime_assert_492' > > drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c:(.text+0x7b1): > > undefined reference to `__compiletime_assert_496' > > > > These __compiletime_assert_xyx() calls would have been optimized away if > > the compiler had seen 'mask' as a constant. > > > > Convert nfp_eth_set_bit_config() into a macro, which allows both gcc and > > clang to identify 'mask' as a compile time constant. > > > > Signed-off-by: Matthias Kaehlcke > > :( > > Is there no chance of fixing the constant propagation in the compiler? LLVM developers are reluctant and would like us kernel folks to evaluate possible alternatives for the affected code first: https://bugs.llvm.org/show_bug.cgi?id=4898 Given that this doesn't seem to be a widespread issue in the kernel personally I would consider the conversion to a macro in this case an acceptable solution, though it is definitely ugly. However I'm not the owner of the driver or the subsystem, so my opinion doesn't really carry much weight here ;-) Any ideas about other, less ugly alternatives? Matthias