Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4575651imu; Tue, 29 Jan 2019 04:05:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN4UKOTx/+DRCIj+rFEFKNWLMa/W2EUKTn3vZAlnat+dtrQFKqdbg4cCXS9AwT4wLuNp55u6 X-Received: by 2002:a17:902:9047:: with SMTP id w7mr25954940plz.270.1548763523290; Tue, 29 Jan 2019 04:05:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548763523; cv=none; d=google.com; s=arc-20160816; b=deD2Ihcpfb8V/sY8C5vDY2u/c+hLeOl57v5tfB1ZuDDNr+WZRsQpDQprWKyGmkOyqQ u9uLeQaTRjLI9WtJddiBQmLBiP+6zC3IktoqCFO90+gtX2zkwRdjkmvuJ6LJM9r5wI8w 4HZu8UQRBzuxFjKilv6KLcLtEdtEpA0+iJzPL3VKqozucFIZ2WtIu++upgjPpNlLFSvD uqrCsiqXulnML5YQ0ThVSsvAGXz+ccZcG6ivfKtQaH7sp4+gBquU96ZjfmIcv6PN8nxT eV9g3BoNfSibxkt38DLJLNKMX/iFJiQ+LJhIDVahGmcZ10tommzJCJM4yFXa1f2YJxpd idPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UArMOhZ0uuX2FfH0kMxJFesoxEkfEXvbzEA/ZnaOUo8=; b=VMiKEjsGhVGLJxol74cWrSr6cR5hW3xLEgS1LCz0e4jb05oZUapIrs4Up3S8C/5Egc RTdWUXiN2MfOXNeXGHQltWiRLWCXzllnEpQN8x4mXQ6lTNBKBYAjw5ib7by1NMIuCfM6 7M7+Sn83YiokU14pTzbJD6ix3N56tZsTTAQ4k+eBmu8uYQudqVP4D7/OLTA2bMk/V+ux xiRTXMf/KxDCB0GDBpb8cx4uJsUUTB6PhDLpd6L9kSrgwx8/pesP/RkIeuts4PrEbcXe 7K7Wg1VBVyTLjzRmgax9iZ90PUz1CFaw5bQRHM48kJXt9uKtA9Dnwaa5+BCRKJEVrnO5 6m3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LclsgPFr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66si35235719pfk.73.2019.01.29.04.05.07; Tue, 29 Jan 2019 04:05:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LclsgPFr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730145AbfA2Lmu (ORCPT + 99 others); Tue, 29 Jan 2019 06:42:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:60676 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730130AbfA2Lms (ORCPT ); Tue, 29 Jan 2019 06:42:48 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 97E7820857; Tue, 29 Jan 2019 11:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548762167; bh=I/baSjvT9WPxQf5cWTWvFDYXVJ6JLDnXfq0SnBAS8gI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LclsgPFrcCUHTm5Osrqs1pxTStcMofOG0Ean2YXNw/MAiFbnw2oMRhjG2t9juSunq hDW7Z0vq25kMU/peqq0fqoaVK8MGjTenCAWnvInlRHqHO4yxsFdvynP9Vub67bn6Uo xoEJTzk6UUnuSnVHbff7gjo2tFyrMWNzlBRp0VIw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ido Schimmel , Semion Lisyansky , Jiri Pirko , "David S. Miller" Subject: [PATCH 4.19 014/103] mlxsw: pci: Ring CQs doorbell before RDQs Date: Tue, 29 Jan 2019 12:34:51 +0100 Message-Id: <20190129113200.380757705@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129113159.567154026@linuxfoundation.org> References: <20190129113159.567154026@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ido Schimmel When a packet should be trapped to the CPU the device consumes a WQE (work queue element) from an RDQ (receive descriptor queue) and copies the packet to the address specified in the WQE. The device then tries to post a CQE (completion queue element) that contains various metadata (e.g., ingress port) about the packet to a CQ (completion queue). In case the device managed to consume a WQE, but did not manage to post the corresponding CQE, it will get stuck. This unlikely situation can be triggered due to the scheme the driver is currently using to process CQEs. The driver will consume up to 512 CQEs at a time and after processing each corresponding WQE it will ring the RDQ's doorbell, letting the device know that a new WQE was posted for it to consume. Only after processing all the CQEs (up to 512), the driver will ring the CQ's doorbell, letting the device know that new ones can be posted. Fix this by having the driver ring the CQ's doorbell for every processed CQE, but before ringing the RDQ's doorbell. This guarantees that whenever we post a new WQE, there is a corresponding CQE available. Copy the currently processed CQE to prevent the device from overwriting it with a new CQE after ringing the doorbell. Note that the driver still arms the CQ only after processing all the pending CQEs, so that interrupts for this CQ will only be delivered after the driver finished its processing. Before commit 8404f6f2e8ed ("mlxsw: pci: Allow to use CQEs of version 1 and version 2") the issue was virtually impossible to trigger since the number of CQEs was twice the number of WQEs and the number of CQEs processed at a time was equal to the number of available WQEs. Fixes: 8404f6f2e8ed ("mlxsw: pci: Allow to use CQEs of version 1 and version 2") Signed-off-by: Ido Schimmel Reported-by: Semion Lisyansky Tested-by: Semion Lisyansky Acked-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlxsw/pci.c | 12 +++++++----- drivers/net/ethernet/mellanox/mlxsw/pci_hw.h | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) --- a/drivers/net/ethernet/mellanox/mlxsw/pci.c +++ b/drivers/net/ethernet/mellanox/mlxsw/pci.c @@ -604,29 +604,31 @@ static void mlxsw_pci_cq_tasklet(unsigne u16 wqe_counter = mlxsw_pci_cqe_wqe_counter_get(cqe); u8 sendq = mlxsw_pci_cqe_sr_get(q->u.cq.v, cqe); u8 dqn = mlxsw_pci_cqe_dqn_get(q->u.cq.v, cqe); + char ncqe[MLXSW_PCI_CQE_SIZE_MAX]; + + memcpy(ncqe, cqe, q->elem_size); + mlxsw_pci_queue_doorbell_consumer_ring(mlxsw_pci, q); if (sendq) { struct mlxsw_pci_queue *sdq; sdq = mlxsw_pci_sdq_get(mlxsw_pci, dqn); mlxsw_pci_cqe_sdq_handle(mlxsw_pci, sdq, - wqe_counter, cqe); + wqe_counter, ncqe); q->u.cq.comp_sdq_count++; } else { struct mlxsw_pci_queue *rdq; rdq = mlxsw_pci_rdq_get(mlxsw_pci, dqn); mlxsw_pci_cqe_rdq_handle(mlxsw_pci, rdq, - wqe_counter, q->u.cq.v, cqe); + wqe_counter, q->u.cq.v, ncqe); q->u.cq.comp_rdq_count++; } if (++items == credits) break; } - if (items) { - mlxsw_pci_queue_doorbell_consumer_ring(mlxsw_pci, q); + if (items) mlxsw_pci_queue_doorbell_arm_consumer_ring(mlxsw_pci, q); - } } static u16 mlxsw_pci_cq_elem_count(const struct mlxsw_pci_queue *q) --- a/drivers/net/ethernet/mellanox/mlxsw/pci_hw.h +++ b/drivers/net/ethernet/mellanox/mlxsw/pci_hw.h @@ -53,6 +53,7 @@ #define MLXSW_PCI_WQE_SIZE 32 /* 32 bytes per element */ #define MLXSW_PCI_CQE01_SIZE 16 /* 16 bytes per element */ #define MLXSW_PCI_CQE2_SIZE 32 /* 32 bytes per element */ +#define MLXSW_PCI_CQE_SIZE_MAX MLXSW_PCI_CQE2_SIZE #define MLXSW_PCI_EQE_SIZE 16 /* 16 bytes per element */ #define MLXSW_PCI_WQE_COUNT (MLXSW_PCI_AQ_SIZE / MLXSW_PCI_WQE_SIZE) #define MLXSW_PCI_CQE01_COUNT (MLXSW_PCI_AQ_SIZE / MLXSW_PCI_CQE01_SIZE)