From nobody Thu Jan 13 07:26:27 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E5B46194B5E4; Thu, 13 Jan 2022 07:26:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JZGFb66Cxz4l0P; Thu, 13 Jan 2022 07:26:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642058787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+jFOby+w3RWcL+Wtj7vwSzliHDkojpbeL3/l1W2s20s=; b=XmtD+odSWB+1i2x3eu14VE7WGdu2kuQbtdyUNNfz842sDpwQagwjRVagAezyGStRHugW/g 08W0iD0xA42b3kGztOLvVrx6DDrZzyfx1RnBIUOACPSBrl+kv57cdAitXLdbKYXqmPEv5+ 6CLNp2tvqMT0afMDHSzzYrLre2aansgfgY3hrzs4raINYulq5Po/GekSoB3/5RxsJJIQVJ 9LBtWQ3kEq93O4slDR0aEmrUP3FXw6aXZEW84CtAfy+0XVdnipwYsAaHYlHuoA1oZYwMQx u+erV4lSkTNl9GcHooA53uIqRDoN4TvZAj4r9NdQTU15xuu1SnLJGmia0/4WqA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B16A71C3FE; Thu, 13 Jan 2022 07:26:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20D7QRwX009229; Thu, 13 Jan 2022 07:26:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20D7QRLR009228; Thu, 13 Jan 2022 07:26:27 GMT (envelope-from git) Date: Thu, 13 Jan 2022 07:26:27 GMT Message-Id: <202201130726.20D7QRLR009228@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Wei Hu Subject: git: 027d0c1c043a - main - mana: fix misc minor handlding issues when error happens. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: whu X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 027d0c1c043ab274f00e51b826c0d4ebea219623 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642058787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+jFOby+w3RWcL+Wtj7vwSzliHDkojpbeL3/l1W2s20s=; b=xQUhF4reaX6WzS16jEPq/2RMsTYRaSCE9LQB6gT4ldJ5xJk/CSK5bc0swlPRVbLo43h4Ba s25lCnlDJQRP8Akm6gqZLIRlP7CS2QfoYgaKawDu31U1nALGRPw9+rnFmZrf7Ur+A933/l TdnZZiY1tjOswdkTqRhtn3umLuVOmqVw3awzbyBMn1SfN+Cd6aj7GYJHGcM7PdyvbM46JD 4O42tMzErhhm3YXU5AQlvg/AwBltEKClrmKCW60CdhHSiNnuCTK7CyzhofmtxMWEiNn8rM 0RbK9dMc3KWn5RkPJh+yHjH9nCGT48ALLO6OLpVyO67rgC4BqwcDsZ0AQ8u8SA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642058787; a=rsa-sha256; cv=none; b=g7CxF7+N4ie0lDwzfXH7pXSz0urN1F3AXroDw6KIzHp5ntfI2QjH5RyFb8OcEUSD9Wcbxr 486q50t4adZSbkgl9hGYpdowfl+2YWL1bH6V3fzLmD+b+Q/v4biz7ac2W0/nrMVjfYQ0ZP FNO41iYSufMxBRnUZZ4PoozqM6hycROTVxT6u6nWlV1nZDYePAs/xy+qy/6KkIMj+tL3FT EJdwhMYjY91SI3G1O/KawGXBqecfR8G+TwzmcMPjuceqi5mNHJa9QHKtuoCjOEZ43K9huj U0RKY+0S/LXyICXjzYRXErf0UtcEsLCNIZQuMg0zS1sqkKnUk1U5lS5s/hpzUQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by whu: URL: https://cgit.FreeBSD.org/src/commit/?id=027d0c1c043ab274f00e51b826c0d4ebea219623 commit 027d0c1c043ab274f00e51b826c0d4ebea219623 Author: Wei Hu AuthorDate: 2022-01-13 06:17:31 +0000 Commit: Wei Hu CommitDate: 2022-01-13 07:22:21 +0000 mana: fix misc minor handlding issues when error happens. - In mana_create_txq(), if test fails we must free some resources as in all the other handling paths of this function. - In mana_gd_read_cqe(), add warning log in case of CQE read overflow, instead of failing silently. - Fix error handling in mana_create_rxq() when cq->gdma_id >= gc->max_num_cqs. - In mana_init_port(), use the correct port index rather than 0. - In mana_hwc_create_wq(), If allocating the DMA buffer fails, mana_hwc_destroy_wq was called without previously storing the pointer to the queue. In order to avoid leaking the pointer to the queue, store it as soon as it is allocated. MFC after: 2 weeks Sponsored by: Microsoft --- sys/dev/mana/gdma_main.c | 6 +++++- sys/dev/mana/hw_channel.c | 10 +++++----- sys/dev/mana/mana_en.c | 10 +++++++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/sys/dev/mana/gdma_main.c b/sys/dev/mana/gdma_main.c index b879695825b1..aa5d5fd5b507 100644 --- a/sys/dev/mana/gdma_main.c +++ b/sys/dev/mana/gdma_main.c @@ -1359,8 +1359,12 @@ mana_gd_read_cqe(struct gdma_queue *cq, struct gdma_comp *comp) new_bits = (cq->head / num_cqe) & GDMA_CQE_OWNER_MASK; /* Return -1 if overflow detected. */ - if (owner_bits != new_bits) + if (owner_bits != new_bits) { + mana_warn(NULL, + "overflow detected! owner_bits %u != new_bits %u\n", + owner_bits, new_bits); return -1; + } comp->wq_num = cqe->cqe_info.wq_num; comp->is_sq = cqe->cqe_info.is_sq; diff --git a/sys/dev/mana/hw_channel.c b/sys/dev/mana/hw_channel.c index 16b644d6c6b7..dbb5b54d9ad1 100644 --- a/sys/dev/mana/hw_channel.c +++ b/sys/dev/mana/hw_channel.c @@ -569,16 +569,16 @@ mana_hwc_create_wq(struct hw_channel_context *hwc, if (err) goto out; - err = mana_hwc_alloc_dma_buf(hwc, q_depth, max_msg_size, - &hwc_wq->msg_buf); - if (err) - goto out; - hwc_wq->hwc = hwc; hwc_wq->gdma_wq = queue; hwc_wq->queue_depth = q_depth; hwc_wq->hwc_cq = hwc_cq; + err = mana_hwc_alloc_dma_buf(hwc, q_depth, max_msg_size, + &hwc_wq->msg_buf); + if (err) + goto out; + *hwc_wq_ptr = hwc_wq; return 0; out: diff --git a/sys/dev/mana/mana_en.c b/sys/dev/mana/mana_en.c index e57a2622d09f..bba6e8a4aeb5 100644 --- a/sys/dev/mana/mana_en.c +++ b/sys/dev/mana/mana_en.c @@ -1935,7 +1935,8 @@ mana_create_txq(struct mana_port_context *apc, struct ifnet *net) if (cq->gdma_id >= gc->max_num_cqs) { if_printf(net, "CQ id %u too large.\n", cq->gdma_id); - return EINVAL; + err = EINVAL; + goto out; } gc->cq_table[cq->gdma_id] = cq->gdma_cq; @@ -2249,8 +2250,10 @@ mana_create_rxq(struct mana_port_context *apc, uint32_t rxq_idx, if (err) goto out; - if (cq->gdma_id >= gc->max_num_cqs) + if (cq->gdma_id >= gc->max_num_cqs) { + err = EINVAL; goto out; + } gc->cq_table[cq->gdma_id] = cq->gdma_cq; @@ -2393,7 +2396,8 @@ mana_init_port(struct ifnet *ndev) err = mana_query_vport_cfg(apc, port_idx, &max_txq, &max_rxq, &num_indirect_entries); if (err) { - if_printf(ndev, "Failed to query info for vPort 0\n"); + if_printf(ndev, "Failed to query info for vPort %d\n", + port_idx); goto reset_apc; }