From patchwork Fri Mar 11 17:53:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 8568291 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7E79DC0553 for ; Fri, 11 Mar 2016 17:55:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ADCDB2026D for ; Fri, 11 Mar 2016 17:55:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3B5A202E9 for ; Fri, 11 Mar 2016 17:55:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aeRGA-0007kh-J3; Fri, 11 Mar 2016 17:53:58 +0000 Received: from mail-pa0-x244.google.com ([2607:f8b0:400e:c03::244]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aeRFt-0007WF-HY for linux-arm-kernel@lists.infradead.org; Fri, 11 Mar 2016 17:53:43 +0000 Received: by mail-pa0-x244.google.com with SMTP id fl4so9033858pad.2 for ; Fri, 11 Mar 2016 09:53:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nQTuROwoPZW3G+ExbYWm98E1TL/1ZMOXt+HPft/JRbA=; b=kjxzr6UPslJLHR7vLuI3I3t55rpEF5UQRA8qnnV4A6+KgPjAYRksxnslyGgj4JvbwE Ffv8Sdo34mssSMzTwVHX5KAC1D3GMkp1AU/pPNJCwIotoIZkJiuiyzeIxDnz3Yaem89r ik47+L2D+3hRlqMNkhQllikm423QB3FbeaFi4oaNqk5YMhPVk1PcuS6GShqK10A/LKKK OTNQnDtuexr3C1SJ34RLMb4VQsBuavmR2N8jL+7+PpOFiAo53Ul0NHKajKrJkvSmqgRd 5Ynx1oaeJ/kWrSSGxYrSpshuZF4MjPp/eL3wRxsfMAb1FD12rzQyzDSS7mdfnTXwBrZI vcVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nQTuROwoPZW3G+ExbYWm98E1TL/1ZMOXt+HPft/JRbA=; b=MhefflwZsCD4xVMxCrcG+0rXtHbed5QCrM5K5HP4cxt9S2eQ9QigLUvFDMDhIwbCDS MXWwcaTHe+zZU7eaRkpYg0pwKGp+7ExDTxm4Qko0sEPSK+mBlUr6V+XK2SFH+PXOQDT7 X7tNZY/LaJc6KO4dNOCr/D0pcTZRkyN6yv1gZyzm58g+GrycTHkgMucEigsZZwaCXf3u IHEWxnOWNEkxTENBt70PIXQlEk566rG9bZKnG34ljIXA9/KFZtssR+V/gPwhp8Q5Accu Zkpl6CvlyIOn8gqvNINhd3r3N+vBn70Qsk0AzZVBC9P19xirXQ56DLlsXN3Hj+o37LRn loGA== X-Gm-Message-State: AD7BkJKN3QL6CSXw9GhaApXdJUxap66lXenHjgT5z3+rVJTZ9O8bQkO50JH5Zu5Ii9aOLw== X-Received: by 10.66.251.194 with SMTP id zm2mr17799189pac.131.1457718801192; Fri, 11 Mar 2016 09:53:21 -0800 (PST) Received: from dl.caveonetworks.com ([64.2.3.194]) by smtp.gmail.com with ESMTPSA id yx4sm14437243pac.5.2016.03.11.09.53.18 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 11 Mar 2016 09:53:18 -0800 (PST) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id u2BHrH3G006547; Fri, 11 Mar 2016 09:53:17 -0800 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id u2BHrHDT006546; Fri, 11 Mar 2016 09:53:17 -0800 From: David Daney To: "David S. Miller" , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Florian Fainelli , Robert Richter , Sunil Goutham , Kumar Gala , Ian Campbell , Mark Rutland , Pawel Moll , Rob Herring Subject: [PATCH v2 1/3] net: thunderx: Cleanup PHY probing code. Date: Fri, 11 Mar 2016 09:53:09 -0800 Message-Id: <1457718791-6505-2-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1457718791-6505-1-git-send-email-ddaney.cavm@gmail.com> References: <1457718791-6505-1-git-send-email-ddaney.cavm@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160311_095341_750542_69E10D52 X-CRM114-Status: GOOD ( 16.12 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Radha Mohan Chintakuntla , linux-kernel@vger.kernel.org, David Daney MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Daney Remove the call to force the octeon-mdio driver to be loaded. Allow the standard driver loading mechanisms to load the PHY drivers, and use -EPROBE_DEFER to cause the BGX driver to be probed only after the PHY drivers are available. Reorder the setting of MAC addresses and PHY probing to allow BGX LMACs with no attached PHY to still be assigned a MAC address. Signed-off-by: David Daney --- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 29 ++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index f8abdff..feed231 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c @@ -978,27 +978,37 @@ static int bgx_init_of_phy(struct bgx *bgx) const char *mac; device_for_each_child_node(&bgx->pdev->dev, fwn) { + struct phy_device *pd; struct device_node *phy_np; struct device_node *node = to_of_node(fwn); - /* If it is not an OF node we cannot handle it yet, so - * exit the loop. + /* Should always be an OF node. But if it is not, we + * cannot handle it, so exit the loop. */ if (!node) break; - phy_np = of_parse_phandle(node, "phy-handle", 0); - if (!phy_np) - continue; - - bgx->lmac[lmac].phydev = of_phy_find_device(phy_np); - mac = of_get_mac_address(node); if (mac) ether_addr_copy(bgx->lmac[lmac].mac, mac); SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev); bgx->lmac[lmac].lmacid = lmac; + + phy_np = of_parse_phandle(node, "phy-handle", 0); + /* If there is no phy or defective firmware presents + * this cortina phy, for which there is no driver + * support, ignore it. + */ + if (phy_np && + !of_device_is_compatible(phy_np, "cortina,cs4223-slice")) { + /* Wait until the phy drivers are available */ + pd = of_phy_find_device(phy_np); + if (!pd) + return -EPROBE_DEFER; + bgx->lmac[lmac].phydev = pd; + } + lmac++; if (lmac == MAX_LMAC_PER_BGX) { of_node_put(node); @@ -1032,9 +1042,6 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) struct bgx *bgx = NULL; u8 lmac; - /* Load octeon mdio driver */ - octeon_mdiobus_force_mod_depencency(); - bgx = devm_kzalloc(dev, sizeof(*bgx), GFP_KERNEL); if (!bgx) return -ENOMEM;