linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/ibmvnic: free reset work of removed device from queue
@ 2019-08-29 23:20 Juliet Kim
  0 siblings, 0 replies; 4+ messages in thread
From: Juliet Kim @ 2019-08-29 23:20 UTC (permalink / raw)
  To: netdev; +Cc: julietk, linuxppc-dev

Commit 36f1031c51a2 ("ibmvnic: Do not process reset during or after
 device removal") made the change to exit reset if the driver has been
removed, but does not free reset work items of the adapter from queue.

Ensure all reset work items are freed when breaking out of the loop early.

Fixes: 36f1031c51a2 ("ibmnvic: Do not process reset during or after
device removal”)

Signed-off-by: Juliet Kim <julietk@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index fa4bb940665c..51bc943e66aa 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1984,8 +1984,11 @@ static void __ibmvnic_reset(struct work_struct *work)
 	rwi = get_next_rwi(adapter);
 	while (rwi) {
 		if (adapter->state == VNIC_REMOVING ||
-		    adapter->state == VNIC_REMOVED)
-			goto out;
+		    adapter->state == VNIC_REMOVED )
+			kfree(rwi);
+			rc = EBUSY;
+			break;
+		}
 
 		if (adapter->force_reset_recovery) {
 			adapter->force_reset_recovery = false;
@@ -2011,7 +2014,7 @@ static void __ibmvnic_reset(struct work_struct *work)
 		netdev_dbg(adapter->netdev, "Reset failed\n");
 		free_all_rwi(adapter);
 	}
-out:
+
 	adapter->resetting = false;
 	if (we_lock_rtnl)
 		rtnl_unlock();
-- 
2.16.4


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

* Re: [PATCH] net/ibmvnic: free reset work of removed device from queue
  2019-09-05 21:30 Juliet Kim
  2019-09-07  4:24 ` kbuild test robot
@ 2019-09-07 15:37 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-09-07 15:37 UTC (permalink / raw)
  To: julietk; +Cc: netdev, linuxppc-dev

From: Juliet Kim <julietk@linux.vnet.ibm.com>
Date: Thu,  5 Sep 2019 17:30:01 -0400

> Commit 36f1031c51a2 ("ibmvnic: Do not process reset during or after
>  device removal") made the change to exit reset if the driver has been
> removed, but does not free reset work items of the adapter from queue.
> 
> Ensure all reset work items are freed when breaking out of the loop early.
> 
> Fixes: 36f1031c51a2 ("ibmnvic: Do not process reset during or after
> device removal”)

Please do not break up Fixes: tags into mutliple lines, also please do
not put an empty line between the Fixes: tag and other tags like the
Signed-off-by:

> Signed-off-by: Juliet Kim <julietk@linux.vnet.ibm.com>

Applied, thanks.

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

* Re: [PATCH] net/ibmvnic: free reset work of removed device from queue
  2019-09-05 21:30 Juliet Kim
@ 2019-09-07  4:24 ` kbuild test robot
  2019-09-07 15:37 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2019-09-07  4:24 UTC (permalink / raw)
  To: Juliet Kim; +Cc: julietk, netdev, linuxppc-dev, kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7041 bytes --]

