Skip to content

Commit 3f5ec37

Browse files
Lijun Pankuba-moo
authored andcommitted
ibmvnic: merge do_change_param_reset into do_reset
Commit b27507b ("net/ibmvnic: unlock rtnl_lock in reset so linkwatch_event can run") introduced do_change_param_reset function to solve the rtnl lock issue. Majority of the code in do_change_param_reset duplicates do_reset. Also, we can handle the rtnl lock issue in do_reset itself. Hence merge do_change_param_reset back into do_reset to clean up the code. Signed-off-by: Lijun Pan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 09b5b5f commit 3f5ec37

File tree

1 file changed

+44
-110
lines changed

1 file changed

+44
-110
lines changed

drivers/net/ethernet/ibm/ibmvnic.c

Lines changed: 44 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,92 +1925,6 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p)
19251925
return rc;
19261926
}
19271927

1928-
/**
1929-
* do_change_param_reset returns zero if we are able to keep processing reset
1930-
* events, or non-zero if we hit a fatal error and must halt.
1931-
*/
1932-
static int do_change_param_reset(struct ibmvnic_adapter *adapter,
1933-
struct ibmvnic_rwi *rwi,
1934-
u32 reset_state)
1935-
{
1936-
struct net_device *netdev = adapter->netdev;
1937-
int i, rc;
1938-
1939-
netdev_dbg(adapter->netdev, "Change param resetting driver (%d)\n",
1940-
rwi->reset_reason);
1941-
1942-
netif_carrier_off(netdev);
1943-
adapter->reset_reason = rwi->reset_reason;
1944-
1945-
ibmvnic_cleanup(netdev);
1946-
1947-
if (reset_state == VNIC_OPEN) {
1948-
rc = __ibmvnic_close(netdev);
1949-
if (rc)
1950-
goto out;
1951-
}
1952-
1953-
release_resources(adapter);
1954-
release_sub_crqs(adapter, 1);
1955-
release_crq_queue(adapter);
1956-
1957-
adapter->state = VNIC_PROBED;
1958-
1959-
rc = init_crq_queue(adapter);
1960-
1961-
if (rc) {
1962-
netdev_err(adapter->netdev,
1963-
"Couldn't initialize crq. rc=%d\n", rc);
1964-
return rc;
1965-
}
1966-
1967-
rc = ibmvnic_reset_init(adapter, true);
1968-
if (rc) {
1969-
rc = IBMVNIC_INIT_FAILED;
1970-
goto out;
1971-
}
1972-
1973-
/* If the adapter was in PROBE state prior to the reset,
1974-
* exit here.
1975-
*/
1976-
if (reset_state == VNIC_PROBED)
1977-
goto out;
1978-
1979-
rc = ibmvnic_login(netdev);
1980-
if (rc) {
1981-
goto out;
1982-
}
1983-
1984-
rc = init_resources(adapter);
1985-
if (rc)
1986-
goto out;
1987-
1988-
ibmvnic_disable_irqs(adapter);
1989-
1990-
adapter->state = VNIC_CLOSED;
1991-
1992-
if (reset_state == VNIC_CLOSED)
1993-
return 0;
1994-
1995-
rc = __ibmvnic_open(netdev);
1996-
if (rc) {
1997-
rc = IBMVNIC_OPEN_FAILED;
1998-
goto out;
1999-
}
2000-
2001-
/* refresh device's multicast list */
2002-
ibmvnic_set_multi(netdev);
2003-
2004-
/* kick napi */
2005-
for (i = 0; i < adapter->req_rx_queues; i++)
2006-
napi_schedule(&adapter->napi[i]);
2007-
2008-
out:
2009-
if (rc)
2010-
adapter->state = reset_state;
2011-
return rc;
2012-
}
2013-
20141928
/**
20151929
* do_reset returns zero if we are able to keep processing reset events, or
20161930
* non-zero if we hit a fatal error and must halt.
@@ -2028,7 +1942,11 @@ static int do_reset(struct ibmvnic_adapter *adapter,
20281942
adapter->state, adapter->failover_pending,
20291943
rwi->reset_reason, reset_state);
20301944

2031-
rtnl_lock();
1945+
adapter->reset_reason = rwi->reset_reason;
1946+
/* requestor of VNIC_RESET_CHANGE_PARAM already has the rtnl lock */
1947+
if (!(adapter->reset_reason == VNIC_RESET_CHANGE_PARAM))
1948+
rtnl_lock();
1949+
20321950
/*
20331951
* Now that we have the rtnl lock, clear any pending failover.
20341952
* This will ensure ibmvnic_open() has either completed or will
@@ -2038,7 +1956,6 @@ static int do_reset(struct ibmvnic_adapter *adapter,
20381956
adapter->failover_pending = false;
20391957

20401958
netif_carrier_off(netdev);
2041-
adapter->reset_reason = rwi->reset_reason;
20421959

20431960
old_num_rx_queues = adapter->req_rx_queues;
20441961
old_num_tx_queues = adapter->req_tx_queues;
@@ -2050,25 +1967,37 @@ static int do_reset(struct ibmvnic_adapter *adapter,
20501967
if (reset_state == VNIC_OPEN &&
20511968
adapter->reset_reason != VNIC_RESET_MOBILITY &&
20521969
adapter->reset_reason != VNIC_RESET_FAILOVER) {
2053-
adapter->state = VNIC_CLOSING;
1970+
if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM) {
1971+
rc = __ibmvnic_close(netdev);
1972+
if (rc)
1973+
goto out;
1974+
} else {
1975+
adapter->state = VNIC_CLOSING;
20541976

2055-
/* Release the RTNL lock before link state change and
2056-
* re-acquire after the link state change to allow
2057-
* linkwatch_event to grab the RTNL lock and run during
2058-
* a reset.
2059-
*/
2060-
rtnl_unlock();
2061-
rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_DN);
2062-
rtnl_lock();
2063-
if (rc)
2064-
goto out;
1977+
/* Release the RTNL lock before link state change and
1978+
* re-acquire after the link state change to allow
1979+
* linkwatch_event to grab the RTNL lock and run during
1980+
* a reset.
1981+
*/
1982+
rtnl_unlock();
1983+
rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_DN);
1984+
rtnl_lock();
1985+
if (rc)
1986+
goto out;
20651987

