linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Yishai Hadas <yishaih@mellanox.com>,
	Artemy Kovalyov <artemyko@mellanox.com>,
	Leon Romanovsky <leonro@mellanox.com>,
	Jason Gunthorpe <jgg@mellanox.com>
Subject: [PATCH 5.0 19/52] net/mlx5: Fix DCT creation bad flow
Date: Tue, 26 Mar 2019 15:30:06 +0900	[thread overview]
Message-ID: <20190326042701.880117127@linuxfoundation.org> (raw)
In-Reply-To: <20190326042700.963224437@linuxfoundation.org>

5.0-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Yishai Hadas <yishaih@mellanox.com>

commit f84b66b9cce78e8f9d38204fdaa75f07c75f4911 upstream.

In case the DCT creation command has succeeded a DRAIN must be issued
before calling DESTROY.

In addition, the original code used the wrong parameter for the DESTROY
command, 'in' instead of 'din', which caused another creation try instead
of destroying.

Cc: <stable@vger.kernel.org> # 4.15
Fixes: 57cda166bbe0 ("net/mlx5: Add DCT command interface")
Signed-off-by: Yishai Hadas <yishaih@mellanox.com>
Reviewed-by: Artemy Kovalyov <artemyko@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/net/ethernet/mellanox/mlx5/core/qp.c |   66 ++++++++++++++-------------
 1 file changed, 36 insertions(+), 30 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlx5/core/qp.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/qp.c
@@ -40,6 +40,9 @@
 #include "mlx5_core.h"
 #include "lib/eq.h"
 
+static int mlx5_core_drain_dct(struct mlx5_core_dev *dev,
+			       struct mlx5_core_dct *dct);
+
 static struct mlx5_core_rsc_common *
 mlx5_get_rsc(struct mlx5_qp_table *table, u32 rsn)
 {
@@ -227,13 +230,42 @@ static void destroy_resource_common(stru
 	wait_for_completion(&qp->common.free);
 }
 
+static int _mlx5_core_destroy_dct(struct mlx5_core_dev *dev,
+				  struct mlx5_core_dct *dct, bool need_cleanup)
+{
+	u32 out[MLX5_ST_SZ_DW(destroy_dct_out)] = {0};
+	u32 in[MLX5_ST_SZ_DW(destroy_dct_in)]   = {0};
+	struct mlx5_core_qp *qp = &dct->mqp;
+	int err;
+
+	err = mlx5_core_drain_dct(dev, dct);
+	if (err) {
+		if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
+			goto destroy;
+		} else {
+			mlx5_core_warn(
+				dev, "failed drain DCT 0x%x with error 0x%x\n",
+				qp->qpn, err);
+			return err;
+		}
+	}
+	wait_for_completion(&dct->drained);
+destroy:
+	if (need_cleanup)
+		destroy_resource_common(dev, &dct->mqp);
+	MLX5_SET(destroy_dct_in, in, opcode, MLX5_CMD_OP_DESTROY_DCT);
+	MLX5_SET(destroy_dct_in, in, dctn, qp->qpn);
+	MLX5_SET(destroy_dct_in, in, uid, qp->uid);
+	err = mlx5_cmd_exec(dev, (void *)&in, sizeof(in),
+			    (void *)&out, sizeof(out));
+	return err;
+}
+
 int mlx5_core_create_dct(struct mlx5_core_dev *dev,
 			 struct mlx5_core_dct *dct,
 			 u32 *in, int inlen)
 {
 	u32 out[MLX5_ST_SZ_DW(create_dct_out)]   = {0};
-	u32 din[MLX5_ST_SZ_DW(destroy_dct_in)]   = {0};
-	u32 dout[MLX5_ST_SZ_DW(destroy_dct_out)] = {0};
 	struct mlx5_core_qp *qp = &dct->mqp;
 	int err;
 
@@ -254,11 +286,7 @@ int mlx5_core_create_dct(struct mlx5_cor
 
 	return 0;
 err_cmd:
-	MLX5_SET(destroy_dct_in, din, opcode, MLX5_CMD_OP_DESTROY_DCT);
-	MLX5_SET(destroy_dct_in, din, dctn, qp->qpn);
-	MLX5_SET(destroy_dct_in, din, uid, qp->uid);
-	mlx5_cmd_exec(dev, (void *)&in, sizeof(din),
-		      (void *)&out, sizeof(dout));
+	_mlx5_core_destroy_dct(dev, dct, false);
 	return err;
 }
 EXPORT_SYMBOL_GPL(mlx5_core_create_dct);
@@ -323,29 +351,7 @@ static int mlx5_core_drain_dct(struct ml
 int mlx5_core_destroy_dct(struct mlx5_core_dev *dev,
 			  struct mlx5_core_dct *dct)
 {
-	u32 out[MLX5_ST_SZ_DW(destroy_dct_out)] = {0};
-	u32 in[MLX5_ST_SZ_DW(destroy_dct_in)]   = {0};
-	struct mlx5_core_qp *qp = &dct->mqp;
-	int err;
-
-	err = mlx5_core_drain_dct(dev, dct);
-	if (err) {
-		if (dev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR) {
-			goto destroy;
-		} else {
-			mlx5_core_warn(dev, "failed drain DCT 0x%x with error 0x%x\n", qp->qpn, err);
-			return err;
-		}
-	}
-	wait_for_completion(&dct->drained);
-destroy:
-	destroy_resource_common(dev, &dct->mqp);
-	MLX5_SET(destroy_dct_in, in, opcode, MLX5_CMD_OP_DESTROY_DCT);
-	MLX5_SET(destroy_dct_in, in, dctn, qp->qpn);
-	MLX5_SET(destroy_dct_in, in, uid, qp->uid);
-	err = mlx5_cmd_exec(dev, (void *)&in, sizeof(in),
-			    (void *)&out, sizeof(out));
-	return err;
+	return _mlx5_core_destroy_dct(dev, dct, true);
 }
 EXPORT_SYMBOL_GPL(mlx5_core_destroy_dct);
 



  parent reply	other threads:[~2019-03-26  6:39 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26  6:29 [PATCH 5.0 00/52] 5.0.5-stable review Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 01/52] ALSA: hda - add Lenovo IdeaCentre B550 to the power_save_blacklist Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 02/52] ALSA: firewire-motu: use version field of unit directory to identify model Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 03/52] mmc: pxamci: fix enum type confusion Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 04/52] mmc: alcor: fix DMA reads Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 05/52] mmc: mxcmmc: "Revert mmc: mxcmmc: handle highmem pages" Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 06/52] mmc: renesas_sdhi: limit block count to 16 bit for old revisions Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 07/52] drm/amdgpu: fix invalid use of change_bit Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 08/52] drm/vmwgfx: Dont double-free the mode stored in par->set_mode Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 09/52] drm/vmwgfx: Return 0 when gmrid::get_node runs out of IDs Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 10/52] iommu/amd: fix sg->dma_address for sg->offset bigger than PAGE_SIZE Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 11/52] iommu/iova: Fix tracking of recently failed iova address Greg Kroah-Hartman
