From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bn3nam01on0100.outbound.protection.outlook.com ([104.47.33.100]:20288 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754058AbeDIATa (ORCPT ); Sun, 8 Apr 2018 20:19:30 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Thomas Falcon , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 108/189] ibmvnic: Wait for device response when changing MAC Date: Mon, 9 Apr 2018 00:18:11 +0000 Message-ID: <20180409001637.162453-108-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Thomas Falcon [ Upstream commit f813614f531114db796ad66ced75c5dc8db7aa3a ] Wait for a response from the VNIC server before exiting after setting the MAC address. The resolves an issue with bonding a VNIC client in ALB or TLB modes. The bonding driver was changing the MAC address more rapidly than the device could respond, causing the following errors. "bond0: the hw address of slave eth2 is in use by the bond; couldn't find a slave with a free hw address to give it (this should not have happened)" If the function waits until the change is finalized, these errors are avoided. Signed-off-by: Thomas Falcon Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/ibm/ibmvnic.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/= ibmvnic.c index b65f5f3ac034..d4e87333bac2 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -1543,15 +1543,19 @@ static int __ibmvnic_set_mac(struct net_device *net= dev, struct sockaddr *p) crq.change_mac_addr.first =3D IBMVNIC_CRQ_CMD; crq.change_mac_addr.cmd =3D CHANGE_MAC_ADDR; ether_addr_copy(&crq.change_mac_addr.mac_addr[0], addr->sa_data); + + init_completion(&adapter->fw_done); ibmvnic_send_crq(adapter, &crq); + wait_for_completion(&adapter->fw_done); /* netdev->dev_addr is changed in handle_change_mac_rsp function */ - return 0; + return adapter->fw_done_rc ? -EIO : 0; } =20 static int ibmvnic_set_mac(struct net_device *netdev, void *p) { struct ibmvnic_adapter *adapter =3D netdev_priv(netdev); struct sockaddr *addr =3D p; + int rc; =20 if (adapter->state =3D=3D VNIC_PROBED) { memcpy(&adapter->desired.mac, addr, sizeof(struct sockaddr)); @@ -1559,9 +1563,9 @@ static int ibmvnic_set_mac(struct net_device *netdev,= void *p) return 0; } =20 - __ibmvnic_set_mac(netdev, addr); + rc =3D __ibmvnic_set_mac(netdev, addr); =20 - return 0; + return rc; } =20 /** @@ -3558,8 +3562,8 @@ static void handle_error_indication(union ibmvnic_crq= *crq, ibmvnic_reset(adapter, VNIC_RESET_NON_FATAL); } =20 -static void handle_change_mac_rsp(union ibmvnic_crq *crq, - struct ibmvnic_adapter *adapter) +static int handle_change_mac_rsp(union ibmvnic_crq *crq, + struct ibmvnic_adapter *adapter) { struct net_device *netdev =3D adapter->netdev; struct device *dev =3D &adapter->vdev->dev; @@ -3568,10 +3572,13 @@ static void handle_change_mac_rsp(union ibmvnic_crq= *crq, rc =3D crq->change_mac_addr_rsp.rc.code; if (rc) { dev_err(dev, "Error %ld in CHANGE_MAC_ADDR_RSP\n", rc); - return; + goto out; } memcpy(netdev->dev_addr, &crq->change_mac_addr_rsp.mac_addr[0], ETH_ALEN); +out: + complete(&adapter->fw_done); + return rc; } =20 static void handle_request_cap_rsp(union ibmvnic_crq *crq, @@ -4031,7 +4038,7 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq= , break; case CHANGE_MAC_ADDR_RSP: netdev_dbg(netdev, "Got MAC address change Response\n"); - handle_change_mac_rsp(crq, adapter); + adapter->fw_done_rc =3D handle_change_mac_rsp(crq, adapter); break; case ERROR_INDICATION: netdev_dbg(netdev, "Got Error Indication\n"); --=20 2.15.1