Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Jie Luo <quic_luoj@quicinc.com>
To: Simon Horman <horms@kernel.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Lei Wei <quic_leiwei@quicinc.com>,
	Suruchi Agarwal <quic_suruchia@quicinc.com>,
	Pavithra R <quic_pavir@quicinc.com>,
	"Jonathan Corbet" <corbet@lwn.net>, Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	<linux-arm-msm@vger.kernel.org>, <netdev@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-doc@vger.kernel.org>, <linux-hardening@vger.kernel.org>,
	<quic_kkumarcs@quicinc.com>, <quic_linchen@quicinc.com>,
	<srinivas.kandagatla@linaro.org>,
	<bartosz.golaszewski@linaro.org>, <john@phrozen.org>
Subject: Re: [PATCH net-next v2 04/14] net: ethernet: qualcomm: Initialize PPE buffer management for IPQ9574
Date: Fri, 10 Jan 2025 23:42:08 +0800	[thread overview]
Message-ID: <36ea74e1-9caa-47b9-a614-5633f38f1444@quicinc.com> (raw)
In-Reply-To: <20250109201154.GS7706@kernel.org>



On 1/10/2025 4:11 AM, Simon Horman wrote:
> On Thu, Jan 09, 2025 at 05:27:14PM +0000, Simon Horman wrote:
>> On Wed, Jan 08, 2025 at 09:47:11PM +0800, Luo Jie wrote:
>>> The BM (Buffer Management) config controls the pause frame generated
>>> on the PPE port. There are maximum 15 BM ports and 4 groups supported,
>>> all BM ports are assigned to group 0 by default. The number of hardware
>>> buffers configured for the port influence the threshold of the flow
>>> control for that port.
>>>
>>> Signed-off-by: Luo Jie <quic_luoj@quicinc.com>
>>
>> ...
>>
>>> diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe_config.c b/drivers/net/ethernet/qualcomm/ppe/ppe_config.c
>>
>> ...
>>
>>> +/* The buffer configurations per PPE port. There are 15 BM ports and
>>> + * 4 BM groups supported by PPE. BM port (0-7) is for EDMA port 0,
>>> + * BM port (8-13) is for PPE physical port 1-6 and BM port 14 is for
>>> + * EIP port.
>>> + */
>>> +static struct ppe_bm_port_config ipq9574_ppe_bm_port_config[] = {
>>> +	{
>>> +		/* Buffer configuration for the BM port ID 0 of EDMA. */
>>> +		.port_id_start	= 0,
>>> +		.port_id_end	= 0,
>>> +		.pre_alloc	= 0,
>>> +		.in_fly_buf	= 100,
>>> +		.ceil		= 1146,
>>> +		.weight		= 7,
>>> +		.resume_offset	= 8,
>>> +		.resume_ceil	= 0,
>>> +		.dynamic	= true,
>>> +	},
>>> +	{
>>> +		/* Buffer configuration for the BM port ID 1-7 of EDMA. */
>>> +		.port_id_start	= 1,
>>> +		.port_id_end	= 7,
>>> +		.pre_alloc	= 0,
>>> +		.in_fly_buf	= 100,
>>> +		.ceil		= 250,
>>> +		.weight		= 4,
>>> +		.resume_offset	= 36,
>>> +		.resume_ceil	= 0,
>>> +		.dynamic	= true,
>>> +	},
>>> +	{
>>> +		/* Buffer configuration for the BM port ID 8-13 of PPE ports. */
>>> +		.port_id_start	= 8,
>>> +		.port_id_end	= 13,
>>> +		.pre_alloc	= 0,
>>> +		.in_fly_buf	= 128,
>>> +		.ceil		= 250,
>>> +		.weight		= 4,
>>> +		.resume_offset	= 36,
>>> +		.resume_ceil	= 0,
>>> +		.dynamic	= true,
>>> +	},
>>> +	{
>>> +		/* Buffer configuration for the BM port ID 14 of EIP. */
>>> +		.port_id_start	= 14,
>>> +		.port_id_end	= 14,
>>> +		.pre_alloc	= 0,
>>> +		.in_fly_buf	= 40,
>>> +		.ceil		= 250,
>>> +		.weight		= 4,
>>> +		.resume_offset	= 36,
>>> +		.resume_ceil	= 0,
>>> +		.dynamic	= true,
>>> +	},
>>> +};
>>> +
>>> +static int ppe_config_bm_threshold(struct ppe_device *ppe_dev, int bm_port_id,
>>> +				   struct ppe_bm_port_config port_cfg)
>>> +{
>>> +	u32 reg, val, bm_fc_val[2];
>>> +	int ret;
>>> +
>>> +	/* Configure BM flow control related threshold. */
>>> +	PPE_BM_PORT_FC_SET_WEIGHT(bm_fc_val, port_cfg.weight);
>>
>> Hi Luo Jie,
>>
>> When compiling with W=1 for x86_32 and ARM (32bit)
>> (but, curiously not x86_64 or arm64), gcc-14 complains that
>> bm_fc_val is uninitialised, I believe due to the line above and
>> similar lines below.
>>
>> In file included from drivers/net/ethernet/qualcomm/ppe/ppe_config.c:10:
>> In function 'u32p_replace_bits',
>>      inlined from 'ppe_config_bm_threshold' at drivers/net/ethernet/qualcomm/ppe/ppe_config.c:112:2:
>> ./include/linux/bitfield.h:189:15: warning: 'bm_fc_val' is used uninitialized [-Wuninitialized]
>>    189 |         *p = (*p & ~to(field)) | type##_encode_bits(val, field);        \
>>        |               ^~
>> ./include/linux/bitfield.h:198:9: note: in expansion of macro '____MAKE_OP'
>>    198 |         ____MAKE_OP(u##size,u##size,,)
>>        |         ^~~~~~~~~~~
>> ./include/linux/bitfield.h:201:1: note: in expansion of macro '__MAKE_OP'
>>    201 | __MAKE_OP(32)
>>        | ^~~~~~~~~
>> drivers/net/ethernet/qualcomm/ppe/ppe_config.c: In function 'ppe_config_bm_threshold':
>> drivers/net/ethernet/qualcomm/ppe/ppe_config.c:108:23: note: 'bm_fc_val' declared here
>>    108 |         u32 reg, val, bm_fc_val[2];
>>        |                       ^~~~~~~~~
>>
>>> +	PPE_BM_PORT_FC_SET_RESUME_OFFSET(bm_fc_val, port_cfg.resume_offset);
>>> +	PPE_BM_PORT_FC_SET_RESUME_THRESHOLD(bm_fc_val, port_cfg.resume_ceil);
>>> +	PPE_BM_PORT_FC_SET_DYNAMIC(bm_fc_val, port_cfg.dynamic);
>>> +	PPE_BM_PORT_FC_SET_REACT_LIMIT(bm_fc_val, port_cfg.in_fly_buf);
>>> +	PPE_BM_PORT_FC_SET_PRE_ALLOC(bm_fc_val, port_cfg.pre_alloc);
>>> +
>>> +	/* Configure low/high bits of the ceiling for the BM port. */
>>> +	val = FIELD_PREP(GENMASK(2, 0), port_cfg.ceil);
>>
>> The value of port_cfg.ceil is 250 or 1146, as set in
>> ipq9574_ppe_bm_port_config. clang-19 W=1 builds complain that this
>> value is too large for the field (3 bits).
>>
>> drivers/net/ethernet/qualcomm/ppe/ppe_config.c:120:8: error: call to '__compiletime_assert_925' declared with 'error' attribute: FIELD_PREP: value too large for the field
>>    120 |         val = FIELD_PREP(GENMASK(2, 0), port_cfg.ceil);
>>        |               ^
>> ./include/linux/bitfield.h:115:3: note: expanded from macro 'FIELD_PREP'
>>    115 |                 __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: ");    \
>>        |                 ^
>> ./include/linux/bitfield.h:68:3: note: expanded from macro '__BF_FIELD_CHECK'
>>     68 |                 BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?           \
>>        |                 ^
>> ./include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
>>     39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
>>        |                                     ^
>> note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
>> ././include/linux/compiler_types.h:530:2: note: expanded from macro '_compiletime_assert'
>>    530 |         __compiletime_assert(condition, msg, prefix, suffix)
>>        |         ^
>> ././include/linux/compiler_types.h:523:4: note: expanded from macro '__compiletime_assert'
>>    523 |                         prefix ## suffix();                             \
>>        |                         ^
>> <scratch space>:95:1: note: expanded from here
>>     95 | __compiletime_assert_925
>>        | ^
>> 1 error generated
>>
>>> +	PPE_BM_PORT_FC_SET_CEILING_LOW(bm_fc_val, val);
>>> +	val = FIELD_PREP(GENMASK(10, 3), port_cfg.ceil);
> 
> One more thing - I was pondering this over dinner.
> 
> I believe that the above will write the bits 0-7 of port_cfg.ceil
> to bits 3-10 of val. I am guessing that the reverse mapping of
> bits is intended.
> 

Thanks for catching this, yes, I will update this code. And also run the
32 bit ARCH check on the patches.

>>> +	PPE_BM_PORT_FC_SET_CEILING_HIGH(bm_fc_val, val);
>>> +
>>> +	reg = PPE_BM_PORT_FC_CFG_TBL_ADDR + PPE_BM_PORT_FC_CFG_TBL_INC * bm_port_id;
>>> +	ret = regmap_bulk_write(ppe_dev->regmap, reg,
>>> +				bm_fc_val, ARRAY_SIZE(bm_fc_val));
>>> +	if (ret)
>>> +		return ret;
>>> +
>>> +	/* Assign the default group ID 0 to the BM port. */
>>> +	val = FIELD_PREP(PPE_BM_PORT_GROUP_ID_SHARED_GROUP_ID, 0);
>>> +	reg = PPE_BM_PORT_GROUP_ID_ADDR + PPE_BM_PORT_GROUP_ID_INC * bm_port_id;
>>> +	ret = regmap_update_bits(ppe_dev->regmap, reg,
>>> +				 PPE_BM_PORT_GROUP_ID_SHARED_GROUP_ID,
>>> +				 val);
>>> +	if (ret)
>>> +		return ret;
>>> +
>>> +	/* Enable BM port flow control. */
>>> +	val = FIELD_PREP(PPE_BM_PORT_FC_MODE_EN, true);
>>> +	reg = PPE_BM_PORT_FC_MODE_ADDR + PPE_BM_PORT_FC_MODE_INC * bm_port_id;
>>> +
>>> +	return regmap_update_bits(ppe_dev->regmap, reg,
>>> +				  PPE_BM_PORT_FC_MODE_EN,
>>> +				  val);
>>> +}
>>
>> ...
>>
>> -- 
>> pw-bot: changes-requested
>>


  reply	other threads:[~2025-01-10 15:42 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08 13:47 [PATCH net-next v2 00/14] Add PPE driver for Qualcomm IPQ9574 SoC Luo Jie
2025-01-08 13:47 ` [PATCH net-next v2 01/14] dt-bindings: net: Add PPE " Luo Jie
2025-01-09  9:15   ` Krzysztof Kozlowski
2025-01-10 15:47     ` Jie Luo
2025-01-08 13:47 ` [PATCH net-next v2 02/14] docs: networking: Add PPE driver documentation " Luo Jie
2025-01-08 13:47 ` [PATCH net-next v2 03/14] net: ethernet: qualcomm: Add PPE driver for " Luo Jie
2025-01-08 19:19   ` Christophe JAILLET
2025-01-09 14:18     ` Jie Luo
2025-01-08 13:47 ` [PATCH net-next v2 04/14] net: ethernet: qualcomm: Initialize PPE buffer management for IPQ9574 Luo Jie
2025-01-09 17:27   ` Simon Horman
2025-01-09 20:11     ` Simon Horman
2025-01-10 15:42       ` Jie Luo [this message]
2025-01-08 13:47 ` [PATCH net-next v2 05/14] net: ethernet: qualcomm: Initialize PPE queue " Luo Jie
2025-01-08 13:47 ` [PATCH net-next v2 06/14] net: ethernet: qualcomm: Initialize the PPE scheduler settings Luo Jie
2025-01-08 19:27   ` Christophe JAILLET
2025-01-09 14:19     ` Jie Luo
2025-01-09 17:42   ` Simon Horman
2025-01-10 15:40     ` Jie Luo
2025-01-08 13:47 ` [PATCH net-next v2 07/14] net: ethernet: qualcomm: Initialize PPE queue settings Luo Jie
2025-01-08 19:29   ` Christophe JAILLET
2025-01-09 14:20     ` Jie Luo
2025-01-09 17:52   ` Simon Horman
2025-01-10 15:38     ` Jie Luo
2025-01-08 13:47 ` [PATCH net-next v2 08/14] net: ethernet: qualcomm: Initialize PPE service code settings Luo Jie
2025-01-09 17:58   ` Simon Horman
2025-01-10 15:36     ` Jie Luo
2025-01-08 13:47 ` [PATCH net-next v2 09/14] net: ethernet: qualcomm: Initialize PPE port control settings Luo Jie
2025-01-08 13:47 ` [PATCH net-next v2 10/14] net: ethernet: qualcomm: Initialize PPE RSS hash settings Luo Jie
2025-01-08 13:47 ` [PATCH net-next v2 11/14] net: ethernet: qualcomm: Initialize PPE queue to Ethernet DMA ring mapping Luo Jie
2025-01-08 13:47 ` [PATCH net-next v2 12/14] net: ethernet: qualcomm: Initialize PPE L2 bridge settings Luo Jie
2025-01-08 16:59   ` Andrew Lunn
2025-01-13  3:39     ` Lei Wei
2025-01-13 13:37       ` Andrew Lunn
2025-01-14 11:29         ` Lei Wei
2025-01-14 13:02           ` Andrew Lunn
2025-01-15  6:57             ` Lei Wei
2025-01-08 13:47 ` [PATCH net-next v2 13/14] net: ethernet: qualcomm: Add PPE debugfs support for PPE counters Luo Jie
2025-01-08 16:43   ` Andrew Lunn
2025-01-09 14:24     ` Jie Luo
2025-01-08 13:47 ` [PATCH net-next v2 14/14] MAINTAINERS: Add maintainer for Qualcomm PPE driver Luo Jie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36ea74e1-9caa-47b9-a614-5633f38f1444@quicinc.com \
    --to=quic_luoj@quicinc.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=gustavoars@kernel.org \
    --cc=horms@kernel.org \
    --cc=john@phrozen.org \
    --cc=kees@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=quic_kkumarcs@quicinc.com \
    --cc=quic_leiwei@quicinc.com \
    --cc=quic_linchen@quicinc.com \
    --cc=quic_pavir@quicinc.com \
    --cc=quic_suruchia@quicinc.com \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox