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=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 50120C04E53 for ; Wed, 15 May 2019 12:12:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 208F920843 for ; Wed, 15 May 2019 12:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557922372; bh=D/64HTEq5TJyB4qOEq58aXDKxa6owfviGOt17SJA/X4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=e3M3ndu9jPzucCqw+KorCm/Gqodnx7mvDrsCnmFi6RxMkcVaUNTp+XvovWlKXBZ2/ qq3ZHiaMhisUTRKq4Je6j8m5s0SqAGSR7bufNV6pIzPbkRCHKajmgfYWbS0zrmc2IK j5g3lXC7ZVfNVadyRsleUngWy7cuumEJBT4oJrC8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728125AbfEOLF7 (ORCPT ); Wed, 15 May 2019 07:05:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:36400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725966AbfEOLF6 (ORCPT ); Wed, 15 May 2019 07:05:58 -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 768EE216FD; Wed, 15 May 2019 11:05:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918358; bh=D/64HTEq5TJyB4qOEq58aXDKxa6owfviGOt17SJA/X4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eqTX5BZTkvsZr0MpVl2ZmMTFgClgfZw/5kfwNd7ezgMNJPTNueoeWO6F1tbvKINUz QULlVDcJqaHY761D4rehb9zRxEgvmQSrL7L1dA4IadzJvMaEJVK5h7kSS/h9vFU7dn tvJD/zRK9wRw4sTMePYmeudkuRwy0PFTeBz0erfI= 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.4 099/266] net: ks8851: Set initial carrier state to down Date: Wed, 15 May 2019 12:53:26 +0200 Message-Id: <20190515090725.799106874@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090722.696531131@linuxfoundation.org> References: <20190515090722.696531131@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 ff6cab4f6343..7377dca6eb57 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -870,6 +870,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; } @@ -1527,6 +1528,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