Skip to contentSkip to conversation

IB/IPoIB/core/drivers: patches for rc/next

PATCH In review Dennis Dalessandro 3 participants 7 messages Jun 30, 2017 – Jul 31, 2017 3 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover IB/IPoIB/core/drivers: patches for rc/next

Hi Doug,

Here are three more patches. The first two we are fine with going into -next, however the third is the patch Niranjana mentioned yesterday that would be good to get into the last RC if the train hasn't left the station yet.

These have not been through zero-day but have been submitted. Niranjana's patch is pretty straight forward and I don't foresee obscure build issues. So given the time crunch for the slightest chance at 4.12 I'm taking a calculated risk and sending. The patch applies ontop of our 4.12 patches cleanly. Builds and tests in our environment.

Patches can can also be found in my GitHub repo at:
https://github.com/ddalessa/kernel/tree/for-4.13

---

Bartlomiej Dudek (1):
IB/hfi1: Check return values from PCI config API calls

Mike Marciniszyn (1):
IB/iser: Handle lack of memory management extensions correctly

Niranjana Vishwanathapura (1):
IB/core,opa_vnic,hfi1,mlx5: Properly free rdma_netdev

 drivers/infiniband/hw/hfi1/chip.c                 |   22 ++
 drivers/infiniband/hw/hfi1/hfi.h                  |    2 
 drivers/infiniband/hw/hfi1/pcie.c                 |  238 +++++++++++++++++----
 drivers/infiniband/hw/hfi1/verbs.c                |    1 
 drivers/infiniband/hw/hfi1/vnic.h                 |    1 
 drivers/infiniband/hw/hfi1/vnic_main.c            |   19 +-
 drivers/infiniband/hw/mlx5/main.c                 |   24 +-
 drivers/infiniband/ulp/ipoib/ipoib_main.c         |    8 -
 drivers/infiniband/ulp/iser/iser_verbs.c          |   10 +
 drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c |    8 -
 include/rdma/ib_verbs.h                           |    6 -
 11 files changed, 260 insertions(+), 79 deletions(-)

--
-Denny
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw

PATCH 1/3 IB/iser: Handle lack of memory management extensions correctly

In reply to a message not in the archive

From: Mike Marciniszyn <[email protected]>

max_fast_reg_page_list_len is only valid when the memory management extensions are signaled by the underlying driver.

Fix by adjusting iser_calc_scsi_params() to use ISCSI_ISER_MAX_SG_TABLESIZE when the extensions are not indicated.

Fixes Commit df749cdc45d9 ("IB/iser: Support up to 8MB data transfer in a single command")
---
 drivers/infiniband/ulp/iser/iser_verbs.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/iser/iser_verbs.c +8 -2
index c538a38..26a004e 100644
@@ -708,8 +708,14 @@ static void iser_connect_error(struct rdma_cm_id *cma_id)
 	unsigned short sg_tablesize, sup_sg_tablesize;
 
 	sg_tablesize = DIV_ROUND_UP(max_sectors * 512, SIZE_4K);
-	sup_sg_tablesize = min_t(unsigned, ISCSI_ISER_MAX_SG_TABLESIZE,
-				 device->ib_device->attrs.max_fast_reg_page_list_len);
+	if (device->ib_device->attrs.device_cap_flags &
+			IB_DEVICE_MEM_MGT_EXTENSIONS)
+		sup_sg_tablesize =
+			min_t(
+			 uint, ISCSI_ISER_MAX_SG_TABLESIZE,
+			 device->ib_device->attrs.max_fast_reg_page_list_len);
+	else
+		sup_sg_tablesize = ISCSI_ISER_MAX_SG_TABLESIZE;
 
 	iser_conn->scsi_sg_tablesize = min(sg_tablesize, sup_sg_tablesize);
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 2/3 IB/hfi1: Check return values from PCI config API calls

In reply to a message not in the archive

From: Bartlomiej Dudek <[email protected]>

Ensure that return values from kernel PCI config access API calls in HFI driver are checked and react properly if they are not expected (i.e. not successful).

---
 drivers/infiniband/hw/hfi1/chip.c |   22 +++
 drivers/infiniband/hw/hfi1/hfi.h  |    2 
 drivers/infiniband/hw/hfi1/pcie.c |  238 ++++++++++++++++++++++++++++++-------
 3 files changed, 215 insertions(+), 47 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +18 -4
