Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2160264ybd; Thu, 27 Jun 2019 07:45:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjH0ZhRETm9gJJ74iBZmwaGgJGGWsC71KiPHaHBiW3ThdJDzP7Bqt3YabObZTL1w+cvShj X-Received: by 2002:a63:130c:: with SMTP id i12mr4121895pgl.316.1561646728656; Thu, 27 Jun 2019 07:45:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561646728; cv=none; d=google.com; s=arc-20160816; b=uQOHFJNUEFHbU705n3/J9Qsr4f9a7yoTXxfx0NRCXhT+aigvTA2AumTO1uXkNf+Nyj 5lbSv2BfWuQsGxQvPpHotM/5xNdwySPkyzG8Tzj3UpZLgHlLYKcszk7Cu4yI70rYbQ6y FZN8E++uUSra3xCdiNne2V+8wbhLu+W8qie+KTTp0cvpMEpKDorOXcxtbZ0mxlbTAf73 D8ePSZ2KkxXXeV+zzvJwEqNpi9kwKrC+c17wfbsCtmasKrh8VnHHfXp/GDJ+x/UH/gLE uxb71ZOZWJfXJk+Ne3vP6g7QwlaRV7TjUqbJYyPT3wQ2G7x6dAMiTNMG5qrVOVbFX6yS HZXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=tx6dF92XYQvz4YacD0VR8WVxRaiNwFBa+2vW1h35TBI=; b=RTsjlEDdbnHMFoDFn7IzbqWKBEZTgcj0I9Nw/xLozbdnED3J16tCMRGRAcCnuSmsPR 4oxgsvyGQ9i2bJLHmxa5cCNO7zf54GU+pSX4M7wNwmPJUlvJIwMrclb26r+IFdzkjjoq U0TUWD0gDK3IpEyTfCbVEsEJoUKeYHRXf9Nwte0Eeea3XilSLiI+FHdnAf2lomyfSVAz 5co9QhOyYTmTTEJVDDVA98VuZjqOvZWD911OpByTCVH4DMlP/zXHcIIT8rYEGzJdsZMW vqEv72k6bcCWP6rH6yg2djxmJejWRlY6Q9paLwcMpPG/MNejGk7wZKidpB6lNmLnBcgW 9nMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=F1tWzUYq; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u24si2656034plq.430.2019.06.27.07.45.12; Thu, 27 Jun 2019 07:45:28 -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=fail header.i=@lunn.ch header.s=20171124 header.b=F1tWzUYq; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbfF0Ono (ORCPT + 99 others); Thu, 27 Jun 2019 10:43:44 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:37094 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726425AbfF0Onn (ORCPT ); Thu, 27 Jun 2019 10:43:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=tx6dF92XYQvz4YacD0VR8WVxRaiNwFBa+2vW1h35TBI=; b=F1tWzUYqbyKtgS6PIeqs3RaAq/ Q/TGgUztRsGKuL0McSm5Sa5oRGuSsC4zkZiof69ujvLInt7txfhqHyQMgsCNYEpP2QJ55mxWB00u1 Or12BnnWm+Wc1RVkI9tqCCGVTE71TW+kWZqjxrHv1a9z9piOaW82mLB96XZnBk3/+9JM=; Received: from andrew by vps0.lunn.ch with local (Exim 4.89) (envelope-from ) id 1hgVch-0000Yx-16; Thu, 27 Jun 2019 16:43:39 +0200 Date: Thu, 27 Jun 2019 16:43:39 +0200 From: Andrew Lunn To: Corentin Labbe Cc: jacmet@sunsite.dk, davem@davemloft.net, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [BUG] net: dm9600: false link status Message-ID: <20190627144339.GG31189@lunn.ch> References: <20190627132137.GB29016@Red> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190627132137.GB29016@Red> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 27, 2019 at 03:21:37PM +0200, Corentin Labbe wrote: > Hello > > I own an USB dongle which is a "Davicom DM96xx USB 10/100 Ethernet". > According to the CHIP_ID, it is a DM9620. > > Since I needed for bringing network to uboot for a board, I have started to create its uboot's driver. > My uboot driver is based on the dm9600 Linux driver. > > The dongle was working but very very slowy (24Kib/s). > After some debug i found that the main problem was that it always link to 10Mbit/s Half-duplex. (according to the MAC registers) > > For checking the status of the dongle I have plugged it on a Linux box which give me: > dm9601 6-2:1.0 enp0s29f0u2: link up, 100Mbps, full-duplex, lpa 0xFFFF > > But in fact the Linux driver is tricked. > > I have added debug of MDIO write/read and got: > [157550.926974] dm9601 6-2:1.0 (unnamed net_device) (uninitialized): dm9601_mdio_write() phy_id=0x00, loc=0x00, val=0x8000 Writing the reset bit. Ideally you should read back the register and wait for this bit to clear. Try adding this, and see if this helps, or you get 0xffff. > [157550.931962] dm9601 6-2:1.0 (unnamed net_device) (uninitialized): dm9601_mdio_write() phy_id=0x00, loc=0x04, val=0x05e1 Advertisement control register. > [157550.951967] dm9601 6-2:1.0 (unnamed net_device) (uninitialized): dm9601_mdio_read() phy_id=0x00, loc=0x00, returns=0xffff And now things are bad. In theory, the power down bit is set, and some PHYs don't respond properly when powered down. However, it is unclear how it got into this state. Did the reset kill it, or setting the advertisement? Or is the PHY simply not responding at all. The MDIO data lines have a pull up, so if the device does not respond, reads give 0xffff. Maybe also check register 0, bit 7, EXT_PHY. Is it 0, indicating the internal PHY should be used? You could also try reading PHY registers 2 and 3 and see if you can get a valid looking PHY ID. Maybe try that before hitting the reset bit? > So it exsists two problem: > - Linux saying 100Mbps, full-duplex even if it is false. The driver is using the old mii code, not a phy driver. So i cannot help too much with linux. But if you can get the MDIO bus working reliably, it should be possible to move this over to phylib. The internal PHY appears to have all the standard registers, so the generic PHY driver has a good chance of working. Andrew