From patchwork Fri Apr 7 12:23:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sai Krishna Gajula X-Patchwork-Id: 80775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp252639vqo; Fri, 7 Apr 2023 05:34:04 -0700 (PDT) X-Google-Smtp-Source: AKy350a7Z1YRCIKyunk/+MA+PYbjcdd9RD+2KhO3jOq3IgYgrRLikDyHa7m0StuP8GWwtOah7AiO X-Received: by 2002:a05:6a20:cf49:b0:d6:c92:9925 with SMTP id hz9-20020a056a20cf4900b000d60c929925mr2544387pzb.31.1680870843965; Fri, 07 Apr 2023 05:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680870843; cv=none; d=google.com; s=arc-20160816; b=UbF7D7JTfbKG0y+ApRI2uMigX9p6yBQZhXHtx5DoJnVSZQtQues1Fd6dWi7UP3bXCO SUqcyg9uAgGa3TerCwYEZ+hJdC5nTeAs7Mj5Y9nlrpUGvcpQrPXihBV7kg28GBFTwmvI xXVDYRKX1gSUc8DAXMlnsA4YiPf+gxoa95Bnrn9fYOSOJKWSsEU4k3WaLndzH2bSeX9U Vuwjs7nWUEO97KI1aMh6NbXccjKZWeKiWoxsg6p8jRx8qci3A+5LsuTqgfDQHllCIKYx PnAs34qgRfaQ9DWk75aq15VYBVsEp5nE5Zt8ZR7gMbrr42omPvI4s8iESKlYJBZcefEQ xGow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BlWiti7aiJ9pMybHjerR+p6XbcoliBYcRK+PVTNGv5s=; b=Yn7swjRk76etUjeBWNB6KDPTqijIiPdbcQ++1yDmLCDaHJWuMj07bQuAUNmZ53FGg8 su15uEUJQOG6o90HapRLEN34sdz1tjxPI0Q2Eq1VNC2X127sUcb2jxG7hntOt90QLaBG iIrmLPjZkd5yfoMq4MnItDNx9e/VVPy89bE05qCIlxCTuB6Tpbp73F2bsYgi7Tz0T4Zk Er0BhYybqQmcXA3uq5I2m6eFmmWnqFfOgbEjEpGbEc5y5QfO1FA/tD+l/Zpcs4sJH3eF 9g8At7F+QgG3RcnZscO6RmFsQvDexHXVV2gE7K7aJ60WvxcINe4jCva9O+oV0iVVamkH oB6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Fz5HXcGX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a1-20020a656401000000b0051322a9ea4dsi3356719pgv.180.2023.04.07.05.33.51; Fri, 07 Apr 2023 05:34:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Fz5HXcGX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240785AbjDGMZj (ORCPT + 99 others); Fri, 7 Apr 2023 08:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240756AbjDGMZ0 (ORCPT ); Fri, 7 Apr 2023 08:25:26 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2669BB8F; Fri, 7 Apr 2023 05:24:58 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 337Ax8Vw000813; Fri, 7 Apr 2023 05:24:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=BlWiti7aiJ9pMybHjerR+p6XbcoliBYcRK+PVTNGv5s=; b=Fz5HXcGXpHc8DrA3zKvJMAkh56ea2XPOBERNxvvoNxWuRstAqZpekdXOOnE76/mUCwav X7Rk879IMbFSykgctgmp14sQrqeVYNvH82U9152jxc9POARJYt1MGilN/vVNGZtPBCjf eFGWCdUA7dsi/zIT3dU2jdAv0KV0rl5sp18kyR6dZQrZh2JabpW+D1MEaWeL2zjsHQNX OZlL9z/fr0VOwfGslLT/USa6ophp+hPsHSS32HB0kIvTQAhIFwfz00ANFYvkugWrYvwn b02+uh65xJGJ6a13xW1WB3WxvLBhSJj/FwxMpgEUSEJ/bRGu/Rkyyhp2BYK3r7KLWxat DA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3pthvw88rd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 07 Apr 2023 05:24:28 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 7 Apr 2023 05:24:26 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Fri, 7 Apr 2023 05:24:26 -0700 Received: from hyd1425.marvell.com (unknown [10.29.37.83]) by maili.marvell.com (Postfix) with ESMTP id 261573F7060; Fri, 7 Apr 2023 05:24:21 -0700 (PDT) From: Sai Krishna To: , , , , , , , , , , , , CC: Sai Krishna Subject: [net PATCH v2 7/7] octeontx2-pf: Disable packet I/O for graceful exit Date: Fri, 7 Apr 2023 17:53:44 +0530 Message-ID: <20230407122344.4059-8-saikrishnag@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230407122344.4059-1-saikrishnag@marvell.com> References: <20230407122344.4059-1-saikrishnag@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 3AJZ7HCkVG9V2nFl585F94nz3U2EnWy_ X-Proofpoint-GUID: 3AJZ7HCkVG9V2nFl585F94nz3U2EnWy_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-07_08,2023-04-06_03,2023-02-09_01 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762520826109806102?= X-GMAIL-MSGID: =?utf-8?q?1762520826109806102?= From: Subbaraya Sundeep At the stage of enabling packet I/O in otx2_open, If mailbox timeout occurs then interface ends up in down state where as hardware packet I/O is enabled. Hence disable packet I/O also before bailing out. This patch also free the LMTST per cpu structure on teardown, if the lmt_info pointer is not NULL. Fixes: 1ea0166da050 ("octeontx2-pf: Fix the device state on error") Signed-off-by: Subbaraya Sundeep Signed-off-by: Sunil Kovvuri Goutham Signed-off-by: Sai Krishna --- drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 11 ++++++++++- drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 8 +++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c index 179433d0a54a..52a57d2493dc 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c @@ -1835,13 +1835,22 @@ int otx2_open(struct net_device *netdev) otx2_dmacflt_reinstall_flows(pf); err = otx2_rxtx_enable(pf, true); - if (err) + /* If a mbox communication error happens at this point then interface + * will end up in a state such that it is in down state but hardware + * mcam entries are enabled to receive the packets. Hence disable the + * packet I/O. + */ + if (err == EIO) + goto err_disable_rxtx; + else if (err) goto err_tx_stop_queues; otx2_do_set_rx_mode(pf); return 0; +err_disable_rxtx: + otx2_rxtx_enable(pf, false); err_tx_stop_queues: netif_tx_stop_all_queues(netdev); netif_carrier_off(netdev); diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c index ab126f8706c7..6ab4780f12fd 100644 --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c @@ -621,7 +621,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id) err = otx2vf_realloc_msix_vectors(vf); if (err) - goto err_mbox_destroy; + goto err_detach_rsrc; err = otx2_set_real_num_queues(netdev, qcount, qcount); if (err) @@ -709,7 +709,8 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id) err_ptp_destroy: otx2_ptp_destroy(vf); err_detach_rsrc: - free_percpu(vf->hw.lmt_info); + if (vf->hw.lmt_info) + free_percpu(vf->hw.lmt_info); if (test_bit(CN10K_LMTST, &vf->hw.cap_flag)) qmem_free(vf->dev, vf->dync_lmt); otx2_detach_resources(&vf->mbox); @@ -763,7 +764,8 @@ static void otx2vf_remove(struct pci_dev *pdev) otx2_shutdown_tc(vf); otx2vf_disable_mbox_intr(vf); otx2_detach_resources(&vf->mbox); - free_percpu(vf->hw.lmt_info); + if (vf->hw.lmt_info) + free_percpu(vf->hw.lmt_info); if (test_bit(CN10K_LMTST, &vf->hw.cap_flag)) qmem_free(vf->dev, vf->dync_lmt); otx2vf_vfaf_mbox_destroy(vf);