linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hal Rosenstock <hal@dev.mellanox.co.il>
To: Honggang LI <honli@redhat.com>,
	dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org
Cc: noaos@mellanox.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] IB/core: Set width to 1X for invalid active widths when port is down
Date: Thu, 15 Mar 2018 08:01:08 -0400	[thread overview]
Message-ID: <74460de7-9603-146b-28ec-2e16b8b5bb52@dev.mellanox.co.il> (raw)
In-Reply-To: <20180315090214.21706-3-honli@redhat.com>

On 3/15/2018 5:02 AM, Honggang LI wrote:
> From: Honggang Li <honli@redhat.com>
> 
> commit f1b65df5a232 ("IB/mlx5: Add support for active_width and
> active_speed in RoCE"). Before this patch applied, the mlx5_ib
> driver set default active_width and active_speed to IB_WIDTH_4X
> and IB_SPEED_QDR.
> 
> When the RoCE port is down, the RoCE port did not negotiate the
> active width with remote side. The active width is zero. If run
> ibstat to require the port status, ibstat will panic as it read
> invalid width from sys file.
> 
> Signed-off-by: Honggang Li <honli@redhat.com>
> ---
>  drivers/infiniband/core/sysfs.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
> index cf36ff1f0068..722e4571f4d2 100644
> --- a/drivers/infiniband/core/sysfs.c
> +++ b/drivers/infiniband/core/sysfs.c
> @@ -240,6 +240,7 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
>  	struct ib_port_attr attr;
>  	char *speed = "";
>  	int rate;		/* in deci-Gb/sec */
> +	int width;
>  	ssize_t ret;
>  
>  	ret = ib_query_port(p->ibdev, p->port_num, &attr);
> @@ -278,13 +279,19 @@ static ssize_t rate_show(struct ib_port *p, struct port_attribute *unused,
>  		break;
>  	}
>  
> -	rate *= ib_width_enum_to_int(attr.active_width);
> -	if (rate < 0)
> -		return -EINVAL;
> +	width = ib_width_enum_to_int(attr.active_width);
> +	if (width < 0) {
> +		if (attr.state != IB_PORT_ACTIVE)

Link width is valid in any PortState other than Down so I think that
this check should be:
		if (attr.state != IB_PORT_DOWN)

However, I don't think overriding width should be needed for this case
and just returning -EINVAL should be fine regardless of port state.
AFAIK it's the driver responsibility to populate acceptable defaults for
such parameters. What driver(s) have this issue ? Shouldn't it be fixed
there rather than here ?

-- Hal

> +			width = 1; /* default to 1X for invalid widths */
> +		else
> +			return -EINVAL;
> +	}
> +
> +	rate *= width;
>  
>  	return sprintf(buf, "%d%s Gb/sec (%dX%s)\n",
>  		       rate / 10, rate % 10 ? ".5" : "",
> -		       ib_width_enum_to_int(attr.active_width), speed);
> +		       width, speed);
>  }
>  
>  static ssize_t phys_state_show(struct ib_port *p, struct port_attribute *unused,
> 

  reply	other threads:[~2018-03-15 12:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15  9:02 [PATCH 0/2] IB/core: Set invalid active widths to 1X when port is not active Honggang LI
2018-03-15  9:02 ` [PATCH 1/2] IB/core: Set speed string to SDR for invalid active rates Honggang LI
2018-03-19 17:53   ` Jason Gunthorpe
2018-03-15  9:02 ` [PATCH 2/2] IB/core: Set width to 1X for invalid active widths when port is down Honggang LI
2018-03-15 12:01   ` Hal Rosenstock [this message]
2018-03-15 12:27     ` Honggang LI
2018-03-15 12:32     ` Hal Rosenstock
2018-03-15 12:43       ` Honggang LI
2018-03-15 12:47         ` Hal Rosenstock
2018-03-16  2:38           ` Honggang LI

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=74460de7-9603-146b-28ec-2e16b8b5bb52@dev.mellanox.co.il \
    --to=hal@dev.mellanox.co.il \
    --cc=dledford@redhat.com \
    --cc=honli@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=noaos@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).