Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3085686yba; Mon, 22 Apr 2019 19:35:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8P7PiwE2XxV0MgCNJlZfS/VxlM7FiIG7frNyLrLY5els9yGBbjicPpgKp36/HzpG0/nwp X-Received: by 2002:a62:121c:: with SMTP id a28mr23916980pfj.58.1555986929464; Mon, 22 Apr 2019 19:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555986929; cv=none; d=google.com; s=arc-20160816; b=r9YqIBMFve94YUenx2Qnj2JKbeVkcw3pOoP/OKK41RmpP87oU5sZlOd/T1RfUX6DbF wJ/gPlMRbFOiK5hyrJjMh3QjkIcsoIPq/WJCsXDF9ZYM5iASKNbeXRCmVmqSWOP1Gh2u 3PZHrt8ztBTZoL0keAOSAKBcPba8+8tRJuxl1coQ1Ncx8yN2bJIhwxs9kt3rfdD0GV0X Y3VCojbH+/pFz/c7RYCnmMyP7S020uSUYWeMxOhNAWJuqtdNDR+8+ul8Mkmk9p0BdbUI mQo1KXSSPIdsEdZQWj4bzYOHk5dMKfgWqUnffiTXQbwtHK+4ENlx4q8AXJ5tbfBcaVq0 JdRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JXwVVlHMGGfx6SS007dZE8oZV9pKSybkdFDYw5QZM0c=; b=BvzAq7NDoOLrUFGA/K4GSmTjsROPZWMvElxRPzWtXfaQthR1Dv289q8T8+yUk4AVTZ f2dNpABwjIbwLSjH4mJMxSR3/nEKzTxk6t9PGYxtGYjXIfKbbi7dWTUFOjKYFzX18MBM eCWlnW7O3rrgpIZtFGdRWKomnK6aPSC7z4BZxfOT3SJYbvqEXC9ioPrpMjMj1z31jXyb Hfwirtz8pd6ZZ7Gf0N6TkNDzhLKTJiyL0qcG6aZiFDyNazbdqzIA69fj61xxfWlwukqZ cm0iXm+Rm39hD3VsALI7sfWxg6mg/4oTjreBdfYzqgxXLuMhTKfNCI0eU/mka5EsuyDq Hwpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jTTP5DID; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j23si978870pff.108.2019.04.22.19.35.14; Mon, 22 Apr 2019 19:35:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jTTP5DID; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732068AbfDVUCv (ORCPT + 99 others); Mon, 22 Apr 2019 16:02:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:48580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729935AbfDVTqU (ORCPT ); Mon, 22 Apr 2019 15:46:20 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C7570218FC; Mon, 22 Apr 2019 19:46:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962379; bh=fIhX/tNaCof+lPJyKim+YQEZAb2IukfLs34A9hCcUOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jTTP5DID3bhdp4Bv29+4CZXgdfJNbVKuOqNXHD0huLFXzFuAwMzhkAidbd1DGOM/5 k3HtffcrxJ0LQmm1fqGJuMfIv21qkhEfwFJnihUqON2RXztDiHBSFwsA3fyw5XFEqc KWfvJckoGFa7kdOoWT9pOZhi+8UzmCM2QUocFij4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lukas Wunner , Frank Pavlic , Ben Dooks , Tristram Ha , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 30/68] net: ks8851: Set initial carrier state to down Date: Mon, 22 Apr 2019 15:44:38 -0400 Message-Id: <20190422194516.11634-30-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194516.11634-1-sashal@kernel.org> References: <20190422194516.11634-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner [ 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 c9faec4c5b25..b83b070a9eec 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -858,6 +858,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; } @@ -1519,6 +1520,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