From patchwork Thu Mar 15 12:43:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10284419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5AFC8602BD for ; Thu, 15 Mar 2018 12:43:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FB1528A0B for ; Thu, 15 Mar 2018 12:43:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 447C328A0D; Thu, 15 Mar 2018 12:43:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDF3628A0B for ; Thu, 15 Mar 2018 12:43:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751482AbeCOMnr (ORCPT ); Thu, 15 Mar 2018 08:43:47 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47538 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751466AbeCOMnq (ORCPT ); Thu, 15 Mar 2018 08:43:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 12813406E8D7; Thu, 15 Mar 2018 12:43:46 +0000 (UTC) Received: from localhost (unknown [10.66.128.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B811BDC2E; Thu, 15 Mar 2018 12:43:45 +0000 (UTC) Date: Thu, 15 Mar 2018 20:43:42 +0800 From: Honggang LI To: Hal Rosenstock Cc: dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, 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 Message-ID: <20180315124342.GA29859@dhcp-13-42.nay.redhat.com> References: <20180315090214.21706-1-honli@redhat.com> <20180315090214.21706-3-honli@redhat.com> <74460de7-9603-146b-28ec-2e16b8b5bb52@dev.mellanox.co.il> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 15 Mar 2018 12:43:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 15 Mar 2018 12:43:46 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'honli@redhat.com' RCPT:'' Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, Mar 15, 2018 at 08:32:02AM -0400, Hal Rosenstock wrote: > On 3/15/2018 8:01 AM, Hal Rosenstock wrote: > > On 3/15/2018 5:02 AM, Honggang LI wrote: > >> From: Honggang Li > >> > >> 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 > >> --- > >> 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 ? > > I just noticed that you reference 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. > > Should the fix be to hw/mlx5/main.c:translate_eth_proto_oper which now has: > > switch (eth_proto_oper) { > ... > default: > return -EINVAL; > } > > return 0; > > and change default case to: > *active_width = IB_WIDTH_1X; > > ? I suggest to restore previous behavior before apply f1b65df5a232. --- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 033b6af90de9..0d73d2772d9b 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -388,6 +388,9 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num, if (err) goto out; + props->active_width = IB_WIDTH_4X; + props->active_speed = IB_SPEED_QDR; + translate_eth_proto_oper(eth_prot_oper, &props->active_speed, &props->active_width);