diff mbox series

[d/azure,1/2] UBUNTU: SAUCE: Don't wait in hvnd_query_gid after interface is already bound to ND

Message ID 20190814180804.6019-1-marcelo.cerri@canonical.com
State New
Headers show
Series [d/azure,1/2] UBUNTU: SAUCE: Don't wait in hvnd_query_gid after interface is already bound to ND | expand

Commit Message

Marcelo Henrique Cerri Aug. 14, 2019, 6:08 p.m. UTC
From: Long Li <longli@microsoft.com>

BugLink: https://bugs.launchpad.net/bugs/1839673

The user mode may call hvnd_query_gid multiple times, and from multiple user
contexts at the same time. If it's already bound, return GID and not wait.

Signed-off-by: Long Li <longli@microsoft.com>
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
---
 .../hw/vmbus-rdma/vmbus-rdma-144.0/provider.c          | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Sultan Alsawaf Aug. 14, 2019, 6:16 p.m. UTC | #1
On Wed, Aug 14, 2019 at 03:08:03PM -0300, Marcelo Henrique Cerri wrote:
> From: Long Li <longli@microsoft.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1839673
> 
> The user mode may call hvnd_query_gid multiple times, and from multiple user
> contexts at the same time. If it's already bound, return GID and not wait.
> 
> Signed-off-by: Long Li <longli@microsoft.com>
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> ---
>  .../hw/vmbus-rdma/vmbus-rdma-144.0/provider.c          | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c b/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
> index 8e15522707b9..3ad27e9d6a5d 100644
> --- a/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
> +++ b/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
> @@ -604,9 +604,11 @@ static int hvnd_query_gid(struct ib_device *ibdev, u8 port, int index,
>  
>  	debug_check(__func__, __LINE__);
>  
> -	ret = wait_for_completion_timeout(&nd_dev->addr_set, 60*HZ);
> -	if (!ret)
> -		return -ETIMEDOUT;
> +	if (!nd_dev->bind_complete) {
> +		ret = wait_for_completion_timeout(&nd_dev->addr_set, 60*HZ);
> +		if (!ret && !nd_dev->bind_complete)
> +			return -ETIMEDOUT;
> +	}
>  
>  	memset(&(gid->raw[0]), 0, sizeof(gid->raw));
>  	memcpy(&(gid->raw[0]), nd_dev->mac_addr, 6);
> @@ -2752,8 +2754,8 @@ static int hvnd_try_bind_nic(unsigned char *mac, __be32 ip)
>  	/* if we reach here, this means bind_nic is a success */
>  	hvnd_error("successfully bound to IP %pI4 MAC %pM\n",
>  		   nd_dev->ip_addr, nd_dev->mac_addr);
> -	complete(&nd_dev->addr_set);
>  	nd_dev->bind_complete = 1;
> +	complete_all(&nd_dev->addr_set);
>  	mutex_unlock(&nd_dev->bind_mutex);
>  
>  	ret = hvnd_register_device(nd_dev, nd_dev->ip_addr, nd_dev->mac_addr);
> -- 
> 2.20.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team

Acked-by: Sultan Alsawaf <sultan.alsawaf@canonical.com>
Connor Kuehl Aug. 15, 2019, 4:59 p.m. UTC | #2
On 8/14/19 11:08 AM, Marcelo Henrique Cerri wrote:
> From: Long Li <longli@microsoft.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1839673
> 
> The user mode may call hvnd_query_gid multiple times, and from multiple user
> contexts at the same time. If it's already bound, return GID and not wait.
> 
> Signed-off-by: Long Li <longli@microsoft.com>
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> ---
>   .../hw/vmbus-rdma/vmbus-rdma-144.0/provider.c          | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c b/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
> index 8e15522707b9..3ad27e9d6a5d 100644
> --- a/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
> +++ b/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
> @@ -604,9 +604,11 @@ static int hvnd_query_gid(struct ib_device *ibdev, u8 port, int index,
>   
>   	debug_check(__func__, __LINE__);
>   
> -	ret = wait_for_completion_timeout(&nd_dev->addr_set, 60*HZ);
> -	if (!ret)
> -		return -ETIMEDOUT;
> +	if (!nd_dev->bind_complete) {
> +		ret = wait_for_completion_timeout(&nd_dev->addr_set, 60*HZ);
> +		if (!ret && !nd_dev->bind_complete)
> +			return -ETIMEDOUT;
> +	}
>   
>   	memset(&(gid->raw[0]), 0, sizeof(gid->raw));
>   	memcpy(&(gid->raw[0]), nd_dev->mac_addr, 6);
> @@ -2752,8 +2754,8 @@ static int hvnd_try_bind_nic(unsigned char *mac, __be32 ip)
>   	/* if we reach here, this means bind_nic is a success */
>   	hvnd_error("successfully bound to IP %pI4 MAC %pM\n",
>   		   nd_dev->ip_addr, nd_dev->mac_addr);
> -	complete(&nd_dev->addr_set);
>   	nd_dev->bind_complete = 1;
> +	complete_all(&nd_dev->addr_set);
>   	mutex_unlock(&nd_dev->bind_mutex);
>   
>   	ret = hvnd_register_device(nd_dev, nd_dev->ip_addr, nd_dev->mac_addr);
> 

For both patches:

Acked-by: Connor Kuehl <connor.kuehl@canonical.com>
Khalid Elmously Aug. 15, 2019, 5:01 p.m. UTC | #3
On 2019-08-14 15:08:03 , Marcelo Henrique Cerri wrote:
> From: Long Li <longli@microsoft.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1839673
> 
> The user mode may call hvnd_query_gid multiple times, and from multiple user
> contexts at the same time. If it's already bound, return GID and not wait.
> 
> Signed-off-by: Long Li <longli@microsoft.com>
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> ---
>  .../hw/vmbus-rdma/vmbus-rdma-144.0/provider.c          | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c b/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
> index 8e15522707b9..3ad27e9d6a5d 100644
> --- a/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
> +++ b/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
> @@ -604,9 +604,11 @@ static int hvnd_query_gid(struct ib_device *ibdev, u8 port, int index,
>  
>  	debug_check(__func__, __LINE__);
>  
> -	ret = wait_for_completion_timeout(&nd_dev->addr_set, 60*HZ);
> -	if (!ret)
> -		return -ETIMEDOUT;
> +	if (!nd_dev->bind_complete) {
> +		ret = wait_for_completion_timeout(&nd_dev->addr_set, 60*HZ);
> +		if (!ret && !nd_dev->bind_complete)
> +			return -ETIMEDOUT;
> +	}
>  
>  	memset(&(gid->raw[0]), 0, sizeof(gid->raw));
>  	memcpy(&(gid->raw[0]), nd_dev->mac_addr, 6);
> @@ -2752,8 +2754,8 @@ static int hvnd_try_bind_nic(unsigned char *mac, __be32 ip)
>  	/* if we reach here, this means bind_nic is a success */
>  	hvnd_error("successfully bound to IP %pI4 MAC %pM\n",
>  		   nd_dev->ip_addr, nd_dev->mac_addr);
> -	complete(&nd_dev->addr_set);
>  	nd_dev->bind_complete = 1;
> +	complete_all(&nd_dev->addr_set);
>  	mutex_unlock(&nd_dev->bind_mutex);
>  
>  	ret = hvnd_register_device(nd_dev, nd_dev->ip_addr, nd_dev->mac_addr);
> -- 

Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
Marcelo Henrique Cerri Aug. 15, 2019, 8:39 p.m. UTC | #4
--
Regards,
Marcelo
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c b/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
index 8e15522707b9..3ad27e9d6a5d 100644
--- a/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
+++ b/drivers/infiniband/hw/vmbus-rdma/vmbus-rdma-144.0/provider.c
@@ -604,9 +604,11 @@  static int hvnd_query_gid(struct ib_device *ibdev, u8 port, int index,
 
 	debug_check(__func__, __LINE__);
 
-	ret = wait_for_completion_timeout(&nd_dev->addr_set, 60*HZ);
-	if (!ret)
-		return -ETIMEDOUT;
+	if (!nd_dev->bind_complete) {
+		ret = wait_for_completion_timeout(&nd_dev->addr_set, 60*HZ);
+		if (!ret && !nd_dev->bind_complete)
+			return -ETIMEDOUT;
+	}
 
 	memset(&(gid->raw[0]), 0, sizeof(gid->raw));
 	memcpy(&(gid->raw[0]), nd_dev->mac_addr, 6);
@@ -2752,8 +2754,8 @@  static int hvnd_try_bind_nic(unsigned char *mac, __be32 ip)
 	/* if we reach here, this means bind_nic is a success */
 	hvnd_error("successfully bound to IP %pI4 MAC %pM\n",
 		   nd_dev->ip_addr, nd_dev->mac_addr);
-	complete(&nd_dev->addr_set);
 	nd_dev->bind_complete = 1;
+	complete_all(&nd_dev->addr_set);
 	mutex_unlock(&nd_dev->bind_mutex);
 
 	ret = hvnd_register_device(nd_dev, nd_dev->ip_addr, nd_dev->mac_addr);