Received: by 10.213.65.68 with SMTP id h4csp1644113imn; Thu, 15 Mar 2018 05:49:16 -0700 (PDT) X-Google-Smtp-Source: AG47ELu//0/xc5KoWRYG0Z5gOnLKtPWBqXTtgbDGgNyrx3OUkJyN7uTmP15TwQC6dY4I3ST5dLqR X-Received: by 10.167.130.88 with SMTP id e24mr7697433pfn.66.1521118156205; Thu, 15 Mar 2018 05:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521118156; cv=none; d=google.com; s=arc-20160816; b=wAf5VgeQx4Q3N5Vo/vVk4nrmH/h+rXg5oPa1ANQQzDi/dcdUlMA52Eahy/b3hdRIWY RQeaRBATLBhwU882IvbfDdxV//UieGgx6B10z44hv0ZZeHy2vgceVP5SVLeK3pgPgIvR Wkz/yI+cARCr98kuvG7/etXb12S1mKo+2Gl8KKa4NtLnTt2uUHPzTylrvSx5N7mE5mY9 0Uoo8gOVVuOCeb1zdSyq1z4hs5JBT+RFCWvg5u/kjBr4RAlu6BmoFoIqaTLwwrbZpf0W B6geU3vbzwPHPMm3f0GJHhKwOCZJ0Wp5IV96TsOdaAuCOBktIAZBEwqC2G/9cFn3mc0y x/PA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=F2+tiCKwD3u9gb/xYXhza3JR5ZGQUiL+JP1BXJhEfdA=; b=MIb5jlcBljuLoYQ0ph4UkxDZNEnLpvk7JlYDvETu394ASkekVXyj3Xl8uSirS/cRIl m0/4JG8sZWWqEjAtSQ2+TihkITW7YBy+qxWQlY9cX+lf7UwemvmTNfrTabtD4qlWvm+0 kPOh2NAuH85BoWfJ+kUYpkUGxBeL0CK1e32oE1OL+uKOmjAkXqkhdz8HsYz6Csuhu+ko FO69WRSmB6UJIRrgUGLr2ZXGYyzzpD+Z7MDgzQeDjAEvSxZGYaue05CeToBdOUJMJ3fr 5TgmNPuY8GMMDnZ65d8iUp2a9e70OKbbpblI7wktRKSvIdWdb9atZBqwUaGV+nQmH6ks FXwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dev-mellanox-co-il.20150623.gappssmtp.com header.s=20150623 header.b=DGRPwTHF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.co.il Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y17si2311772pff.238.2018.03.15.05.49.01; Thu, 15 Mar 2018 05:49:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@dev-mellanox-co-il.20150623.gappssmtp.com header.s=20150623 header.b=DGRPwTHF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.co.il Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751619AbeCOMrs (ORCPT + 99 others); Thu, 15 Mar 2018 08:47:48 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:43187 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751414AbeCOMrr (ORCPT ); Thu, 15 Mar 2018 08:47:47 -0400 Received: by mail-qt0-f193.google.com with SMTP id s48so6985690qtb.10 for ; Thu, 15 Mar 2018 05:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=F2+tiCKwD3u9gb/xYXhza3JR5ZGQUiL+JP1BXJhEfdA=; b=DGRPwTHF7UU4BVj+WyKxV65jtzt8gstbVZ56oah9UHGPJ6ZQ8idKffRXBSJ2Hx7OP7 SGRvs5d51hwg71fmL97Hv0DaBOqhxvkl+HtgT+O4DhDtOmo+CbTDHe9UNBYkSMzjJ6r5 bmh5lHbSTCqq5s0KeQTIU84+Dq/uIZxbpWavsKFvRIpZv/R7Ld0bG7qqTJeR+BELC4Cc dh6fM6nidCx8M9Kl7XUUgFfP1noGbWC40BNVRnZ0u6/xGfxOtQ1Oi/LF7Gp6pxIYik8F rY8/bvSWHpsh8lhum6L6KLhhDBarDBs5n6wuNyEKRfKJ62YGr74LiCmjoV0BU2plwqRx xoDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=F2+tiCKwD3u9gb/xYXhza3JR5ZGQUiL+JP1BXJhEfdA=; b=lOuXsPAJ6ZcvL0S/oQDaDTHa52ExQZ4kjbF/ilR5TrysLY4yxz0qfoBl90ytIepxBo nlI/6Xk8ajJvi9oNIBf/k2ikwtr76h6qGje+lmkHHbC8Tq6EVanaaTkd+ZjmBrukdIeB DFobZ1JFNc7jjXVSIC6brp0wy2ww9NrTIPjpcvrMJf+CDTmM6NERa/CWZ5WWfMR/cFJy Lnho8LAJhfHd2DZm0XiX7Uk9/Ow1sAPss7gf1FOjEizIhXYH0/z4Uk7c96LT3ab/o211 JwfVN/jrX5FfbtHBku+ecl9oAIb34yXkvJkHn9uhOWp5UWhvPulh2ZDeTORuqWaD5aj9 9Gog== X-Gm-Message-State: AElRT7FV+KjtFa3lgFTbuZoZxZBWJOjI8EzmutCD9SgVlEpgyYxpZ2sc s+/zW1IHKR9CRA2ypXcKAUZSK974 X-Received: by 10.200.53.164 with SMTP id k33mr4302130qtb.37.1521118066118; Thu, 15 Mar 2018 05:47:46 -0700 (PDT) Received: from [192.168.1.183] (c-73-182-207-166.hsd1.ma.comcast.net. [73.182.207.166]) by smtp.googlemail.com with ESMTPSA id i63sm3601496qtb.96.2018.03.15.05.47.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 05:47:45 -0700 (PDT) Subject: Re: [PATCH 2/2] IB/core: Set width to 1X for invalid active widths when port is down To: Honggang LI Cc: dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, noaos@mellanox.com, linux-kernel@vger.kernel.org References: <20180315090214.21706-1-honli@redhat.com> <20180315090214.21706-3-honli@redhat.com> <74460de7-9603-146b-28ec-2e16b8b5bb52@dev.mellanox.co.il> <20180315124342.GA29859@dhcp-13-42.nay.redhat.com> From: Hal Rosenstock Message-ID: Date: Thu, 15 Mar 2018 08:47:44 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180315124342.GA29859@dhcp-13-42.nay.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/15/2018 8:43 AM, Honggang LI wrote: > 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. > > 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); > Sure; makes sense that it should preserve the original behavior for this case. Thanks. -- Hal