All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: "David S. Miller" <davem@davemloft.net>,
	Tristram Ha <Tristram.Ha@microchip.com>,
	netdev@vger.kernel.org
Cc: Frank Pavlic <f.pavlic@kunbus.de>,
	Eduard Mainhardt <e.mainhardt@kunbus.de>,
	Ben Dooks <ben.dooks@codethink.co.uk>, Nishanth Menon <nm@ti.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Sergey Shcherbakov <shchers@gmail.com>,
	Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Subject: [PATCH 4/6] net: ks8851: Set initial carrier state to down
Date: Wed, 20 Mar 2019 15:02:00 +0100	[thread overview]
Message-ID: <b61eceed52beb9253d3e77fcef5e5c0cdac25bad.1553089248.git.lukas@wunner.de> (raw)
In-Reply-To: <cover.1553089248.git.lukas@wunner.de>

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 <lukas@wunner.de>
Cc: Frank Pavlic <f.pavlic@kunbus.de>
Cc: Ben Dooks <ben.dooks@codethink.co.uk>
Cc: Tristram Ha <Tristram.Ha@microchip.com>
---
 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.20.1


  parent reply	other threads:[~2019-03-20 14:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 14:02 [PATCH 0/6] ks8851 fixes & cleanups Lukas Wunner
2019-03-20 14:02 ` [PATCH 2/6] net: ks8851: Reassert reset pin if chip ID check fails Lukas Wunner
2019-03-20 14:02 ` [PATCH 6/6] net: ks8851: Deduplicate register macros Lukas Wunner
2019-03-20 14:02 ` Lukas Wunner [this message]
2019-03-20 14:02 ` [PATCH 1/6] net: ks8851: Dequeue RX packets explicitly Lukas Wunner
2019-03-20 14:02 ` [PATCH 5/6] net: ks8851: Fix register macro misnomers Lukas Wunner
2019-03-20 14:02 ` [PATCH 3/6] net: ks8851: Delay requesting IRQ until opened Lukas Wunner
2019-03-20 17:26 ` [PATCH 0/6] ks8851 fixes & cleanups Ben Dooks
2019-03-20 19:44 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b61eceed52beb9253d3e77fcef5e5c0cdac25bad.1553089248.git.lukas@wunner.de \
    --to=lukas@wunner.de \
    --cc=Tristram.Ha@microchip.com \
    --cc=ben.dooks@codethink.co.uk \
    --cc=davem@davemloft.net \
    --cc=e.mainhardt@kunbus.de \
    --cc=f.pavlic@kunbus.de \
    --cc=netdev@vger.kernel.org \
    --cc=nm@ti.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=sboyd@codeaurora.org \
    --cc=shchers@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.