From patchwork Thu Apr 18 01:11:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 1087328 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lunn.ch Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=lunn.ch header.i=@lunn.ch header.b="YS/3F3kq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44l1Lq6ZJ8z9s3Z for ; Thu, 18 Apr 2019 11:13:07 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732898AbfDRBM3 (ORCPT ); Wed, 17 Apr 2019 21:12:29 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:36914 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728268AbfDRBM3 (ORCPT ); Wed, 17 Apr 2019 21:12:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version :Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=cfAKKbOntr31Ns5hOI1qvgozDnu5jgO+EJ/MEcN0hPg=; b=YS/3F3kqNmYfRWy65I+a7aDy5i hBLHBQbUM5gdD4a4LHvh4saNcuj2/lvIJwlBuRUCs+JXunYZChUdDRnW3UpNFZFnaUidk/L+dmksw 5jfDA7Z/ZTniTfUiukMsi7oBaMiPc5zgEzzwJT1Qf1FXsTLW7Y/rmB+uFn/oB4dDLbQ4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.89) (envelope-from ) id 1hGvaY-00042n-Aq; Thu, 18 Apr 2019 03:11:42 +0200 From: Andrew Lunn To: David Miller Cc: Vivien Didelot , netdev , Andrew Lunn Subject: [PATCH net-next] net: dsa: mv88e6xxx: Only reconfigure MAC when something changes Date: Thu, 18 Apr 2019 03:11:39 +0200 Message-Id: <20190418011139.15506-1-andrew@lunn.ch> X-Mailer: git-send-email 2.11.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org phylink will call the mac_config() callback once per second when polling a PHY or a fixed link. The MAC driver is not supposed to reconfigure the MAC if nothing has changed. Make the mv88e6xxx driver look at the current configuration of the port, and return early if nothing has changed. Signed-off-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx/chip.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 65da6709a173..bfd5a7faef3b 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -553,11 +553,28 @@ int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link, int speed, int duplex, int pause, phy_interface_t mode) { + struct phylink_link_state state; int err; if (!chip->info->ops->port_set_link) return 0; + if (!chip->info->ops->port_link_state) + return 0; + + err = chip->info->ops->port_link_state(chip, port, &state); + if (err) + return err; + + /* Has anything actually changed? We don't expect the + * interface mode to change without one of the other + * parameters also changing + */ + if (state.link == link && + state.speed == speed && + state.duplex == duplex) + return 0; + /* Port's MAC control must not be changed unless the link is down */ err = chip->info->ops->port_set_link(chip, port, 0); if (err)