diff mbox series

[focal:linux-azure,groovy:linux-azure,1/1] RDMA/mlx4: Read pkey table length instead of hardcoded value

Message ID 20200924123554.2836931-2-marcelo.cerri@canonical.com
State New
Headers show
Series LP:#1896760 - Mellanox patch for fixing failures in ConnectX3 Pro/DPDK | expand

Commit Message

Marcelo Henrique Cerri Sept. 24, 2020, 12:35 p.m. UTC
From: Mark Bloch <markb@mellanox.com>

BugLink: https://bugs.launchpad.net/bugs/1896760

If the pkey_table is not available (which is the case when RoCE is not
supported), the cited commit caused a regression where mlx4_devices
without RoCE are not created.

Fix this by returning a pkey table length of zero in procedure
eth_link_query_port() if the pkey-table length reported by the device is
zero.

Link: https://lore.kernel.org/r/20200824110229.1094376-1-leon@kernel.org
Cc: <stable@vger.kernel.org>
Fixes: 1901b91f9982 ("IB/core: Fix potential NULL pointer dereference in pkey cache")
Fixes: fa417f7b520e ("IB/mlx4: Add support for IBoE")
Signed-off-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
(cherry picked from commit ec78b3bd66bc9a015505df0ef0eb153d9e64b03b)
Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
---
 drivers/infiniband/hw/mlx4/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kleber Sacilotto de Souza Sept. 24, 2020, 12:51 p.m. UTC | #1
On 24.09.20 14:35, Marcelo Henrique Cerri wrote:
> From: Mark Bloch <markb@mellanox.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1896760
> 
> If the pkey_table is not available (which is the case when RoCE is not
> supported), the cited commit caused a regression where mlx4_devices
> without RoCE are not created.
> 
> Fix this by returning a pkey table length of zero in procedure
> eth_link_query_port() if the pkey-table length reported by the device is
> zero.
> 
> Link: https://lore.kernel.org/r/20200824110229.1094376-1-leon@kernel.org
> Cc: <stable@vger.kernel.org>
> Fixes: 1901b91f9982 ("IB/core: Fix potential NULL pointer dereference in pkey cache")
> Fixes: fa417f7b520e ("IB/mlx4: Add support for IBoE")
> Signed-off-by: Mark Bloch <markb@mellanox.com>
> Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> (cherry picked from commit ec78b3bd66bc9a015505df0ef0eb153d9e64b03b)
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>

Simple fix and clean cherry-pick.

Could you please add the SRU template to the bug report?

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>


Thanks,
Kleber

> ---
>  drivers/infiniband/hw/mlx4/main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index c46826d34ac8..4860d484f733 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -781,7 +781,8 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
>  	props->ip_gids = true;
>  	props->gid_tbl_len	= mdev->dev->caps.gid_table_len[port];
>  	props->max_msg_sz	= mdev->dev->caps.max_msg_sz;
> -	props->pkey_tbl_len	= 1;
> +	if (mdev->dev->caps.pkey_table_len[port])
> +		props->pkey_tbl_len = 1;
>  	props->max_mtu		= IB_MTU_4096;
>  	props->max_vl_num	= 2;
>  	props->state		= IB_PORT_DOWN;
>
Marcelo Henrique Cerri Sept. 24, 2020, 1 p.m. UTC | #2
Thanks. I updated the bug description with the SRU template.

