From 89428ab0d127c2a3a8c61d622d6d1a7c7afa124a Mon Sep 17 00:00:00 2001 From: Wei Lin Guay Date: Wed, 7 Dec 2016 09:08:09 +0100 Subject: [PATCH] IB/cm: remove unnecessary ib_query_device in PSIF RNR WA MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The query device is performed in CM REQ/REP to retrieve the vendorID of the sif device. This operation is illegal because it is calling a sleeping function (ib_query_device) from a non-sleepable context. Thus, this patch removes this illegal call and reuses the cached vendorID/DeviceID in the pci_dev data structure. Orabug: 25892550 Signed-off-by: Wei Lin Guay Reviewed-by: Håkon Bugge Reviewed-by: Francisco Triviño García Reviewed-by: Gerd Rausch --- drivers/infiniband/core/cm.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 28839cf45afb..0c59a80929c6 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -51,6 +51,7 @@ #include #include +#include #include "cm_msgs.h" #include "core_priv.h" @@ -63,6 +64,9 @@ MODULE_LICENSE("Dual BSD/GPL"); #endif #define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__ +#define SIF_VENDID(n) ((n) ? (to_pci_dev((n))->vendor == PCI_VENDOR_ID_SUN) : 0) +#define SIF_DEVID(n) (SIF_VENDID(n) ? to_pci_dev((n))->device : 0) + static void cm_add_one(struct ib_device *device); static void cm_remove_one(struct ib_device *device); @@ -1286,10 +1290,10 @@ static void cm_format_mad_hdr(struct ib_mad_hdr *hdr, } #define SIF_DEVICES 6 -const u32 sif_family_vendor_part_id[SIF_DEVICES] = { +const u16 sif_family_vendor_part_id[SIF_DEVICES] = { 0x2088, 0x2089, 0x2188, 0x2189, 0x2198, 0x2199}; -static inline bool is_vendor_sif_family(u32 part_id) +static inline bool is_vendor_sif_family(u16 part_id) { int i; @@ -1306,19 +1310,7 @@ 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 = 0; - - /* - * 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; + u16 vendor_part_id = SIF_DEVID(cm_id_priv->id.device->dma_device); cm_format_mad_hdr(&req_msg->hdr, CM_REQ_ATTR_ID, cm_form_tid(cm_id_priv, CM_MSG_SEQUENCE_REQ)); @@ -2014,19 +2006,7 @@ static void cm_format_rep(struct cm_rep_msg *rep_msg, struct cm_id_private *cm_id_priv, struct ib_cm_rep_param *param) { - struct ib_device_attr attr; - u32 vendor_part_id = 0; - - /* - * 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; + u16 vendor_part_id = SIF_DEVID(cm_id_priv->id.device->dma_device); 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