Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp221747rdb; Sat, 30 Sep 2023 01:42:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRI3+c/V/tXrHLVRys12ig8B/rU1/nG2V8sSmRBh1Q310YA9bp7v6FXqez7GleIZeroE3Q X-Received: by 2002:a05:6870:638c:b0:1b0:649f:e68a with SMTP id t12-20020a056870638c00b001b0649fe68amr7298644oap.25.1696063334576; Sat, 30 Sep 2023 01:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696063334; cv=none; d=google.com; s=arc-20160816; b=CuvW02oOMV0yVABA1c2JNhsAtC5btfa5fe8dEdiQ6+0D4JN2iPjiBK9Ap49ZOvYQ3G ZuYLlULeo3Wl1+FwHFhjrUX/UIToZX4ELBXxzVVVpXtYoAOjWy3ZueYVI5c/egPLbgKC dkzrJudOtnM0FZT4ePhk57lrSZLB+mZ89FOv7/+6Y/rOhGPwRVbsG5iWyGuPE8fgXe98 12D7VzZ/AmBbiPPSUpBJEOz3rJZoMcN0bh6CE+wYDIDZZakkcVbGK/vfKg+b1dWml3Ue 9EUOAXDoV7etvctUNRvLBGFjW8xwKGjdKQF72dRjTAwwc6mQ7KjJckiI4mlsZP0UaiBE dPEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=WirU31vdyVWFoRReCE9Xc6m91/bAALSTYkykSiyElrM=; fh=UzKFNzVrZRdlag0VtEiG7nfwNiGO5v6olHL/3/x/RSo=; b=k41Il19y9t1G74oggGbV8cpQjKhWh+XnXtgrxGEuLA7kllT4DqS5rB/TAlzaGEfPeX chnEIhBpvVsBLMN6by7IOnOcVcQK0RgcwEPKATjEPeHPKVBSRDmI8Zu1qr43MTDxRoUj 5AP6D8WPevmXY4cIbVl8EIH/99xmj30a5stfBPWd6yufcj/xiKUTNLipjgjqJJPAoBum zj/SfjRUVKaJ3wLbE8Hg7i0Frdyh65Wp564c14qOb7alWAhER8G0thQmeNAQGS54Jff7 jEhtNqd8+se2QAbtq/uHUGuqY/NyaI0RklPaaA/9RZ/+vWGEuo5R9gBJdTeklL/nzbAX Y1ww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y129-20020a62ce87000000b0068fea8a6169si20845710pfg.404.2023.09.30.01.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 01:42:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 68756826CB50; Sat, 30 Sep 2023 01:42:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbjI3Il4 (ORCPT + 99 others); Sat, 30 Sep 2023 04:41:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229489AbjI3Ilz (ORCPT ); Sat, 30 Sep 2023 04:41:55 -0400 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D83741A4; Sat, 30 Sep 2023 01:41:50 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=guwen@linux.alibaba.com;NM=1;PH=DS;RN=17;SR=0;TI=SMTPD_---0Vt5scEN_1696063306; Received: from 30.236.0.214(mailfrom:guwen@linux.alibaba.com fp:SMTPD_---0Vt5scEN_1696063306) by smtp.aliyun-inc.com; Sat, 30 Sep 2023 16:41:48 +0800 Message-ID: <643c479a-b8bc-7526-330a-5c3f5547385c@linux.alibaba.com> Date: Sat, 30 Sep 2023 16:41:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH net-next v4 03/18] net/smc: extract v2 check helper from SMC-D device registration To: Jan Karcher , kgraul@linux.ibm.com, wenjia@linux.ibm.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: wintera@linux.ibm.com, schnelle@linux.ibm.com, gbayer@linux.ibm.com, pasic@linux.ibm.com, alibuda@linux.alibaba.com, tonylu@linux.alibaba.com, dust.li@linux.alibaba.com, linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1695568613-125057-1-git-send-email-guwen@linux.alibaba.com> <1695568613-125057-4-git-send-email-guwen@linux.alibaba.com> <902e41df-0c98-c8ef-09cb-a92cf053f9d2@linux.ibm.com> From: Wen Gu In-Reply-To: <902e41df-0c98-c8ef-09cb-a92cf053f9d2@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sat, 30 Sep 2023 01:42:12 -0700 (PDT) On 2023/9/28 11:08, Jan Karcher wrote: > > > On 24/09/2023 17:16, Wen Gu wrote: >> This patch extracts v2-capable logic from the process of registering the >> ISM device as an SMC-D device, so that the registration process of other >> underlying devices can reuse it. >> >> Signed-off-by: Wen Gu >> --- >>   net/smc/smc_ism.c | 29 ++++++++++++++++++----------- >>   net/smc/smc_ism.h |  1 + >>   2 files changed, 19 insertions(+), 11 deletions(-) >> >> diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c >> index 455ae0a..8f1ba74 100644 >> --- a/net/smc/smc_ism.c >> +++ b/net/smc/smc_ism.c >> @@ -69,6 +69,22 @@ bool smc_ism_is_v2_capable(void) >>       return smc_ism_v2_capable; >>   } >> +/* must be called under smcd_dev_list.mutex lock */ >> +void smc_ism_check_v2_capable(struct smcd_dev *smcd) >> +{ >> +    u8 *system_eid = NULL; >> + >> +    if (smc_ism_v2_capable) >> +        return; >> + >> +    system_eid = smcd->ops->get_system_eid(); >> +    if (smcd->ops->supports_v2()) { >> +        smc_ism_v2_capable = true; >> +        memcpy(smc_ism_v2_system_eid, system_eid, >> +               SMC_MAX_EID_LEN); >> +    } >> +} >> + >>   /* Set a connection using this DMBE. */ >>   void smc_ism_set_conn(struct smc_connection *conn) >>   { >> @@ -423,16 +439,7 @@ static void smcd_register_dev(struct ism_dev *ism) >>           smc_pnetid_by_table_smcd(smcd); >>       mutex_lock(&smcd_dev_list.mutex); >> -    if (list_empty(&smcd_dev_list.list)) { >> -        u8 *system_eid = NULL; >> - >> -        system_eid = smcd->ops->get_system_eid(); >> -        if (smcd->ops->supports_v2()) { >> -            smc_ism_v2_capable = true; >> -            memcpy(smc_ism_v2_system_eid, system_eid, >> -                   SMC_MAX_EID_LEN); >> -        } >> -    } >> +    smc_ism_check_v2_capable(smcd); > > The list_empty check is omitted here which means the smc_ism_check_v2_capable does not touch the list. > So i think the call could be placed prior the mutex_lock. > Good catch. I omitted the list_empty check in this version but forget to remove 'the lock comments' and place the helper prior to the mutex_lock. It will be fixed. Thank you. >>       /* sort list: devices without pnetid before devices with pnetid */ >>       if (smcd->pnetid[0]) >>           list_add_tail(&smcd->list, &smcd_dev_list.list); >> @@ -535,10 +542,10 @@ int smc_ism_init(void) >>   { >>       int rc = 0; >> -#if IS_ENABLED(CONFIG_ISM) >>       smc_ism_v2_capable = false; >>       memset(smc_ism_v2_system_eid, 0, SMC_MAX_EID_LEN); >> +#if IS_ENABLED(CONFIG_ISM) >>       rc = ism_register_client(&smc_ism_client); >>   #endif >>       return rc; >> diff --git a/net/smc/smc_ism.h b/net/smc/smc_ism.h >> index 832b2f4..14d2e77 100644 >> --- a/net/smc/smc_ism.h >> +++ b/net/smc/smc_ism.h >> @@ -42,6 +42,7 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int buf_size, >>   void smc_ism_get_system_eid(u8 **eid); >>   u16 smc_ism_get_chid(struct smcd_dev *dev); >>   bool smc_ism_is_v2_capable(void); >> +void smc_ism_check_v2_capable(struct smcd_dev *dev); >>   int smc_ism_init(void); >>   void smc_ism_exit(void); >>   int smcd_nl_get_device(struct sk_buff *skb, struct netlink_callback *cb);