From 0f82ab40b762ad23e30db7de4a91db56fd8b42e6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Francisco=20Trivi=C3=B1o?= Date: Mon, 14 Nov 2016 08:46:14 -0800 Subject: [PATCH] IB/cm: avoid query device in CM REQ/REP MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Santosh Shilimkar Signed-off-by: Francisco Triviño --- drivers/infiniband/core/cm.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index c106016c6d0e..c3c3d154765f 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -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; -- 2.50.1