From patchwork Wed Sep 18 06:14:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KhaiWenTan X-Patchwork-Id: 13806601 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 B571EC3ABB2 for ; Wed, 18 Sep 2024 06:27:48 +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=i1qP3gecVeufL1pBPqBsjcjBqFnjruAHGxmnOJIY/eQ=; b=nGCkdl6JccY9t/SHIMq3GHn7Tt SqU6Gqh+FdoLsyFV88xPmYLFesvKHgMNIboMPw2Snq5y3dFzvqOrM5S/Y+zWcM1PjkFUr4XdZA0l/ wKdxlXMYvdOvCDDs/E7StpUJSz0YbjGRLH/CNqU722kfsN0t0wmyIRRiqCsuSs2cr2WhXiQH/mTQd h5gltBypW2wpJZkAxauxa54ma13UqFhGJnxir1JLwd3qv8S3q01TV7QMX9feIfmREGpAu9P9bxOY9 6/j4Hfc0RIG6F/2qS93Yjpgk5LQCSDh+Nlpi6OCX17mcwobSRtqHKM5C8hK40kkyAKn5iZElYIUrQ xupy+jeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sqoA6-00000007Y1b-04Ic; Wed, 18 Sep 2024 06:27:38 +0000 Received: from mgamail.intel.com ([198.175.65.14]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sqo90-00000007Xue-1X8y for linux-arm-kernel@lists.infradead.org; Wed, 18 Sep 2024 06:26:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1726640790; x=1758176790; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zSOYUxVDYof5O8HzjP7w7b3TgXQQUUKw4vi7RnEmVQA=; b=jV0LBq1wItmbTF7FXPNsFM+GUnKO02Zdc+rjSMbFRsXCzp6hHaVdcv/P /WrNtcmw0ChztZU9Tq6Egaisy1zHKFGGE1lDK0S4g/DE6jZDB932O4J8K 1bGx0e8E7XLSbmBHbuBIF10SjVbcEEVpsiclpxw7XjPPU1pZdi2M36MCc aIwJWpuk0EoFbGzEuUdUQxdVWlvK9PM/1k/m1gKML8NPqPBm6coE4M/7f mwwpYyX/wC8+HkXembB3I5WUMnLKdTgb74hlg5Mk4Tg8t5Rze8iY3xkTB SgFGC1Gmqzkv5sxUQ/W3TC0OTaCiZ2kteaMXrseaKUw13NMDg+pBT3YW8 Q==; X-CSE-ConnectionGUID: TGjDacR+RTiD1JLbxG5wRA== X-CSE-MsgGUID: fA+2/sIZRmmZ/2ldfrut8Q== X-IronPort-AV: E=McAfee;i="6700,10204,11198"; a="29320980" X-IronPort-AV: E=Sophos;i="6.10,235,1719903600"; d="scan'208";a="29320980" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2024 23:26:28 -0700 X-CSE-ConnectionGUID: cof3tvK7TpKfLtSMiaEe2g== X-CSE-MsgGUID: BP99Hid8QN67+/+d5Z4i8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,235,1719903600"; d="scan'208";a="69300193" Received: from linux.intel.com ([10.54.29.200]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2024 23:26:28 -0700 Received: from P12HL2yongliang.png.intel.com (P12HL2yongliang.png.intel.com [10.158.65.196]) by linux.intel.com (Postfix) with ESMTP id 0530E20CFEE5; Tue, 17 Sep 2024 23:26:24 -0700 (PDT) From: KhaiWenTan To: Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Xiaolei Wang , Simon Horman Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Choong Yong Liang , Tan Khai Wen Subject: [PATCH net v2 1/1] net: stmmac: Fix zero-division error when disabling tc cbs Date: Wed, 18 Sep 2024 14:14:22 +0800 Message-Id: <20240918061422.1589662-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-20240917_232630_480615_37E0F2BF X-CRM114-Status: GOOD ( 11.94 ) 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 Reviewed-by: Simon Horman --- v2: - reflected code for better understanding v1: https://patchwork.kernel.org/project/netdevbpf/patch/20240912015541.363600-1-khai.wen.tan@linux.intel.com/ --- drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index 832998bc020b..75ad2da1a37f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c @@ -386,6 +386,7 @@ static int tc_setup_cbs(struct stmmac_priv *priv, return ret; priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB; + return 0; } /* Final adjustments for HW */