Received: by 10.213.65.68 with SMTP id h4csp120665imn; Thu, 15 Mar 2018 19:40:25 -0700 (PDT) X-Google-Smtp-Source: AG47ELtxqwLCvq2480bqJkSK+L4d/Z77x0OxpqFORASPCrwXTysCwaGheJG3aCVcsvGHUM/6CuWR X-Received: by 10.99.125.78 with SMTP id m14mr139525pgn.190.1521168025833; Thu, 15 Mar 2018 19:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521168025; cv=none; d=google.com; s=arc-20160816; b=QDpuqtL4TzKXfwaJUZvId2N4MI+PpHOTbHY9d58ad/qI3wnCRzB/rLOJPeT3AIukIS MiR2t3nsU4KG1XSk7lQHIRH/Lx7Csr5eoYgXyliLghaUG+LM6iYCqWwgc6Gu5DnY45B0 7Fzorl2K6loz8jvq2GOVc3Hyf/Dz7VyPBubYJG70JcLtWvcUN5rcKEKWJiDVTHXxFlrL CjtCBiMBnDmzMpnAAXAsTiXFTSzJ38CzlgyOH6B6T5G7I7+7kbzFYtnnIDS7kLiMP11j +mhUlJ/TXWSjT3AiPjqz+ulcFUfCqXQrp3Xn0zvcS1NyJjn+fSMY8y4ya1pFFDL/TxAu 7I6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=sXiq8SRa1WUzNjbS6YhumzvXQMjeRNSBd9JA79eVKfU=; b=UJ2WSZJEQx3SZRJtFzXv7GUod437gmbg1BmvOFWHO+CSCH/Ec/QEaBXWVSAwD4lr5Y Y+saKYS8DLOyhiq1bCMZ9UsRdzMeyr1mSSTPNUj/wOy/jNTRKoniaRCmwzrQPusof7Dg R3diczgz3R//fGKyG0t8yPco5Cfkm+dvHGcpjM/IKWkIAVuG1JnS0mEuaM32MkvkDFfO qAqqf+l36pT2ZVy2Qy2WjSkvh2oIlGHM8nhp6hKAHt26FBFSwfV4a/XLGnsoWSHpFo6r qpmdTnuBbqnhkhtbLj9DOOrC7VzmJxQnk1PJmhkxWYCIUG8rf+3aAFHkejDIiJSN5wDc 4BCg== 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 b91-v6si5137086plb.268.2018.03.15.19.40.11; Thu, 15 Mar 2018 19:40:25 -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 S1753022AbeCPCi7 (ORCPT + 99 others); Thu, 15 Mar 2018 22:38:59 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34822 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751791AbeCPCi6 (ORCPT ); Thu, 15 Mar 2018 22:38:58 -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 08C34814F0A4; Fri, 16 Mar 2018 02:38:58 +0000 (UTC) Received: from localhost (unknown [10.66.128.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B52A84451; Fri, 16 Mar 2018 02:38:57 +0000 (UTC) Date: Fri, 16 Mar 2018 10:38:54 +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: <20180316023854.GA30019@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> <20180315124342.GA29859@dhcp-13-42.nay.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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.8]); Fri, 16 Mar 2018 02:38:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 16 Mar 2018 02:38:58 +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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 15, 2018 at 08:47:44AM -0400, Hal Rosenstock wrote: > 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. [PATCH] IB/mlx5: Set the default active rate and width to QDR and 4X This new patch had been sent to upstream mailing list for review. thanks