Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1967868ima; Thu, 25 Oct 2018 07:42:41 -0700 (PDT) X-Google-Smtp-Source: AJdET5fPl9RCqRpf+KDPyy5I10advrmb2PftQF3ZRRVODmvqTIDWwvQHrNpnraDaRLplKOYyI4WN X-Received: by 2002:a63:700e:: with SMTP id l14-v6mr1670987pgc.359.1540478561829; Thu, 25 Oct 2018 07:42:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540478561; cv=none; d=google.com; s=arc-20160816; b=o4fSAxxfmARotKz6cm7BW9329XeHmeYf8LcUH5IiPFK/R4klW6F33uYXfbnLqGs2DZ WbbxskCcnquqUJ0/WdmJqsSbK7U148EmsAfTG+dH9FGokouzZA1ODKeN8s+D4wB8FJOd TZthpvf95PBHxRsuUUuJagMeof8VNsv6Ee5xVAE+vcGL/fE5ZMajlQ8jMT919GPjyvLx lWr42NgNxjuZUUS8koFfM78lMFWk5ReF3mC313Z4/LN+u6b3fcGJ8cQgwhKBrd8qqyfP knSzQgt70xZ32hYTaLoxVhZVHzqIJLRKtYYPC5aBwqWmrxn3NrffOxj7OjIdPrKMz14j MTWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=YUCkqQ4TZQWQPxrYJn815ApBj41gDLN4uH8HrpA4YZs=; b=d+t9/FNoA0a/sGbAU7fG4QYp97Z4OqOTie/7guQsAKxKhT/ur83HPI63ep8wfadD/W n9pjk6ca795F0cdq7aLHeNZHXpOG/wlKMrIqgKykI7wwQBPCTHtzlAqTwcXro4MJlHwg RGqxGfxZwqhrekbp19lcQxE5DUZUg60Pi4scPZQnSO5NRGssVuZVzXP6QHb/r/RF0RDs Xf4+TPYsqfXo68gCeQmlRWrnUkdvqOMoMq4eo/fFtDA2X5EUXfQ8w38JsXFaEsKR8YBZ gDtEXP8+GP3oP2PV93VYdNTmUIOOUFV486SPJsSLP3Gltpxt29jX7a5/c65ceCyDkbQQ v2PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jspm4Nr5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id s18-v6si3644394pgd.484.2018.10.25.07.42.25; Thu, 25 Oct 2018 07:42:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jspm4Nr5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728973AbeJYWs0 (ORCPT + 99 others); Thu, 25 Oct 2018 18:48:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:57032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728919AbeJYWsY (ORCPT ); Thu, 25 Oct 2018 18:48:24 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C9C820868; Thu, 25 Oct 2018 14:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476928; bh=53xX52h4Yw/EFt8jdx9HH4IU29b7TeImviG7Gapl6kI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jspm4Nr5VlUi4QGAAQuVDu0wm4nkf0zfvcV1cHPOkAK1i4c0SGaWbynTZQoBBlZl+ mUlvAaOWN1oI6/lzt7GfAzjODDM8M4ozMUxogBPKsJLSmb2yZ/eNOewtjeEtvGjPu4 0Rx6g8OFQmsM/RU/jrjjj7ViaVHC4T7BUZV1ElgU= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Talat Batheesh , Saeed Mahameed , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.9 43/98] net/mlx5e: Fix fixpoint divide exception in mlx5e_am_stats_compare Date: Thu, 25 Oct 2018 10:13:28 -0400 Message-Id: <20181025141423.213774-43-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141423.213774-1-sashal@kernel.org> References: <20181025141423.213774-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Talat Batheesh [ Upstream commit e58edaa4863583b54409444f11b4f80dff0af1cd ] Helmut reported a bug about division by zero while running traffic and doing physical cable pull test. When the cable unplugged the ppms become zero, so when dividing the current ppms by the previous ppms in the next dim iteration there is division by zero. This patch prevent this division for both ppms and epms. Fixes: c3164d2fc48f ("net/mlx5e: Added BW check for DIM decision mechanism") Reported-by: Helmut Grauer Signed-off-by: Talat Batheesh Signed-off-by: Saeed Mahameed Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c index 23ccec4cb7f5..a1f3556307c7 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx_am.c @@ -197,9 +197,15 @@ static int mlx5e_am_stats_compare(struct mlx5e_rx_am_stats *curr, return (curr->bpms > prev->bpms) ? MLX5E_AM_STATS_BETTER : MLX5E_AM_STATS_WORSE; + if (!prev->ppms) + return curr->ppms ? MLX5E_AM_STATS_BETTER : + MLX5E_AM_STATS_SAME; + if (IS_SIGNIFICANT_DIFF(curr->ppms, prev->ppms)) return (curr->ppms > prev->ppms) ? MLX5E_AM_STATS_BETTER : MLX5E_AM_STATS_WORSE; + if (!prev->epms) + return MLX5E_AM_STATS_SAME; if (IS_SIGNIFICANT_DIFF(curr->epms, prev->epms)) return (curr->epms < prev->epms) ? MLX5E_AM_STATS_BETTER : -- 2.17.1