From patchwork Thu Sep 12 01:55:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KhaiWenTan X-Patchwork-Id: 13801233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5155EE6420 for ; Thu, 12 Sep 2024 02:09:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=TlSbat9ZbH1VgKENmcXcCkdRSpNlHIkgrEMlmHMN7yM=; b=dfLNOPyT/EPQQU5RCeIti0F8va KNfbOcbvTRl3WQihVpgZ7ksakN+oBx0E4JtjXpzgbMkQoQaHTwusJXmswp6E/RPHaIFBuMLiRo+vp LBdIeMLrpQuQnXZmFT+6wfEwAbIHfMG7Z1DZ6xn00QOSdn2zsfFMwkpbFurpAQoYBUC5B+FX5j7LQ h1vBzYI2AXTBiDZecaCsJ90s9CYIcv6RAjgt80hJQTHhZAaoRXB96mRXi69DVT9t5a1b/D4gsSmGS VaSO1SUaUPXNWkDAlZ45AG6erAjGYziEOGWAdR4XB7OYgO2u1FyBbnJWRoS/FprD54PAlrO2xWFv4 RrWBqiDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soZGR-0000000BZXk-3i3L; Thu, 12 Sep 2024 02:08:55 +0000 Received: from mgamail.intel.com ([198.175.65.18]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soZFN-0000000BZSi-2XIL for linux-arm-kernel@lists.infradead.org; Thu, 12 Sep 2024 02:07:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726106870; x=1757642870; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2pC7oUHqvWMtu/IF0XFSSJJ+/UjqjyzX7Lx26PSeFBE=; b=GEmIdPyAuXU5xhpciBPG3miuE6aCDQxHLeGhe6BUSY/6rcSwmgnVZnKV yZmA3HeBTtN7+UdRFmeBbBFK90rnBSTBOwbyNciFxYfPPVkrWSUxPd2fZ kGOVVHCKC26FXTIN4bNq61c9oBRUsh7DKhYJpVdeuE8xiRHlzwzxwKf5u uFb8vYOBXEsFzikkx0XuC55QioBgxM7V8YRp8kEPWozerGy6mOYLkz8fZ scB/2r7GEwCmwxJJrlBQFPSZkOUEZbRGpUyDn7ORBjlwAIaurKjv3ATfc 3YpL+Vs2yjWjuWAY1nnyr/AxaVJYZdlfCv6UQj6IIP1DTBGX+9XSBiakA Q==; X-CSE-ConnectionGUID: r37GHK3pRISwvHXGwDA6ew== X-CSE-MsgGUID: OoY0NngIQXCs4YTT/4Dz8g== X-IronPort-AV: E=McAfee;i="6700,10204,11192"; a="25070642" X-IronPort-AV: E=Sophos;i="6.10,221,1719903600"; d="scan'208";a="25070642" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2024 19:07:47 -0700 X-CSE-ConnectionGUID: omHwZdw+SlO9u0NbszeNcw== X-CSE-MsgGUID: iSlPjsQBTnKTSinp9R5LKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,221,1719903600"; d="scan'208";a="67174707" Received: from linux.intel.com ([10.54.29.200]) by fmviesa006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2024 19:07:46 -0700 Received: from P12HL2yongliang.png.intel.com (P12HL2yongliang.png.intel.com [10.158.65.196]) by linux.intel.com (Postfix) with ESMTP id 91C5A20CFEDA; Wed, 11 Sep 2024 19:07:42 -0700 (PDT) From: KhaiWenTan To: Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Simon Horman , Xiaolei Wang Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Choong Yong Liang , Tan Khai Wen Subject: [PATCH net 1/1] net: stmmac: Fix zero-division error when disabling tc cbs Date: Thu, 12 Sep 2024 09:55:41 +0800 Message-Id: <20240912015541.363600-1-khai.wen.tan@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_190749_719741_30E674FE X-CRM114-Status: GOOD ( 13.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The commit b8c43360f6e4 ("net: stmmac: No need to calculate speed divider when offload is disabled") allows the "port_transmit_rate_kbps" to be set to a value of 0, which is then passed to the "div_s64" function when tc-cbs is disabled. This leads to a zero-division error. When tc-cbs is disabled, the idleslope, sendslope, and credit values the credit values are not required to be configured. Therefore, adding a return statement after setting the txQ mode to DCB when tc-cbs is disabled would prevent a zero-division error. Fixes: b8c43360f6e4 ("net: stmmac: No need to calculate speed divider when offload is disabled") Cc: Co-developed-by: Choong Yong Liang Signed-off-by: Choong Yong Liang Signed-off-by: KhaiWenTan --- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index 996f2bcd07a2..2c3fd9c66d14 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -392,10 +392,10 @@ static int tc_setup_cbs(struct stmmac_priv *priv, } else if (!qopt->enable) { ret = stmmac_dma_qmode(priv, priv->ioaddr, queue, MTL_QUEUE_DCB); - if (ret) - return ret; + if (!ret) + priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB; - priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB; + return ret; } /* Final adjustments for HW */