Re: [PATCH rdma-next v1 3/3] RDMA/cma: Introduce and use cma_ib_acquire_dev()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2018-09-15 at 12:07 +0300, Leon Romanovsky wrote:
> 
> +	gid_type = listen_id_priv->cma_dev->default_gid_type[req->port - 1];
> +	sgid_attr = cma_validate_port(req->device, req->port,
> +				      gid_type, &gid, id_priv);
> +	if (IS_ERR(sgid_attr))
> +		return PTR_ERR(sgid_attr);
> +
> +	id_priv->id.port_num = req->port;
> +	cma_bind_sgid_attr(id_priv, sgid_attr);
> +	/* Need to acquire lock to protect against reader
> +	 * of cma_dev->id_list such as cma_netdev_callback() and
> +	 * cma_process_remove().
> +	 */
> +	mutex_lock(&lock);
> +	cma_attach_to_dev(id_priv, listen_id_priv->cma_dev);
> +	mutex_unlock(&lock);

Why does cma_ib_acquire_dev perform cma_validate_port and
cma_bind_sgid_attr outside of the mutex_lock(&lock),

> 
> +static int cma_iw_acquire_dev(struct rdma_id_private *id_priv,
> +			      const struct rdma_id_private *listen_id_priv)
>  {
>  	struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;
>  	const struct ib_gid_attr *sgid_attr;
>  	struct cma_device *cma_dev;
> -	union ib_gid gid, iboe_gid, *gidp;
>  	enum ib_gid_type gid_type;
>  	int ret = -ENODEV;
> +	union ib_gid gid;
>  	u8 port;
>  
>  	if (dev_addr->dev_type != ARPHRD_INFINIBAND &&
>  	    id_priv->id.ps == RDMA_PS_IPOIB)
>  		return -EINVAL;
>  
> -	mutex_lock(&lock);
> -	rdma_ip2gid((struct sockaddr *)&id_priv->id.route.addr.src_addr,
> -		    &iboe_gid);
> -
>  	memcpy(&gid, dev_addr->src_dev_addr +
> -	       rdma_addr_gid_offset(dev_addr), sizeof gid);
> +	       rdma_addr_gid_offset(dev_addr), sizeof(gid));
> +
> +	mutex_lock(&lock);
>  
>  	cma_dev = listen_id_priv->cma_dev;
>  	port = listen_id_priv->id.port_num;
> -	gidp = rdma_protocol_roce(cma_dev->device, port) ? &iboe_gid : &gid;
>  	gid_type = listen_id_priv->gid_type;
>  	sgid_attr = cma_validate_port(cma_dev->device, port,
> -				      gid_type, gidp, id_priv);
> +				      gid_type, &gid, id_priv);
>  	if (!IS_ERR(sgid_attr)) {
>  		id_priv->id.port_num = port;
>  		cma_bind_sgid_attr(id_priv, sgid_attr);

while cma_iw_acquire_dev does those same two activities under the lock?

-- 
Doug Ledford <dledford@xxxxxxxxxx>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux