Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2302269rwi; Fri, 21 Oct 2022 02:09:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7fbFq/7kC+mYz2ot5OvGEywY86Pp+8bNTXeoqM3h5IuIY6aG7AFmjzdLvZZg2zNO4V8scX X-Received: by 2002:a17:90b:4c10:b0:20d:5388:a479 with SMTP id na16-20020a17090b4c1000b0020d5388a479mr21226763pjb.184.1666343390914; Fri, 21 Oct 2022 02:09:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666343390; cv=none; d=google.com; s=arc-20160816; b=jaxaMuMvmGSG6O77w0OGScvCPKi+FtCRi73KJERp+mBU8G+cQ1bkX05ZIdjY26zOvg 6xha1Qc2uPFBT6kBiBim+udNJpVsWGEDeRBt1EA1EFwukEXYZtwglym6IfuBVYmf5QPf I9/XhimlPD19DqhtvPA0Vp5jw4VNtGGso2KwE4Q7nEd8jjdbFpHeXjGSA4NS5i3Y/tJE DedgPJj+G3jcSca5+Z7wA9WpjLn6ntURXxaU3cerUQGY/7O2LK2IIXQzg7V1qwsD3Akb r78cte14CH6l7uG9ksP110l9s35wrg5PqA2EY6zLdLhTllun963Lnd18HDmZ/Pl0ZRFI b01A== 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=2ylxranhZz12oTuS4EWw+wrdnWf1AUeDlEepiaKSKI4=; b=NgaZNyLm7uz1M6/u03PGSgqNZc54cWQR1Ye83mpxi3amRYr8EUYMUdPfUa4DVBorvQ tQF7MRGGgrndKjMOt3662MmOYZXmN4rdOONz53IjOFihjrksS5Csxtm2MhnWmpnKWbOr zsKSBisy11mE9kTItJjeiF3Ryze1iCkYmetxUEa4E9B75cSpeZVmjB92Hnt9UWKaHnfM dssQ3qkbwLEyC7kWvf3AM1We6MRAwBbXmiBx9PevFPvGGMSfiX0U0HeNmeC1JTh9s3qi 65H8DZMBMWLwkMNbXC5kq48gSwvRtNo75uWzHGq7S66WwhuHnQQUSCunyMTPfp7Grxqd u3yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=zGkDplqS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k128-20020a636f86000000b00463dbc5cebfsi23339459pgc.67.2022.10.21.02.09.39; Fri, 21 Oct 2022 02:09:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=zGkDplqS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229861AbiJUJDI (ORCPT + 99 others); Fri, 21 Oct 2022 05:03:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbiJUJDD (ORCPT ); Fri, 21 Oct 2022 05:03:03 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7C02527C6; Fri, 21 Oct 2022 02:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1666342983; x=1697878983; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=xgDHZDyzvlvCXScq/7p55/MCpFwOFhGPVzkOBo9ENoM=; b=zGkDplqS6/k9ahwkk2WeTliotPyYliCuLqNt898fYms6xuJax7YYhK3S iFNosXf3XvmgTE76n39EO105pZCQ9Y4T8lqaL+M/BPHuDIq8yP3PdKxYg wVLAwBQEg4Gj8yooPHk7F0duCQmnFxqi35xLaX92bUtQRFu5Kv98bwQv0 pZ/1ab9L/aFaKaX7shtsybNXsyLeQZNp+aW4wA9Mli9sOC59XbNf6M1I4 JRe8kK73xcSKpJYaJOWcd6PIqYMsydyYub039B0UfKeh6K5Pzjrw1NrR4 4OkAnx4Y0KYmkkDwhPeFfxQbqWR0dFhGN4U7yJzOCm02oK3gw2KUIh4HB A==; X-IronPort-AV: E=Sophos;i="5.95,200,1661842800"; d="scan'208";a="179906665" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 21 Oct 2022 02:03:01 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 21 Oct 2022 02:03:00 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 21 Oct 2022 02:02:58 -0700 From: Horatiu Vultur To: , CC: , , , , , Horatiu Vultur Subject: [PATCH net] net: lan966x: Stop replacing tx dcbs and dcbs_buf when changing MTU Date: Fri, 21 Oct 2022 11:07:11 +0200 Message-ID: <20221021090711.3749009-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a frame is sent using FDMA, the skb is mapped and then the mapped address is given to an tx dcb that is different than the last used tx dcb. Once the HW finish with this frame, it would generate an interrupt and then the dcb can be reused and memory can be freed. For each dcb there is an dcb buf that contains some meta-data(is used by PTP, is it free). There is 1 to 1 relationship between dcb and dcb_buf. The following issue was observed. That sometimes after changing the MTU to allocate new tx dcbs and dcbs_buf, two frames were not transmitted. The frames were not transmitted because when reloading the tx dcbs, it was always presuming to use the first dcb but that was not always happening. Because it could be that the last tx dcb used before changing MTU was first dcb and then when it tried to get the next dcb it would take dcb 1 instead of 0. Because it is supposed to take a different dcb than the last used one. This can be fixed simply by changing tx->last_in_use to -1 when the fdma is disabled to reload the new dcb and dcbs_buff. But there could be a different issue. For example, right after the frame is sent, the MTU is changed. Now all the dcbs and dcbs_buf will be cleared. And now get the interrupt from HW that it finished with the frame. So when we try to clear the skb, it is not possible because we lost all the dcbs_buf. The solution here is to stop replacing the tx dcbs and dcbs_buf when changing MTU because the TX doesn't care what is the MTU size, it is only the RX that needs this information. Fixes: 2ea1cbac267e ("net: lan966x: Update FDMA to change MTU.") Signed-off-by: Horatiu Vultur --- .../ethernet/microchip/lan966x/lan966x_fdma.c | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c index 7e4061c854f0e..a42035cec611c 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -309,6 +309,7 @@ static void lan966x_fdma_tx_disable(struct lan966x_tx *tx) lan966x, FDMA_CH_DB_DISCARD); tx->activated = false; + tx->last_in_use = -1; } static void lan966x_fdma_tx_reload(struct lan966x_tx *tx) @@ -687,17 +688,14 @@ static int lan966x_qsys_sw_status(struct lan966x *lan966x) static int lan966x_fdma_reload(struct lan966x *lan966x, int new_mtu) { - void *rx_dcbs, *tx_dcbs, *tx_dcbs_buf; - dma_addr_t rx_dma, tx_dma; + dma_addr_t rx_dma; + void *rx_dcbs; u32 size; int err; /* Store these for later to free them */ rx_dma = lan966x->rx.dma; - tx_dma = lan966x->tx.dma; rx_dcbs = lan966x->rx.dcbs; - tx_dcbs = lan966x->tx.dcbs; - tx_dcbs_buf = lan966x->tx.dcbs_buf; napi_synchronize(&lan966x->napi); napi_disable(&lan966x->napi); @@ -715,17 +713,6 @@ static int lan966x_fdma_reload(struct lan966x *lan966x, int new_mtu) size = ALIGN(size, PAGE_SIZE); dma_free_coherent(lan966x->dev, size, rx_dcbs, rx_dma); - lan966x_fdma_tx_disable(&lan966x->tx); - err = lan966x_fdma_tx_alloc(&lan966x->tx); - if (err) - goto restore_tx; - - size = sizeof(struct lan966x_tx_dcb) * FDMA_DCB_MAX; - size = ALIGN(size, PAGE_SIZE); - dma_free_coherent(lan966x->dev, size, tx_dcbs, tx_dma); - - kfree(tx_dcbs_buf); - lan966x_fdma_wakeup_netdev(lan966x); napi_enable(&lan966x->napi); @@ -735,11 +722,6 @@ static int lan966x_fdma_reload(struct lan966x *lan966x, int new_mtu) lan966x->rx.dcbs = rx_dcbs; lan966x_fdma_rx_start(&lan966x->rx); -restore_tx: - lan966x->tx.dma = tx_dma; - lan966x->tx.dcbs = tx_dcbs; - lan966x->tx.dcbs_buf = tx_dcbs_buf; - return err; } -- 2.38.0