index 937350d..efc8481 100644
@@ -13846,9 +13846,10 @@ static void init_sc2vl_tables(struct hfi1_devdata *dd)
  * a reset following the (possible) FLR in this routine.
  *
  */
-static void init_chip(struct hfi1_devdata *dd)
+static int init_chip(struct hfi1_devdata *dd)
 {
 	int i;
+	int ret = 0;
 
 	/*
 	 * Put the HFI CSRs in a known state.
@@ -13896,12 +13897,22 @@ static void init_chip(struct hfi1_devdata *dd)
 		pcie_flr(dd->pcidev);
 
 		/* restore command and BARs */
-		restore_pci_variables(dd);
+		ret = restore_pci_variables(dd);
+		if (ret) {
+			dd_dev_err(dd, "%s: Could not restore PCI variables\n",
+				   __func__);
+			return ret;
+		}
 
 		if (is_ax(dd)) {
 			dd_dev_info(dd, "Resetting CSRs with FLR\n");
 			pcie_flr(dd->pcidev);
-			restore_pci_variables(dd);
+			ret = restore_pci_variables(dd);
+			if (ret) {
+				dd_dev_err(dd, "%s: Could not restore PCI variables\n",
+					   __func__);
+				return ret;
+			}
 		}
 	} else {
 		dd_dev_info(dd, "Resetting CSRs with writes\n");
@@ -13929,6 +13940,7 @@ static void init_chip(struct hfi1_devdata *dd)
 	write_csr(dd, ASIC_QSFP1_OUT, 0x1f);
 	write_csr(dd, ASIC_QSFP2_OUT, 0x1f);
 	init_chip_resources(dd);
+	return ret;
 }
 
 static void init_early_variables(struct hfi1_devdata *dd)
@@ -14914,7 +14926,9 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev,
 		goto bail_cleanup;
 
 	/* obtain chip sizes, reset chip CSRs */
-	init_chip(dd);
+	ret = init_chip(dd);
+	if (ret)
+		goto bail_cleanup;
 
 	/* read in the PCIe link speed information */
 	ret = pcie_speeds(dd);
