]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
IB/cm: avoid query device in CM REQ/REP
authorFrancisco Triviño <francisco.trivino@oracle.com>
Mon, 14 Nov 2016 16:46:14 +0000 (08:46 -0800)
committerSantosh Shilimkar <santosh.shilimkar@oracle.com>
Mon, 14 Nov 2016 16:46:14 +0000 (08:46 -0800)
The query device needed in CM REQ/REP is a bit expensive since
it involves a MAD query and also it is not saved in the cache.
When the driver that holds the local device is different from
sif then there is no need to go through the query device. If
sif driver is identified, then we still need to go through the
query device in order to get the specific vendor id. This last
is to make sure the software workaround is applied only to the
PSIF revisions that are affected.

This patch filters those cases and avoids unnecessary MAD queries
when driver is different from sif.

Orabug: 24785622

Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: Francisco Triviño <francisco.trivino@oracle.com>
drivers/infiniband/core/cm.c

index c106016c6d0e9b7dd0cf75582c18a0b8bf61c660..c3c3d154765f9374e55a0a911e68832a35584877 100644 (file)
@@ -1302,12 +1302,18 @@ static void cm_format_req(struct cm_req_msg *req_msg,
        struct ib_sa_path_rec *pri_path = param->primary_path;
        struct ib_sa_path_rec *alt_path = param->alternate_path;
        struct ib_device_attr attr;
-       u32 vendor_part_id;
+       u32 vendor_part_id = 0;
 
-       if (ib_query_device(cm_id_priv->id.device, &attr))
-               vendor_part_id = 0;
-       else
-               vendor_part_id = attr.vendor_part_id;
+       /*
+        * ib_query_device is still needed to check if the local
+        * device is one of the sif_family_vendor_part_id list
+        * (PSIF 2.1 Rev 3)
+        */
+       if (cm_id_priv->id.device->dma_device)
+               if (!strcmp(cm_id_priv->id.device->dma_device->driver->name,
+                               "sif"))
+                       if (!ib_query_device(cm_id_priv->id.device, &attr))
+                               vendor_part_id = attr.vendor_part_id;
 
        cm_format_mad_hdr(&req_msg->hdr, CM_REQ_ATTR_ID,
                          cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_REQ));
@@ -2004,12 +2010,18 @@ static void cm_format_rep(struct cm_rep_msg *rep_msg,
                          struct ib_cm_rep_param *param)
 {
        struct ib_device_attr attr;
-       u32 vendor_part_id;
+       u32 vendor_part_id = 0;
 
-       if (ib_query_device(cm_id_priv->id.device, &attr))
-               vendor_part_id = 0;
-       else
-               vendor_part_id = attr.vendor_part_id;
+       /*
+        * ib_query_device is still needed to check if the local
+        * device is one of the sif_family_vendor_part_id list
+        * (PSIF 2.1 Rev 3)
+        */
+       if (cm_id_priv->id.device->dma_device)
+               if (!strcmp(cm_id_priv->id.device->dma_device->driver->name,
+                               "sif"))
+                       if (!ib_query_device(cm_id_priv->id.device, &attr))
+                               vendor_part_id = attr.vendor_part_id;
 
        cm_format_mad_hdr(&rep_msg->hdr, CM_REP_ATTR_ID, cm_id_priv->tid);
        rep_msg->local_comm_id = cm_id_priv->id.local_id;