From nobody Mon Nov 25 22:21:18 2024 Received: from mail-pj1-f98.google.com (mail-pj1-f98.google.com [209.85.216.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D72B1CEE8D for ; Wed, 23 Oct 2024 20:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716704; cv=none; b=lO52G/535DmIT1oE+WdXDPN0Xh+YspCR8S0QNZ8faL5FgBShQK54E9e2bQgb5mf1sEaQNerdEOiScnRReIkTK9jkGu3kVkGVgJOvvZMQ2CAyfw9QSgh5K0Z+66XWs3M6LSEwTtv3moGvDCD+mQPIZ7uzYzxyuLZWsdZJfSA+JBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729716704; c=relaxed/simple; bh=K44ATCiMDHxMTMJcyBAwfGkIfgGnFaUTSMZ5dOBioco=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=tSmHk4a9lQnlN5I9T7iLxnnLxn0np5so/pWnRh2X+e1PCBSbBs27JSt55aEngTjZ9SYYv8EIAbrf4hOLxopW8bd9veYCqLe5BolCQojK82WBBt32BZ7idOFGskolOUDt6F23RBJwfH44lNcGm8WXV1qxLTXEt+3Ns2GU15xDruo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=Z66+ohz6; arc=none smtp.client-ip=209.85.216.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="Z66+ohz6" Received: by mail-pj1-f98.google.com with SMTP id 98e67ed59e1d1-2e2da8529e1so40003a91.1 for ; Wed, 23 Oct 2024 13:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1729716702; x=1730321502; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vCyXfoKZLYIrM6bHNOmey4+JbsNLY/BGPRNE02WxQwo=; b=Z66+ohz6/PuKBA4Cw1XCx8sMFctDfz66PzgpeffsEO3CzcUL9ZkvouWpft+AHyiX7F WuLVkaGqWI+opb2qABPmJHWUwqIYam3XtOhZha+E9Bky+c89a+l7+ePXIW0iZx5sJ9hL /LLEDDA5D5td8ppzDr4XLaJJeAq0P67HS/dJazSTASsQH6KN2Dp042ctaXgsHXGN1ioP EMKrsZvzlPLwSmjqNA/aGtTFD0Z5mIfX6N5mmfJiwb9RCZyak4N5teZ5kOI6hj67hCb+ /oZEtVUV3kqej9ga7M5jki2LzyaSe1ai22s5PskBd0KmuXEjb8tt5lL+Za5m1eclkT3G oL+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729716702; x=1730321502; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vCyXfoKZLYIrM6bHNOmey4+JbsNLY/BGPRNE02WxQwo=; b=EEWp3KXsjUFJ79jAJFV56nKWvwwnMFkvveeBBkm3fXLkZ5r7tSvMZl/PTM/Qgs4ML5 M1KswyoJDegaIta3Qut928plOdWQ+jEI704t05d8aryzuuLP/zxi0VQsFpDtDajEoybj ov7wbhhplkf7ExifAwTQV5lFNtclZE1iwYeF6Vfi8lLVTcchfDFb5eIrtAeX4bo+ojk7 yfVJHF739GFUCC6za6x1LNzv+/S65i1nUefGcck7/UoWr9Fz8tAszN7dThS/L9bnEZFc 1+42JBS8/aIkeEhUwTviv2f5AI4/Wty4G4Z29++GZpBSW4VsX1aEknJm+X/PRbzRJ4C1 GJrg== X-Forwarded-Encrypted: i=1; AJvYcCWiI5L79lHtp8zX+dcb7rnDhHHCrliwl65eK2Uvi9Q3xqmbh/iqbqHRRujZqdbtrfck30MU3ZGjsUR41LI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9uU04i/DsFLimjIX5K4SKZNzvMG8QxIEm6Y5D3QSG2gL2jI0i HbrFjbGfw1Dw91sixhm9Vhtg16hGCjFwzA2duwmR3JKFUSU1yF+stke4jQ3w/JOHQq/16CoxgEk fpdzGDaT0E5qqMhvjSmB30YMP3akTJIwzJ0Sy85zkAxZVOR85 X-Google-Smtp-Source: AGHT+IG35rzOCpF6xzICIlXnd2xKWIdeRqdxmgfplqytKRI7gARk7EO/TkF1EVCs0mtdYwpJbkfTYQSa4jYI X-Received: by 2002:a17:903:32cc:b0:20c:85dc:6630 with SMTP id d9443c01a7336-20fa9deb651mr23890985ad.1.1729716701633; Wed, 23 Oct 2024 13:51:41 -0700 (PDT) Received: from c7-smtp-2023.dev.purestorage.com ([2620:125:9017:12:36:3:5:0]) by smtp-relay.gmail.com with ESMTPS id d9443c01a7336-20e7f0dd5c7sm2620325ad.54.2024.10.23.13.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 13:51:41 -0700 (PDT) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.7.70.37]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 3B88D3400B6; Wed, 23 Oct 2024 14:51:40 -0600 (MDT) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 2D9E7E40BE0; Wed, 23 Oct 2024 14:51:40 -0600 (MDT) From: Caleb Sander Mateos To: Saeed Mahameed , Leon Romanovsky , Tariq Toukan , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Caleb Sander Mateos , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] mlx5: simplify EQ interrupt polling logic Date: Wed, 23 Oct 2024 14:51:12 -0600 Message-ID: <20241023205113.255866-1-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use a while loop in mlx5_eq_comp_int() and mlx5_eq_async_int() to clarify the EQE polling logic. This consolidates the next_eqe_sw() calls for the first and subequent iterations. It also avoids a goto. Turn the num_eqes < MLX5_EQ_POLLING_BUDGET check into a break condition. Signed-off-by: Caleb Sander Mateos Reviewed-by: Simon Horman Reviewed-by: Tariq Toukan --- drivers/net/ethernet/mellanox/mlx5/core/eq.c | 22 +++++++------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/eth= ernet/mellanox/mlx5/core/eq.c index 68cb86b37e56..859dcf09b770 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c @@ -114,15 +114,11 @@ static int mlx5_eq_comp_int(struct notifier_block *nb, struct mlx5_eq *eq =3D &eq_comp->core; struct mlx5_eqe *eqe; int num_eqes =3D 0; u32 cqn =3D -1; =20 - eqe =3D next_eqe_sw(eq); - if (!eqe) - goto out; - - do { + while ((eqe =3D next_eqe_sw(eq))) { struct mlx5_core_cq *cq; =20 /* Make sure we read EQ entry contents after we've * checked the ownership bit. */ @@ -140,13 +136,14 @@ static int mlx5_eq_comp_int(struct notifier_block *nb, "Completion event for bogus CQ 0x%x\n", cqn); } =20 ++eq->cons_index; =20 - } while ((++num_eqes < MLX5_EQ_POLLING_BUDGET) && (eqe =3D next_eqe_sw(eq= ))); + if (++num_eqes >=3D MLX5_EQ_POLLING_BUDGET) + break; + } =20 -out: eq_update_ci(eq, 1); =20 if (cqn !=3D -1) tasklet_schedule(&eq_comp->tasklet_ctx.task); =20 @@ -213,15 +210,11 @@ static int mlx5_eq_async_int(struct notifier_block *n= b, eqt =3D dev->priv.eq_table; =20 recovery =3D action =3D=3D ASYNC_EQ_RECOVER; mlx5_eq_async_int_lock(eq_async, recovery, &flags); =20 - eqe =3D next_eqe_sw(eq); - if (!eqe) - goto out; - - do { + while ((eqe =3D next_eqe_sw(eq))) { /* * Make sure we read EQ entry contents after we've * checked the ownership bit. */ dma_rmb(); @@ -229,13 +222,14 @@ static int mlx5_eq_async_int(struct notifier_block *n= b, atomic_notifier_call_chain(&eqt->nh[eqe->type], eqe->type, eqe); atomic_notifier_call_chain(&eqt->nh[MLX5_EVENT_TYPE_NOTIFY_ANY], eqe->ty= pe, eqe); =20 ++eq->cons_index; =20 - } while ((++num_eqes < MLX5_EQ_POLLING_BUDGET) && (eqe =3D next_eqe_sw(eq= ))); + if (++num_eqes >=3D MLX5_EQ_POLLING_BUDGET) + break; + } =20 -out: eq_update_ci(eq, 1); mlx5_eq_async_int_unlock(eq_async, recovery, &flags); =20 return unlikely(recovery) ? num_eqes : 0; } --=20 2.45.2