drivers/infiniband/hw/hfi1/hfi.h +1 -1
index 1a33a50..62f843d 100644
@@ -1854,7 +1854,7 @@ int hfi1_create_port_files(struct ib_device *ibdev, u8 port_num,
 void hfi1_pcie_ddcleanup(struct hfi1_devdata *);
 int pcie_speeds(struct hfi1_devdata *dd);
 int request_msix(struct hfi1_devdata *dd, u32 msireq);
-void restore_pci_variables(struct hfi1_devdata *dd);
+int restore_pci_variables(struct hfi1_devdata *dd);
 int do_pcie_gen3_transition(struct hfi1_devdata *dd);
 int parse_platform_config(struct hfi1_devdata *dd);
 int get_platform_config_field(struct hfi1_devdata *dd,
drivers/infiniband/hw/hfi1/pcie.c +196 -42

378 lines not on this page · raw message

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

PATCH 3/3 IB/core, opa_vnic, hfi1, mlx5: Properly free rdma_netdev

In reply to a message not in the archive

From: Niranjana Vishwanathapura <niranjana.vishwanathapura-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

IPOIB is calling free_rdma_netdev even though alloc_rdma_netdev has returned -EOPNOTSUPP.
Move free_rdma_netdev from ib_device structure to rdma_netdev structure thus ensuring proper cleanup function is called for the rdma net device.

Fix the following trace:

ib0: Failed to modify QP to ERROR state

BUG: unable to handle kernel paging request at 0000000000001d20
IP: hfi1_vnic_free_rn+0x26/0xb0 [hfi1]
Call Trace:
 ipoib_remove_one+0xbe/0x160 [ib_ipoib]
 ib_unregister_device+0xd0/0x170 [ib_core]
 rvt_unregister_device+0x29/0x90 [rdmavt]
 hfi1_unregister_ib_device+0x1a/0x100 [hfi1]
 remove_one+0x4b/0x220 [hfi1]
 pci_device_remove+0x39/0xc0
 device_release_driver_internal+0x141/0x200
 driver_detach+0x3f/0x80
 bus_remove_driver+0x55/0xd0
 driver_unregister+0x2c/0x50
 pci_unregister_driver+0x2a/0xa0
 hfi1_mod_cleanup+0x10/0xf65 [hfi1]
 SyS_delete_module+0x171/0x250
 do_syscall_64+0x67/0x150
 entry_SYSCALL64_slow_path+0x25/0x25
---
 drivers/infiniband/hw/hfi1/verbs.c                |    1 -
 drivers/infiniband/hw/hfi1/vnic.h                 |    1 -
 drivers/infiniband/hw/hfi1/vnic_main.c            |   19 +++++++++--------
 drivers/infiniband/hw/mlx5/main.c                 |   24 +++++++++++++--------
 drivers/infiniband/ulp/ipoib/ipoib_main.c         |    8 ++++---
 drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c |    8 ++++---
 include/rdma/ib_verbs.h                           |    6 ++++-
 7 files changed, 37 insertions(+), 30 deletions(-)
drivers/infiniband/hw/hfi1/verbs.c +0 -1
index 8a63a7e..720e71d 100644
@@ -1770,7 +1770,6 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
 	ibdev->alloc_hw_stats = alloc_hw_stats;
 	ibdev->get_hw_stats = get_hw_stats;
 	ibdev->alloc_rdma_netdev = hfi1_vnic_alloc_rn;
-	ibdev->free_rdma_netdev = hfi1_vnic_free_rn;
 
 	/* keep process mad in the driver */
 	ibdev->process_mad = hfi1_process_mad;
drivers/infiniband/hw/hfi1/vnic.h +0 -1
index e2c4552..4a621cd 100644
@@ -176,7 +176,6 @@ struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,
 				      const char *name,
 				      unsigned char name_assign_type,
 				      void (*setup)(struct net_device *));
-void hfi1_vnic_free_rn(struct net_device *netdev);
 int hfi1_vnic_send_dma(struct hfi1_devdata *dd, u8 q_idx,
 		       struct hfi1_vnic_vport_info *vinfo,
 		       struct sk_buff *skb, u64 pbc, u8 plen);
drivers/infiniband/hw/hfi1/vnic_main.c +10 -9
index 950c1b4..5a3f80b 100644
@@ -836,6 +836,15 @@ static void hfi1_vnic_set_vesw_id(struct net_device *netdev, int id)
 	.ndo_get_stats64 = hfi1_vnic_get_stats64,
 };
 
+static void hfi1_vnic_free_rn(struct net_device *netdev)
+{
+	struct hfi1_vnic_vport_info *vinfo = opa_vnic_dev_priv(netdev);
+
+	hfi1_vnic_deinit(vinfo);
+	mutex_destroy(&vinfo->lock);
+	free_netdev(netdev);
+}
+
 struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,
 				      u8 port_num,
 				      enum rdma_netdev_t type,
@@ -867,6 +876,7 @@ struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,
 	vinfo->num_tx_q = dd->chip_sdma_engines;
 	vinfo->num_rx_q = HFI1_NUM_VNIC_CTXT;
 	vinfo->netdev = netdev;
+	rn->free_rdma_netdev = hfi1_vnic_free_rn;
 	rn->set_id = hfi1_vnic_set_vesw_id;
 
 	netdev->features = NETIF_F_HIGHDMA | NETIF_F_SG;
@@ -895,12 +905,3 @@ struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,
 	free_netdev(netdev);
 	return ERR_PTR(rc);
 }
-
-void hfi1_vnic_free_rn(struct net_device *netdev)
-{
-	struct hfi1_vnic_vport_info *vinfo = opa_vnic_dev_priv(netdev);
-
-	hfi1_vnic_deinit(vinfo);
-	mutex_destroy(&vinfo->lock);
-	free_netdev(netdev);
-}
drivers/infiniband/hw/mlx5/main.c +15 -9
index 9ecc089..cec5932 100644
@@ -3542,6 +3542,11 @@ static int mlx5_ib_get_hw_stats(struct ib_device *ibdev,
 	return num_counters;
 }
 
