Received: by 10.213.65.68 with SMTP id h4csp1568376imn; Thu, 29 Mar 2018 07:07:30 -0700 (PDT) X-Google-Smtp-Source: AIpwx49i6QFaWPm3MXdYnXwoSNTiCv4QXMKgZxaD6wxvvLarv20IpZNVeOXCqJ4uFTfrnJMBeqs0 X-Received: by 10.98.107.138 with SMTP id g132mr6419475pfc.163.1522332450446; Thu, 29 Mar 2018 07:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522332450; cv=none; d=google.com; s=arc-20160816; b=kG5WA9i5jKwwwSQ7MSRqtjJcuS9ew4hRne6+xmCtzNQk4grPfB+tCewmhXujSmTHW5 0y98NnC9fazYTUqznpZ+GafySrBjZHGPFVe2sz/OWo6GgXfYQDuik5ADH6zw0leLBjMp +TUMCu6y+0q+T/9vs0hWKjtgY0vVU9VQEH9NL8RHdpJh7+NZ0rOWG5QoVDbq0QOKCSNu Y7ABrvfkykSoOXBRR0ZOSVzCfmYppI/8FUB2+VOgjOSekIbTk3y6qd+IkJLOayAK4fwg Q5O5bh7vX7idJoV4rkAVQ+/U1RhzjbFlwGSGI9rZ43TYRRCt6aD2yikbAND5B7Ky4QMc 9CtQ== 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=NXWhBRkjF645qWRWtxEjdlFQnb8PioDM6rW5cJv0cN8=; b=sj98Umyqk7ejHa5mXsTZ8fEfzqr8z96274edQTmXyHJagemyuJT0BuRB28crjLSjMy 048vEORw0Bl//zUX3DpFQWEZUMekd7FiDrB4QRghbmPsl99zv/1dKPjhkZ5gGLV525IS Uwc+wX7/h8grVIe9Y+XR45vv7+muQvqcaAtJPbuO0cyyQg0RC0GrP1xSfTlmdDcE3elH l+B8UfQe724TtTQaGeNcc2APZLaXAYexlZ/ymd13WkovmM6u+LBox6hjeSgPfqXlssDW uvca2GYzGmSBKSoL0fK7qJwzoHpA+qasOPuMt4vzFWbfss6eHWWpVD4Zn8PQdMsOtryf wHCw== 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 z8-v6si1249584plh.126.2018.03.29.07.07.15; Thu, 29 Mar 2018 07:07:30 -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 S1752859AbeC2OF5 (ORCPT + 99 others); Thu, 29 Mar 2018 10:05:57 -0400 Received: from mail.bootlin.com ([62.4.15.54]:41718 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752387AbeC2OFz (ORCPT ); Thu, 29 Mar 2018 10:05:55 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 45AF620879; Thu, 29 Mar 2018 16:05:54 +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, URIBL_BLOCKED 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 180712037A; Thu, 29 Mar 2018 16:05:44 +0200 (CEST) Date: Thu, 29 Mar 2018 16:05:44 +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: <20180329140544.GB12066@piout.net> References: <20180323201117.8416-1-alexandre.belloni@bootlin.com> <20180323201117.8416-4-alexandre.belloni@bootlin.com> <20180323204939.GS24361@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180323204939.GS24361@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 23/03/2018 at 21:49:39 +0100, Andrew Lunn wrote: > On Fri, Mar 23, 2018 at 09:11:12PM +0100, Alexandre Belloni wrote: > > Add a driver for the Microsemi MII Management controller (MIIM) found on > > Microsemi SoCs. > > On Ocelot, there are two controllers, one is connected to the internal > > PHYs, the other one can communicate with external PHYs. > > Hi Alexandre > > This looks to be standalone. Such drivers we try to put in > drivers/net/phy. > > > +static int mscc_miim_read(struct mii_bus *bus, int mii_id, int regnum) > > +{ > > + struct mscc_miim_dev *miim = bus->priv; > > + u32 val; > > + int ret; > > + > > + mutex_lock(&miim->lock); > > What are you locking against here? > > And you don't appear to initialize the mutex anywhere. > > > +static int mscc_miim_reset(struct mii_bus *bus) > > +{ > > + struct mscc_miim_dev *miim = bus->priv; > > + int i; > > + > > + if (miim->phy_regs) { > > + writel(0, miim->phy_regs + MSCC_PHY_REG_PHY_CFG); > > + writel(0x1ff, miim->phy_regs + MSCC_PHY_REG_PHY_CFG); > > + mdelay(500); > > + } > > + > > + 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. Anyway, I'll remove that loop for now because I'm only supporting DT. I'll get back to that later. -- Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com