Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4396155pxt; Wed, 11 Aug 2021 05:14:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxijnC9fupQiRA5WXC9wS7I8rcqA//0Xj9t5/2MTaVZXtoA6V5DR/NNQsSC/+8tCfzY0LSu X-Received: by 2002:a17:906:d147:: with SMTP id br7mr3446504ejb.126.1628684089150; Wed, 11 Aug 2021 05:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628684089; cv=none; d=google.com; s=arc-20160816; b=xUEQB8JhL3w+jLK7pel+12WJqZAiEOcWQ+ygUufk/MY86QDV0NjOUy9/6ov+s1fIvs 7U9dBlQd0BbfNJIY596lPP4oY9p3A3GjYN3Jg48UN6UdCysm0JQr4LrgRfiLgDoGKWje g3NKR7ahz9Bs5BP4uexzk8zb+2s9wlR57tmnh2zgF/TUqfMc3tidolWRa2O+Prt5ytJx 3Aw+AGrovnEG05kY2rO+Qgvnha0eVsfI+fjyvPyCxLZRk5crShOKGT8q/7oGlvDh0M6s M3VLd1Uoe4rPOsA+59AqSmR8Zde6NpezviKC0FaFSuwg+vsKF14/t/EtU9BvC89TF4By PqhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hz6JnNqjeE1dNI91THqXFiD7MRW6NIrsj39GmKTFOfw=; b=VjUSypg8VQe3jaqkCqO6HjTdB+DDXDqfGi7hM6KV8Axx+cxtf6Xu2eHXVF8rx2CcZB mZTK2qVoPZs6IfapkKX7U/aidB5MdZuPm9fY1D0E9lmx2UslYQ/KLkFEZdAYWcdD/aIm YLzwyfl19JF2qo/xvUOFzmx+LGGLlB8SHiNL8qE/WiMzTeEMmevJINmJpf5OYo0XJzxS Dr+8p8jl4M9pFrYmkaqfvOQweiYxyj4x6MEPDUwTg5227k6P424AuW66+PFC3edjsYBF 2FSf+eqQ4Ir7mG/733Txm07VbPxEcljEjzOiXwPBEprto3qo3ebZcnhle9Y8WvL4ukSH R4BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b0eCa2VN; 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 z5si23485995edb.235.2021.08.11.05.14.24; Wed, 11 Aug 2021 05:14:49 -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=b0eCa2VN; 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 S237531AbhHKMNQ (ORCPT + 99 others); Wed, 11 Aug 2021 08:13:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:51298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237509AbhHKMNK (ORCPT ); Wed, 11 Aug 2021 08:13:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1738960F56; Wed, 11 Aug 2021 12:12:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628683966; bh=4URCwI+To5dzXx4W9xSAGUE66foFtybz8x7Tq5j21xs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b0eCa2VNlzrHho/Aa0bnBVVEd1hZKqMFi/Ynn1MaDNzuT3jxIfgeIynU6uBdLeo0g bdHJ6dS95I1toqj12ufYyxGntNxxAkPNKx0C2UB63TrYici1Hl4751oZtZbTmtPrhq Qv3qp28v2acvPvCM3Y/qM/Ay+ooiCxMIqLut486eXliBDZY2Ydpnyjpw1SiYpRv8Si p81o0srOcOxLxKVbtIr7AVf3S1CoCne6hCveJHWzah23bNGjs7zjjxhxS7/fco7Ece RKduTGUoHfn3XVFhO4kKDVCSvt24h9Y8dxwXVZ9EqYxut56ES1ncn3eELk3Ouep15M ru2ZNWmJP3xgA== Date: Wed, 11 Aug 2021 15:12:42 +0300 From: Leon Romanovsky To: Alex Elder Cc: davem@davemloft.net, kuba@kernel.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, lkp@intel.com, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] net: ipa: always inline ipa_aggr_granularity_val() Message-ID: References: <20210810160213.2257424-1-elder@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 11, 2021 at 07:06:01AM -0500, Alex Elder wrote: > On 8/11/21 7:02 AM, Leon Romanovsky wrote: > > On Tue, Aug 10, 2021 at 11:02:13AM -0500, Alex Elder wrote: > >> 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. And given that the function is inline, we can switch the > >> WARN_ON() there to be BUILD_BUG_ON(). > >> > >> Fixes: 5bc5588466a1f ("net: ipa: use WARN_ON() rather than assertions") > >> Reported-by: kernel test robot > >> Signed-off-by: Alex Elder > >> --- > >> > >> David/Jakub, this fixes a bug in a commit in net-next/master. -Alex > >> > >> drivers/net/ipa/ipa_main.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c > >> index 25bbb456e0078..f90b3521e266b 100644 > >> --- a/drivers/net/ipa/ipa_main.c > >> +++ b/drivers/net/ipa/ipa_main.c > >> @@ -255,9 +255,9 @@ ipa_hardware_config_qsb(struct ipa *ipa, const struct ipa_data *data) > >> * less than the number of timer ticks in the requested period. 0 is not > >> * a valid granularity value. > >> */ > >> -static u32 ipa_aggr_granularity_val(u32 usec) > >> +static __always_inline u32 ipa_aggr_granularity_val(u32 usec) > >> { > >> - WARN_ON(!usec); > >> + BUILD_BUG_ON(!usec); > > > > So what exactly are you checking here if all callers pass same value? > > It is in-kernel API, declared as static inside one module. There is no > > need to protect from itself. > > Yeah that's a good point. It can just as well be removed. > I think the check was added before I knew it was only going > to be used with a single constant value. That said, the > point was to check at runtime a required constraint. > > I'll post version 2 that simply removes it. Thanks. Thanks > > -Alex > > > > > Thanks > > > >> > >> return DIV_ROUND_CLOSEST(usec * TIMER_FREQUENCY, USEC_PER_SEC) - 1; > >> } > >> -- > >> 2.27.0 > >> >