From patchwork Tue Jul 12 02:26:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12914470 X-Patchwork-Delegate: kuba@kernel.org 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 47E38CCA47B for ; Tue, 12 Jul 2022 02:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230005AbiGLC0n (ORCPT ); Mon, 11 Jul 2022 22:26:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229839AbiGLC0k (ORCPT ); Mon, 11 Jul 2022 22:26:40 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CC7732ECF for ; Mon, 11 Jul 2022 19:26:38 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id 73so6321508pgb.10 for ; Mon, 11 Jul 2022 19:26:38 -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=gaNcqhFMItPwOzeq7hJXrhcVLq/0CJ17yndwMXl7Ocs=; b=D1nNM/gIOy15tqeaADkzhqoSXJV0Q3H57o2jWriHvxCgAqK4wFw4mH3HrgwHkZZYLG CFTYcKTMjtdDeGqeFInB3KI6AZ6pwUOBM7TZW2NjdMu7FAQ/Tr576R06XUdbK/6AOXa0 KLhlAt4CLpBABEkcjf+Xiv2pq/7XHjp5EEsoQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gaNcqhFMItPwOzeq7hJXrhcVLq/0CJ17yndwMXl7Ocs=; b=K3tORV54V1lBc7qDgv1dHXJZqaTpefngjWw6FmZ04ocUL3RsFOHi1ceCYQ2BnM9Tnd EC7GBEhdm05f99Da+o5UTkonkgv6124ZdMi5Tp8h8D1xMM0PQ6yp5LsRms3tsLsEW9DR SvsLl8X4wf+OHHBAxbpsgh+b0P8m2OQCTID6FgZS3gUKLJz0Xif5YBbRGcnPS9Hv9Hlo ETOBV5j6nA6AXBYqnKepHIC0RsNUmmYRZg+GJTiDBX98WCeVYlT5XdpdU3CXOeeqRp2u P9aDuz3xxtCafvB86OhapQAvU7Q0ymrXNHVqQkExkQ3Rwef05XErgIsWnsDb56dxSgKv 8ZVw== X-Gm-Message-State: AJIora9GT+cQJUVo1puRglypni5XOH7agpifvLlAhiJrZBOJUTJwdamK yg4GtOtm20gB1WxPF+qQjPs6x06NryhX2lTj X-Google-Smtp-Source: AGRyM1sdhgWyaPb7wRDkZ/0K3RCAtLMzMweyDEwA8wWCxhk+khRsAojGwtiGH7o0kG8U8I0uZIoh4w== X-Received: by 2002:a63:ee10:0:b0:40d:7f37:77c4 with SMTP id e16-20020a63ee10000000b0040d7f3777c4mr17827689pgi.28.1657592797933; Mon, 11 Jul 2022 19:26:37 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id p4-20020a62d004000000b0052878f66f8asm5443049pfg.132.2022.07.11.19.26.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jul 2022 19:26:36 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com, Kashyap Desai Subject: [PATCH net 1/5] bnxt_en: reclaim max resources if sriov enable fails Date: Mon, 11 Jul 2022 22:26:14 -0400 Message-Id: <1657592778-12730-2-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1657592778-12730-1-git-send-email-michael.chan@broadcom.com> References: <1657592778-12730-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Kashyap Desai If bnxt_sriov_enable() fails after some resources have been reserved for the VFs, the current code is not unwinding properly and the reserved resources become unavailable afterwards. Fix it by properly unwinding with a call to bnxt_hwrm_func_qcaps() to reset all maximum resources. Also, add the missing bnxt_ulp_sriov_cfg() call to let the RDMA driver know to abort. Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.") Signed-off-by: Kashyap Desai Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 7 ++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 56b46b8206a7..7ba181ccaac2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -7790,7 +7790,7 @@ static void bnxt_hwrm_dbg_qcaps(struct bnxt *bp) static int bnxt_hwrm_queue_qportcfg(struct bnxt *bp); -static int bnxt_hwrm_func_qcaps(struct bnxt *bp) +int bnxt_hwrm_func_qcaps(struct bnxt *bp) { int rc; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index a1dca8c58f54..075c6206325c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2314,6 +2314,7 @@ int bnxt_cancel_reservations(struct bnxt *bp, bool fw_reset); int bnxt_hwrm_alloc_wol_fltr(struct bnxt *bp); int bnxt_hwrm_free_wol_fltr(struct bnxt *bp); int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all); +int bnxt_hwrm_func_qcaps(struct bnxt *bp); int bnxt_hwrm_fw_set_time(struct bnxt *); int bnxt_open_nic(struct bnxt *, bool, bool); int bnxt_half_open_nic(struct bnxt *bp); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c index ddf2f3963abe..a1a2c7a64fd5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c @@ -823,8 +823,10 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs) goto err_out2; rc = pci_enable_sriov(bp->pdev, *num_vfs); - if (rc) + if (rc) { + bnxt_ulp_sriov_cfg(bp, 0); goto err_out2; + } return 0; @@ -832,6 +834,9 @@ static int bnxt_sriov_enable(struct bnxt *bp, int *num_vfs) /* Free the resources reserved for various VF's */ bnxt_hwrm_func_vf_resource_free(bp, *num_vfs); + /* Restore the max resources */ + bnxt_hwrm_func_qcaps(bp); + err_out1: bnxt_free_vf_resources(bp);