]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
IB/cm: remove unnecessary ib_query_device in PSIF RNR WA
authorWei Lin Guay <wei.lin.guay@oracle.com>
Wed, 7 Dec 2016 08:08:09 +0000 (09:08 +0100)
committerChuck Anderson <chuck.anderson@oracle.com>
Sat, 10 Jun 2017 00:33:25 +0000 (17:33 -0700)
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 <wei.lin.guay@oracle.com>
Reviewed-by: Håkon Bugge <haakon.bugge@oracle.com>
Reviewed-by: Francisco Triviño García <francisco.trivino@oracle.com>
Reviewed-by: Gerd Rausch <gerd.rausch@oracle.com>
drivers/infiniband/core/cm.c

index 28839cf45afbc606ab603e1ad7552950dc297f03..0c59a80929c641905238be0c507346db768a5db6 100644 (file)
@@ -51,6 +51,7 @@
 
 #include <rdma/ib_cache.h>
 #include <rdma/ib_cm.h>
+#include <linux/pci.h>
 #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;