2019-03-26  6:29 ` [PATCH 5.0 12/52] libceph: wait for latest osdmap in ceph_monc_blacklist_add() Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 13/52] udf: Fix crash on IO error during truncate Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 14/52] mips: loongson64: lemote-2f: Add IRQF_NO_SUSPEND to "cascade" irqaction Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 15/52] MIPS: Ensure ELF appended dtb is relocated Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 16/52] MIPS: Fix kernel crash for R6 in jump label branch function Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 17/52] powerpc/vdso64: Fix CLOCK_MONOTONIC inconsistencies across Y2038 Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 18/52] powerpc/security: Fix spectre_v2 reporting Greg Kroah-Hartman
2019-03-26  6:30 ` Greg Kroah-Hartman [this message]
2019-03-26  6:30 ` [PATCH 5.0 20/52] scsi: core: Avoid that a kernel warning appears during system resume Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 21/52] scsi: qla2xxx: Fix FC-AL connection target discovery Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 22/52] scsi: ibmvscsi: Protect ibmvscsi_head from concurrent modificaiton Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 23/52] scsi: ibmvscsi: Fix empty event pool access during host removal Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 24/52] futex: Ensure that futex address is aligned in handle_futex_death() Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 25/52] cifs: allow guest mounts to work for smb3.11 Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 26/52] perf probe: Fix getting the kernel map Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 27/52] objtool: Move objtool_file struct off the stack Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 28/52] irqchip/gic-v3-its: Fix comparison logic in lpi_range_cmp Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 29/52] clocksource/drivers/riscv: Fix clocksource mask Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 30/52] SMB3: Fix SMB3.1.1 guest mounts to Samba Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 31/52] ALSA: hda - Dont trigger jackpoll_work in azx_resume Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 32/52] ALSA: ac97: Fix of-node refcount unbalance Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 33/52] ext4: fix NULL pointer dereference while journal is aborted Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 34/52] ext4: fix data corruption caused by unaligned direct AIO Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 35/52] ext4: brelse all indirect buffer in ext4_ind_remove_space() Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 36/52] media: v4l2-ctrls.c/uvc: zero v4l2_event Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 37/52] Bluetooth: hci_uart: Check if socket buffer is ERR_PTR in h4_recv_buf() Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 38/52] Bluetooth: Fix decrementing reference count twice in releasing socket Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 39/52] Bluetooth: hci_ldisc: Initialize hci_dev before open() Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 40/52] Bluetooth: hci_ldisc: Postpone HCI_UART_PROTO_READY bit set in hci_uart_set_proto() Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 41/52] drm/vkms: Fix flush_work() without INIT_WORK() Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 42/52] RDMA/cma: Rollback source IP address if failing to acquire device Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 43/52] f2fs: fix to avoid deadlock of atomic file operations Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 44/52] aio: simplify - and fix - fget/fput for io_submit() Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 45/52] netfilter: ebtables: remove BUGPRINT messages Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 46/52] loop: access lo_backing_file only when the loop device is Lo_bound Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 47/52] x86/unwind: Handle NULL pointer calls better in frame unwinder Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 48/52] x86/unwind: Add hardcoded ORC entry for NULL Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 49/52] locking/lockdep: Add debug_locks check in __lock_downgrade() Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 50/52] mm, mempolicy: fix uninit memory access Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 51/52] ALSA: hda - Record the current power state before suspend/resume calls Greg Kroah-Hartman
2019-03-26  6:30 ` [PATCH 5.0 52/52] ALSA: hda - Enforces runtime_resume after S3 and S4 for each codec Greg Kroah-Hartman
2019-03-26 15:20 ` [PATCH 5.0 00/52] 5.0.5-stable review Jon Hunter
2019-03-27  0:56   ` Greg Kroah-Hartman
2019-03-26 17:50 ` Guenter Roeck
2019-03-27  0:59   ` Greg Kroah-Hartman
2019-03-26 23:18 ` shuah
2019-03-27  0:55   ` Greg Kroah-Hartman
2019-03-27  4:06 ` Naresh Kamboju
2019-03-27  5:06   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190326042701.880117127@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=artemyko@mellanox.com \
    --cc=jgg@mellanox.com \
    --cc=leonro@mellanox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yishaih@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).