Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp1416109lqs; Sat, 15 Jun 2024 07:48:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3oTux9Fs81WsIy0M74/8W5H7KN66IfWH5S+/hI2/lPrCg0NIWCQwmE+uVzyHUUJHje63JbcCiRyj7Bi2f8FxxvimbEE3FqcNKKmvAvw== X-Google-Smtp-Source: AGHT+IE6m26kPanj2oY/SMQg0dxZ9ReYJWIPMQbldrLFgxiySlZbZ+Z2vb4EkbcvLKC4UY9+vfE3 X-Received: by 2002:a05:6e02:b28:b0:36b:3af2:2349 with SMTP id e9e14a558f8ab-375e0e22fb3mr61908975ab.15.1718462886337; Sat, 15 Jun 2024 07:48:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718462886; cv=pass; d=google.com; s=arc-20160816; b=aT8+JJkzi+8Xjeozhfz7+JQ90L0rXnemmdEbrBK3s7ujQbS1Ra8fnwZ7PIo3XB9VLR 1dTqxesPQrjj3H+XHS85V9FZ+Fq3fuTx9IIUbBj6NjNc/hu8gJWEbeiTz/TZRNvZhE6S 5HcHsviZxQ2JR1+fk8rtoZLJX4uPZXbFrN6DASQh5KZlotWW5UD9liYfoaE1UDfs8am5 eKrtr0ph3Yz3wD9z2Jth3zNAo7znWFGCTVAijwLmBVaq6QhAX0uiROtAPc6yWYCeca/C E3/a5V7Mks5vRil+7Qrd1Xi5s3MLku5BrLuG8e6ljSVhGzJVWAqwc+oEpjBV8Gsw/h0G BVTg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=0/DeHs+zBAffnlQYjo6QqlU0bYkI8NsUySUnEt8HXjo=; fh=N96hI+UVQL7T9QwT076804tmusRw/mn9kBMVK00T9XY=; b=N9HZ7kVbsohUcLLv6JFxGg73UPQKgdZ+OWXOU8wUx9MqELkyPVrgFtG72r9o/Fh/5c Qb1BoULhhNZ5dCUzRof3zyXf5hj/9WNaAxRPD95JLz+vf2JKvnASmky/JAMjIaGLeUJT qb985HMIhkBpImkuZR6FDZrU37ws/f3gRTjpDIGo3ahZv/u/nv7Pek6rLrrx4VPSlFeA WoAYLgBs+y9ADNdMMJFf7F4HF3Nadko5V7JgwTuXLfg8Wzva0nTgp587XVj+g9vj6XRL 9aD5jZgiOI1TmGsv0uS7WDlWhyazBRtZC/BG+hXr3O2BRnrvXHt8K/foFv1LPgdqVRJZ uRQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nrMaZFtr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-215909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215909-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fee67ba67dsi3892139a12.900.2024.06.15.07.48.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jun 2024 07:48:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nrMaZFtr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-215909-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215909-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 460F7B21A8D for ; Sat, 15 Jun 2024 14:48:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5B5649637; Sat, 15 Jun 2024 14:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nrMaZFtr" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06C5A2E3E5; Sat, 15 Jun 2024 14:47:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718462873; cv=none; b=XVkf07w1O5epo3yV/pFiC87tkCeICG7AIz314mVh5T1u7v3LvzNT5CMVoPy45BAZUwYw3gDWsyMktinvKdusZG/gpOEIuQp7IPt1JgHBd8padJ6+kxqDUsJEinVqPQArPILxR8F5TXhUVYUV2TXrIOcA1FOIktgX7ECCfA6XAMc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718462873; c=relaxed/simple; bh=fCXa3vZakqpvWMT0I15XosFZpQRBqFNMEGngNkHbA1k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z48VwzeSDOW2+qOGtxlpd6Tq6KTUW29H2OmxDpkuNe2fmxQlF8prhxVL3jSHxAx0Xq33NAWuZlKZOgrLDqO8KNa+kiOuLn3UHvyb0ZHxtR6sdsdvxxzxdEskhPiLQ8/v/2kI+8zmOm0RlpWsCttHwiQfaa9J2qbkWfcAlPpXp8k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nrMaZFtr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFDE8C116B1; Sat, 15 Jun 2024 14:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718462872; bh=fCXa3vZakqpvWMT0I15XosFZpQRBqFNMEGngNkHbA1k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nrMaZFtrG0SE+dgMHmeC2txn+fNLcYtVY2pUD2TcZl7TRUjHU0TYb+o3yh6DkJ7pw zSQV4ur34vd0LzQsuoB/LaTBrIV7v6eHdx/6yo69bIshqm8wBRDUwqhC1fHETNTvKo szhRaETr+J3CBIc4tgFQ4xRIrhvbLv5jjsSoxwexjA8gMZrMDLkF49ahZSpE+5z2AX CXMQqe2UveF+wmfpgK6RTYsPxRJI1z1dJ416dtGJJy6tw1vJW8nrAdhPDe2i9ssgy5 w42PwjIcgUd+NvNYwC72ZCy7QcVw1L4DwlVAwo9E6BSdApFBGOmBpJUm9lGRzyAYEQ h9w7yk7/nNXHg== Date: Sat, 15 Jun 2024 15:47:47 +0100 From: Simon Horman To: Xiaolei Wang Cc: olteanv@gmail.com, linux@armlinux.org.uk, alexandre.torgue@foss.st.com, andrew@lunn.ch, joabreu@synopsys.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, wojciech.drewek@intel.com, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [net PATCH] net: stmmac: No need to calculate speed divider when offload is disabled Message-ID: <20240615144747.GE8447@kernel.org> References: <20240614081916.764761-1-xiaolei.wang@windriver.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240614081916.764761-1-xiaolei.wang@windriver.com> On Fri, Jun 14, 2024 at 04:19:16PM +0800, Xiaolei Wang wrote: > commit be27b8965297 ("net: stmmac: replace priv->speed with > the portTransmitRate from the tc-cbs parameters") introduced > a problem. When deleting, it prompts "Invalid portTransmitRate > 0 (idleSlope - sendSlope)" and exits. Add judgment on cbs.enable. > Only when offload is enabled, speed divider needs to be calculated. > > Fixes: be27b8965297 ("net: stmmac: replace priv->speed with the portTransmitRate from the tc-cbs parameters") > Signed-off-by: Xiaolei Wang > --- > .../net/ethernet/stmicro/stmmac/stmmac_tc.c | 38 ++++++++++--------- > 1 file changed, 20 insertions(+), 18 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > index 1562fbdd0a04..b0fd2d6e525e 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c > @@ -358,24 +358,26 @@ static int tc_setup_cbs(struct stmmac_priv *priv, > > port_transmit_rate_kbps = qopt->idleslope - qopt->sendslope; > > - /* Port Transmit Rate and Speed Divider */ > - switch (div_s64(port_transmit_rate_kbps, 1000)) { > - case SPEED_10000: > - case SPEED_5000: > - ptr = 32; > - break; > - case SPEED_2500: > - case SPEED_1000: > - ptr = 8; > - break; > - case SPEED_100: > - ptr = 4; > - break; > - default: > - netdev_err(priv->dev, > - "Invalid portTransmitRate %lld (idleSlope - sendSlope)\n", > - port_transmit_rate_kbps); > - return -EINVAL; > + if (qopt->enable) { > + /* Port Transmit Rate and Speed Divider */ > + switch (div_s64(port_transmit_rate_kbps, 1000)) { > + case SPEED_10000: > + case SPEED_5000: > + ptr = 32; > + break; > + case SPEED_2500: > + case SPEED_1000: > + ptr = 8; > + break; > + case SPEED_100: > + ptr = 4; > + break; > + default: > + netdev_err(priv->dev, > + "Invalid portTransmitRate %lld (idleSlope - sendSlope)\n", > + port_transmit_rate_kbps); > + return -EINVAL; > + } > } > mode_to_use = priv->plat->tx_queues_cfg[queue].mode_to_use; Hi Xiaolei Wang, The code following this function looks like this: if (mode_to_use == MTL_QUEUE_DCB && qopt->enable) { ret = stmmac_dma_qmode(priv, priv->ioaddr, queue, MTL_QUEUE_AVB); if (ret) return ret; priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_AVB; } else if (!qopt->enable) { ret = stmmac_dma_qmode(priv, priv->ioaddr, queue, MTL_QUEUE_DCB); if (ret) return ret; priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB; } /* Final adjustments for HW */ value = div_s64(qopt->idleslope * 1024ll * ptr, port_transmit_rate_kbps); priv->plat->tx_queues_cfg[queue].idle_slope = value & GENMASK(31, 0); value = div_s64(-qopt->sendslope * 1024ll * ptr, port_transmit_rate_kbps); priv->plat->tx_queues_cfg[queue].send_slope = value & GENMASK(31, 0); And the div_s64() lines above appear to use ptr uninitialised in the !qopt->enable case. Flagged by Smatch. -- pw-bot: changes-requested