All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2] ibmvnic: Bail from ibmvnic_open if driver is already open
@ 2018-03-12 19:19 John Allen
  2018-03-12 19:33 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: John Allen @ 2018-03-12 19:19 UTC (permalink / raw)
  To: netdev; +Cc: Thomas Falcon, Nathan Fontenot, Andrew Lunn

If the driver is already in the "open" state, don't attempt the procedure
for opening the driver.

Signed-off-by: John Allen <jallen@linux.vnet.ibm.com>
---
v2: Unlock reset_lock mutex before returning.

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 7be4b06..9a5e8ac 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1057,6 +1057,11 @@ static int ibmvnic_open(struct net_device *netdev)

 	mutex_lock(&adapter->reset_lock);

+	if (adapter->state == VNIC_OPEN) {
+		mutex_unlock(&adapter->reset_lock);
+		return 0;
+	}
+
 	if (adapter->state != VNIC_CLOSED) {
 		rc = ibmvnic_login(netdev);
 		if (rc) {

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2] ibmvnic: Bail from ibmvnic_open if driver is already open
  2018-03-12 19:19 [PATCH net-next v2] ibmvnic: Bail from ibmvnic_open if driver is already open John Allen
@ 2018-03-12 19:33 ` Andrew Lunn
  2018-03-12 19:56   ` John Allen
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2018-03-12 19:33 UTC (permalink / raw)
  To: John Allen; +Cc: netdev, Thomas Falcon, Nathan Fontenot

On Mon, Mar 12, 2018 at 02:19:52PM -0500, John Allen wrote:
> If the driver is already in the "open" state, don't attempt the procedure
> for opening the driver.
> 
> Signed-off-by: John Allen <jallen@linux.vnet.ibm.com>
> ---
> v2: Unlock reset_lock mutex before returning.
> 
> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
> index 7be4b06..9a5e8ac 100644
> --- a/drivers/net/ethernet/ibm/ibmvnic.c
> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
> @@ -1057,6 +1057,11 @@ static int ibmvnic_open(struct net_device *netdev)
> 
>  	mutex_lock(&adapter->reset_lock);
> 
> +	if (adapter->state == VNIC_OPEN) {
> +		mutex_unlock(&adapter->reset_lock);
> +		return 0;
> +	}

Hi John

This looks better.

But how did you get ibmvnic_open() to be called twice? Is the actual
issue that __ibmvnic_close() does not kill off the
adapter->ibmvnic_reset workqueue, so that a reset can happen after
close() has been called?

	   Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2] ibmvnic: Bail from ibmvnic_open if driver is already open
  2018-03-12 19:33 ` Andrew Lunn
@ 2018-03-12 19:56   ` John Allen
  2018-03-12 20:10     ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: John Allen @ 2018-03-12 19:56 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, Thomas Falcon, Nathan Fontenot

On 03/12/2018 02:33 PM, Andrew Lunn wrote:
> On Mon, Mar 12, 2018 at 02:19:52PM -0500, John Allen wrote:
>> If the driver is already in the "open" state, don't attempt the procedure
>> for opening the driver.
>>
>> Signed-off-by: John Allen <jallen@linux.vnet.ibm.com>
>> ---
>> v2: Unlock reset_lock mutex before returning.
>>
>> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
>> index 7be4b06..9a5e8ac 100644
>> --- a/drivers/net/ethernet/ibm/ibmvnic.c
>> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
>> @@ -1057,6 +1057,11 @@ static int ibmvnic_open(struct net_device *netdev)
>>
>>  	mutex_lock(&adapter->reset_lock);
>>
>> +	if (adapter->state == VNIC_OPEN) {
>> +		mutex_unlock(&adapter->reset_lock);
>> +		return 0;
>> +	}
> 
> Hi John
> 
> This looks better.
> 
> But how did you get ibmvnic_open() to be called twice? Is the actual
> issue that __ibmvnic_close() does not kill off the
> adapter->ibmvnic_reset workqueue, so that a reset can happen after
> close() has been called?

The problem here is that our routine to change the mtu does a full reset on
the driver meaning that in the process we go from effectively "open" to
"closed" to "open" again.

Consider the scenario where we change the mtu by running "ifdown <interface>",
editing the ifcfg file with the new mtu, and finally running "ifup <interface".
In this case, we call ibmvnic_close from the ifdown and as a result of the ifup,
we do the reset for the mtu change (which puts us back in the "open" state) and
call ibmvnic_open. After the reset, we are already in the "open" state and the
following call to open is redundant. The check in ibmvnic_open to see if we're
in the open state is really just insurance to guard against any case like this
where we're in the open state from the driver perspective and something decides
to trigger the drivers open routine.

-John

> 
> 	   Andrew
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2] ibmvnic: Bail from ibmvnic_open if driver is already open
  2018-03-12 19:56   ` John Allen
@ 2018-03-12 20:10     ` Andrew Lunn
  2018-03-12 20:12       ` John Allen
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2018-03-12 20:10 UTC (permalink / raw)
  To: John Allen; +Cc: netdev, Thomas Falcon, Nathan Fontenot

> The problem here is that our routine to change the mtu does a full reset on
> the driver meaning that in the process we go from effectively "open" to
> "closed" to "open" again.
> 
> Consider the scenario where we change the mtu by running "ifdown <interface>",
> editing the ifcfg file with the new mtu, and finally running "ifup <interface".
> In this case, we call ibmvnic_close from the ifdown and as a result of the ifup,
> we do the reset for the mtu change (which puts us back in the "open" state) and
> call ibmvnic_open. After the reset, we are already in the "open" state and the
> following call to open is redundant.

Hi John

So you are saying "ip link set mtu 4242 eth1" on a down interface will
put it up. That i would say is broken. You should be fixing this,
rather than papering over the cracks.

      Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2] ibmvnic: Bail from ibmvnic_open if driver is already open
  2018-03-12 20:10     ` Andrew Lunn
@ 2018-03-12 20:12       ` John Allen
  0 siblings, 0 replies; 5+ messages in thread
From: John Allen @ 2018-03-12 20:12 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: netdev, Thomas Falcon, Nathan Fontenot

On 03/12/2018 03:10 PM, Andrew Lunn wrote:
>> The problem here is that our routine to change the mtu does a full reset on
>> the driver meaning that in the process we go from effectively "open" to
>> "closed" to "open" again.
>>
>> Consider the scenario where we change the mtu by running "ifdown <interface>",
>> editing the ifcfg file with the new mtu, and finally running "ifup <interface".
>> In this case, we call ibmvnic_close from the ifdown and as a result of the ifup,
>> we do the reset for the mtu change (which puts us back in the "open" state) and
>> call ibmvnic_open. After the reset, we are already in the "open" state and the
>> following call to open is redundant.
> 
> Hi John
> 
> So you are saying "ip link set mtu 4242 eth1" on a down interface will
> put it up. That i would say is broken. You should be fixing this,
> rather than papering over the cracks.

That's a good point. I'll work on a fix to address that.

-John

> 
>       Andrew
> 
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-12 20:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-12 19:19 [PATCH net-next v2] ibmvnic: Bail from ibmvnic_open if driver is already open John Allen
2018-03-12 19:33 ` Andrew Lunn
2018-03-12 19:56   ` John Allen
2018-03-12 20:10     ` Andrew Lunn
2018-03-12 20:12       ` John Allen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.