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=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,T_DKIMWL_WL_HIGH,USER_AGENT_GIT 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 E7ABCC04AA9 for ; Thu, 2 May 2019 15:24:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B62AC21670 for ; Thu, 2 May 2019 15:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556810649; bh=i54gu8M1Gac1Abp/1+h0ZD6qWrpfaSAE41vGpfFq4/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Y+k+X3X7piNvV9jIB/PIMDflSPlcRbhF1Ds0vJLzDWqdtVGroP9QxgAJ7Hh4jqWbf 3XDotUyG88odzVASa5qb+x/6lrDCVtNOHTH4dFiZDe3vJVAtkMJ3pDaZZ3PvVJjn1K YRp5CfKpTySVbCHxCXfxt2nSbdh/vVrUoG/FTGlg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727216AbfEBPYI (ORCPT ); Thu, 2 May 2019 11:24:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:39876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727189AbfEBPYF (ORCPT ); Thu, 2 May 2019 11:24:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 B9E0D2085A; Thu, 2 May 2019 15:24:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556810644; bh=i54gu8M1Gac1Abp/1+h0ZD6qWrpfaSAE41vGpfFq4/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AYb8MR8ZkfdLhwwyLNyMecFENxKIFi5hM4+F7sX7YE/LNLjpkIs9MbwIf3XJcgiTm jzqbO0NvT6nsz/RYSC5brb5gawoC6gq7tInpQ9tJ/Xgkw4kC4QVFmNx6Fx6jIcUkj9 DQDOL+bwpif9sao+fe7fWdigabMfkKlRu9TYhHSY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Frank Pavlic , Ben Dooks , Tristram Ha , "David S. Miller" , "Sasha Levin (Microsoft)" Subject: [PATCH 4.14 24/49] net: ks8851: Set initial carrier state to down Date: Thu, 2 May 2019 17:21:01 +0200 Message-Id: <20190502143326.953300590@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190502143323.397051088@linuxfoundation.org> References: <20190502143323.397051088@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 9624bafa5f6418b9ca5b3f66d1f6a6a2e8bf6d4c ] The ks8851 chip's initial carrier state is down. A Link Change Interrupt is signaled once interrupts are enabled if the carrier is up. The ks8851 driver has it backwards by assuming that the initial carrier state is up. The state is therefore misrepresented if the interface is opened with no cable attached. Fix it. The Link Change interrupt is sometimes not signaled unless the P1MBSR register (which contains the Link Status bit) is read on ->ndo_open(). This might be a hardware erratum. Read the register by calling mii_check_link(), which has the desirable side effect of setting the carrier state to down if the cable was detached while the interface was closed. Signed-off-by: Lukas Wunner Cc: Frank Pavlic Cc: Ben Dooks Cc: Tristram Ha Signed-off-by: David S. Miller Signed-off-by: Sasha Levin (Microsoft) --- drivers/net/ethernet/micrel/ks8851.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index b8f20aa2b7ad..7ddaa7d88f1d 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -849,6 +849,7 @@ static int ks8851_net_open(struct net_device *dev) netif_dbg(ks, ifup, ks->netdev, "network device up\n"); mutex_unlock(&ks->lock); + mii_check_link(&ks->mii); return 0; } @@ -1510,6 +1511,7 @@ static int ks8851_probe(struct spi_device *spi) spi_set_drvdata(spi, ks); + netif_carrier_off(ks->netdev); ndev->if_port = IF_PORT_100BASET; ndev->netdev_ops = &ks8851_netdev_ops; ndev->irq = spi->irq; -- 2.19.1