Hi Juliet,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.3-rc7 next-20190904]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Juliet-Kim/net-ibmvnic-free-reset-work-of-removed-device-from-queue/20190906-195317
config: powerpc-allyesconfig (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   drivers/net/ethernet/ibm/ibmvnic.c: In function '__ibmvnic_reset':
>> drivers/net/ethernet/ibm/ibmvnic.c:1986:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
      if (adapter->state == VNIC_REMOVING ||
      ^~
   drivers/net/ethernet/ibm/ibmvnic.c:1989:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
       rc = EBUSY;
       ^~
>> drivers/net/ethernet/ibm/ibmvnic.c:2002:4: error: break statement not within loop or switch
       break;
       ^~~~~
   drivers/net/ethernet/ibm/ibmvnic.c: At top level:
>> drivers/net/ethernet/ibm/ibmvnic.c:2007:2: error: expected identifier or '(' before 'if'
     if (adapter->wait_for_reset) {
     ^~
   drivers/net/ethernet/ibm/ibmvnic.c:2013:2: error: expected identifier or '(' before 'if'
     if (rc) {
     ^~
>> drivers/net/ethernet/ibm/ibmvnic.c:2018:9: error: expected '=', ',', ';', 'asm' or '__attribute__' before '->' token
     adapter->resetting = false;
            ^~
   drivers/net/ethernet/ibm/ibmvnic.c:2019:2: error: expected identifier or '(' before 'if'
     if (we_lock_rtnl)
     ^~
>> drivers/net/ethernet/ibm/ibmvnic.c:2021:1: error: expected identifier or '(' before '}' token
    }
    ^
   drivers/net/ethernet/ibm/ibmvnic.c:1953:13: warning: 'free_all_rwi' defined but not used [-Wunused-function]
    static void free_all_rwi(struct ibmvnic_adapter *adapter)
                ^~~~~~~~~~~~

vim +2002 drivers/net/ethernet/ibm/ibmvnic.c

ed651a10875f13 Nathan Fontenot 2017-05-03  1963  
ed651a10875f13 Nathan Fontenot 2017-05-03  1964  static void __ibmvnic_reset(struct work_struct *work)
ed651a10875f13 Nathan Fontenot 2017-05-03  1965  {
ed651a10875f13 Nathan Fontenot 2017-05-03  1966  	struct ibmvnic_rwi *rwi;
ed651a10875f13 Nathan Fontenot 2017-05-03  1967  	struct ibmvnic_adapter *adapter;
a5681e20b541a5 Juliet Kim      2018-11-19  1968  	bool we_lock_rtnl = false;
ed651a10875f13 Nathan Fontenot 2017-05-03  1969  	u32 reset_state;
c26eba03e4073b John Allen      2017-10-26  1970  	int rc = 0;
ed651a10875f13 Nathan Fontenot 2017-05-03  1971  
ed651a10875f13 Nathan Fontenot 2017-05-03  1972  	adapter = container_of(work, struct ibmvnic_adapter, ibmvnic_reset);
ed651a10875f13 Nathan Fontenot 2017-05-03  1973  
a5681e20b541a5 Juliet Kim      2018-11-19  1974  	/* netif_set_real_num_xx_queues needs to take rtnl lock here
a5681e20b541a5 Juliet Kim      2018-11-19  1975  	 * unless wait_for_reset is set, in which case the rtnl lock
a5681e20b541a5 Juliet Kim      2018-11-19  1976  	 * has already been taken before initializing the reset
a5681e20b541a5 Juliet Kim      2018-11-19  1977  	 */
a5681e20b541a5 Juliet Kim      2018-11-19  1978  	if (!adapter->wait_for_reset) {
a5681e20b541a5 Juliet Kim      2018-11-19  1979  		rtnl_lock();
a5681e20b541a5 Juliet Kim      2018-11-19  1980  		we_lock_rtnl = true;
a5681e20b541a5 Juliet Kim      2018-11-19  1981  	}
ed651a10875f13 Nathan Fontenot 2017-05-03  1982  	reset_state = adapter->state;
ed651a10875f13 Nathan Fontenot 2017-05-03  1983  
ed651a10875f13 Nathan Fontenot 2017-05-03  1984  	rwi = get_next_rwi(adapter);
ed651a10875f13 Nathan Fontenot 2017-05-03  1985  	while (rwi) {
36f1031c51a253 Thomas Falcon   2019-08-27 @1986  		if (adapter->state == VNIC_REMOVING ||
36f1031c51a253 Thomas Falcon   2019-08-27  1987  		    adapter->state == VNIC_REMOVED)
42a863ed7971cb Juliet Kim      2019-09-05  1988  			kfree(rwi);
42a863ed7971cb Juliet Kim      2019-09-05 @1989  			rc = EBUSY;
42a863ed7971cb Juliet Kim      2019-09-05  1990  			break;
42a863ed7971cb Juliet Kim      2019-09-05  1991  		}
36f1031c51a253 Thomas Falcon   2019-08-27  1992  
2770a7984db588 Thomas Falcon   2018-05-23  1993  		if (adapter->force_reset_recovery) {
2770a7984db588 Thomas Falcon   2018-05-23  1994  			adapter->force_reset_recovery = false;
2770a7984db588 Thomas Falcon   2018-05-23  1995  			rc = do_hard_reset(adapter, rwi, reset_state);
2770a7984db588 Thomas Falcon   2018-05-23  1996  		} else {
ed651a10875f13 Nathan Fontenot 2017-05-03  1997  			rc = do_reset(adapter, rwi, reset_state);
2770a7984db588 Thomas Falcon   2018-05-23  1998  		}
ed651a10875f13 Nathan Fontenot 2017-05-03  1999  		kfree(rwi);
2770a7984db588 Thomas Falcon   2018-05-23  2000  		if (rc && rc != IBMVNIC_INIT_FAILED &&
2770a7984db588 Thomas Falcon   2018-05-23  2001  		    !adapter->force_reset_recovery)
ed651a10875f13 Nathan Fontenot 2017-05-03 @2002  			break;
ed651a10875f13 Nathan Fontenot 2017-05-03  2003  
ed651a10875f13 Nathan Fontenot 2017-05-03  2004  		rwi = get_next_rwi(adapter);
ed651a10875f13 Nathan Fontenot 2017-05-03  2005  	}
ed651a10875f13 Nathan Fontenot 2017-05-03  2006  
c26eba03e4073b John Allen      2017-10-26 @2007  	if (adapter->wait_for_reset) {
c26eba03e4073b John Allen      2017-10-26  2008  		adapter->wait_for_reset = false;
c26eba03e4073b John Allen      2017-10-26  2009  		adapter->reset_done_rc = rc;
c26eba03e4073b John Allen      2017-10-26  2010  		complete(&adapter->reset_done);
c26eba03e4073b John Allen      2017-10-26  2011  	}
c26eba03e4073b John Allen      2017-10-26  2012  
ed651a10875f13 Nathan Fontenot 2017-05-03 @2013  	if (rc) {
d1cf33d93166f1 Nathan Fontenot 2017-08-08  2014  		netdev_dbg(adapter->netdev, "Reset failed\n");
ed651a10875f13 Nathan Fontenot 2017-05-03  2015  		free_all_rwi(adapter);
ed651a10875f13 Nathan Fontenot 2017-05-03  2016  	}
42a863ed7971cb Juliet Kim      2019-09-05  2017  
ed651a10875f13 Nathan Fontenot 2017-05-03 @2018  	adapter->resetting = false;
a5681e20b541a5 Juliet Kim      2018-11-19  2019  	if (we_lock_rtnl)
a5681e20b541a5 Juliet Kim      2018-11-19  2020  		rtnl_unlock();
ed651a10875f13 Nathan Fontenot 2017-05-03 @2021  }
ed651a10875f13 Nathan Fontenot 2017-05-03  2022  

:::::: The code at line 2002 was first introduced by commit
:::::: ed651a10875f13135a5f59c1bae4d51b377b3925 ibmvnic: Updated reset handling

:::::: TO: Nathan Fontenot <nfont@linux.vnet.ibm.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 62432 bytes --]

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

* [PATCH] net/ibmvnic: free reset work of removed device from queue
@ 2019-09-05 21:30 Juliet Kim
  2019-09-07  4:24 ` kbuild test robot
  2019-09-07 15:37 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Juliet Kim @ 2019-09-05 21:30 UTC (permalink / raw)
  To: netdev; +Cc: julietk, linuxppc-dev

Commit 36f1031c51a2 ("ibmvnic: Do not process reset during or after
 device removal") made the change to exit reset if the driver has been
removed, but does not free reset work items of the adapter from queue.

Ensure all reset work items are freed when breaking out of the loop early.

Fixes: 36f1031c51a2 ("ibmnvic: Do not process reset during or after
device removal”)

Signed-off-by: Juliet Kim <julietk@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index fa4bb940665c..6644cabc8e75 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1985,7 +1985,10 @@ static void __ibmvnic_reset(struct work_struct *work)
 	while (rwi) {
 		if (adapter->state == VNIC_REMOVING ||
 		    adapter->state == VNIC_REMOVED)
-			goto out;
+			kfree(rwi);
+			rc = EBUSY;
+			break;
+		}
 
 		if (adapter->force_reset_recovery) {
 			adapter->force_reset_recovery = false;
@@ -2011,7 +2014,7 @@ static void __ibmvnic_reset(struct work_struct *work)
 		netdev_dbg(adapter->netdev, "Reset failed\n");
 		free_all_rwi(adapter);
 	}
-out:
+
 	adapter->resetting = false;
 	if (we_lock_rtnl)
 		rtnl_unlock();
-- 
2.16.4


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

end of thread, other threads:[~2019-09-07 15:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-29 23:20 [PATCH] net/ibmvnic: free reset work of removed device from queue Juliet Kim
2019-09-05 21:30 Juliet Kim
2019-09-07  4:24 ` kbuild test robot
2019-09-07 15:37 ` David Miller

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).