From patchwork Sun Aug 29 07:35:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 504242 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.0 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, 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 D3E7CC432BE for ; Sun, 29 Aug 2021 07:35:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5B7F60F39 for ; Sun, 29 Aug 2021 07:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234907AbhH2Hgj (ORCPT ); Sun, 29 Aug 2021 03:36:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234894AbhH2Hga (ORCPT ); Sun, 29 Aug 2021 03:36:30 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79791C0617AE for ; Sun, 29 Aug 2021 00:35:37 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id i21so23797509ejd.2 for ; Sun, 29 Aug 2021 00:35:37 -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=/8Hy0GpQCnGXthQ0fLz5hZ9IOmv5qOwO4qvYESCzXus=; b=GeW2AcNE9YAKyCE5hhZQ2xIPTkpaz6+s01bH4igjXiFmJQYdCwNKDPRI3dsYS+hRDm RiNHtIJx8ja/y1PqACLjlI+atgUV+3EdH9BO9hE5v8RfIQqB1aghAH34oFSXHXwWA5+y iz55yTyceOxE1d4gxUM9euuqT8y6XLGm7kiIY= 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=/8Hy0GpQCnGXthQ0fLz5hZ9IOmv5qOwO4qvYESCzXus=; b=AfbDSUanXAycoDgadhHYRlVNy1f+25Ly/T5Y1hnLELdQWJ4blXTIUvFxCZBr25O5Np jNo2mgle27cGG5zk5/OBBcLoghqt1AcTu3V/XGzEBq0MUvMbhpMBVNaIox03QYmT7iQY x4htgIh3kns/9Pu+JxsCsiL4f+UtKbmWmXmHAxK5gLBYPZzmLWsUGPZoFdA4foo4NTSj DRZiwuW6LqdVnEpI2RyUeU7lKfzzJ9v55nRY3IQQEKCODWv0VzVKjogqOearSUyteINe UAk5hLbKinZyIVuANNQb30ELzXbhzn0WSibAKjbA4jfzRRZBknyAcQmjnXQv3zNW6vAp sBYQ== X-Gm-Message-State: AOAM530CkysfP22latSEjDCXUTCQfuZD70pMZOSSM8ntIDSRr8Y0d9zs OntqjqsczXUKLusFQNFlnsj3MQ== X-Google-Smtp-Source: ABdhPJweFX9Xgv+LdjlwK3NY5kHPcVSYHqPWyEXj2T65+/1GI8gIrqXb2JR1ZoNT9kQFt1eTAJde6g== X-Received: by 2002:a17:907:960b:: with SMTP id gb11mr14399854ejc.517.1630222535667; Sun, 29 Aug 2021 00:35:35 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id dy7sm984007edb.38.2021.08.29.00.35.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Aug 2021 00:35:35 -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 v2 08/11] bnxt_en: use link_lock instead of hwrm_cmd_lock to protect link_info Date: Sun, 29 Aug 2021 03:35:03 -0400 Message-Id: <1630222506-19532-9-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1630222506-19532-1-git-send-email-michael.chan@broadcom.com> References: <1630222506-19532-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;