From: Francisco Triviño Date: Mon, 14 Nov 2016 16:46:14 +0000 (-0800) Subject: IB/cm: avoid query device in CM REQ/REP X-Git-Tag: v4.1.12-92~36^2~3 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0f82ab40b762ad23e30db7de4a91db56fd8b42e6;p=users%2Fjedix%2Flinux-maple.git IB/cm: avoid query device in CM REQ/REP 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 --- diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index c106016c6d0e9..c3c3d154765f9 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;