From patchwork Fri Jun 16 06:17:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kashyap Desai X-Patchwork-Id: 13282012 X-Patchwork-Delegate: jgg@ziepe.ca 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 632D9EB64D7 for ; Fri, 16 Jun 2023 06:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbjFPGTg (ORCPT ); Fri, 16 Jun 2023 02:19:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231727AbjFPGTd (ORCPT ); Fri, 16 Jun 2023 02:19:33 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A7B710E9 for ; Thu, 15 Jun 2023 23:19:33 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-666669bb882so450535b3a.1 for ; Thu, 15 Jun 2023 23:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1686896372; x=1689488372; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=uXPiL1PAF4V7Ybxk1Vbr8Vy8WM9X5iVchsoZ4C341tk=; b=aGIf4eRu61eF2wT+QGdNLOb/txjq7DfYGtOVdZ4bQx1qqRjSaDAsQ9NTbK++3s8iyg kB2GTxoP8kIvdYt68WO19bbGxtGIMy86q9qA3TVZsxZkoQEnXGCqBzTb4KmisheOZPg4 4J8sLpGJ55ihisqSrdKvWg1uXkj21yv3LxtqE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686896372; x=1689488372; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uXPiL1PAF4V7Ybxk1Vbr8Vy8WM9X5iVchsoZ4C341tk=; b=CmZzWqseOSh7Q1M1vz4jpgqfWxA58lOv7Rh6ibAs3cWX5Ybb5d8jr9m6fxYdxS8vS7 +n914uNgxemhD+qmrtMSy+JUnzJv/NKuxigdlvljAO+VOgXluEOvrlHlwNuaglea4L1o ybBiloQ3BLBSlbU/psAafTicB4WX2ptn/ptJqh6Q0styO172OMTD57Eu/uyixpDToTau pJqnNNpz3f8GU9+0rZPza8nE2RqitoQOenNqaM6dzqKQqhRcLXwuBhLfkq8bCyEur5Dz IL/8TIqq7b+M+RJHmTa5m0WzEwiQY2eSvsKhm68KdGq+Uoy0FgJYcWB3cRKR8CYHiU3H 94ww== X-Gm-Message-State: AC+VfDzx/v9iVIGkk/q8esrCYpNg0Ncgwx9/WDU4dt7fJ/Vw4z6vOjsU RQ3KLx7wRMGMT7TSEw3GFrIGDt5rpw0KhU8Y8Cac3wmL77iG79b/fIoB10yKV7Lgsui8/pWszIi mpwLY1p9oqYfnR3wx3m8bd1hb8gElieNpbvZyo9Y39tjrjpJ3Y6d97CEoZ8l6C4VItkMrHwCjaT GLuR1ZcdUkqWE= X-Google-Smtp-Source: ACHHUZ6ddxXgkYuwF0qk/mcZdqJod8A72SV0cg2SOjLgJ5VAAd3P2U8nkR/vBXsF2WKFhWpWGJx+yQ== X-Received: by 2002:a05:6a00:14ca:b0:64d:42f6:4c7b with SMTP id w10-20020a056a0014ca00b0064d42f64c7bmr1334543pfu.27.1686896371758; Thu, 15 Jun 2023 23:19:31 -0700 (PDT) Received: from amd_smc.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c9-20020a62e809000000b0064d48d98260sm12878506pfi.156.2023.06.15.23.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 23:19:31 -0700 (PDT) From: Kashyap Desai To: linux-rdma@vger.kernel.org Cc: dan.carpenter@linaro.org, Kashyap Desai , Selvin Xavier Subject: [PATCH for-next 2/2] RDMA/bnxt_re: refactor code around bnxt_qplib_map_rc Date: Fri, 16 Jun 2023 11:47:00 +0530 Message-Id: <20230616061700.741769-2-kashyap.desai@broadcom.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230616061700.741769-1-kashyap.desai@broadcom.com> References: <20230616061700.741769-1-kashyap.desai@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Updated function comment of bnxt_qplib_map_rc Removed intermediate return value ENXIO and directly called bnxt_qplib_map_rc from __send_message_basic_sanity. Reported-by: Dan Carpenter Signed-off-by: Kashyap Desai Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c index 30c6e865d691..a8323054cfee 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_rcfw.c @@ -57,13 +57,20 @@ static void bnxt_qplib_service_creq(struct tasklet_struct *t); * bnxt_qplib_map_rc - map return type based on opcode * @opcode - roce slow path opcode * - * In some cases like firmware halt is detected, the driver is supposed to - * remap the error code of the timed out command. + * case #1 + * Firmware initiated error recovery is a safe state machine and + * driver can consider all the underlying rdma resources are free. + * In this state, it is safe to return success for opcodes related to + * destroying rdma resources (like destroy qp, destroy cq etc.). * - * It is not safe to assume hardware is really inactive so certain opcodes - * like destroy qp etc are not safe to be returned success, but this function - * will be called when FW already reports a timeout. This would be possible - * only when FW crashes and resets. This will clear all the HW resources. + * case #2 + * If driver detect potential firmware stall, it is not safe state machine + * and the driver can not consider all the underlying rdma resources are + * freed. + * In this state, it is not safe to return success for opcodes related to + * destroying rdma resources (like destroy qp, destroy cq etc.). + * + * Scope of this helper function is only for case #1. * * Returns: * 0 to communicate success to caller. @@ -418,7 +425,7 @@ static int __send_message_basic_sanity(struct bnxt_qplib_rcfw *rcfw, /* Prevent posting if f/w is not in a state to process */ if (test_bit(ERR_DEVICE_DETACHED, &rcfw->cmdq.flags)) - return -ENXIO; + return bnxt_qplib_map_rc(opcode); if (test_bit(FIRMWARE_STALL_DETECTED, &cmdq->flags)) return -ETIMEDOUT; @@ -488,7 +495,7 @@ static int __bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw, rc = __send_message_basic_sanity(rcfw, msg, opcode); if (rc) - return rc == -ENXIO ? bnxt_qplib_map_rc(opcode) : rc; + return rc; rc = __send_message(rcfw, msg); if (rc)