Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5893861imb; Fri, 8 Mar 2019 04:57:24 -0800 (PST) X-Google-Smtp-Source: APXvYqzk3gIB1WNnbRzDFyycH0JlzttXYzCWN51cWMTeLQxbHsedhKti6kCCnrgVGfCNe8HfoYMK X-Received: by 2002:a17:902:6804:: with SMTP id h4mr18600709plk.115.1552049844332; Fri, 08 Mar 2019 04:57:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552049844; cv=none; d=google.com; s=arc-20160816; b=f+zqDaTPHDAWuLw9Lr54jHGtblVX6zh442d2VeRiUfl5BcC99wphLWgtEtj1SlqhMF 9Ozu6YqAznY9spnHYW16p4Gd87rRAyRFhRRbT9zFVD7INn9d67R9DalsH1sjYTPN/A2H uFrOHzzRBbu+SdgUIwsndzzZdKSb4Thcs0gHuwleIYAOvBc/K4V8P8iKoEsP8i9PQzno DkmZ+Qy8Dhcd05RsaZXiAIFy6tk1V5KEbRKxY7yRF2XwRoz9p+n5ppo+5+8z2/n/ISk3 0RZCdVKXtHU2E12Tqq2daMaOGULKdOusYN1uNh/uZV9NXOVSHFVK5GT34MhmBQjg3Woe daag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kFEknq1u/PSklgKzoTBTmgtyNznamalmycOq0tSSWrY=; b=y0USalLo4Ud7Dbs/E5p0DMSgbNa3EF4xyzXTin3osOS9teU5tPXVjJXLQjWkJJsdMN mVS4y5PeNlGZKqraKFXJmizheGXDVVNVulmyOiZrJUnTaB74wga93KGZFY7CJloj/U5j LmujsP9Ikn92+nkBC5L+i/fZ/G6bXtkRJ01Bk/j6mi6oGv3aY3mtStU7NUrVg8BCyeRc TrlvFECyXfr0upR6NhD1haia9auZhSBaPnoBah8iDefJlpJOPHo4C9Njg9eB4P6PLyzC KQEBhhimyxtk1jjCk2LFq7cDwE+VfJOcyCz93sRX/g6WVXSkYJiO0f+CWl76CPXjhp0M iSlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LKFYRahW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e17si6941722pfh.6.2019.03.08.04.57.08; Fri, 08 Mar 2019 04:57:24 -0800 (PST) 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=LKFYRahW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727615AbfCHM4E (ORCPT + 99 others); Fri, 8 Mar 2019 07:56:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:60288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727065AbfCHM4D (ORCPT ); Fri, 8 Mar 2019 07:56:03 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 499A12087C; Fri, 8 Mar 2019 12:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552049762; bh=avf5HClIququXIe+EZhsV+qJq+ZLqYQ9cYg7ZRVPw9M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LKFYRahWZB8YHs1eMCu3pJ5+rMqaH4pbuNadIM1dfwWiI2Vvtz/NWY4Qr7bfzBraQ ngP5WzLc67Ey2kKhuxYOXEKs3zZ/X5dti/8oD+Griav6g3PhAzu1lG2u3WlrfbtQ6y LlybyEeRda+/DR2epR9juRiyvZBsyUNUtZ4nEqqI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heiner Kallweit , "David S. Miller" Subject: [PATCH 4.20 56/76] net: dsa: mv88e6xxx: prevent interrupt storm caused by mv88e6390x_port_set_cmode Date: Fri, 8 Mar 2019 13:50:08 +0100 Message-Id: <20190308124916.786451030@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190308124914.789210760@linuxfoundation.org> References: <20190308124914.789210760@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Heiner Kallweit [ Upstream commit ed8fe20205ac054bf585156709de3913d1890f30 ] When debugging another issue I faced an interrupt storm in this driver (88E6390, port 9 in SGMII mode), consisting of alternating link-up / link-down interrupts. Analysis showed that the driver wanted to set a cmode that was set already. But so far mv88e6390x_port_set_cmode() doesn't check this and powers down SERDES, what causes the link to break, and eventually results in the described interrupt storm. Fix this by checking whether the cmode actually changes. We want that the very first call to mv88e6390x_port_set_cmode() always configures the registers, therefore initialize port.cmode with a value that is different from any supported cmode value. We have to take care that we only init the ports cmode once chip->info->num_ports is set. v2: - add small helper and init the number of actual ports only Fixes: 364e9d7776a3 ("net: dsa: mv88e6xxx: Power on/off SERDES on cmode change") Signed-off-by: Heiner Kallweit Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/mv88e6xxx/chip.c | 10 ++++++++++ drivers/net/dsa/mv88e6xxx/port.c | 4 ++++ drivers/net/dsa/mv88e6xxx/port.h | 1 + 3 files changed, 15 insertions(+) --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -4579,6 +4579,14 @@ static int mv88e6xxx_smi_init(struct mv8 return 0; } +static void mv88e6xxx_ports_cmode_init(struct mv88e6xxx_chip *chip) +{ + int i; + + for (i = 0; i < mv88e6xxx_num_ports(chip); i++) + chip->ports[i].cmode = MV88E6XXX_PORT_STS_CMODE_INVALID; +} + static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds, int port) { @@ -4615,6 +4623,8 @@ static const char *mv88e6xxx_drv_probe(s if (err) goto free; + mv88e6xxx_ports_cmode_init(chip); + mutex_lock(&chip->reg_lock); err = mv88e6xxx_switch_reset(chip); mutex_unlock(&chip->reg_lock); --- a/drivers/net/dsa/mv88e6xxx/port.c +++ b/drivers/net/dsa/mv88e6xxx/port.c @@ -395,6 +395,10 @@ int mv88e6390x_port_set_cmode(struct mv8 cmode = 0; } + /* cmode doesn't change, nothing to do for us */ + if (cmode == chip->ports[port].cmode) + return 0; + lane = mv88e6390x_serdes_get_lane(chip, port); if (lane < 0) return lane; --- a/drivers/net/dsa/mv88e6xxx/port.h +++ b/drivers/net/dsa/mv88e6xxx/port.h @@ -52,6 +52,7 @@ #define MV88E6185_PORT_STS_CMODE_1000BASE_X 0x0005 #define MV88E6185_PORT_STS_CMODE_PHY 0x0006 #define MV88E6185_PORT_STS_CMODE_DISABLED 0x0007 +#define MV88E6XXX_PORT_STS_CMODE_INVALID 0xff /* Offset 0x01: MAC (or PCS or Physical) Control Register */ #define MV88E6XXX_PORT_MAC_CTL 0x01