+static void mlx5_ib_free_rdma_netdev(struct net_device *netdev)
+{
+	return mlx5_rdma_netdev_free(netdev);
+}
+
 static struct net_device*
 mlx5_ib_alloc_rdma_netdev(struct ib_device *hca,
 			  u8 port_num,
@@ -3550,16 +3555,18 @@ static int mlx5_ib_get_hw_stats(struct ib_device *ibdev,
 			  unsigned char name_assign_type,
 			  void (*setup)(struct net_device *))
 {
+	struct net_device *netdev;
+	struct rdma_netdev *rn;
+
 	if (type != RDMA_NETDEV_IPOIB)
 		return ERR_PTR(-EOPNOTSUPP);
 
-	return mlx5_rdma_netdev_alloc(to_mdev(hca)->mdev, hca,
-				      name, setup);
-}
+	netdev = mlx5_rdma_netdev_alloc(to_mdev(hca)->mdev, hca,
+					name, setup);
+	rn = netdev_priv(netdev);
+	rn->free_rdma_netdev = mlx5_ib_free_rdma_netdev;
 
-static void mlx5_ib_free_rdma_netdev(struct net_device *netdev)
-{
-	return mlx5_rdma_netdev_free(netdev);
+	return netdev;
 }
 
 static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
@@ -3692,10 +3699,9 @@ static void mlx5_ib_free_rdma_netdev(struct net_device *netdev)
 	dev->ib_dev.check_mr_status	= mlx5_ib_check_mr_status;
 	dev->ib_dev.get_port_immutable  = mlx5_port_immutable;
 	dev->ib_dev.get_dev_fw_str      = get_dev_fw_str;
-	if (MLX5_CAP_GEN(mdev, ipoib_enhanced_offloads)) {
+	if (MLX5_CAP_GEN(mdev, ipoib_enhanced_offloads))
 		dev->ib_dev.alloc_rdma_netdev	= mlx5_ib_alloc_rdma_netdev;
-		dev->ib_dev.free_rdma_netdev	= mlx5_ib_free_rdma_netdev;
-	}
+
 	if (mlx5_core_is_pf(mdev)) {
 		dev->ib_dev.get_vf_config	= mlx5_ib_get_vf_config;
 		dev->ib_dev.set_vf_link_state	= mlx5_ib_set_vf_link_state;
drivers/infiniband/ulp/ipoib/ipoib_main.c +4 -4
index 1015a63..9ec0dbe 100644
@@ -1893,6 +1893,7 @@ static void ipoib_build_priv(struct net_device *dev)
 	rn->send = ipoib_send;
 	rn->attach_mcast = ipoib_mcast_attach;
 	rn->detach_mcast = ipoib_mcast_detach;
+	rn->free_rdma_netdev = free_netdev;
 	rn->hca = hca;
 
 	dev->netdev_ops = &ipoib_netdev_default_pf;
@@ -2288,6 +2289,8 @@ static void ipoib_remove_one(struct ib_device *device, void *client_data)
 		return;
 
 	list_for_each_entry_safe(priv, tmp, dev_list, list) {
+		struct rdma_netdev *rn = netdev_priv(priv->dev);
+
 		ib_unregister_event_handler(&priv->event_handler);
 		flush_workqueue(ipoib_workqueue);
 
@@ -2304,10 +2307,7 @@ static void ipoib_remove_one(struct ib_device *device, void *client_data)
 		flush_workqueue(priv->wq);
 
 		unregister_netdev(priv->dev);
-		if (device->free_rdma_netdev)
-			device->free_rdma_netdev(priv->dev);
-		else
-			free_netdev(priv->dev);
+		rn->free_rdma_netdev(priv->dev);
 
 		list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list)
 			kfree(cpriv);
drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c +4 -4
index 905f39d..5c656c7 100644
@@ -323,13 +323,13 @@ struct opa_vnic_adapter *opa_vnic_add_netdev(struct ib_device *ibdev,
 	else if (IS_ERR(netdev))
 		return ERR_CAST(netdev);
 
+	rn = netdev_priv(netdev);
 	adapter = kzalloc(sizeof(*adapter), GFP_KERNEL);
 	if (!adapter) {
 		rc = -ENOMEM;
 		goto adapter_err;
 	}
 
-	rn = netdev_priv(netdev);
 	rn->clnt_priv = adapter;
 	rn->hca = ibdev;
 	rn->port_num = port_num;
@@ -367,7 +367,7 @@ struct opa_vnic_adapter *opa_vnic_add_netdev(struct ib_device *ibdev,
 	mutex_destroy(&adapter->stats_lock);
 	kfree(adapter);
 adapter_err:
-	ibdev->free_rdma_netdev(netdev);
+	rn->free_rdma_netdev(netdev);
 
 	return ERR_PTR(rc);
 }
@@ -376,7 +376,7 @@ struct opa_vnic_adapter *opa_vnic_add_netdev(struct ib_device *ibdev,
 void opa_vnic_rem_netdev(struct opa_vnic_adapter *adapter)
 {
 	struct net_device *netdev = adapter->netdev;
-	struct ib_device *ibdev = adapter->ibdev;
+	struct rdma_netdev *rn = netdev_priv(netdev);
 
 	v_info("removing\n");
 	unregister_netdev(netdev);
@@ -385,5 +385,5 @@ void opa_vnic_rem_netdev(struct opa_vnic_adapter *adapter)
 	mutex_destroy(&adapter->mactbl_lock);
 	mutex_destroy(&adapter->stats_lock);
 	kfree(adapter);
-	ibdev->free_rdma_netdev(netdev);
+	rn->free_rdma_netdev(netdev);
 }
include/rdma/ib_verbs.h +4 -2
index 9d4d2a7..8c78657 100644
@@ -1930,6 +1930,9 @@ struct rdma_netdev {
 	struct ib_device  *hca;
 	u8                 port_num;
 
+	/* cleanup function must be specified */
+	void (*free_rdma_netdev)(struct net_device *netdev);
+
 	/* control functions */
 	void (*set_id)(struct net_device *netdev, int id);
 	/* send packet */
@@ -2197,7 +2200,7 @@ struct ib_device {
 							   struct ib_udata *udata);
 	int                        (*destroy_rwq_ind_table)(struct ib_rwq_ind_table *wq_ind_table);
 	/**
-	 * rdma netdev operations
+	 * rdma netdev operation
 	 *
 	 * Driver implementing alloc_rdma_netdev must return -EOPNOTSUPP if it
 	 * doesn't support the specified rdma netdev type.
@@ -2209,7 +2212,6 @@ struct ib_device {
 					const char *name,
 					unsigned char name_assign_type,
 					void (*setup)(struct net_device *));
-	void (*free_rdma_netdev)(struct net_device *netdev);
 
 	struct module               *owner;
 	struct device                dev;

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw

Re: [PATCH for-next 3/3] IB/core, opa_vnic, hfi1, mlx5: Properly free rdma_netdev

In reply to a message not in the archive
Quoted 128 lines · Dennis Dalessandro

From: Niranjana Vishwanathapura <niranjana.vishwanathapura-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

IPOIB is calling free_rdma_netdev even though alloc_rdma_netdev has returned -EOPNOTSUPP.
Move free_rdma_netdev from ib_device structure to rdma_netdev structure thus ensuring proper cleanup function is called for the rdma net device.

Fix the following trace:

ib0: Failed to modify QP to ERROR state

BUG: unable to handle kernel paging request at 0000000000001d20
IP: hfi1_vnic_free_rn+0x26/0xb0 [hfi1]
Call Trace:
 ipoib_remove_one+0xbe/0x160 [ib_ipoib]
 ib_unregister_device+0xd0/0x170 [ib_core]
 rvt_unregister_device+0x29/0x90 [rdmavt]
 hfi1_unregister_ib_device+0x1a/0x100 [hfi1]
 remove_one+0x4b/0x220 [hfi1]
 pci_device_remove+0x39/0xc0
 device_release_driver_internal+0x141/0x200
 driver_detach+0x3f/0x80
 bus_remove_driver+0x55/0xd0
 driver_unregister+0x2c/0x50
 pci_unregister_driver+0x2a/0xa0
 hfi1_mod_cleanup+0x10/0xf65 [hfi1]
 SyS_delete_module+0x171/0x250
 do_syscall_64+0x67/0x150
 entry_SYSCALL64_slow_path+0x25/0x25
---
 drivers/infiniband/hw/hfi1/verbs.c                |    1 -
 drivers/infiniband/hw/hfi1/vnic.h                 |    1 -
 drivers/infiniband/hw/hfi1/vnic_main.c            |   19 +++++++++--------
 drivers/infiniband/hw/mlx5/main.c                 |   24 +++++++++++++--------
 drivers/infiniband/ulp/ipoib/ipoib_main.c         |    8 ++++---
 drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c |    8 ++++---
 include/rdma/ib_verbs.h                           |    6 ++++-
 7 files changed, 37 insertions(+), 30 deletions(-)
drivers/infiniband/hw/hfi1/verbs.c +0 -1
index 8a63a7e..720e71d 100644
@@ -1770,7 +1770,6 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)
 	ibdev->alloc_hw_stats = alloc_hw_stats;
 	ibdev->get_hw_stats = get_hw_stats;
 	ibdev->alloc_rdma_netdev = hfi1_vnic_alloc_rn;
-	ibdev->free_rdma_netdev = hfi1_vnic_free_rn;
 
 	/* keep process mad in the driver */
 	ibdev->process_mad = hfi1_process_mad;
drivers/infiniband/hw/hfi1/vnic.h +0 -1
index e2c4552..4a621cd 100644
@@ -176,7 +176,6 @@ struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,
 				      const char *name,
 				      unsigned char name_assign_type,
 				      void (*setup)(struct net_device *));
-void hfi1_vnic_free_rn(struct net_device *netdev);
 int hfi1_vnic_send_dma(struct hfi1_devdata *dd, u8 q_idx,
 		       struct hfi1_vnic_vport_info *vinfo,
 		       struct sk_buff *skb, u64 pbc, u8 plen);
drivers/infiniband/hw/hfi1/vnic_main.c +10 -9
index 950c1b4..5a3f80b 100644
@@ -836,6 +836,15 @@ static void hfi1_vnic_set_vesw_id(struct net_device *netdev, int id)
 	.ndo_get_stats64 = hfi1_vnic_get_stats64,
 };
 
+static void hfi1_vnic_free_rn(struct net_device *netdev)
+{
+	struct hfi1_vnic_vport_info *vinfo = opa_vnic_dev_priv(netdev);
+
+	hfi1_vnic_deinit(vinfo);
+	mutex_destroy(&vinfo->lock);
+	free_netdev(netdev);
+}
+
 struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,
 				      u8 port_num,
 				      enum rdma_netdev_t type,
@@ -867,6 +876,7 @@ struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,
 	vinfo->num_tx_q = dd->chip_sdma_engines;
 	vinfo->num_rx_q = HFI1_NUM_VNIC_CTXT;
 	vinfo->netdev = netdev;
+	rn->free_rdma_netdev = hfi1_vnic_free_rn;
 	rn->set_id = hfi1_vnic_set_vesw_id;
 
 	netdev->features = NETIF_F_HIGHDMA | NETIF_F_SG;
@@ -895,12 +905,3 @@ struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,
 	free_netdev(netdev);
 	return ERR_PTR(rc);
 }
-
-void hfi1_vnic_free_rn(struct net_device *netdev)
-{
-	struct hfi1_vnic_vport_info *vinfo = opa_vnic_dev_priv(netdev);
-
-	hfi1_vnic_deinit(vinfo);
-	mutex_destroy(&vinfo->lock);
-	free_netdev(netdev);
-}
drivers/infiniband/hw/mlx5/main.c +6 -0
index 9ecc089..cec5932 100644
@@ -3542,6 +3542,11 @@ static int mlx5_ib_get_hw_stats(struct ib_device *ibdev,
 	return num_counters;
 }
 
+static void mlx5_ib_free_rdma_netdev(struct net_device *netdev)
+{
+	return mlx5_rdma_netdev_free(netdev);
+}
+
 static struct net_device*
 mlx5_ib_alloc_rdma_netdev(struct ib_device *hca,
 			  u8 port_num,
@@ -3550,16 +3555,18 @@ static int mlx5_ib_get_hw_stats(struct ib_device *ibdev,
 			  unsigned char name_assign_type,
 			  void (*setup)(struct net_device *))
 {
+	struct net_device *netdev;

drivers/infiniband/hw/mlx5/main.c static int mlx5_ib_get_hw_stats(struct ib_device *ibdev, · line 3565

Quoted 10 lines
drivers/infiniband/hw/mlx5/main.c +4 -3
+	struct rdma_netdev *rn;
+
 	if (type != RDMA_NETDEV_IPOIB)
 		return ERR_PTR(-EOPNOTSUPP);
 
-	return mlx5_rdma_netdev_alloc(to_mdev(hca)->mdev, hca,
-				      name, setup);
-}
+	netdev = mlx5_rdma_netdev_alloc(to_mdev(hca)->mdev, hca,
+					name, setup);

It can return NULL

drivers/infiniband/hw/mlx5/main.c static int mlx5_ib_get_hw_stats(struct ib_device *ibdev, · line 3567

Quoted 2 lines
drivers/infiniband/hw/mlx5/main.c +2 -0
+	rn = netdev_priv(netdev);
+	rn->free_rdma_netdev = mlx5_ib_free_rdma_netdev;

This will crash in such case.

#8 lore raw

Re: [PATCH for-next 3/3] IB/core, opa_vnic, hfi1, mlx5: Properly free rdma_netdev

In reply to a message not in the archive
Quoted 10 lines · Leon Romanovsky

drivers/infiniband/hw/mlx5/main.c static int mlx5_ib_get_hw_stats(struct ib_device *ibdev, · line 3565

Quoted 6 lines · Dennis Dalessandro

From: Niranjana Vishwanathapura <[email protected] m>

drivers/infiniband/hw/mlx5/main.c +2 -0
+	netdev = mlx5_rdma_netdev_alloc(to_mdev(hca)->mdev, hca,
+					name, setup);

It can return NULL

Quoted 4 lines

drivers/infiniband/hw/mlx5/main.c static int mlx5_ib_get_hw_stats(struct ib_device *ibdev, · line 3567

Quoted 2 lines
drivers/infiniband/hw/mlx5/main.c +2 -0
+	rn = netdev_priv(netdev);
+	rn->free_rdma_netdev = mlx5_ib_free_rdma_netdev;

This will crash in such case.

A fixed version of this patch is the last thing I'm waiting on before sending my final -rc pull request to Linus. I would skip this, but since the IPoIB fixes broke things, we need a proper version of this patch to undo that breakage. I fixed it up as I saw fit and sent the fixed version to the list on its own thread, please double check it before I send it to Linus.

Signature · 8 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw
In reply to a message not in the archive
Quoted 8 lines · Dennis Dalessandro

Hi Doug,

Here are three more patches. The first two we are fine with going into -next,
however the third is the patch Niranjana mentioned yesterday that would
be good to get into the last RC if the train hasn't left the station yet.

Hi Denny,

This pull is a bit confusing, but I figured it out. I had already grabbed patch #1 from a previous time that you submitted the same patch (I know this because it still has the spelling error in the subject, and made it into Linus' tree with that spelling error, whereas the subject spelling is corrected in this submission). So, #1 is done, and #3 was done too (I fixed it up to resolve the crash Leon referenced). So, that only leaves #2 undone. Adding it to -next right now.

Quoted 41 lines

These have not been through zero-day but have been submitted. Niranjana's patch
is pretty straight forward and I don't foresee obscure build issues. So given
the time crunch for the slightest chance at 4.12 I'm taking a calculated risk
and sending. The patch applies ontop of our 4.12 patches cleanly. Builds and
tests in our environment.

Patches can can also be found in my GitHub repo at:
https://github.com/ddalessa/kernel/tree/for-4.13

---

Bartlomiej Dudek (1):
IB/hfi1: Check return values from PCI config API calls

Mike Marciniszyn (1):
IB/iser: Handle lack of memory management extensions correctly

Niranjana Vishwanathapura (1):
IB/core,opa_vnic,hfi1,mlx5: Properly free rdma_netdev

 drivers/infiniband/hw/hfi1/chip.c                 |   22 ++
 drivers/infiniband/hw/hfi1/hfi.h                  |    2 
 drivers/infiniband/hw/hfi1/pcie.c                 |  238
+++++++++++++++++----
 drivers/infiniband/hw/hfi1/verbs.c                |    1 
 drivers/infiniband/hw/hfi1/vnic.h                 |    1 
 drivers/infiniband/hw/hfi1/vnic_main.c            |   19 +-
 drivers/infiniband/hw/mlx5/main.c                 |   24 +-
 drivers/infiniband/ulp/ipoib/ipoib_main.c         |    8 -
 drivers/infiniband/ulp/iser/iser_verbs.c          |   10 +
 drivers/infiniband/ulp/opa_vnic/opa_vnic_netdev.c |    8 -
 include/rdma/ib_verbs.h                           |    6 -
 11 files changed, 260 insertions(+), 79 deletions(-)

--
-Denny

Signature · 8 lines
Doug Ledford <[email protected]>
    GPG KeyID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html