From patchwork Tue Aug 18 15:40:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ganji Aravind X-Patchwork-Id: 1347074 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=chelsio.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BWFWt1JMrz9sPB for ; Wed, 19 Aug 2020 01:41:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726703AbgHRPln (ORCPT ); Tue, 18 Aug 2020 11:41:43 -0400 Received: from stargate.chelsio.com ([12.32.117.8]:36597 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726639AbgHRPl0 (ORCPT ); Tue, 18 Aug 2020 11:41:26 -0400 Received: from localhost (fedora32ganji.blr.asicdesigners.com [10.193.80.135]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id 07IFfDXT024132; Tue, 18 Aug 2020 08:41:13 -0700 From: Ganji Aravind To: netdev@vger.kernel.org Cc: davem@davemloft.net, vishal@chelsio.com, rahul.lakkireddy@chelsio.com Subject: [PATCH net 1/2] cxgb4: Fix work request size calculation for loopback test Date: Tue, 18 Aug 2020 21:10:57 +0530 Message-Id: <20200818154058.1770002-2-ganji.aravind@chelsio.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818154058.1770002-1-ganji.aravind@chelsio.com> References: <20200818154058.1770002-1-ganji.aravind@chelsio.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Work request used for sending loopback packet needs to add the firmware work request only once. So, fix by using correct structure size. Fixes: 7235ffae3d2c ("cxgb4: add loopback ethtool self-test") Signed-off-by: Ganji Aravind Reviewed-by: Jesse Brandeburg --- drivers/net/ethernet/chelsio/cxgb4/sge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index d2b587d1670a..7c9fe4bc235b 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c @@ -2553,8 +2553,8 @@ int cxgb4_selftest_lb_pkt(struct net_device *netdev) pkt_len = ETH_HLEN + sizeof(CXGB4_SELFTEST_LB_STR); - flits = DIV_ROUND_UP(pkt_len + sizeof(struct cpl_tx_pkt) + - sizeof(*wr), sizeof(__be64)); + flits = DIV_ROUND_UP(pkt_len + sizeof(*cpl) + sizeof(*wr), + sizeof(__be64)); ndesc = flits_to_desc(flits); lb = &pi->ethtool_lb; From patchwork Tue Aug 18 15:40:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ganji Aravind X-Patchwork-Id: 1347073 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=chelsio.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BWFWl4MZdz9sPB for ; Wed, 19 Aug 2020 01:41:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726870AbgHRPlc (ORCPT ); Tue, 18 Aug 2020 11:41:32 -0400 Received: from stargate.chelsio.com ([12.32.117.8]:2266 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726616AbgHRPl0 (ORCPT ); Tue, 18 Aug 2020 11:41:26 -0400 Received: from localhost (fedora32ganji.blr.asicdesigners.com [10.193.80.135]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id 07IFfHk7024135; Tue, 18 Aug 2020 08:41:18 -0700 From: Ganji Aravind To: netdev@vger.kernel.org Cc: davem@davemloft.net, vishal@chelsio.com, rahul.lakkireddy@chelsio.com Subject: [PATCH net 2/2] cxgb4: Fix race between loopback and normal Tx path Date: Tue, 18 Aug 2020 21:10:58 +0530 Message-Id: <20200818154058.1770002-3-ganji.aravind@chelsio.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200818154058.1770002-1-ganji.aravind@chelsio.com> References: <20200818154058.1770002-1-ganji.aravind@chelsio.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Even after Tx queues are marked stopped, there exists a small window where the current packet in the normal Tx path is still being sent out and loopback selftest ends up corrupting the same Tx ring. So, ensure selftest takes the Tx lock to synchronize access the Tx ring. Fixes: 7235ffae3d2c ("cxgb4: add loopback ethtool self-test") Signed-off-by: Ganji Aravind Reviewed-by: Jesse Brandeburg --- drivers/net/ethernet/chelsio/cxgb4/sge.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 7c9fe4bc235b..869431a1eedd 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c @@ -2561,11 +2561,14 @@ int cxgb4_selftest_lb_pkt(struct net_device *netdev) lb->loopback = 1; q = &adap->sge.ethtxq[pi->first_qset]; + __netif_tx_lock(q->txq, smp_processor_id()); reclaim_completed_tx(adap, &q->q, -1, true); credits = txq_avail(&q->q) - ndesc; - if (unlikely(credits < 0)) + if (unlikely(credits < 0)) { + __netif_tx_unlock(q->txq); return -ENOMEM; + } wr = (void *)&q->q.desc[q->q.pidx]; memset(wr, 0, sizeof(struct tx_desc)); @@ -2598,6 +2601,7 @@ int cxgb4_selftest_lb_pkt(struct net_device *netdev) init_completion(&lb->completion); txq_advance(&q->q, ndesc); cxgb4_ring_tx_db(adap, &q->q, ndesc); + __netif_tx_unlock(q->txq); /* wait for the pkt to return */ ret = wait_for_completion_timeout(&lb->completion, 10 * HZ);