From patchwork Thu Nov 24 15:22:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 13055109 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBDE0C43217 for ; Thu, 24 Nov 2022 15:23:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229630AbiKXPXM (ORCPT ); Thu, 24 Nov 2022 10:23:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbiKXPXL (ORCPT ); Thu, 24 Nov 2022 10:23:11 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFB2D69314 for ; Thu, 24 Nov 2022 07:23:10 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4D28B621A7 for ; Thu, 24 Nov 2022 15:23:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A8CCC433C1; Thu, 24 Nov 2022 15:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669303389; bh=gkG/CFKzk4MuB3f6M6uabhgEVgS5tUtQ/c7+V8pmd0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o4ARMKcDZhk+RaLk1n+PeZVKM+ce0g02Ic8oaQK7KxG/jY975Q7OI9Y0qCx/+cwhB n9wL7EZvlYGYh++jIRGkB7Y16ukGvb9xc3cJsiyAlawlEN34AJBD84k7BoHBmVoNgi 1V8L5mokzkz4y5f7cteRC75GjrU0oeJnoTIx1kmv+RodVCdD99/+NyHS5r+sb7sPp+ xo9oM+teD44fuRt7A4GaO8fKl1bGk19+3dum/ncqU2QsrLugTZe1FBlCPaL0bsVWIB kRJ2nYuLtVNeodcC+oJKm5MoGrwQjxrFms6n/lXiL8wt6I8XSXO8KdzoEd7SpVlERd Rl0GHB/dwBRng== From: Lorenzo Bianconi To: netdev@vger.kernel.org Cc: nbd@nbd.name, john@phrozen.org, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, lorenzo.bianconi@redhat.com, sujuan.chen@mediatek.com, linux-mediatek@lists.infradead.org Subject: [PATCH v2 net-next 1/5] net: ethernet: mtk_wed: return status value in mtk_wdma_rx_reset Date: Thu, 24 Nov 2022 16:22:51 +0100 Message-Id: X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Move MTK_WDMA_RESET_IDX configuration in mtk_wdma_rx_reset routine. Increase poll timeout to 10ms in order to be aligned with vendor sdk. This is a preliminary patch to add Wireless Ethernet Dispatcher reset support. Co-developed-by: Sujuan Chen Signed-off-by: Sujuan Chen Signed-off-by: Lorenzo Bianconi --- drivers/net/ethernet/mediatek/mtk_wed.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c index 7d8842378c2b..dc898ded2f05 100644 --- a/drivers/net/ethernet/mediatek/mtk_wed.c +++ b/drivers/net/ethernet/mediatek/mtk_wed.c @@ -101,17 +101,21 @@ mtk_wdma_read_reset(struct mtk_wed_device *dev) return wdma_r32(dev, MTK_WDMA_GLO_CFG); } -static void +static int mtk_wdma_rx_reset(struct mtk_wed_device *dev) { u32 status, mask = MTK_WDMA_GLO_CFG_RX_DMA_BUSY; - int i; + int i, ret; wdma_clr(dev, MTK_WDMA_GLO_CFG, MTK_WDMA_GLO_CFG_RX_DMA_EN); - if (readx_poll_timeout(mtk_wdma_read_reset, dev, status, - !(status & mask), 0, 1000)) + ret = readx_poll_timeout(mtk_wdma_read_reset, dev, status, + !(status & mask), 0, 10000); + if (ret) dev_err(dev->hw->dev, "rx reset failed\n"); + wdma_w32(dev, MTK_WDMA_RESET_IDX, MTK_WDMA_RESET_IDX_RX); + wdma_w32(dev, MTK_WDMA_RESET_IDX, 0); + for (i = 0; i < ARRAY_SIZE(dev->rx_wdma); i++) { if (dev->rx_wdma[i].desc) continue; @@ -119,6 +123,8 @@ mtk_wdma_rx_reset(struct mtk_wed_device *dev) wdma_w32(dev, MTK_WDMA_RING_RX(i) + MTK_WED_RING_OFS_CPU_IDX, 0); } + + return ret; } static void @@ -565,9 +571,7 @@ mtk_wed_detach(struct mtk_wed_device *dev) mtk_wed_stop(dev); - wdma_w32(dev, MTK_WDMA_RESET_IDX, MTK_WDMA_RESET_IDX_RX); - wdma_w32(dev, MTK_WDMA_RESET_IDX, 0); - + mtk_wdma_rx_reset(dev); mtk_wed_reset(dev, MTK_WED_RESET_WED); if (mtk_wed_get_rx_capa(dev)) { wdma_clr(dev, MTK_WDMA_GLO_CFG, MTK_WDMA_GLO_CFG_TX_DMA_EN); @@ -582,7 +586,6 @@ mtk_wed_detach(struct mtk_wed_device *dev) mtk_wed_wo_reset(dev); mtk_wed_free_rx_rings(dev); mtk_wed_wo_deinit(hw); - mtk_wdma_rx_reset(dev); } if (dev->wlan.bus_type == MTK_WED_BUS_PCIE) { @@ -999,11 +1002,7 @@ mtk_wed_reset_dma(struct mtk_wed_device *dev) wed_w32(dev, MTK_WED_RESET_IDX, 0); } - wdma_w32(dev, MTK_WDMA_RESET_IDX, MTK_WDMA_RESET_IDX_RX); - wdma_w32(dev, MTK_WDMA_RESET_IDX, 0); - - if (mtk_wed_get_rx_capa(dev)) - mtk_wdma_rx_reset(dev); + mtk_wdma_rx_reset(dev); if (busy) { mtk_wed_reset(dev, MTK_WED_RESET_WDMA_INT_AGENT);