From patchwork Mon Dec 9 14:15:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 1206296 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 (no SPF record) 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=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="ta0Rhd7i"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47Wlbm70N3z9sP6 for ; Tue, 10 Dec 2019 01:16:04 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727856AbfLIOQE (ORCPT ); Mon, 9 Dec 2019 09:16:04 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:34500 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727513AbfLIOQD (ORCPT ); Mon, 9 Dec 2019 09:16:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=k75eVxRkH9hK0US4CJHl3gA2kV6IWi3YPXYPfOA9oy0=; b=ta0Rhd7idpE4hm5gjLhhVnwN/Q rpmBS5rS0b7+1/MCbUNuVKHTdpjLKD9KHrWeiISO6xbZ1OCsjwmQ4JtgUZVlfWKPZm463kGoFhgIs J2H2kalJleWDmuoKnj0Gti4AZVy0k4zSzTs93cD7kmaMs9Br8S4t7B32o2QbRr0yCYU6uNyw/zVR6 L+sYoaSx9UirjlefbK6GhYOQovKu7e6Vf+akladmQ6G/HDC3lyJ82T/w+xuYtOvllfRDL2IZ3wVUy HG8OIYzNaBYMft8LX9Cc4ERYVvhN5JDzyFi4PWhi4gc6YgNgAsI0BmunikrxOWo566Bh/cD5NFFCt NfUFoT6w==; Received: from e0022681537dd.dyn.armlinux.org.uk ([2002:4e20:1eda:1:222:68ff:fe15:37dd]:50206 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ieJpM-0003Uo-5H; Mon, 09 Dec 2019 14:15:56 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1ieJpL-0004UQ-L7; Mon, 09 Dec 2019 14:15:55 +0000 In-Reply-To: <20191209141525.GK25745@shell.armlinux.org.uk> References: <20191209141525.GK25745@shell.armlinux.org.uk> From: Russell King To: Andrew Lunn , Florian Fainelli , Heiner Kallweit Cc: "David S. Miller" , netdev@vger.kernel.org Subject: [PATCH net-next 1/4] net: sfp: use a definition for the fault recovery attempts MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Mon, 09 Dec 2019 14:15:55 +0000 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Russell King Reviewed-by: Andrew Lunn --- drivers/net/phy/sfp.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index bfe268028154..b1c564b79e3e 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -172,6 +172,14 @@ static const enum gpiod_flags gpio_flags[] = { #define T_RESET_US 10 #define T_FAULT_RECOVER msecs_to_jiffies(1000) +/* N_FAULT_INIT is the number of recovery attempts at module initialisation + * time. If the TX_FAULT signal is not deasserted after this number of + * attempts at clearing it, we decide that the module is faulty. + * N_FAULT is the same but after the module has initialised. + */ +#define N_FAULT_INIT 5 +#define N_FAULT 5 + /* SFP module presence detection is poor: the three MOD DEF signals are * the same length on the PCB, which means it's possible for MOD DEF 0 to * connect before the I2C bus on MOD DEF 1/2. @@ -1885,7 +1893,7 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event) sfp_module_tx_enable(sfp); /* Initialise the fault clearance retries */ - sfp->sm_retries = 5; + sfp->sm_retries = N_FAULT_INIT; /* We need to check the TX_FAULT state, which is not defined * while TX_DISABLE is asserted. The earliest we want to do @@ -1925,7 +1933,7 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event) * or t_start_up, so assume there is a fault. */ sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT, - sfp->sm_retries == 5); + sfp->sm_retries == N_FAULT_INIT); } else if (event == SFP_E_TIMEOUT || event == SFP_E_TX_CLEAR) { init_done: /* TX_FAULT deasserted or we timed out with TX_FAULT * clear. Probe for the PHY and check the LOS state. @@ -1938,7 +1946,7 @@ static void sfp_sm_main(struct sfp *sfp, unsigned int event) sfp_sm_link_check_los(sfp); /* Reset the fault retry count */ - sfp->sm_retries = 5; + sfp->sm_retries = N_FAULT; } break;