Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1052757pxv; Thu, 22 Jul 2021 21:00:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyY0r8KcIfD4oI53YToJd5/1nv1zxvsjvwLReZf2HvzK6x4WMJIc8l5u4B5HJ9HgaqXaC3 X-Received: by 2002:a05:6402:1488:: with SMTP id e8mr3280016edv.341.1627012808507; Thu, 22 Jul 2021 21:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627012808; cv=none; d=google.com; s=arc-20160816; b=wXjrJU514jOlV4sMTQronRPklSuNCBFWBmQwRYnDT3QZYJrsdV4WznCMcK3y/MwAvW S4G82JWNSElAJPD/09wYKZ3PPbPVckVzwjd3yWEU0EOg8ojl1AfcEjqSynKa6PQBoymG Cr3UyJjYwoE4ueVzAD/pqJ+bWbVWJwIliCsvIy4tLb9Fx98g64rU49j7m9lKf7RN5jyK JBEcMaj4jfa/3ubC85v4U+LFrIgGea7V8nO1KBJ26LitTUe/Xb7DSD0TkeV0ocyHa2gN C9fDoMqRJejEtI5OWJEAMb4AAiVUhXEXsrCMViPRr1jx+sCbVIaJW5WMQe7RXLDZMxNt lkcg== 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=A6vAznSGDywpH2I16ynjdK7gwvH5MSgDjYV8sxBdxjY=; b=UxDrnNiT7x6G4wcHMsTTM2hgACfdc77w/qeFwGTVWJB8Z3LSSVx9SsA7Ra5OHC0+Ur 7F9GPfnF+1Rc0OtpTQaq0LOYj7q6hRK6Ofc3ktEI2+73NlnwoibgpOSZq9NRG1t84k2H DkClaI4gmjxJSfmz4voa4RlIkl0aTdxTdI3touUkS5JZxIl/nTAaIaq9aZ0CqkDNYhI6 NTuRRL7vpJEOqgKUGGyy+fQIdjKJI5239yi1KoEWwe04Vs0APoj/fobVxveP6nmcDfdW XZ29VTbVqyO3zAP7q6daBMdLG2TTfpcoL1MfZ1qAWJ9r7wLbjcvbbEhXTHHJJx6jSYjo A2cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tgj1wjOe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dy27si30490121edb.131.2021.07.22.20.59.43; Thu, 22 Jul 2021 21:00:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tgj1wjOe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233904AbhGWDRU (ORCPT + 99 others); Thu, 22 Jul 2021 23:17:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:37140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233720AbhGWDQ7 (ORCPT ); Thu, 22 Jul 2021 23:16:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6ACCC60ED7; Fri, 23 Jul 2021 03:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627012653; bh=XtMkpLHRLWK+zAm2LioxcOrroipcW2wChBIfA5L+Rxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tgj1wjOepIFw4XR4aHV/JdjjLjhmq+S6cO85G+W6ff6p4yf0ELohAAmDe/NqfpyDk prKlRu97Bi6daIt3TrPNXVbnExSvT6y9yTLALKwGfeZngFN5zV+M1qLEkmHttxlnBl WEpKC08Zq25c6wEB4KxBcEuqoZzVqkwov7TuRHsFai46qy5GoO6eg0PNUBYc9vLd6G zGlxsE+65cblYSYjelTyhf4Nmn4sSBbBfWXGpmxblscYm557soJggC/5xO3igpK4Oc Ycjz+CIQKVJ+kA99Z7nYtWbFGo6KHgNYp8Y6J3O3lxYurbLjhQaLm4TDshegzOkfs2 R8ITKTdxdhhjw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.13 09/19] sfc: ensure correct number of XDP queues Date: Thu, 22 Jul 2021 23:57:10 -0400 Message-Id: <20210723035721.531372-9-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210723035721.531372-1-sashal@kernel.org> References: <20210723035721.531372-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Íñigo Huguet [ Upstream commit 788bc000d4c2f25232db19ab3a0add0ba4e27671 ] Commit 99ba0ea616aa ("sfc: adjust efx->xdp_tx_queue_count with the real number of initialized queues") intended to fix a problem caused by a round up when calculating the number of XDP channels and queues. However, this was not the real problem. The real problem was that the number of XDP TX queues had been reduced to half in commit e26ca4b53582 ("sfc: reduce the number of requested xdp ev queues"), but the variable xdp_tx_queue_count had remained the same. Once the correct number of XDP TX queues is created again in the previous patch of this series, this also can be reverted since the error doesn't actually exist. Only in the case that there is a bug in the code we can have different values in xdp_queue_number and efx->xdp_tx_queue_count. Because of this, and per Edward Cree's suggestion, I add instead a WARN_ON to catch if it happens again in the future. Note that the number of allocated queues can be higher than the number of used ones due to the round up, as explained in the existing comment in the code. That's why we also have to stop increasing xdp_queue_number beyond efx->xdp_tx_queue_count. Signed-off-by: Íñigo Huguet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/sfc/efx_channels.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet/sfc/efx_channels.c index a3ca406a3561..bea0b27baf4b 100644 --- a/drivers/net/ethernet/sfc/efx_channels.c +++ b/drivers/net/ethernet/sfc/efx_channels.c @@ -891,18 +891,20 @@ int efx_set_channels(struct efx_nic *efx) if (efx_channel_is_xdp_tx(channel)) { efx_for_each_channel_tx_queue(tx_queue, channel) { tx_queue->queue = next_queue++; - netif_dbg(efx, drv, efx->net_dev, "Channel %u TXQ %u is XDP %u, HW %u\n", - channel->channel, tx_queue->label, - xdp_queue_number, tx_queue->queue); + /* We may have a few left-over XDP TX * queues owing to xdp_tx_queue_count * not dividing evenly by EFX_MAX_TXQ_PER_CHANNEL. * We still allocate and probe those * TXQs, but never use them. */ - if (xdp_queue_number < efx->xdp_tx_queue_count) + if (xdp_queue_number < efx->xdp_tx_queue_count) { + netif_dbg(efx, drv, efx->net_dev, "Channel %u TXQ %u is XDP %u, HW %u\n", + channel->channel, tx_queue->label, + xdp_queue_number, tx_queue->queue); efx->xdp_tx_queues[xdp_queue_number] = tx_queue; - xdp_queue_number++; + xdp_queue_number++; + } } } else { efx_for_each_channel_tx_queue(tx_queue, channel) { @@ -914,8 +916,7 @@ int efx_set_channels(struct efx_nic *efx) } } } - if (xdp_queue_number) - efx->xdp_tx_queue_count = xdp_queue_number; + WARN_ON(xdp_queue_number != efx->xdp_tx_queue_count); rc = netif_set_real_num_tx_queues(efx->net_dev, efx->n_tx_channels); if (rc) -- 2.30.2