int ib_attach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
 {
+       int ret;
+
        if (!qp->device->attach_mcast)
                return -ENOSYS;
        if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
                return -EINVAL;
 
-       return qp->device->attach_mcast(qp, gid, lid);
+       ret = qp->device->attach_mcast(qp, gid, lid);
+       if (!ret)
+               atomic_inc(&qp->usecnt);
+       return ret;
 }
 EXPORT_SYMBOL(ib_attach_mcast);
 
 int ib_detach_mcast(struct ib_qp *qp, union ib_gid *gid, u16 lid)
 {
+       int ret;
+
        if (!qp->device->detach_mcast)
                return -ENOSYS;
        if (gid->raw[0] != 0xff || qp->qp_type != IB_QPT_UD)
                return -EINVAL;
 
-       return qp->device->detach_mcast(qp, gid, lid);
+       ret = qp->device->detach_mcast(qp, gid, lid);
+       if (!ret)
+               atomic_dec(&qp->usecnt);
+       return ret;
 }
 EXPORT_SYMBOL(ib_detach_mcast);
 
 
        struct ib_srq          *srq;
        struct ib_xrcd         *xrcd; /* XRC TGT QPs only */
        struct list_head        xrcd_list;
-       atomic_t                usecnt; /* count times opened */
+       atomic_t                usecnt; /* count times opened, mcast attaches */
        struct list_head        open_list;
        struct ib_qp           *real_qp;
        struct ib_uobject      *uobject;