From patchwork Mon Mar 6 13:34:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 735708 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vcLQX1KGHz9sNg for ; Tue, 7 Mar 2017 00:35:48 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b="XFeCpVJN"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752901AbdCFNex (ORCPT ); Mon, 6 Mar 2017 08:34:53 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34197 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752789AbdCFNes (ORCPT ); Mon, 6 Mar 2017 08:34:48 -0500 Received: by mail-wr0-f196.google.com with SMTP id u48so21801179wrc.1 for ; Mon, 06 Mar 2017 05:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=BAtLDYZrUqsEP29AwPUK3/vGo4NpSXNEN0uyYL8INLU=; b=XFeCpVJNxdP6E3Lw6XVN+4gzFDV0Br3390AQkkt2Rt7e61piEEgzmUpG8iH2rN0Fzn 1Lkp1cP6Uxn6BzN/GSTIhbv9zxMBZeRKQO9xXl8mhiFeNiWEixp0u3pM69EReUqDFppN 4QrwI+ZB59afGGs3rIooDLP7zuObwbusjnQryOjApNV2+ampgiy6zjIWOVixju2Z1/Cj c3awrFlfXqcbbe2tgunafxLwWbrMT/h3mnwAzt9f1wiIWze08Qq5x+T9m+TESm73TYWF 0rYaFyfu+2tp8WM7/PWv35SxEqFK7hOPrl6KEGFVwFxCsQk+uEFDiq5IGpmbHx3Aqas4 N+1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BAtLDYZrUqsEP29AwPUK3/vGo4NpSXNEN0uyYL8INLU=; b=Y/wznzifA0hWUJYSqk3DEnTGfpYKexqsAayfFSTunNLJhriX+T1XEoudVsQba3w3B9 4saZFCaPI6WQB2/eLI7nXfFTzUwMDQW35/ieS7jbaHl4C1THHDqtd2tlnUd//RBcro69 /IR2eVa8bA3DVnkbCJR6adfFL3xYfj6ew/Z9Ejee8HVzsprKMKmEt/r1nZGGJtMqo2nn JKFdp8HZG18Rx7g9Wm0bpMQe5fEl6NmSN718RifCCV/qdUH33c4YYPR/TXz8PpOND5wy OaDbMiWFuItcrA0ul4z7c3jNFueKeC9Ef4BXdx4ddf9mO6JpeBPYn8+Px/Fjpv5E7S1Y /lEQ== X-Gm-Message-State: AMke39mF+UhB8jD7Zuoo3cxMxkNMMokKYkddH8FiaFclw64mGCpo/7fK3sCLq94cp+C/cw== X-Received: by 10.223.129.74 with SMTP id 68mr13401761wrm.183.1488807269027; Mon, 06 Mar 2017 05:34:29 -0800 (PST) Received: from debian64.daheim (p200300D5FBC06DFCD63D7EFFFEBDE96E.dip0.t-ipconnect.de. [2003:d5:fbc0:6dfc:d63d:7eff:febd:e96e]) by smtp.gmail.com with ESMTPSA id 63sm14790071wmp.9.2017.03.06.05.34.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Mar 2017 05:34:28 -0800 (PST) Received: from chuck by debian64.daheim with local (Exim 4.89_RC7) (envelope-from ) id 1cksmR-00072f-2o; Mon, 06 Mar 2017 14:34:27 +0100 From: Christian Lamparter To: netdev@vger.kernel.org Cc: Julian Margetson , "David S . Miller" Subject: [PATCH] net: ibm: emac: fix regression caused by emac_dt_phy_probe() Date: Mon, 6 Mar 2017 14:34:27 +0100 Message-Id: <20170306133427.27025-1-chunkeey@googlemail.com> X-Mailer: git-send-email 2.11.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Julian Margetson reported a panic on his SAM460EX with Kernel 4.11-rc1: | Unable to handle kernel paging request for data at address 0x00000014 | Oops: Kernel access of bad area, sig: 11 [#1] | PREEMPT | Canyonlands | Modules linked in: | CPU: 0 PID: 1 Comm: swapper Not tainted [...] | task: ea838000 task.stack: ea836000 | NIP: c0599f5c LR: c0599dd8 CTR: 00000000 | REGS: ea837c80 TRAP: 0300 Not tainted [...] | MSR: 00029000 | CR: 24371242 XER: 20000000 | DEAR: 00000014 ESR: 00000000 | GPR00: c0599ce8 ea837d30 ea838000 c0e52dcc c0d56ffb [...] | NIP [c0599f5c] emac_probe+0xfb4/0x1304 | LR [c0599dd8] emac_probe+0xe30/0x1304 | Call Trace: | [ea837d30] [c0599ce8] emac_probe+0xd40/0x1304 (unreliable) | [ea837d80] [c0533504] platform_drv_probe+0x48/0x90 | [ea837da0] [c0531c14] driver_probe_device+0x15c/0x2c4 | [ea837dd0] [c0531e04] __driver_attach+0x88/0xb0 | ---[ end trace ... ]--- The problem is caused by emac_dt_phy_probe() returing success (0) for existing device-trees configurations that do not specify a "phy-handle" property. This caused the code to skip the existing phy probe and setup. Which led to essential phy related data-structures being uninitialized. This patch also removes the unused variable in emac_dt_phy_connect(). Fixes: a577ca6badb5261d ("net: emac: add support for device-tree based PHY discovery and setup") Reported-by: Julian Margetson Signed-off-by: Christian Lamparter --- drivers/net/ethernet/ibm/emac/core.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index 275c2e2349ad..c44036d5761a 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -2589,8 +2589,6 @@ static int emac_dt_mdio_probe(struct emac_instance *dev) static int emac_dt_phy_connect(struct emac_instance *dev, struct device_node *phy_handle) { - int res; - dev->phy.def = devm_kzalloc(&dev->ofdev->dev, sizeof(*dev->phy.def), GFP_KERNEL); if (!dev->phy.def) @@ -2617,7 +2615,7 @@ static int emac_dt_phy_probe(struct emac_instance *dev) { struct device_node *np = dev->ofdev->dev.of_node; struct device_node *phy_handle; - int res = 0; + int res = 1; phy_handle = of_parse_phandle(np, "phy-handle", 0); @@ -2714,13 +2712,24 @@ static int emac_init_phy(struct emac_instance *dev) if (emac_has_feature(dev, EMAC_FTR_HAS_RGMII)) { int res = emac_dt_phy_probe(dev); - mutex_unlock(&emac_phy_map_lock); - if (!res) + switch (res) { + case 1: + /* No phy-handle property configured. + * Continue with the existing phy probe + * and setup code. + */ + break; + + case 0: + mutex_unlock(&emac_phy_map_lock); goto init_phy; - dev_err(&dev->ofdev->dev, "failed to attach dt phy (%d).\n", - res); - return res; + default: + mutex_unlock(&emac_phy_map_lock); + dev_err(&dev->ofdev->dev, "failed to attach dt phy (%d).\n", + res); + return res; + } } if (dev->phy_address != 0xffffffff)