Merge branch 'bkl-removal' into next
[pandora-kernel.git] / drivers / infiniband / core / sa_query.c
index d271bd7..1341de7 100644 (file)
@@ -30,8 +30,6 @@
  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  * SOFTWARE.
- *
- * $Id: sa_query.c 2811 2005-07-06 18:11:43Z halr $
  */
 
 #include <linux/module.h>
@@ -123,14 +121,10 @@ static u32 tid;
        .field_name          = "sa_path_rec:" #field
 
 static const struct ib_field path_rec_table[] = {
-       { RESERVED,
+       { PATH_REC_FIELD(service_id),
          .offset_words = 0,
          .offset_bits  = 0,
-         .size_bits    = 32 },
-       { RESERVED,
-         .offset_words = 1,
-         .offset_bits  = 0,
-         .size_bits    = 32 },
+         .size_bits    = 64 },
        { PATH_REC_FIELD(dgid),
          .offset_words = 2,
          .offset_bits  = 0,
@@ -179,7 +173,7 @@ static const struct ib_field path_rec_table[] = {
          .offset_words = 12,
          .offset_bits  = 16,
          .size_bits    = 16 },
-       { RESERVED,
+       { PATH_REC_FIELD(qos_class),
          .offset_words = 13,
          .offset_bits  = 0,
          .size_bits    = 12 },
@@ -365,7 +359,7 @@ static void update_sm_ah(struct work_struct *work)
 {
        struct ib_sa_port *port =
                container_of(work, struct ib_sa_port, update_task);
-       struct ib_sa_sm_ah *new_ah, *old_ah;
+       struct ib_sa_sm_ah *new_ah;
        struct ib_port_attr port_attr;
        struct ib_ah_attr   ah_attr;
 
@@ -401,12 +395,9 @@ static void update_sm_ah(struct work_struct *work)
        }
 
        spin_lock_irq(&port->ah_lock);
-       old_ah = port->sm_ah;
        port->sm_ah = new_ah;
        spin_unlock_irq(&port->ah_lock);
 
-       if (old_ah)
-               kref_put(&old_ah->ref, free_sm_ah);
 }
 
 static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event)
@@ -417,8 +408,17 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
            event->event == IB_EVENT_PKEY_CHANGE ||
            event->event == IB_EVENT_SM_CHANGE   ||
            event->event == IB_EVENT_CLIENT_REREGISTER) {
-               struct ib_sa_device *sa_dev;
-               sa_dev = container_of(handler, typeof(*sa_dev), event_handler);
+               unsigned long flags;
+               struct ib_sa_device *sa_dev =
+                       container_of(handler, typeof(*sa_dev), event_handler);
+               struct ib_sa_port *port =
+                       &sa_dev->port[event->element.port_num - sa_dev->start_port];
+
+               spin_lock_irqsave(&port->ah_lock, flags);
+               if (port->sm_ah)
+                       kref_put(&port->sm_ah->ref, free_sm_ah);
+               port->sm_ah = NULL;
+               spin_unlock_irqrestore(&port->ah_lock, flags);
 
                schedule_work(&sa_dev->port[event->element.port_num -
                                            sa_dev->start_port].update_task);
@@ -523,6 +523,10 @@ static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
        unsigned long flags;
 
        spin_lock_irqsave(&query->port->ah_lock, flags);
+       if (!query->port->sm_ah) {
+               spin_unlock_irqrestore(&query->port->ah_lock, flags);
+               return -EAGAIN;
+       }
        kref_get(&query->port->sm_ah->ref);
        query->sm_ah = query->port->sm_ah;
        spin_unlock_irqrestore(&query->port->ah_lock, flags);
@@ -531,7 +535,7 @@ static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
                                            query->sm_ah->pkey_index,
                                            0, IB_MGMT_SA_HDR, IB_MGMT_SA_DATA,
                                            gfp_mask);
-       if (!query->mad_buf) {
+       if (IS_ERR(query->mad_buf)) {
                kref_put(&query->sm_ah->ref, free_sm_ah);
                return -ENOMEM;
        }