From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66CB1C282C4 for ; Sat, 9 Feb 2019 06:09:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 306C921903 for ; Sat, 9 Feb 2019 06:09:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbfBIGJ0 (ORCPT ); Sat, 9 Feb 2019 01:09:26 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:41138 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725925AbfBIGJZ (ORCPT ); Sat, 9 Feb 2019 01:09:25 -0500 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::bf5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 278541496ED41; Fri, 8 Feb 2019 22:09:25 -0800 (PST) Date: Fri, 08 Feb 2019 22:09:24 -0800 (PST) Message-Id: <20190208.220924.1009748238168528290.davem@davemloft.net> To: hkallweit1@gmail.com Cc: andrew@lunn.ch, f.fainelli@gmail.com, netdev@vger.kernel.org, linux@armlinux.org.uk Subject: Re: [PATCH net-next] net: phy: consider latched link-down status in polling mode From: David Miller In-Reply-To: <7180c54c-34b2-0a36-97ff-bbda302eb427@gmail.com> References: <7180c54c-34b2-0a36-97ff-bbda302eb427@gmail.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 08 Feb 2019 22:09:25 -0800 (PST) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Heiner Kallweit Date: Wed, 6 Feb 2019 19:39:52 +0100 > The link status value latches link-down events. To get the current > status we read the register twice in genphy_update_link(). There's > a potential risk that we miss a link-down event in polling mode. > This may cause issues if the user e.g. connects his machine to a > different network. > > On the other hand reading the latched value may cause issues in > interrupt mode. Following scenario: > > - After boot link goes up > - phy_start() is called triggering an aneg restart, hence link goes > down and link-down info is latched. > - After aneg has finished link goes up and triggers an interrupt. > Interrupt handler reads link status, means it reads the latched > "link is down" info. But there won't be another interrupt as long > as link stays up, therefore phylib will never recognize that link > is up. > > Deal with both scenarios by reading the register twice in interrupt > mode only. > > Signed-off-by: Heiner Kallweit Applied, thanks.