From patchwork Thu Oct 13 20:13:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brenden Blanco X-Patchwork-Id: 681952 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sw24G1fvtz9sQw for ; Fri, 14 Oct 2016 07:13:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=plumgrid-com.20150623.gappssmtp.com header.i=@plumgrid-com.20150623.gappssmtp.com header.b=0kD1XyNk; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753644AbcJMUNd (ORCPT ); Thu, 13 Oct 2016 16:13:33 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:34793 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752883AbcJMUNZ (ORCPT ); Thu, 13 Oct 2016 16:13:25 -0400 Received: by mail-pf0-f170.google.com with SMTP id r16so15784970pfg.1 for ; Thu, 13 Oct 2016 13:13:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plumgrid-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=PsZjjwNzP2b093zyQg2sVqpjTnq4DI5RaRnv+xLCucQ=; b=0kD1XyNkE5PowHGSSUT5ou82yHAyycy83i3SfyNDMO9MHKCz+qD80l7RmYEXQLraBZ 9LNOy3UFmi55YgHZ5Rv2EcVrUEhczMoV1qefy2Bg4rjYl3L/TZx2hGW93UPymsiObQFs en1PRUiI7PCJnr9SxgKMUT0ndS5TGfVvDnIIcCALq1btWwHiz5rBwkGIIsAx0LJNqnEh r49DnKo6uk5JEfcy5+xm3j2T3tR0jwlEEUZnXdDmCILlzLnFA6S3N4UgALr3jesdsK1e BjnH6cXvNFmUlYy18UK0lZgRB/pHkoEDheq4s2kBcSFDFrvOsJAAEf8ujJgJdMJ14BJf Zx0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PsZjjwNzP2b093zyQg2sVqpjTnq4DI5RaRnv+xLCucQ=; b=i0bTZjYUsidabsOXosqvwF2LgBBBnaAp3H9idoTrnPvq6AopJnOZVo3S/gWNv5SAeW zaTzZsFLps9vhPR9qpVzlegq/oHOM/NS9Pqs8mvGHVs/ULV2yfFIcigxYOrOSLfN/akp 07ivwpSc+MW5Y1nr+mgGjp2ySBtKmq6JZYH7U6QitK20Z9x8azIMs1MT1/Wgo7yhP2Ax mCMLMB2HgIZ+egk27TAYHWIoIM7Ey45f5ykBsSo6pSOoBU6ffQdrWlIwzR+tm5V0z33G 33eedj6bgyHXVh2/WLUF/qN/hE7Ci94TGqHmyO1XX585WHitW9qSe0WXb1gyco8XbU58 UqvQ== X-Gm-Message-State: AA6/9RkHC1z7BvqiKlBpdxTDvstQb6kPJzkGkSD8L4eRsCdEQO0tSmx3bNu97wJg4wFVW6a3 X-Received: by 10.98.159.70 with SMTP id g67mr12628575pfe.62.1476389604362; Thu, 13 Oct 2016 13:13:24 -0700 (PDT) Received: from iovisor-test1.plumgrid.com ([12.97.19.201]) by smtp.gmail.com with ESMTPSA id c135sm21675464pfc.28.2016.10.13.13.13.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Oct 2016 13:13:23 -0700 (PDT) From: Brenden Blanco To: davem@davemloft.net, netdev@vger.kernel.org Cc: Brenden Blanco , Alexei Starovoitov , Tariq Toukan , Or Gerlitz , Saeed Mahameed , Jesper Dangaard Brouer Subject: [PATCH net] net/mlx4_en: fixup xdp tx irq to match rx Date: Thu, 13 Oct 2016 13:13:11 -0700 Message-Id: <20161013201311.20844-1-bblanco@plumgrid.com> X-Mailer: git-send-email 2.9.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In cases where the number of tx rings is not a multiple of the number of rx rings, the tx completion event will be handled on a different core from the transmit and population of the ring. Races on the ring will lead to a double-free of the page, and possibly other corruption. The rings are initialized by default with a valid multiple of rings, based on the number of cpus, therefore an invalid configuration requires ethtool to change the ring layout. For instance 'ethtool -L eth0 rx 9 tx 8' will cause packets received on rx0, and XDP_TX'd to tx48, to be completed on cpu3 (48 % 9 == 3). Resolve this discrepancy by shifting the irq for the xdp tx queues to start again from 0, modulo rx_ring_num. Fixes: 9ecc2d86171a ("net/mlx4_en: add xdp forwarding and data write support") Reported-by: Jesper Dangaard Brouer Signed-off-by: Brenden Blanco --- drivers/net/ethernet/mellanox/mlx4/en_cq.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ethernet/mellanox/mlx4/en_cq.c index 132cea6..e3be7e4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c @@ -127,7 +127,15 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, /* For TX we use the same irq per ring we assigned for the RX */ struct mlx4_en_cq *rx_cq; - + int xdp_index; + + /* The xdp tx irq must align with the rx ring that forwards to + * it, so reindex these from 0. This should only happen when + * tx_ring_num is not a multiple of rx_ring_num. + */ + xdp_index = (priv->xdp_ring_num - priv->tx_ring_num) + cq_idx; + if (xdp_index >= 0) + cq_idx = xdp_index; cq_idx = cq_idx % priv->rx_ring_num; rx_cq = priv->rx_cq[cq_idx]; cq->vector = rx_cq->vector;