Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ipa: always inline ipa_aggr_granularity_val()

It isn't required, but all callers of ipa_aggr_granularity_val()
pass a constant value (IPA_AGGR_GRANULARITY) as the usec argument.
Two of those callers are in ipa_validate_build(), with the result
being passed to BUILD_BUG_ON().

Evidently the "sparc64-linux-gcc" compiler (at least) doesn't always
inline ipa_aggr_granularity_val(), so the result of the function is
not constant at compile time, and that leads to build errors.

Define the function with the __always_inline attribute to avoid the
errors. We can see by inspection that the value passed is never
zero, so we can just remove its WARN_ON() call.

Fixes: 5bc5588466a1f ("net: ipa: use WARN_ON() rather than assertions")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Alex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/20210811135948.2634264-1-elder@linaro.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Alex Elder and committed by
Jakub Kicinski
676eec8e bed5a942

+3 -4
+3 -4
drivers/net/ipa/ipa_main.c
··· 253 253 /* Compute the value to use in the COUNTER_CFG register AGGR_GRANULARITY 254 254 * field to represent the given number of microseconds. The value is one 255 255 * less than the number of timer ticks in the requested period. 0 is not 256 - * a valid granularity value. 256 + * a valid granularity value (so for example @usec must be at least 16 for 257 + * a TIMER_FREQUENCY of 32000). 257 258 */ 258 - static u32 ipa_aggr_granularity_val(u32 usec) 259 + static __always_inline u32 ipa_aggr_granularity_val(u32 usec) 259 260 { 260 - WARN_ON(!usec); 261 - 262 261 return DIV_ROUND_CLOSEST(usec * TIMER_FREQUENCY, USEC_PER_SEC) - 1; 263 262 } 264 263