From patchwork Thu Feb 17 03:01:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng Xu X-Patchwork-Id: 12749251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A44EFC433F5 for ; Thu, 17 Feb 2022 03:01:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232184AbiBQDBg (ORCPT ); Wed, 16 Feb 2022 22:01:36 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231487AbiBQDBg (ORCPT ); Wed, 16 Feb 2022 22:01:36 -0500 Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5361811798C for ; Wed, 16 Feb 2022 19:01:22 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R671e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=chengyou@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0V4fho4o_1645066879; Received: from localhost(mailfrom:chengyou@linux.alibaba.com fp:SMTPD_---0V4fho4o_1645066879) by smtp.aliyun-inc.com(127.0.0.1); Thu, 17 Feb 2022 11:01:19 +0800 From: Cheng Xu To: jgg@ziepe.ca, dledford@redhat.com Cc: leon@kernel.org, linux-rdma@vger.kernel.org, KaiShen@linux.alibaba.com, chengyou@linux.alibaba.com, tonylu@linux.alibaba.com Subject: [PATCH for-next v3 02/12] RDMA/core: Allow calling query_port when netdev isn't attached in iWarp Date: Thu, 17 Feb 2022 11:01:06 +0800 Message-Id: <20220217030116.6324-3-chengyou.xc@alibaba-inc.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220217030116.6324-1-chengyou.xc@alibaba-inc.com> References: <20220217030116.6324-1-chengyou.xc@alibaba-inc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Cheng Xu This change lets the iWarp device drivers decide the return value of iw_query_port when attached netdev is NULL. This allows ib_register_device calling when netdev is NULL. background: https://lore.kernel.org/all/20220118141324.GF8034@ziepe.ca/ Signed-off-by: Cheng Xu --- drivers/infiniband/core/device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index a311df07b1bd..29e42279e983 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2019,8 +2019,12 @@ static int iw_query_port(struct ib_device *device, memset(port_attr, 0, sizeof(*port_attr)); netdev = ib_device_get_netdev(device, port_num); + /* Some iwarp device may be not binded to a netdev temporarily when + * ib_register_device called. To adapt this scenario, and let iWarp + * device drivers decide the return value. + */ if (!netdev) - return -ENODEV; + goto query_port; port_attr->max_mtu = IB_MTU_4096; port_attr->active_mtu = ib_mtu_int_to_enum(netdev->mtu); @@ -2045,6 +2049,7 @@ static int iw_query_port(struct ib_device *device, } dev_put(netdev); +query_port: return device->ops.query_port(device, port_num, port_attr); }