RDMA/cxgb3: Fix deadlock initializing iw_cxgb3 device

Running 'ifconfig up' on the cxgb3 interface with iw_cxgb3 loaded
causes a deadlock. The rtnl lock is already held in this path. The
function fw_supports_fastreg() was introduced in 2.6.27 to
conditionally set the IB_DEVICE_MEM_MGT_EXTENSIONS bit iff the
firmware was at 7.0 or greater, and this function also acquires the
rtnl lock and which thus causes a deadlock. Further, if iw_cxgb3 is
loaded _after_ the nic interface is brought up, then the deadlock does
not occur and therefore fw_supports_fastreg() does need to grab the
rtnl lock in that path.

It turns out this code is all useless anyway. The low level driver
will NOT allow the open if the firmware isn't 7.0, so iw_cxgb3 can
always set the MEM_MGT_EXTENSIONS bit. Simplify...

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>

authored by Steve Wise and committed by Roland Dreier be43324d 1c355a6e

+3 -25
+3 -25
drivers/infiniband/hw/cxgb3/iwch_provider.c
··· 1187 return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type); 1188 } 1189 1190 - static int fw_supports_fastreg(struct iwch_dev *iwch_dev) 1191 - { 1192 - struct ethtool_drvinfo info; 1193 - struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; 1194 - char *cp, *next; 1195 - unsigned fw_maj, fw_min; 1196 - 1197 - rtnl_lock(); 1198 - lldev->ethtool_ops->get_drvinfo(lldev, &info); 1199 - rtnl_unlock(); 1200 - 1201 - next = info.fw_version+1; 1202 - cp = strsep(&next, "."); 1203 - sscanf(cp, "%i", &fw_maj); 1204 - cp = strsep(&next, "."); 1205 - sscanf(cp, "%i", &fw_min); 1206 - 1207 - PDBG("%s maj %u min %u\n", __func__, fw_maj, fw_min); 1208 - 1209 - return fw_maj > 6 || (fw_maj == 6 && fw_min > 0); 1210 - } 1211 - 1212 static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) 1213 { 1214 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, ··· 1303 memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); 1304 memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); 1305 dev->ibdev.owner = THIS_MODULE; 1306 - dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW; 1307 1308 /* cxgb3 supports STag 0. */ 1309 dev->ibdev.local_dma_lkey = 0; 1310 - if (fw_supports_fastreg(dev)) 1311 - dev->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS; 1312 1313 dev->ibdev.uverbs_cmd_mask = 1314 (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
··· 1187 return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type); 1188 } 1189 1190 static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) 1191 { 1192 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, ··· 1325 memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); 1326 memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); 1327 dev->ibdev.owner = THIS_MODULE; 1328 + dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY | 1329 + IB_DEVICE_MEM_WINDOW | 1330 + IB_DEVICE_MEM_MGT_EXTENSIONS; 1331 1332 /* cxgb3 supports STag 0. */ 1333 dev->ibdev.local_dma_lkey = 0; 1334 1335 dev->ibdev.uverbs_cmd_mask = 1336 (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |