* [PATCH net-next] cxgb4: don't hold RTNL during ethtool phys_id
@ 2011-04-07 0:09 Stephen Hemminger
2011-04-07 0:20 ` Casey Leedom
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2011-04-07 0:09 UTC (permalink / raw)
To: Dimitris Michailidis, Casey Leedom, Ben Hutchings, David Miller; +Cc: netdev
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 <shemminger@vyatta.com>
---
drivers/net/cxgb4/cxgb4_main.c | 17 ++++++++++++++---
drivers/net/cxgb4vf/cxgb4vf_main.c | 21 +++++++++++++++++++--
2 files changed, 33 insertions(+), 5 deletions(-)
--- 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 <linux/etherdevice.h>
#include <linux/debugfs.h>
#include <linux/ethtool.h>
+#include <linux/rtnetlink.h>
#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;
}
/*
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] cxgb4: don't hold RTNL during ethtool phys_id
2011-04-07 0:09 [PATCH net-next] cxgb4: don't hold RTNL during ethtool phys_id Stephen Hemminger
@ 2011-04-07 0:20 ` Casey Leedom
2011-04-07 0:33 ` Stephen Hemminger
2011-04-07 0:35 ` Ben Hutchings
0 siblings, 2 replies; 5+ messages in thread
From: Casey Leedom @ 2011-04-07 0:20 UTC (permalink / raw)
To: Stephen Hemminger
Cc: Dimitris Michailidis, Ben Hutchings, David Miller, netdev
| From: Stephen Hemminger <shemminger@linux-foundation.org>
| Date: Wednesday, April 06, 2011 05:09 pm
|
| 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 <shemminger@vyatta.com>
Are you assuming that the firmware won't respond with a command completion
until the LED blinking is complete? If so, that's a bad assumption. The
firmware runs as an asynchronous real-time OS. The LED blinking simply becomes
a thread of activity within the OS and the command completes immediately.
Casey
| ---
| drivers/net/cxgb4/cxgb4_main.c | 17 ++++++++++++++---
| drivers/net/cxgb4vf/cxgb4vf_main.c | 21 +++++++++++++++++++--
| 2 files changed, 33 insertions(+), 5 deletions(-)
|
| --- 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 <linux/etherdevice.h>
| #include <linux/debugfs.h>
| #include <linux/ethtool.h>
| +#include <linux/rtnetlink.h>
|
| #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;
| }
|
| /*
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] cxgb4: don't hold RTNL during ethtool phys_id
2011-04-07 0:20 ` Casey Leedom
@ 2011-04-07 0:33 ` Stephen Hemminger
2011-04-07 8:18 ` Dimitris Michailidis
2011-04-07 0:35 ` Ben Hutchings
1 sibling, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2011-04-07 0:33 UTC (permalink / raw)
To: Casey Leedom; +Cc: Dimitris Michailidis, Ben Hutchings, David Miller, netdev
On Wed, 6 Apr 2011 17:20:29 -0700
Casey Leedom <leedom@chelsio.com> wrote:
> | From: Stephen Hemminger <shemminger@linux-foundation.org>
> | Date: Wednesday, April 06, 2011 05:09 pm
> |
> | 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 <shemminger@vyatta.com>
>
> Are you assuming that the firmware won't respond with a command completion
> until the LED blinking is complete? If so, that's a bad assumption. The
> firmware runs as an asynchronous real-time OS. The LED blinking simply becomes
> a thread of activity within the OS and the command completes immediately.
>
> Casey
Then how is LED blinking stopped?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] cxgb4: don't hold RTNL during ethtool phys_id
2011-04-07 0:33 ` Stephen Hemminger
@ 2011-04-07 8:18 ` Dimitris Michailidis
0 siblings, 0 replies; 5+ messages in thread
From: Dimitris Michailidis @ 2011-04-07 8:18 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Casey Leedom, Ben Hutchings, David Miller, netdev
Stephen Hemminger wrote:
> On Wed, 6 Apr 2011 17:20:29 -0700
> Casey Leedom <leedom@chelsio.com> wrote:
>
>> | From: Stephen Hemminger <shemminger@linux-foundation.org>
>> | Date: Wednesday, April 06, 2011 05:09 pm
>> |
>> | 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 <shemminger@vyatta.com>
>>
>> Are you assuming that the firmware won't respond with a command completion
>> until the LED blinking is complete? If so, that's a bad assumption. The
>> firmware runs as an asynchronous real-time OS. The LED blinking simply becomes
>> a thread of activity within the OS and the command completes immediately.
>>
>> Casey
>
> Then how is LED blinking stopped?
You can pass 0 as blinks to cancel your request, which may or may not cancel
the LED blinking depending on what other drivers have concurrent blinking
requests in progress. But you can't pass UINT_MAX as the patch does. I'll
fix it up to use the new ethtool interface this week.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] cxgb4: don't hold RTNL during ethtool phys_id
2011-04-07 0:20 ` Casey Leedom
2011-04-07 0:33 ` Stephen Hemminger
@ 2011-04-07 0:35 ` Ben Hutchings
1 sibling, 0 replies; 5+ messages in thread
From: Ben Hutchings @ 2011-04-07 0:35 UTC (permalink / raw)
To: Casey Leedom
Cc: Stephen Hemminger, Dimitris Michailidis, David Miller, netdev
On Wed, 2011-04-06 at 17:20 -0700, Casey Leedom wrote:
> | From: Stephen Hemminger <shemminger@linux-foundation.org>
> | Date: Wednesday, April 06, 2011 05:09 pm
> |
> | 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 <shemminger@vyatta.com>
>
> Are you assuming that the firmware won't respond with a command completion
> until the LED blinking is complete? If so, that's a bad assumption. The
> firmware runs as an asynchronous real-time OS. The LED blinking simply becomes
> a thread of activity within the OS and the command completes immediately.
[...]
Stephen was assuming (as I did) that you actually implemented this
operation correctly. You're supposed to blink the LED for the specified
time but let the user interrupt early. If you just start the LED
blinking and then return, then it appears the user has no way to
interrupt it.
Is there a defined firmware command to stop blinking the LED?
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-04-07 8:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-07 0:09 [PATCH net-next] cxgb4: don't hold RTNL during ethtool phys_id Stephen Hemminger
2011-04-07 0:20 ` Casey Leedom
2011-04-07 0:33 ` Stephen Hemminger
2011-04-07 8:18 ` Dimitris Michailidis
2011-04-07 0:35 ` Ben Hutchings
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).