From patchwork Tue May 15 02:11:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomoya MORINAGA X-Patchwork-Id: 159219 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 24344B705A for ; Tue, 15 May 2012 11:12:11 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932763Ab2EOBMH (ORCPT ); Mon, 14 May 2012 21:12:07 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:63739 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932599Ab2EOBMF (ORCPT ); Mon, 14 May 2012 21:12:05 -0400 Received: by mail-pz0-f46.google.com with SMTP id y13so6611275dad.19 for ; Mon, 14 May 2012 18:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=XVu9g840M/SLjRAbY2b3/kbe0zk/A1L9xlrnut/z5WU=; b=C8LfBMqSWGiJKqErRi1iosuBYA4E5FyFCIX3fJBMR5X2EF7FIzfJqO0q1pRr87rFp9 c7TpCkonlhEVOY6exJGSNZDPxJDP/64khlzmYp9wVUuAfrkRf1MMpsU+vL+s26NOc5Zk 5hotEeBA08Qbj8i2kbhrKtGFCB0nRP5l26vOTmslfbEUC07p2AJnCDOhwINgJZlYvNwS QfGzk4HfAJN7PMz+qT0yWl2+62V9tbTXYItCwYyxgXp6MqEBKU2cFZTTQVKd8kQiHvN3 /I6607tBOKOnjk5Hli1Bsi1hjlDo0YvWbDFbSZZxzZaqso0Wl8Nn0khbFr0SggU9NCzl KW4A== Received: by 10.68.202.130 with SMTP id ki2mr141440pbc.52.1337044325319; Mon, 14 May 2012 18:12:05 -0700 (PDT) Received: from localhost.localdomain ([60.32.152.216]) by mx.google.com with ESMTPS id oy8sm51857pbc.52.2012.05.14.18.12.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 14 May 2012 18:12:04 -0700 (PDT) From: Tomoya MORINAGA To: stable@vger.kernel.org Cc: Tomoya MORINAGA , Darren Hart , Arjan van de Ven , Alan Cox , Jeff Kirsher , "David S. Miller" , Paul Gortmaker , Jon Mason , netdev@vger.kernel.org, Mark Brown , David Laight , Joe Perches Subject: [PATCH 6/7] pch_gbe: Do not abort probe on bad MAC Date: Tue, 15 May 2012 11:11:30 +0900 Message-Id: <1337047891-2973-6-git-send-email-tomoya.rohm@gmail.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1337047891-2973-1-git-send-email-tomoya.rohm@gmail.com> References: <1337047891-2973-1-git-send-email-tomoya.rohm@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If the MAC is invalid or not implemented, do not abort the probe. Issue a warning and prevent bringing the interface up until a MAC is set manually (via ifconfig $IFACE hw ether $MAC). Tested on two platforms, one with a valid MAC, the other without a MAC. The real MAC is used if present, the interface fails to come up until the MAC is set on the other. They successfully get an IP over DHCP and pass a simple ping and login over ssh test. This is meant to allow the Inforce SYS940X development board: http://www.inforcecomputing.com/SYS940X_ECX.html (and others suffering from a missing MAC) to work with the mainline kernel. Without this patch, the probe will fail and the interface will not be created, preventing the user from configuring the MAC manually. This does not make any attempt to address a missing or invalid MAC for the pch_phub driver. commit 2b53d07891630dead46d65c8f896955fd3ae0302 Kernel 3.0 Cc: stable@vger.kernel.org Signed-off-by: Darren Hart CC: Arjan van de Ven CC: Alan Cox CC: Tomoya MORINAGA CC: Jeff Kirsher CC: "David S. Miller" CC: Paul Gortmaker CC: Jon Mason CC: netdev@vger.kernel.org CC: Mark Brown CC: David Laight CC: Joe Perches Signed-off-by: David S. Miller Signed-off-by: Tomoya MORINAGA --- drivers/net/pch_gbe/pch_gbe_main.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c index b8b4ba2..d506e28 100644 --- a/drivers/net/pch_gbe/pch_gbe_main.c +++ b/drivers/net/pch_gbe/pch_gbe_main.c @@ -1745,6 +1745,12 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter) struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring; int err; + /* Ensure we have a valid MAC */ + if (!is_valid_ether_addr(adapter->hw.mac.addr)) { + pr_err("Error: Invalid MAC address\n"); + return -EINVAL; + } + /* hardware has been reset, we need to reload some things */ pch_gbe_set_multi(netdev); @@ -2467,9 +2473,14 @@ static int pch_gbe_probe(struct pci_dev *pdev, memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len); if (!is_valid_ether_addr(netdev->dev_addr)) { - dev_err(&pdev->dev, "Invalid MAC Address\n"); - ret = -EIO; - goto err_free_adapter; + /* + * If the MAC is invalid (or just missing), display a warning + * but do not abort setting up the device. pch_gbe_up will + * prevent the interface from being brought up until a valid MAC + * is set. + */ + dev_err(&pdev->dev, "Invalid MAC address, " + "interface disabled.\n"); } setup_timer(&adapter->watchdog_timer, pch_gbe_watchdog, (unsigned long)adapter);