Received: by 10.213.65.68 with SMTP id h4csp1525591imn; Thu, 15 Mar 2018 02:04:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELvTH/ZNwHzlgKCp4DWGtlNykEJf0ufZAv6c4RT/8BZfXODpS6orhpUhhzrRDffNZ+4U5QNF X-Received: by 10.101.93.138 with SMTP id f10mr6153268pgt.255.1521104648105; Thu, 15 Mar 2018 02:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521104648; cv=none; d=google.com; s=arc-20160816; b=oItHn2QnH3UueIixf3ef8V87zqmWVeL8Pq1QUDwoRVMhn2fe9HIpaNz+40KXS5967M 4Y96MLp3fSdBXYd68NQsLyM42U2Im3LC9yranumCmoZkm8JbfeCSO5kb0sIGJiGLI0pv JtjaQd/WnpJBI6rz8GE729p7aiDxi2+hSiSptyfKZViALQjNnhtYTiiZKa4quvzid/qe HEhYtvC5z315H+L1gFHVMZwrD4A9FYB5Jv7KXnItnrQvUiaVWyhIAF6nJlWVBfsKVfmB t2oiGdMo5t8BzJp5A1sXswLg7EkfjMNdePLM/6yHtJbapAzFL7lW/tjmPDzVWB5ZZunu XoZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=42IymhNma+SYhEN7hH6SDf70XlW200Ay22FW6V+7R+0=; b=gvDkBLmPDuNzjakhHwR80SSmn2ZAzrbstXZSpewvEPRuGPdVNbW1ijEzYZoyd5Gcic 9LZAGpLDyRcHP7ExWJjh0T5I1ieoPieiWZap9y/YbK0ihcHcflZuH9U8Lq7iwDAQFPPo SzQC+Sg9P8KI7iZ7fsO2CzdQ6xcHiROetju975bZ0u3QrCwajUX6I1eg7HCrf/zt8XNA /ERgHyNRxNLKXB1zKptJ1Nspx6pRRCNgVNbF2lSdZYTa86RIWoZbMlHqFFOjqofoI4jR Te4ZvirDP/XYebo+KcDyOzvHeXFkVFis58p9MiR17PFls21VPvinm6IDqfL27eg1YgUt s91A== ARC-Authentication-Results: i=1; mx.google.com; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o89si216192pfa.272.2018.03.15.02.03.53; Thu, 15 Mar 2018 02:04:08 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751928AbeCOJC2 (ORCPT + 99 others); Thu, 15 Mar 2018 05:02:28 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38576 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751860AbeCOJCY (ORCPT ); Thu, 15 Mar 2018 05:02:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C51984023141; Thu, 15 Mar 2018 09:02:23 +0000 (UTC) Received: from dhcp-13-42.nay.redhat.com (unknown [10.66.128.195]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C8AB202322B; Thu, 15 Mar 2018 09:02:21 +0000 (UTC) From: Honggang LI To: dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org Cc: noaos@mellanox.com, linux-kernel@vger.kernel.org, honli@redhat.com Subject: [PATCH 2/2] IB/core: Set width to 1X for invalid active widths when port is down Date: Thu, 15 Mar 2018 17:02:14 +0800 Message-Id: <20180315090214.21706-3-honli@redhat.com> In-Reply-To: <20180315090214.21706-1-honli@redhat.com> References: <20180315090214.21706-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 15 Mar 2018 09:02:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 15 Mar 2018 09:02:23 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'honli@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) + 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, -- 2.14.GIT