On Thu, Sep 24, 2020 at 02:51:00PM +0200, Kleber Souza wrote:
> On 24.09.20 14:35, Marcelo Henrique Cerri wrote:
> > From: Mark Bloch <markb@mellanox.com>
> > 
> > BugLink: https://bugs.launchpad.net/bugs/1896760
> > 
> > If the pkey_table is not available (which is the case when RoCE is not
> > supported), the cited commit caused a regression where mlx4_devices
> > without RoCE are not created.
> > 
> > Fix this by returning a pkey table length of zero in procedure
> > eth_link_query_port() if the pkey-table length reported by the device is
> > zero.
> > 
> > Link: https://lore.kernel.org/r/20200824110229.1094376-1-leon@kernel.org
> > Cc: <stable@vger.kernel.org>
> > Fixes: 1901b91f9982 ("IB/core: Fix potential NULL pointer dereference in pkey cache")
> > Fixes: fa417f7b520e ("IB/mlx4: Add support for IBoE")
> > Signed-off-by: Mark Bloch <markb@mellanox.com>
> > Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
> > Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> > (cherry picked from commit ec78b3bd66bc9a015505df0ef0eb153d9e64b03b)
> > Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> 
> Simple fix and clean cherry-pick.
> 
> Could you please add the SRU template to the bug report?
> 
> Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
> 
> 
> Thanks,
> Kleber
> 
> > ---
> >  drivers/infiniband/hw/mlx4/main.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> > index c46826d34ac8..4860d484f733 100644
> > --- a/drivers/infiniband/hw/mlx4/main.c
> > +++ b/drivers/infiniband/hw/mlx4/main.c
> > @@ -781,7 +781,8 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
> >  	props->ip_gids = true;
> >  	props->gid_tbl_len	= mdev->dev->caps.gid_table_len[port];
> >  	props->max_msg_sz	= mdev->dev->caps.max_msg_sz;
> > -	props->pkey_tbl_len	= 1;
> > +	if (mdev->dev->caps.pkey_table_len[port])
> > +		props->pkey_tbl_len = 1;
> >  	props->max_mtu		= IB_MTU_4096;
> >  	props->max_vl_num	= 2;
> >  	props->state		= IB_PORT_DOWN;
> > 
>
Stefan Bader Sept. 24, 2020, 1:27 p.m. UTC | #3
On 24.09.20 14:35, Marcelo Henrique Cerri wrote:
> From: Mark Bloch <markb@mellanox.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1896760
> 
> If the pkey_table is not available (which is the case when RoCE is not
> supported), the cited commit caused a regression where mlx4_devices
> without RoCE are not created.
> 
> Fix this by returning a pkey table length of zero in procedure
> eth_link_query_port() if the pkey-table length reported by the device is
> zero.
> 
> Link: https://lore.kernel.org/r/20200824110229.1094376-1-leon@kernel.org
> Cc: <stable@vger.kernel.org>
> Fixes: 1901b91f9982 ("IB/core: Fix potential NULL pointer dereference in pkey cache")
> Fixes: fa417f7b520e ("IB/mlx4: Add support for IBoE")
> Signed-off-by: Mark Bloch <markb@mellanox.com>
> Reviewed-by: Maor Gottlieb <maorg@nvidia.com>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> (cherry picked from commit ec78b3bd66bc9a015505df0ef0eb153d9e64b03b)
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  drivers/infiniband/hw/mlx4/main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index c46826d34ac8..4860d484f733 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -781,7 +781,8 @@ static int eth_link_query_port(struct ib_device *ibdev, u8 port,
>  	props->ip_gids = true;
>  	props->gid_tbl_len	= mdev->dev->caps.gid_table_len[port];
>  	props->max_msg_sz	= mdev->dev->caps.max_msg_sz;
> -	props->pkey_tbl_len	= 1;
> +	if (mdev->dev->caps.pkey_table_len[port])
> +		props->pkey_tbl_len = 1;
>  	props->max_mtu		= IB_MTU_4096;
>  	props->max_vl_num	= 2;
>  	props->state		= IB_PORT_DOWN;
>
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index c46826d34ac8..4860d484f733 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -781,7 +781,8 @@  static int eth_link_query_port(struct ib_device *ibdev, u8 port,
 	props->ip_gids = true;
 	props->gid_tbl_len	= mdev->dev->caps.gid_table_len[port];
 	props->max_msg_sz	= mdev->dev->caps.max_msg_sz;
-	props->pkey_tbl_len	= 1;
+	if (mdev->dev->caps.pkey_table_len[port])
+		props->pkey_tbl_len = 1;
 	props->max_mtu		= IB_MTU_4096;
 	props->max_vl_num	= 2;
 	props->state		= IB_PORT_DOWN;