Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3265875rdb; Wed, 13 Sep 2023 07:12:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdwkY2hgajH+kaB1jBiiL+odiwoUsYA4UOCdzjlfz4q7WAFe17vZpyqudoJLA+MNU+EcjT X-Received: by 2002:a05:6a20:4320:b0:154:bfaf:a710 with SMTP id h32-20020a056a20432000b00154bfafa710mr2870563pzk.41.1694614353619; Wed, 13 Sep 2023 07:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694614353; cv=none; d=google.com; s=arc-20160816; b=pGHIYJd15utK1s8BLk9p85E0YySlYa4ljwOjgyHZUX5DDFUblyD2cnCo8SMg+vDIDm P2MsmpvJJAy1E7LavBwD70RHnaPCITuTL5OeO/FNrqtY1RZeeHZ5y1JdrsKfFt06kzeP 03sn4XGgIBe3VtqrGxCyiejF38FCract3l299KnjLvyuJLrpaTINBW+2Dy/JYEi+ssUr BD9mHnvaHyXbyaIGymqhuGNSKjYpX7jUs7+oZm5d/tTlnjP03RhAN4twIKD75GSAIKuH 2lyQFLRXEEy1OX5hxYNSQopYHLUxmyFRDw2OjhFMoVX64l21IV3WnWv0xWRZcLMAdcCm TUEQ== 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=NUevUetpd87fHFVlXkqG1gYoA4+HNk0VhI7PisrEu00=; fh=ENjXDcI1v9WIMy2Dx/NgjUEuAfJk/j4EQc+fzYBuTUY=; b=D+wUTxQa77qcLhWy7eSWIv454nUe0iZVXNxkdP6/y3cNiNlcPZUqpWoLT1zXG8y+2l +/ZCszHkFV6Tdfiz19POEFKUpJhJaGc30PC4MtY1L91fwYeSZQdduf1jllR5aOj5OhUt E/2MLgAcbCtAWGE5U6dVUFBd1xqAcaUnBPo+yp83RUXUPypnX4HpWs4ebgTaRTERnhOW gjyw/CHkIUhipPSFmGEqNTFOeDncoq5lprH3K8SrEFIbOz464jAi7AgSjwYouuRz1lxb gzKJB2UBjJBeOF/oA3kDAvOrtd8j0325CYlpDGYfohvL4mkSDGBZd5HEthw4j0VMVVqW Mjjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=KCMfuNfW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id cn13-20020a056a00340d00b0068e28792ef2si10158018pfb.98.2023.09.13.07.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 07:12:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=KCMfuNfW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id ED3D981DE5B1; Wed, 13 Sep 2023 01:42:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238922AbjIMImU (ORCPT + 99 others); Wed, 13 Sep 2023 04:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238958AbjIMImT (ORCPT ); Wed, 13 Sep 2023 04:42:19 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7506910C0; Wed, 13 Sep 2023 01:42:15 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38CKesBK014882; Wed, 13 Sep 2023 01:42:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=NUevUetpd87fHFVlXkqG1gYoA4+HNk0VhI7PisrEu00=; b=KCMfuNfWxplSvCcILvtIOAsipS4tPpfle/xqyTUYY/im419LK9pcwU6FkdRGQqf3ffNm fvnBy9XjL/IoZjs/cOudhrmWsU/TrxDoemkaAqZ+i4Zs35Xkuj+7Cgs+YQKEFliKm/vI Is0BrCg6x8jbeil2gaiJzsWFdhpZ7v1eToozsnNhi5r1tef+wqea0INknYYxx2T9pp49 CMH56kuT8JgGNNm5DKAkQXjQaLya5IROewOL0i8Q+3XnSUGRoMyp18ArpMdIKhxEkFZx Llx9jpd2MGdmZKrCiJuQbmEQY8+GWbPhRdDaD0PtcRLAC5H0L9+01GDXbEf2XfHrfPTz sg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3t2y84t293-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 13 Sep 2023 01:42:05 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 13 Sep 2023 01:42:03 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 13 Sep 2023 01:42:03 -0700 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 6787A3F707F; Wed, 13 Sep 2023 01:42:03 -0700 (PDT) From: Shinas Rasheed To: CC: , , , , , , , , , , , , , , Subject: [net PATCH v2] octeon_ep: fix tx dma unmap len values in SG Date: Wed, 13 Sep 2023 01:41:56 -0700 Message-ID: <20230913084156.2147106-1-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: Juqmh0BqqHsvmTlZu-fWJZ_vI7OnMgJF X-Proofpoint-ORIG-GUID: Juqmh0BqqHsvmTlZu-fWJZ_vI7OnMgJF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-12_24,2023-09-05_01,2023-05-22_02 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 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 01:42:21 -0700 (PDT) X-Spam-Status: No, score=-0.9 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 fry.vger.email Lengths of SG pointers are kept in the following order in the SG entries in hardware. 63 48|47 32|31 16|15 0 ----------------------------------------- | Len 0 | Len 1 | Len 2 | Len 3 | ----------------------------------------- | Ptr 0 | ----------------------------------------- | Ptr 1 | ----------------------------------------- | Ptr 2 | ----------------------------------------- | Ptr 3 | ----------------------------------------- Dma pointers have to be unmapped based on their respective lengths given in this format. Fixes: 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support") Signed-off-by: Shinas Rasheed --- .../net/ethernet/marvell/octeon_ep/octep_main.c | 8 ++++---- .../net/ethernet/marvell/octeon_ep/octep_tx.c | 8 ++++---- .../net/ethernet/marvell/octeon_ep/octep_tx.h | 16 +++++++++++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 4424de2ffd70..dbc518ff8276 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -734,13 +734,13 @@ static netdev_tx_t octep_start_xmit(struct sk_buff *skb, dma_map_sg_err: if (si > 0) { dma_unmap_single(iq->dev, sglist[0].dma_ptr[0], - sglist[0].len[0], DMA_TO_DEVICE); - sglist[0].len[0] = 0; + sglist[0].len[3], DMA_TO_DEVICE); + sglist[0].len[3] = 0; } while (si > 1) { dma_unmap_page(iq->dev, sglist[si >> 2].dma_ptr[si & 3], - sglist[si >> 2].len[si & 3], DMA_TO_DEVICE); - sglist[si >> 2].len[si & 3] = 0; + sglist[si >> 2].len[3 - (si & 3)], DMA_TO_DEVICE); + sglist[si >> 2].len[3 - (si & 3)] = 0; si--; } tx_buffer->gather = 0; diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c b/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c index 5a520d37bea0..d0adb82d65c3 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_tx.c @@ -69,12 +69,12 @@ int octep_iq_process_completions(struct octep_iq *iq, u16 budget) compl_sg++; dma_unmap_single(iq->dev, tx_buffer->sglist[0].dma_ptr[0], - tx_buffer->sglist[0].len[0], DMA_TO_DEVICE); + tx_buffer->sglist[0].len[3], DMA_TO_DEVICE); i = 1; /* entry 0 is main skb, unmapped above */ while (frags--) { dma_unmap_page(iq->dev, tx_buffer->sglist[i >> 2].dma_ptr[i & 3], - tx_buffer->sglist[i >> 2].len[i & 3], DMA_TO_DEVICE); + tx_buffer->sglist[i >> 2].len[3 - (i & 3)], DMA_TO_DEVICE); i++; } @@ -131,13 +131,13 @@ static void octep_iq_free_pending(struct octep_iq *iq) dma_unmap_single(iq->dev, tx_buffer->sglist[0].dma_ptr[0], - tx_buffer->sglist[0].len[0], + tx_buffer->sglist[0].len[3], DMA_TO_DEVICE); i = 1; /* entry 0 is main skb, unmapped above */ while (frags--) { dma_unmap_page(iq->dev, tx_buffer->sglist[i >> 2].dma_ptr[i & 3], - tx_buffer->sglist[i >> 2].len[i & 3], DMA_TO_DEVICE); + tx_buffer->sglist[i >> 2].len[3 - (i & 3)], DMA_TO_DEVICE); i++; } diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_tx.h b/drivers/net/ethernet/marvell/octeon_ep/octep_tx.h index 2ef57980eb47..21e75ff9f5e7 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_tx.h +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_tx.h @@ -17,7 +17,21 @@ #define TX_BUFTYPE_NET_SG 2 #define NUM_TX_BUFTYPES 3 -/* Hardware format for Scatter/Gather list */ +/* Hardware format for Scatter/Gather list + * + * 63 48|47 32|31 16|15 0 + * ----------------------------------------- + * | Len 0 | Len 1 | Len 2 | Len 3 | + * ----------------------------------------- + * | Ptr 0 | + * ----------------------------------------- + * | Ptr 1 | + * ----------------------------------------- + * | Ptr 2 | + * ----------------------------------------- + * | Ptr 3 | + * ----------------------------------------- + */ struct octep_tx_sglist_desc { u16 len[4]; dma_addr_t dma_ptr[4]; -- 2.25.1