From patchwork Thu Apr 7 00:09:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 90115 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 24EDBB6F14 for ; Thu, 7 Apr 2011 10:10:17 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755895Ab1DGAKK (ORCPT ); Wed, 6 Apr 2011 20:10:10 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:60760 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755537Ab1DGAKJ (ORCPT ); Wed, 6 Apr 2011 20:10:09 -0400 Received: from nehalam (static-50-53-80-93.bvtn.or.frontiernet.net [50.53.80.93]) (authenticated bits=0) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id p3709U3X026957 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 6 Apr 2011 17:09:32 -0700 Date: Wed, 6 Apr 2011 17:09:29 -0700 From: Stephen Hemminger To: Dimitris Michailidis , Casey Leedom , Ben Hutchings , David Miller Cc: netdev@vger.kernel.org Subject: [PATCH net-next] cxgb4: don't hold RTNL during ethtool phys_id Message-ID: <20110406170929.6e427b36@nehalam> Organization: Linux Foundation X-Mailer: Claws Mail 3.7.6 (GTK+ 2.22.0; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, hits=-104.333 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED, USER_IN_WHITELIST X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The Chelsio cxgb4 drivers implement blinking in a unique way by waiting on the mailbox. This patch cleans it up slightly by no longer holding the system wide network configuration lock during the process. The patch also uses correct semantics for the time argument which is supposed to be in seconds; and zero is supposed to signify infinite blinking. This is still a bad firmware interface design for this since it means the board is basically hung while doing the blink. But fixing it correctly would require hardware and firmware documentation. With that information the device could be converted to the new set_phys_id. Compile tested only. Signed-off-by: Stephen Hemminger --- drivers/net/cxgb4/cxgb4_main.c | 17 ++++++++++++++--- drivers/net/cxgb4vf/cxgb4vf_main.c | 21 +++++++++++++++++++-- 2 files changed, 33 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/net/cxgb4/cxgb4_main.c 2011-04-06 16:49:02.045648800 -0700 +++ b/drivers/net/cxgb4/cxgb4_main.c 2011-04-06 17:00:59.508851692 -0700 @@ -1339,12 +1339,23 @@ static int restart_autoneg(struct net_de static int identify_port(struct net_device *dev, u32 data) { struct adapter *adap = netdev2adap(dev); + int rc; + unsigned long blinks; if (data == 0) - data = 2; /* default to 2 seconds */ + blinks = UINT_MAX; + else + blinks = 2*data + data/2; - return t4_identify_port(adap, adap->fn, netdev2pinfo(dev)->viid, - data * 5); + /* Don't block networking updates while blink is in progress */ + dev_hold(dev); + rtnl_unlock(); + + rc = t4_identify_port(adap, adap->fn, netdev2pinfo(dev)->viid, + blinks); + rtnl_lock(); + dev_put(dev); + return rc; } static unsigned int from_fw_linkcaps(unsigned int type, unsigned int caps) --- a/drivers/net/cxgb4vf/cxgb4vf_main.c 2011-04-06 16:49:09.989728600 -0700 +++ b/drivers/net/cxgb4vf/cxgb4vf_main.c 2011-04-06 17:02:38.609846223 -0700 @@ -43,6 +43,7 @@ #include #include #include +#include #include "t4vf_common.h" #include "t4vf_defs.h" @@ -1352,11 +1353,27 @@ static int cxgb4vf_set_rx_csum(struct ne /* * Identify the port by blinking the port's LED. */ -static int cxgb4vf_phys_id(struct net_device *dev, u32 id) +static int cxgb4vf_phys_id(struct net_device *dev, u32 data) { struct port_info *pi = netdev_priv(dev); + int rc; + unsigned int blinks; - return t4vf_identify_port(pi->adapter, pi->viid, 5); + if (data == 0) + blinks = UINT_MAX; + else + blinks = 2*data + data/2; + + /* Don't block networking updates while blink is in progress */ + dev_hold(dev); + rtnl_unlock(); + + rc = t4vf_identify_port(pi->adapter, pi->viid, blinks); + + rtnl_lock(); + dev_put(dev); + + return rc; } /*