2066-
if (adapter->state != VNIC_CLOSING) {
2067-
rc = -1;
2068-
goto out;
1988+
if (adapter->state != VNIC_CLOSING) {
1989+
rc = -1;
1990+
goto out;
1991+
}
1992+
1993+
adapter->state = VNIC_CLOSED;
20691994
}
1995+
}
20701996

2071-
adapter->state = VNIC_CLOSED;
1997+
if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM) {
1998+
release_resources(adapter);
1999+
release_sub_crqs(adapter, 1);
2000+
release_crq_queue(adapter);
20722001
}
20732002

20742003
if (adapter->reset_reason != VNIC_RESET_NON_FATAL) {
@@ -2077,7 +2006,9 @@ static int do_reset(struct ibmvnic_adapter *adapter,
20772006
*/
20782007
adapter->state = VNIC_PROBED;
20792008

2080-
if (adapter->reset_reason == VNIC_RESET_MOBILITY) {
2009+
if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM) {
2010+
rc = init_crq_queue(adapter);
2011+
} else if (adapter->reset_reason == VNIC_RESET_MOBILITY) {
20812012
rc = ibmvnic_reenable_crq_queue(adapter);
20822013
release_sub_crqs(adapter, 1);
20832014
} else {
@@ -2116,7 +2047,11 @@ static int do_reset(struct ibmvnic_adapter *adapter,
21162047
goto out;
21172048
}
21182049

2119-
if (adapter->req_rx_queues != old_num_rx_queues ||
2050+
if (adapter->reset_reason == VNIC_RESET_CHANGE_PARAM) {
2051+
rc = init_resources(adapter);
2052+
if (rc)
2053+
goto out;
2054+
} else if (adapter->req_rx_queues != old_num_rx_queues ||
21202055
adapter->req_tx_queues != old_num_tx_queues ||
21212056
adapter->req_rx_add_entries_per_subcrq !=
21222057
old_num_rx_slots ||
@@ -2181,7 +2116,9 @@ static int do_reset(struct ibmvnic_adapter *adapter,
21812116
/* restore the adapter state if reset failed */
21822117
if (rc)
21832118
adapter->state = reset_state;
2184-
rtnl_unlock();
2119+
/* requestor of VNIC_RESET_CHANGE_PARAM should still hold the rtnl lock */
2120+
if (!(adapter->reset_reason == VNIC_RESET_CHANGE_PARAM))
2121+
rtnl_unlock();
21852122

21862123
netdev_dbg(adapter->netdev, "[S:%d FOP:%d] Reset done, rc %d\n",
21872124
adapter->state, adapter->failover_pending, rc);
@@ -2312,10 +2249,7 @@ static void __ibmvnic_reset(struct work_struct *work)
23122249
}
23132250
spin_unlock_irqrestore(&adapter->state_lock, flags);
23142251

2315-
if (rwi->reset_reason == VNIC_RESET_CHANGE_PARAM) {
2316-
/* CHANGE_PARAM requestor holds rtnl_lock */
2317-
rc = do_change_param_reset(adapter, rwi, reset_state);
2318-
} else if (adapter->force_reset_recovery) {
2252+
if (adapter->force_reset_recovery) {
23192253
/*
23202254
* Since we are doing a hard reset now, clear the
23212255
* failover_pending flag so we don't ignore any

0 commit comments

Comments
 (0)