From patchwork Tue Oct 17 10:50:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinas Rasheed X-Patchwork-Id: 154062 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4044990vqb; Tue, 17 Oct 2023 03:51:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPUg03C/oxxVKkhGQclZ4QI1Vx78z3oHwx2caNIJrAVxpIFlkTi1vei+DezJgqYLHDiETo X-Received: by 2002:a05:6870:be8d:b0:1d0:e372:6cf8 with SMTP id nx13-20020a056870be8d00b001d0e3726cf8mr2025467oab.2.1697539865669; Tue, 17 Oct 2023 03:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697539865; cv=none; d=google.com; s=arc-20160816; b=qbHt+Mhb8LqA066o/nKr8sxEgISpC5T0BeByzXabvYDqaKO52T2IGSHiMt92hcZeFk T4lgwhZnAqlPmD4EyfEdf8ML53QKeluHVgEazKet5c0TaTc4faJxuYs/H453/5P/2Hn0 TQVYLm7x/pw3dmJ7kNG/Y1CTGZNCR21qBk7QeKAIDCwKdkZfic/oKw4Jib13RzZv25m/ ttDsNMlF9akAOhhcXg2oYHOYWOY0MmAvSKUILV7lZSlXvSAdmILsDF5xI5GqgYwFORGw LBeccxNpHDcKiD5w06CLMi+V1KUaSFwmnIQ0fk7fA8nuRAhJszhdo++8ncb6Fz6aGvjK mVsw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=LSRCKb8JzrEBoZi94vlE+OdKI7L0JbMMj1EiLEo1A7Y=; fh=v3+dPAfyDoQk/qXxjqJuSNCqATLUiQS6cmHrW7hGVqY=; b=qwi9VuCJ1fWECdNSGPJJO9Rl+QT4PhfY5mxL3aaonPW8KKyA76aLNr95yKy1BtsXhV uW3J1VCY2kSCMwuhEKyTT/WUZrh7mH8k7E4dL5jioIyAuMjPskl1ZxTF0oeulloTUlmW l1uaVBz46yETYP7Awt9Sf2NpGEtjccPb9eV9clqUIf34XQg2yVU85rXnB3ELL7cGD/oL YKg/lEHJDtG2tJTza8mZfsKhKwAUqX94n3PcPOMVTkfQIuGf6tS5kJ9bVJ5R339vWLaU RTTwW7kjX1nSTtyOU+1pikwFIhLvcB0LPWYBVb6ucR8pljX0Y6DmayLwLYuwtiOhw2If 7gTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Dh8fbntq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id o27-20020a63921b000000b00578666614f1si1450399pgd.63.2023.10.17.03.51.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 03:51:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=Dh8fbntq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id ECEFD80A9F5F; Tue, 17 Oct 2023 03:51:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343717AbjJQKuw (ORCPT + 19 others); Tue, 17 Oct 2023 06:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234846AbjJQKut (ORCPT ); Tue, 17 Oct 2023 06:50:49 -0400 Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03A6FF0; Tue, 17 Oct 2023 03:50:47 -0700 (PDT) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39H3JocE008487; Tue, 17 Oct 2023 03:50:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=LSRCKb8JzrEBoZi94vlE+OdKI7L0JbMMj1EiLEo1A7Y=; b=Dh8fbntqyrSq/Z6FSpfyxPkf5JOoWxVQvUH1mL/1n3Rxf1xJKqOdsMopN08ltP6oTOaL UXV01MHZKat1ddbJUWhkIhRVC6AE3hiFkTzhEDmGNN8a9GJWDqB2LUs88SjX/f/55fVE 6hFCI3Q46VwzOu77MzfevwbsyFDbAJAk/nOs5bsBuFFTQFbmAV4IYWVorM/WWVSl4vhy dukIB4j7VTI6+Sl2SZxL9sbb5LtIogMeGTHV3c9WYLXFh2Bf3HBz1Hn9n+aIf0q8POHg FkilLeBC+/zvXwe+Vdcg6U4n4UJ18JTGUNb7qZF05ZB4o9PN+oFQ0Pgd7lga+Q+MPB6P aw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3tsj8shjf3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 17 Oct 2023 03:50:34 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 17 Oct 2023 03:50:33 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 17 Oct 2023 03:50:32 -0700 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id CC9F45B6943; Tue, 17 Oct 2023 03:50:32 -0700 (PDT) From: Shinas Rasheed To: , CC: , , , , , , , , , , Subject: [PATCH net v3] octeon_ep: update BQL sent bytes before ringing doorbell Date: Tue, 17 Oct 2023 03:50:30 -0700 Message-ID: <20231017105030.2310966-1-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 7fydJ-HZjoIX1jq51LDFzlEZrCj4EjrU X-Proofpoint-GUID: 7fydJ-HZjoIX1jq51LDFzlEZrCj4EjrU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-16_13,2023-10-17_01,2023-05-22_02 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 17 Oct 2023 03:51:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779999562392622531 X-GMAIL-MSGID: 1779999562392622531 Sometimes Tx is completed immediately after doorbell is updated, which causes Tx completion routing to update completion bytes before the same packet bytes are updated in sent bytes in transmit function, hence hitting BUG_ON() in dql_completed(). To avoid this, update BQL sent bytes before ringing doorbell. Fixes: 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support") Signed-off-by: Shinas Rasheed --- V3: - Update skb timestamp and host write index before memory barrier V2: https://lore.kernel.org/all/20231012101706.2291551-1-srasheed@marvell.com/ - Call netdev_tx_sent_queue before memory barrier V1: https://lore.kernel.org/all/20231010115015.2279977-1-srasheed@marvell.com/ drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index dbc518ff8276..5b46ca47c8e5 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -715,20 +715,19 @@ static netdev_tx_t octep_start_xmit(struct sk_buff *skb, hw_desc->dptr = tx_buffer->sglist_dma; } - /* Flush the hw descriptor before writing to doorbell */ - wmb(); - - /* Ring Doorbell to notify the NIC there is a new packet */ - writel(1, iq->doorbell_reg); + netdev_tx_sent_queue(iq->netdev_q, skb->len); + skb_tx_timestamp(skb); atomic_inc(&iq->instr_pending); wi++; if (wi == iq->max_count) wi = 0; iq->host_write_index = wi; + /* Flush the hw descriptor before writing to doorbell */ + wmb(); - netdev_tx_sent_queue(iq->netdev_q, skb->len); + /* Ring Doorbell to notify the NIC there is a new packet */ + writel(1, iq->doorbell_reg); iq->stats.instr_posted++; - skb_tx_timestamp(skb); return NETDEV_TX_OK; dma_map_sg_err: