Received: by 10.213.65.68 with SMTP id h4csp1614733imn; Thu, 15 Mar 2018 05:03:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELtxhPmETqyflP8bFnk5lViFhLbKFk76AQ9yws+joNqN271Zmq8hIziCNEe36qU/qUQ85CMr X-Received: by 2002:a17:902:a614:: with SMTP id u20-v6mr7817169plq.249.1521115385145; Thu, 15 Mar 2018 05:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521115385; cv=none; d=google.com; s=arc-20160816; b=KEUzbOvM12WwJ3iKjJn0iZupLu+qqSPgKkyg8HyxeuOMCFgVgM58GqQVYwYvBclws1 R9WI4QaNrWsAjw2phxFMw8rFit6sAWcid6Yy26ry6QryQRgH84rD8zBtObNXM5Faybyi +oQUTP+u/rduib85U/7twTlm+OaSdOxPUXBKrqqjWD2Dlol7oYtKZEjI/ZgnUyyPGw7a 1fkfaxqmorsDeyFN05FzVZXWQyv/nXvelMrP4FgWlcF3bmiaWP0x3aG6Pv8iTsi9ch6O sbmqEwhGQp/jagqOsofOO7kYvSaSxRm/MLi7YqrgnTgUw/awt6sUe1fuMuYVXCc4gsZ/ unvQ== 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=6bYLM55eOBPitUf9w0fMR25TPLWpxOmoJhBGadQLSj4=; b=W5LWNt6kAVHxSVLp3LRfvLFdHFDERRlhlmWfDWKGJ0G+ocWcVXA4ddGzoJtaFs1zSE DFpVJ+6EtuqxR690wRoKCneGvJJ+g08I+28w8PueJvZ9BtLd4AuKKGV0DUcRSyrXxpxb AvpHRNx7cxLskMnPAq3W7ImHnVgJij2ARmwxRYRl55R4Mpg0dR77KyF3ywd7w3/pt3eI 1WrfoP7OmWSXvviZORkLzhSIPU9QXLZ6/INEHoRjK1UOCGUAorf+TuG/2qMWi8Rjd3JC wxRVZO0LrpGPW+NmoumpkKoQGR2l/Jh199eWKBBpbYHbRqaofrUaP3B1Vzf+rYfH80RW uZyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dev-mellanox-co-il.20150623.gappssmtp.com header.s=20150623 header.b=fsb20/EW; 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 f19-v6si3894373plj.292.2018.03.15.05.02.22; Thu, 15 Mar 2018 05:03:05 -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=fsb20/EW; 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 S1751495AbeCOMBO (ORCPT + 99 others); Thu, 15 Mar 2018 08:01:14 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:39334 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750731AbeCOMBM (ORCPT ); Thu, 15 Mar 2018 08:01:12 -0400 Received: by mail-qk0-f196.google.com with SMTP id z197so6943097qkb.6 for ; Thu, 15 Mar 2018 05:01:12 -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=6bYLM55eOBPitUf9w0fMR25TPLWpxOmoJhBGadQLSj4=; b=fsb20/EWV6okcwTp7ZTDXBvy0EdC9J5pu3PJZTfFiJkMmp4SOns64T++XI1HEAxrFH oqHqko3xh45G169qQiVISRNgMBMBwETVOFPD7hVh3tdg0Mvl2K+V2hyM9iSTvrH7I1SK yMOvfPNM/6msGiRsYKiltFJUiMfqp28I3WQ8w23Sn17zQ/Ej381EuMUDvkfGvrDSKT+4 /gYRboMvqs4AvhgNT7T0hOwK+SeQ5XI9/dpA33ah10vDPt4mW2n4jSPbSFC06OZe9mbF nakS4mwBsWMILHd5xHur+Qo+tew3e0loX2tEOncBqn7CwZBVw51DTCBkiAVRo6gvMkV4 io/w== 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=6bYLM55eOBPitUf9w0fMR25TPLWpxOmoJhBGadQLSj4=; b=h57KGNg+3WRNnAPIQMLyqhU600s6fTy3WkMu8BDzwa+kZIMKCEMmwYVhl3GWbQVUx0 +5KXEiHg/aRrmFcdn7Rt+aR0I8rCmyLd9brqvqm9VpJxYFPMmGgsUbNFQ8LwXUePYq6r NyzYm2gDsuuL6sumb7oPW1/F2Y14lMbR+2id7c335cH1bshJEDsmZ5Cm9O6HIop7MmGg 0GcfwP0dQuekXBUOmN7CvfDW2+vhbx9G4vusJqFMlVUZTn9/5J04/vd+Hq/UspnAbIHF eiUyBmyRNAAGKyJFnf0K12AoPUc0C2p3allhxQxPwpZvFKZQKZpVkQBYPAyKE4FO+oQv /fAg== X-Gm-Message-State: AElRT7F+faanWeapw5MSsIfPlcSjxROeeEz8C2VfiXtW/B0I3eR7f3I9 jBjTbfE6H0SKwKKwY/T4EKS2o60q X-Received: by 10.55.3.140 with SMTP id 134mr12493868qkd.26.1521115270541; Thu, 15 Mar 2018 05:01:10 -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 h184sm3098991qkc.78.2018.03.15.05.01.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Mar 2018 05:01:09 -0700 (PDT) Subject: Re: [PATCH 2/2] IB/core: Set width to 1X for invalid active widths when port is down To: Honggang LI , dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org Cc: noaos@mellanox.com, linux-kernel@vger.kernel.org References: <20180315090214.21706-1-honli@redhat.com> <20180315090214.21706-3-honli@redhat.com> From: Hal Rosenstock Message-ID: <74460de7-9603-146b-28ec-2e16b8b5bb52@dev.mellanox.co.il> Date: Thu, 15 Mar 2018 08:01:08 -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: <20180315090214.21706-3-honli@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 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 ? -- 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, >