Skip to content

Commit 89428ab

Browse files
Wei Lin GuayLinuxMinion
authored andcommitted
IB/cm: remove unnecessary ib_query_device in PSIF RNR WA
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 <[email protected]> Reviewed-by: Håkon Bugge <[email protected]> Reviewed-by: Francisco Triviño García <[email protected]> Reviewed-by: Gerd Rausch <[email protected]>
1 parent 5d8379a commit 89428ab

File tree

1 file changed

+8
-28
lines changed
  • drivers/infiniband/core

1 file changed

+8
-28
lines changed

drivers/infiniband/core/cm.c

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
#include <rdma/ib_cache.h>
5353
#include <rdma/ib_cm.h>
54+
#include <linux/pci.h>
5455
#include "cm_msgs.h"
5556
#include "core_priv.h"
5657

@@ -63,6 +64,9 @@ MODULE_LICENSE("Dual BSD/GPL");
6364
#endif
6465
#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
6566

67+
#define SIF_VENDID(n) ((n) ? (to_pci_dev((n))->vendor == PCI_VENDOR_ID_SUN) : 0)
68+
#define SIF_DEVID(n) (SIF_VENDID(n) ? to_pci_dev((n))->device : 0)
69+
6670
static void cm_add_one(struct ib_device *device);
6771
static void cm_remove_one(struct ib_device *device);
6872

@@ -1286,10 +1290,10 @@ static void cm_format_mad_hdr(struct ib_mad_hdr *hdr,
12861290
}
12871291

12881292
#define SIF_DEVICES 6
1289-
const u32 sif_family_vendor_part_id[SIF_DEVICES] = {
1293+
const u16 sif_family_vendor_part_id[SIF_DEVICES] = {
12901294
0x2088, 0x2089, 0x2188, 0x2189, 0x2198, 0x2199};
12911295

1292-
static inline bool is_vendor_sif_family(u32 part_id)
1296+
static inline bool is_vendor_sif_family(u16 part_id)
12931297
{
12941298
int i;
12951299

@@ -1306,19 +1310,7 @@ static void cm_format_req(struct cm_req_msg *req_msg,
13061310
{
13071311
struct ib_sa_path_rec *pri_path = param->primary_path;
13081312
struct ib_sa_path_rec *alt_path = param->alternate_path;
1309-
struct ib_device_attr attr;
1310-
u32 vendor_part_id = 0;
1311-
1312-
/*
1313-
* ib_query_device is still needed to check if the local
1314-
* device is one of the sif_family_vendor_part_id list
1315-
* (PSIF 2.1 Rev 3)
1316-
*/
1317-
if (cm_id_priv->id.device->dma_device)
1318-
if (!strcmp(cm_id_priv->id.device->dma_device->driver->name,
1319-
"sif"))
1320-
if (!ib_query_device(cm_id_priv->id.device, &attr))
1321-
vendor_part_id = attr.vendor_part_id;
1313+
u16 vendor_part_id = SIF_DEVID(cm_id_priv->id.device->dma_device);
13221314

13231315
cm_format_mad_hdr(&req_msg->hdr, CM_REQ_ATTR_ID,
13241316
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,
20142006
struct cm_id_private *cm_id_priv,
20152007
struct ib_cm_rep_param *param)
20162008
{
2017-
struct ib_device_attr attr;
2018-
u32 vendor_part_id = 0;
2019-
2020-
/*
2021-
* ib_query_device is still needed to check if the local
2022-
* device is one of the sif_family_vendor_part_id list
2023-
* (PSIF 2.1 Rev 3)
2024-
*/
2025-
if (cm_id_priv->id.device->dma_device)
2026-
if (!strcmp(cm_id_priv->id.device->dma_device->driver->name,
2027-
"sif"))
2028-
if (!ib_query_device(cm_id_priv->id.device, &attr))
2029-
vendor_part_id = attr.vendor_part_id;
2009+
u16 vendor_part_id = SIF_DEVID(cm_id_priv->id.device->dma_device);
20302010

20312011
cm_format_mad_hdr(&rep_msg->hdr, CM_REP_ATTR_ID, cm_id_priv->tid);
20322012
rep_msg->local_comm_id = cm_id_priv->id.local_id;

0 commit comments

Comments
 (0)