Received: by 10.213.65.68 with SMTP id h4csp1615052imn; Thu, 29 Mar 2018 07:55:45 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/P5zXvHobYwF/qpwchV5Qng2W6BM62ZCE3QrSWpLJ9XGepqp3ticyK8WXfYV98BonSaZll X-Received: by 10.101.101.66 with SMTP id a2mr5847929pgw.223.1522335345362; Thu, 29 Mar 2018 07:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522335345; cv=none; d=google.com; s=arc-20160816; b=w86aDyaYFPShzt6tCM4ghK2kHVtuGayLJ3HRkr3C8FVw3RA9ooOUTtJEUmFhhz6MMu Q7DuAhrB7Qx3km35jtHQLFG3gFBvShkJrg8ANVj0YDOM2Sco5t9urx9IbNwYaMEHugnf kCzHFsSiiu1Lu8MtNSMrorSfOhQ5UJwPxW9rDlYP+I1ExpCe9YEhfdtaZHzh6krizTd6 jt+AWjaHZzfrejbHZhrD6MZ6ouOCpCuHwecGLplih+PB74ffA8bfRiijRZz8PC2HkY4f MmhmuFynmD0FCcaQAiXyqbR7fxr7+E6B9leLl6asK2fjv7VfTrruGNIiJLv8CGP/1dhG viQg== 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:arc-authentication-results; bh=fX+qbL+GB0wnKkstTjpl+vUhJspiob3QBg0AXcYywhM=; b=AVaVa3V1pbslV1KGeYwb15XhBCj6UDBm0FbLVa4wsP9Yt77ANlYPhBFFFDQ/AVTdxY Pdpr0s+7O5U4gVPZSrvNa7TSjBF+IUasPLHcQLDlVGL9M4aSTBH9p/LZa8XjLq3FAbdq JU52E6adJU4kp7HZFjeaE0qRsOAH5fBuPCN7Rl4HTHbAPRp6QeuRmkfdPlQHoBO9B8vz LRPXdCN/gUXlluCK9wAf5GmFRuWkPLGhlHS9luIsNMZRDqn/fecgX5RIMoxpFUhzXJE2 dmkX4HWOOM4hdmih9aqbUwboAcQ+YeZiwY5cRY8es3/rYB3Cb1rI/Y6SxMWKFSymKkgJ dYOg== ARC-Authentication-Results: i=1; mx.google.com; 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 71-v6si6144985pla.707.2018.03.29.07.55.31; Thu, 29 Mar 2018 07:55:45 -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; 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 S1752096AbeC2OyG (ORCPT + 99 others); Thu, 29 Mar 2018 10:54:06 -0400 Received: from mail.bootlin.com ([62.4.15.54]:43453 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751096AbeC2OyE (ORCPT ); Thu, 29 Mar 2018 10:54:04 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 212AC2037A; Thu, 29 Mar 2018 16:54:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (242.171.71.37.rev.sfr.net [37.71.171.242]) by mail.bootlin.com (Postfix) with ESMTPSA id E94D420711; Thu, 29 Mar 2018 16:53:52 +0200 (CEST) Date: Thu, 29 Mar 2018 16:53:52 +0200 From: Alexandre Belloni To: Andrew Lunn Cc: "David S . Miller" , Allan Nielsen , razvan.stefanescu@nxp.com, po.liu@nxp.com, Thomas Petazzoni , Florian Fainelli , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@linux-mips.org Subject: Re: [PATCH net-next 3/8] net: mscc: Add MDIO driver Message-ID: <20180329145352.GD12066@piout.net> References: <20180323201117.8416-1-alexandre.belloni@bootlin.com> <20180323201117.8416-4-alexandre.belloni@bootlin.com> <20180323204939.GS24361@lunn.ch> <20180329140544.GB12066@piout.net> <20180329144041.GA25752@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180329144041.GA25752@lunn.ch> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29/03/2018 at 16:40:41 +0200, Andrew Lunn wrote: > > > > + for (i = 0; i < PHY_MAX_ADDR; i++) { > > > > + if (mscc_miim_read(bus, i, MII_PHYSID1) < 0) > > > > + bus->phy_mask |= BIT(i); > > > > + } > > > > > > Why do this? Especially so for the external bus, where the PHYs might > > > have a GPIO reset line, and won't respond until the gpio is > > > released. The core code does that just before it scans the bus, or > > > just before it scans the particular address on the bus, depending on > > > the scope of the GPIO. > > > > > > > IIRC, this was needed when probing the bus without DT, in that case, the > > mdiobus_scan loop of __mdiobus_register() will fail when doing the > > get_phy_id for phys 0 to 31 because get_phy_id() transforms any error in > > -EIO and so it is impossible to register the bus. Other drivers have a > > similar code to handle that case. > > Hi Alexandre > > Do you mean mscc_miim_read() will return -EIO if there is no device on > the bus at the address trying to be read? Most devices just return > 0xffff because there is a pull up on the data line, nothing is driving > it, so all 1's are read. > It will return -EIO but I tried to be clever and return -ENODEV but this gets changed to -EIO by get_phy_id. > It sounds like the correct fix is for get_phy_id() to look at the > error code for mdiobus_read(bus, addr, MII_PHYSID1). If it is EIO and > maybe ENODEV, set *phy_id to 0xffffffff and return. The scan code > should then do the correct thing. > That could work indeed. Do you want me to test and send a patch? -- Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com