From patchwork Tue May 28 12:52:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13676615 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6779F16DEB0 for ; Tue, 28 May 2024 12:53:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900808; cv=none; b=juSiYxV6kw0bjGzQ7lMDKYk87UacApZVVjKa4F6HAHvV/WkEk6zUu8Kh7UCpaYzhVUfcMYZ5qBKYeRsG4VsEs8P8IkbPsWoJQdQLI/lrVmsJaCtDQt290OqsyQWhLdy3AmX3J+8XEGB/msSQctopqlcnWSvyaui6l2kHlNwzXZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900808; c=relaxed/simple; bh=8b1Gin9FaAJQpL4LJCGBu7mBYgjW+aJMJ3DuG0aHCh0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=an3cUilfHeADbMSEHOtCQIm289cNiyV2RDr3FNyLmcUIt50pFUBvNxvXi1Tvg7hwjS4c61w7prcrqtHnnl5cuKV2DYZpUEP9uAXUIa3BrtW7k0IC6rL7JSbTRjByrZRykWdh+BD5Qc7fkGnMSFfBnqw/3ihZxyFAbblY4AXvkCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FMjhTSqD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FMjhTSqD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59686C3277B; Tue, 28 May 2024 12:53:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716900807; bh=8b1Gin9FaAJQpL4LJCGBu7mBYgjW+aJMJ3DuG0aHCh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FMjhTSqDVj8rVvLrBDoSJ5K32lcqGBO07nuL4qsuD/bQo+KluVZYZMnmMvpkS66Vg VABZzF9Gr+pY5noPDMzOcjv7jEJ/95GCidIhrepvfM65/yvMNtqHEYtGM8AOluuUqo FPj2VUPilQdXsSrWKVTxnnSPpHMC2QEhbGRMX860Zqp2LQrWm6cPvrzCyCWYdVpLx7 PUCTZUSF230oRzhb456ERi89LY0+IZueZofEmVAbqdBL4h+M/Wd1zYnIU4IpUNh6BV lGARCMCbJTDQRr9dxavl6DqbLapbC5w2+4cqSJ6tLZ5axZ5nxFwRCl72ADey2RtjfX JnSNT6wBJSFEw== From: Leon Romanovsky To: Jason Gunthorpe Cc: Leon Romanovsky , linux-rdma@vger.kernel.org, Mark Zhang , Michael Guralnik , Or Har-Toov , Patrisious Haddad , Yishai Hadas Subject: [PATCH rdma-rc 1/6] RDMA/cache: Release GID table even if leak is detected Date: Tue, 28 May 2024 15:52:51 +0300 Message-ID: X-Mailer: git-send-email 2.45.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Leon Romanovsky When the table is released, we nullify pointer to GID table, it means that in case GID entry leak is detected, we will leak table too. Delete code that prevents table destruction. Fixes: b150c3862d21 ("IB/core: Introduce GID entry reference counts") Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/cache.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index c02a96d3572a..aa62c8c7ca75 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c @@ -794,7 +794,6 @@ static struct ib_gid_table *alloc_gid_table(int sz) static void release_gid_table(struct ib_device *device, struct ib_gid_table *table) { - bool leak = false; int i; if (!table) @@ -803,15 +802,11 @@ static void release_gid_table(struct ib_device *device, for (i = 0; i < table->sz; i++) { if (is_gid_entry_free(table->data_vec[i])) continue; - if (kref_read(&table->data_vec[i]->kref) > 1) { - dev_err(&device->dev, - "GID entry ref leak for index %d ref=%u\n", i, - kref_read(&table->data_vec[i]->kref)); - leak = true; - } + + dev_err(&device->dev, + "GID entry ref leak for index %d ref=%u\n", i, + kref_read(&table->data_vec[i]->kref)); } - if (leak) - return; mutex_destroy(&table->lock); kfree(table->data_vec); From patchwork Tue May 28 12:52:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13676611 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3539E16D9BD for ; Tue, 28 May 2024 12:53:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900791; cv=none; b=uCNoSNQyp2YoeMsBscXmYfMHUM9h8qiuVKOrMbkAv9QUNB+pFrhHXB20Jh6Ymo0nqfGRBxJg1OhcMcG4lkDcrQQprfFWyHSZBb19eqpV5r8H51KK4luSn+UNbPIO5wDwxJiVB7KfoA4IGu3VgaZekYupKbaXPxGGW0fNSYbOOjo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900791; c=relaxed/simple; bh=jb55TNR3k3CgqDAMPDfcN/zdxlqKbDs6fmeZQ+ZCYhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RvoP6xhYhnYpbsdBIKa3fyIP15HYrUGt1IK3NmLkoFPG/GPuHPikMd9u+6O5nr69FKU3zR16qzu0LQYxVFKp5rlToGA1p0w79m1VdKOG0/eUNbY5YPxruyof8WEsvlIokMNSs9T85UBbrA5OTqfopmFJ5GNyE3XsTL21xEC9TCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VlW9j5pU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VlW9j5pU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30040C3277B; Tue, 28 May 2024 12:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716900790; bh=jb55TNR3k3CgqDAMPDfcN/zdxlqKbDs6fmeZQ+ZCYhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VlW9j5pUSe9AZArHKbds17J85gzO2bb+J2gA09jiwR0fZqvnqW+uZZ5LM3YV89+e/ seDp5em+Znriten9qiNmjkTqqeTiFiUpxHasmg+IJJABJXVKV/WP59/v6c14yUTdUL ljW3HgLmGulmE9C2CYnYtxOn7qBCmnDxUqAqEL35RzFj1j3haP5npg89PxrAWdhS6J TaaLp2xIH7GKWfFON+3As6texZxBodc6cCMVZHTaP8RPwoCiRuHu94W5zv82e9hRMj WYLwRgl4Xf1c3NibNsSbas/LcHWYPbq5W4vnEQ7QwmtTQT77Pcb2R8frutY4OnVw6Q CjShHkoxnhBuA== From: Leon Romanovsky To: Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, Mark Zhang , Michael Guralnik , Or Har-Toov , Patrisious Haddad , Yishai Hadas Subject: [PATCH rdma-rc 2/6] RDMA/mlx5: Remove extra unlock on error path Date: Tue, 28 May 2024 15:52:52 +0300 Message-ID: <78090c210c750f47219b95248f9f782f34548bb1.1716900410.git.leon@kernel.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jason Gunthorpe The below commit lifted the locking out of this function but left this error path unlock behind resulting in unbalanced locking. Remove the missed unlock too. Cc: stable@vger.kernel.org Fixes: 627122280c87 ("RDMA/mlx5: Add work to remove temporary entries from the cache") Signed-off-by: Jason Gunthorpe Reviewed-by: Michael Guralnik Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/mr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index ecc111ed5d86..38d2c743db87 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -641,10 +641,8 @@ static int mlx5_cache_ent_insert(struct mlx5_mkey_cache *cache, new = &((*new)->rb_left); if (cmp < 0) new = &((*new)->rb_right); - if (cmp == 0) { - mutex_unlock(&cache->rb_lock); + if (cmp == 0) return -EEXIST; - } } /* Add new node and rebalance tree. */ From patchwork Tue May 28 12:52:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13676612 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 681DE16D31F for ; Tue, 28 May 2024 12:53:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900795; cv=none; b=dS/kzOHosy+9kYg/7iveo3I3uZ1CESqwfKLhagXcohdrjkt7ACZXdsvbBHjBCgpAgBmwkOJCrGuJM7k+Qxia6syJcLMHoNAt0iifwaVC7eaEnf8Tm5u34ewMy+4q/u8cWgvHbxvzxduGm7shlICi+Fzq24/+pjAkfRAq+G5Nt5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900795; c=relaxed/simple; bh=j/VaX961WtOx0tOpWiKQjxZSDBDT5m+pLYMsvbM6Ji8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d11WgeyZpMquD8WlITcZa1eeTEEK3xEJ3q9vjex7QplSJ/PdbGWeAgWS0fL4yaZZ8/vKFDExMw9ouKCqccFb8lSVPU9wr0pY+iT/MQberWu78zL/HObBhnXSs7fnLezO8bvmrcSh9c0tU2Y7fwCklkNrB5JKNXhh5X10YYs3q9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q5ekjcuJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q5ekjcuJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 626A0C32782; Tue, 28 May 2024 12:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716900794; bh=j/VaX961WtOx0tOpWiKQjxZSDBDT5m+pLYMsvbM6Ji8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q5ekjcuJE+f49i4GjOc70Gafn1Gp32I+u4aTmcO+GmXqoyaFPoBAsosTtdlGvcJk7 BpKxOXNx3IJ78vxv5mrHJrqpKHUuiFI/8tnz9/jcc9zYu8DFsLp+VRvlfGxr/vK6ZI 2U+6F2AQeajByCIhApHxzdWoJWRtIbX7IJqd00FUsFA1XRAccQhGIN6aEq2L85bxcO M7IfP4cfmwXHWp0bOzPDAYEATPjkeHZuDG/4sci9QI7afDyOMd1mpkTP7ahC4N6PUe o5QJBRx7vZmJkefa5pY5wqihccAUkKkfXT0TVZpoN6vl2qChdN/uwuRhQRrwfdMV8w 6TJQsly/PHdvw== From: Leon Romanovsky To: Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, Mark Zhang , Michael Guralnik , Or Har-Toov , Patrisious Haddad , Yishai Hadas Subject: [PATCH rdma-rc 3/6] RDMA/mlx5: Follow rb_key.ats when creating new mkeys Date: Tue, 28 May 2024 15:52:53 +0300 Message-ID: <7c5613458ecb89fbe5606b7aa4c8d990bdea5b9a.1716900410.git.leon@kernel.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jason Gunthorpe When a cache ent already exists but doesn't have any mkeys in it the cache will automatically create a new one based on the specification in the ent->rb_key. ent->ats was missed when creating the new key and so ma_translation_mode was not being set even though the ent requires it. Cc: stable@vger.kernel.org Fixes: 73d09b2fe833 ("RDMA/mlx5: Introduce mlx5r_cache_rb_key") Signed-off-by: Jason Gunthorpe Reviewed-by: Michael Guralnik Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/mr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index 38d2c743db87..35dcb9d9e12a 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -246,6 +246,7 @@ static void set_cache_mkc(struct mlx5_cache_ent *ent, void *mkc) MLX5_SET(mkc, mkc, access_mode_1_0, ent->rb_key.access_mode & 0x3); MLX5_SET(mkc, mkc, access_mode_4_2, (ent->rb_key.access_mode >> 2) & 0x7); + MLX5_SET(mkc, mkc, ma_translation_mode, !!ent->rb_key.ats); MLX5_SET(mkc, mkc, translations_octword_size, get_mkc_octo_size(ent->rb_key.access_mode, From patchwork Tue May 28 12:52:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13676613 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B39116E866 for ; Tue, 28 May 2024 12:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900799; cv=none; b=fg/ms4KA0ITmseZV3lA03SW32LjTPnW2EtWfSjbLcxmDgYG12nCwscHdiAJRl25WCutIPzyf8zYdArfjJxaWAxmVl8gfvWoFBxVhtM4yttrqIIJN7pdpeitOoBtyDq+nJBFwm9UzMSj2RjOHQlXhTN9lruf7nRbSbQE9w3tGix4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900799; c=relaxed/simple; bh=TM/gJtG2Qa0zhwgcXm0tDtj2n6FAF818ZS88FOkE+8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K3JKK1Ruryz8Q70KWw+6rWQc4ATvxmwfcwgfZYgrMdeTm7BrNZTiQSa0mr6t5/R2fS5YdOpisyHF7FOMVZIFvnEkS15+ORqS4L0Amz1XkLX3STdY+O9nwr5ZHo+4Oge7QP8rjoVH6rFxwLAodyOMTxH4qZgRYqUbdzcrLP+C5hM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K6KF4x83; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K6KF4x83" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D313C4AF07; Tue, 28 May 2024 12:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716900799; bh=TM/gJtG2Qa0zhwgcXm0tDtj2n6FAF818ZS88FOkE+8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K6KF4x837hLn9wtgZiTwSdRFxZxDkxNXzOLJkS+zWfACMuxl05cEKHOnPtmghT4l/ EyX0FyAmGbufOWYeh+2d9vwQkQL1S+NoHXuw9Q8ugGkosKh2JCIECfmuLtQbGUBNgc 4GcVuABAIRPA2C9qSlbe/RzrZHOvahihh1v4wqMv87igIn9+blvBIWtKrCTC9brKk+ cFNAjebOXLNQfA8hi9H5EVdesGdzslEtGyxdCz3fR3GdOpEp1SQAZN7PhUhQTKBLN+ 27nt6+SIbZd7v/4lPULbXPk08WEjIjTdTLzYccpn2SyDXUuZClmg1cvJXyO3kf+Skp QP1NtAvDrixaA== From: Leon Romanovsky To: Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, Mark Zhang , Michael Guralnik , Or Har-Toov , Patrisious Haddad , Yishai Hadas Subject: [PATCH rdma-rc 4/6] RDMA/mlx5: Ensure created mkeys always have a populated rb_key Date: Tue, 28 May 2024 15:52:54 +0300 Message-ID: <7778c02dfa0999a30d6746c79a23dd7140a9c729.1716900410.git.leon@kernel.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jason Gunthorpe cachable and mmkey.rb_key together are used by mlx5_revoke_mr() to put the MR/mkey back into the cache. In all cases they should be set correctly. alloc_cacheable_mr() was setting cachable but not filling rb_key, resulting in cache_ent_find_and_store() bucketing them all into a 0 length entry. implicit_get_child_mr()/mlx5_ib_alloc_implicit_mr() failed to set cachable or rb_key at all, so the cache was not working at all for implicit ODP. Cc: stable@vger.kernel.org Fixes: 8c1185fef68c ("RDMA/mlx5: Change check for cacheable mkeys") Fixes: dd1b913fb0d0 ("RDMA/mlx5: Cache all user cacheable mkeys on dereg MR flow") Signed-off-by: Jason Gunthorpe Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/mr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index 35dcb9d9e12a..d3c1f63791a2 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -718,6 +718,8 @@ static struct mlx5_ib_mr *_mlx5_mr_cache_alloc(struct mlx5_ib_dev *dev, } mr->mmkey.cache_ent = ent; mr->mmkey.type = MLX5_MKEY_MR; + mr->mmkey.rb_key = ent->rb_key; + mr->mmkey.cacheable = true; init_waitqueue_head(&mr->mmkey.wait); return mr; } @@ -1168,7 +1170,6 @@ static struct mlx5_ib_mr *alloc_cacheable_mr(struct ib_pd *pd, mr->ibmr.pd = pd; mr->umem = umem; mr->page_shift = order_base_2(page_size); - mr->mmkey.cacheable = true; set_mr_fields(dev, mr, umem->length, access_flags, iova); return mr; From patchwork Tue May 28 12:52:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13676614 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7B1116D9AA for ; Tue, 28 May 2024 12:53:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900803; cv=none; b=T1FtxecZR3/fcW6hKbAbZ4cBddBON0kE1PpMHi4OBDicKdowRQjWNQzubPeWcswwPBRnJjlu3P6uCDqDCZeN6Hcqw/5LR99ByDXxqTrbr77VBlKx0yZQAPURRtU7zaqX/W3pb9h6dVMOEh7QZeNU84fmmCyf0n8umS+bDBCu0f0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900803; c=relaxed/simple; bh=T9X4/Jsk3ptLSS5AoN6LbKLk43UbEhUp3ngVpQOpVI4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hhvFLxmntJNEkVvKVwS5rm9xzvVFhjK8HC8BihH//R0484NEmgDrYXx6g4foEdc3doLTHzt8XxPHm3pmORJ3ttsL1/yrnEuvPth31NsWfDhMo73X75P0UFksWC24nk/ulwvP9+vpsAdg8Q4umi0MCIPIkyNX6bFQAZr4WRyLlXI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B6YvJb6W; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B6YvJb6W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B1F4C32789; Tue, 28 May 2024 12:53:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716900803; bh=T9X4/Jsk3ptLSS5AoN6LbKLk43UbEhUp3ngVpQOpVI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B6YvJb6WziXRgphZw9y4+ke7U6PNVoTKeKBVGF/33tsGa7m1a67Nh1ceesRf0m6uw 2AboN+mpCT4JRC7yPQJWijTQMTOQZtodTCnxKlcc15sciO1oVjoJ5poR+lVTBTxwzj i/y1z+N77zFMkwKnOh2J7OWKJb6TrJYIR9Us8w2xd+raiIaqBvsSs5xdxsG7nn+GWo N5hK9Daw/eCHRja5gK6nGGioSt9b0ruF4Itlt7eU+9sjVfcKFnCDvjUB4hW2C1xIQm p3m13NGuhMsWgFWWItfAExps/sLW3E8pFu3QTEydjKtHU1+CJgP+wUBnFedbcPpXvr 38SARouqDNreA== From: Leon Romanovsky To: Jason Gunthorpe Cc: Yishai Hadas , linux-rdma@vger.kernel.org, Mark Zhang , Michael Guralnik , Or Har-Toov , Patrisious Haddad Subject: [PATCH rdma-rc 5/6] RDMA/mlx5: Fix unwind flow as part of mlx5_ib_stage_init_init Date: Tue, 28 May 2024 15:52:55 +0300 Message-ID: X-Mailer: git-send-email 2.45.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Yishai Hadas Fix unwind flow as part of mlx5_ib_stage_init_init to use the correct goto upon an error. Fixes: 758ce14aee82 ("RDMA/mlx5: Implement MACsec gid addition and deletion") Signed-off-by: Yishai Hadas Reviewed-by: Patrisious Haddad Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 2366c46eebc8..43660c831b22 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -3759,10 +3759,10 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev) spin_lock_init(&dev->dm.lock); dev->dm.dev = mdev; return 0; -err: - mlx5r_macsec_dealloc_gids(dev); err_mp: mlx5_ib_cleanup_multiport_master(dev); +err: + mlx5r_macsec_dealloc_gids(dev); return err; } From patchwork Tue May 28 12:52:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 13676616 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49A4F16D9AA for ; Tue, 28 May 2024 12:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900813; cv=none; b=FKzVx191lr8DFiX7AZSu4PCwCaCoBQSillSMA1N2sjqwmJ/ARqgO8nY35gKbfi2CuBOnAvNfBE8uJ17BvLHm9JZhMBGwLE7975fK5mv3udKO/wW+PEJXvPZuqXJR/Apw6xpnQ+fzZmTcqyhCQnod4lBwTBTMwbfCpB6nxjlwNcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716900813; c=relaxed/simple; bh=j2OYHNjPbW6hoVk6/0XlL3jE4lhTroPogrU5k0LNsWk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P7NqXHTHx3Sb5qE868eKJOIm3lVowbkNqqGp6meRmfqAM4ohQGH95NIoijIS6V+C2UdUIoBYn2mQk2GE8HMqHY9lcFTiZRE2mOC9DNcM3Nwa0+7zfY/H/08jvr3HlyjVGUfw59IaibYXxon7Bo4ty7c3pZloWR7fUAghQEwBHYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rxZwnYVk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rxZwnYVk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48966C3277B; Tue, 28 May 2024 12:53:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716900812; bh=j2OYHNjPbW6hoVk6/0XlL3jE4lhTroPogrU5k0LNsWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rxZwnYVkAt16lE4BQ7v7Knl/EB90y4uPCxRp32d6GBp5LFEsIAjxtzx1HoKCODDu1 q4t+WkIKH1AcGr7dwyPAqbzUz2y979tyx1TJCI4CUT7zB5mi2aYNGZF0auVedbZVyF S9qpWYeVpW9s3tp//PDlzu7e5kQU3Tsk2wIgUBMoEp4IeG7+CZ0PwhdTXCL0DddmCO nSIOu/PnPBbFUGoFVKQYZX6jDzE8hEJIXsctRZnexmH9ad4byc4csdSvG2Wk50393W Y/h7cpyFOcRtZqtXHzttAkaarUPUrYPdvPC9w2aJfhsAZTJ53/Wvn/rFnwt0KyuOo0 iF5kaee1vqr5w== From: Leon Romanovsky To: Jason Gunthorpe Cc: Patrisious Haddad , linux-rdma@vger.kernel.org, Mark Zhang , Michael Guralnik , Or Har-Toov , Yishai Hadas Subject: [PATCH rdma-rc 6/6] RDMA/mlx5: Add check for srq max_sge attribute Date: Tue, 28 May 2024 15:52:56 +0300 Message-ID: <277ccc29e8d57bfd53ddeb2ac633f2760cf8cdd0.1716900410.git.leon@kernel.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Patrisious Haddad max_sge attribute is passed by the user, and is inserted and used unchecked, so verify that the value doesn't exceed maximum allowed value before using it. Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters") Signed-off-by: Patrisious Haddad Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/mlx5/srq.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c index a056ea835da5..84be0c3d5699 100644 --- a/drivers/infiniband/hw/mlx5/srq.c +++ b/drivers/infiniband/hw/mlx5/srq.c @@ -199,17 +199,20 @@ int mlx5_ib_create_srq(struct ib_srq *ib_srq, int err; struct mlx5_srq_attr in = {}; __u32 max_srq_wqes = 1 << MLX5_CAP_GEN(dev->mdev, log_max_srq_sz); + __u32 max_sge_sz = MLX5_CAP_GEN(dev->mdev, max_wqe_sz_rq) / + sizeof(struct mlx5_wqe_data_seg); if (init_attr->srq_type != IB_SRQT_BASIC && init_attr->srq_type != IB_SRQT_XRC && init_attr->srq_type != IB_SRQT_TM) return -EOPNOTSUPP; - /* Sanity check SRQ size before proceeding */ - if (init_attr->attr.max_wr >= max_srq_wqes) { - mlx5_ib_dbg(dev, "max_wr %d, cap %d\n", - init_attr->attr.max_wr, - max_srq_wqes); + /* Sanity check SRQ and sge size before proceeding */ + if (init_attr->attr.max_wr >= max_srq_wqes || + init_attr->attr.max_sge > max_sge_sz) { + mlx5_ib_dbg(dev, "max_wr %d,wr_cap %d,max_sge %d, sge_cap:%d\n", + init_attr->attr.max_wr, max_srq_wqes, + init_attr->attr.max_sge, max_sge_sz); return -EINVAL; }