From patchwork Sat Aug 28 21:58:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 503948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19F0AC4320A for ; Sat, 28 Aug 2021 21:59:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE48160462 for ; Sat, 28 Aug 2021 21:59:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232831AbhH1WAB (ORCPT ); Sat, 28 Aug 2021 18:00:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232544AbhH1V75 (ORCPT ); Sat, 28 Aug 2021 17:59:57 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBB13C0617AE for ; Sat, 28 Aug 2021 14:59:04 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id d6so15456640edt.7 for ; Sat, 28 Aug 2021 14:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zztbr2RT08h2Gg3ZRLJOpdvZh0byniSaDhTvmmU6fp8=; b=eJe1d3HqlSqvH9mnzR1V5D2bQrI44+SshAM+y83hVcE6AHK/ltPH13c7PIQin7xZc2 JSu1wFKALsqMF0qgy8Ce+55vY55lHHHB+k8thz5Enw5r6vntMzu1Dj4nvd+lwG9Yj8tn TJPod0+6lOb3csZbyMjaamBgzI9SfjBOoWoWk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zztbr2RT08h2Gg3ZRLJOpdvZh0byniSaDhTvmmU6fp8=; b=PGEwlcdg8EOCMxO8L3J0iNrXd3wbUdLNGG2SUwOfSi/kDRfRvDZ6rPwWtiO9DYjWsT +e6niDdFItFBQ4OI/BTrDYb7W+McyzEi1xx3G8qD9mHpxqDPVW+ku+IJqBS6UpUm1LWB Kea8r7CIUU0hpMguL7XhSzPXXEzzwz3BC1pYLn4Xjm5SFbvlDKH0WOMhsH+lat6z+hUk crY1XPP950mUvupSBTN11WnsTqoLVFp/kapx6S0diMCJswo3jC4ifNOcAHXmOr7sEUBo 2u/xoeJiSuUxROY0JxS9g1wRiQm194JA2yc2SogvUDu8kohg6/0v9yWl+Yfq1hNwqVdb 6ABg== X-Gm-Message-State: AOAM531eOtUtyDds/9I8DBAbpDyLLuM/nqdd06LlNO+5AwEScB387sGj xSqgKKnJfKwF0s8RyS5VPK8RPA== X-Google-Smtp-Source: ABdhPJwDMk4PLtBdOKSBqa8LL1R8qxjmGMuBZLp2T2GE/Y0f4beMdWuO9gtE1Ovfotm31wbh3Ac48Q== X-Received: by 2002:aa7:c799:: with SMTP id n25mr16067830eds.16.1630187943132; Sat, 28 Aug 2021 14:59:03 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id cf11sm5361239edb.65.2021.08.28.14.59.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Aug 2021 14:59:02 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, edwin.peer@broadcom.com, gospo@broadcom.com Subject: [PATCH net-next 08/11] bnxt_en: use link_lock instead of hwrm_cmd_lock to protect link_info Date: Sat, 28 Aug 2021 17:58:27 -0400 Message-Id: <1630187910-22252-9-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1630187910-22252-1-git-send-email-michael.chan@broadcom.com> References: <1630187910-22252-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Edwin Peer We currently use the hwrm_cmd_lock to serialize the update of the firmware's link status response data and the copying of link status data to the VF. This won't work when we update the firmware message APIs, so we use the link_lock mutex instead. All link_info data should be updated under the link_lock mutex. Also add link_lock to functions that touch link_info in __bnxt_open_nic() and bnxt_probe_phy(). The locking is probably not strictly necessary during probe, but it's more consistent. Signed-off-by: Edwin Peer Reviewed-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 +++++ drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 23486f382b91..b9aa56cc10d2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10008,7 +10008,9 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) bnxt_tx_enable(bp); mod_timer(&bp->timer, jiffies + bp->current_interval); /* Poll link status and check for SFP+ module status */ + mutex_lock(&bp->link_lock); bnxt_get_port_module_status(bp); + mutex_unlock(&bp->link_lock); /* VF-reps may need to be re-opened after the PF is re-opened */ if (BNXT_PF(bp)) @@ -12599,8 +12601,10 @@ static int bnxt_probe_phy(struct bnxt *bp, bool fw_dflt) if (!fw_dflt) return 0; + mutex_lock(&bp->link_lock); rc = bnxt_update_link(bp, false); if (rc) { + mutex_unlock(&bp->link_lock); netdev_err(bp->dev, "Probe phy can't update link (rc: %x)\n", rc); return rc; @@ -12613,6 +12617,7 @@ static int bnxt_probe_phy(struct bnxt *bp, bool fw_dflt) link_info->support_auto_speeds = link_info->support_speeds; bnxt_init_ethtool_link_settings(bp); + mutex_unlock(&bp->link_lock); return 0; } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c index 7b0e308e44c2..07e8e9f657e4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c @@ -1032,10 +1032,10 @@ static int bnxt_vf_set_link(struct bnxt *bp, struct bnxt_vf_info *vf) phy_qcfg_req = (struct hwrm_port_phy_qcfg_input *)vf->hwrm_cmd_req_addr; - mutex_lock(&bp->hwrm_cmd_lock); + mutex_lock(&bp->link_lock); memcpy(&phy_qcfg_resp, &bp->link_info.phy_qcfg_resp, sizeof(phy_qcfg_resp)); - mutex_unlock(&bp->hwrm_cmd_lock); + mutex_unlock(&bp->link_lock); phy_qcfg_resp.resp_len = cpu_to_le16(sizeof(phy_qcfg_resp)); phy_qcfg_resp.seq_id = phy_qcfg_req->seq_id; phy_qcfg_resp.valid = 1;