From patchwork Mon Nov 13 11:07:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 164409 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1127282vqg; Mon, 13 Nov 2023 03:07:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFotTtWqq3PxKFGHFKWE4aD4PNXK+peoNqZ03iCtzi/w9nav+X2jtRm1y25A34MX5Wn+dAP X-Received: by 2002:a05:6a20:2d2c:b0:171:4921:f1b7 with SMTP id g44-20020a056a202d2c00b001714921f1b7mr5482285pzl.41.1699873666518; Mon, 13 Nov 2023 03:07:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699873666; cv=none; d=google.com; s=arc-20160816; b=hTKWTJaIwWRZ2GPaPUjFWlf1xC2era+0iY7pYotBXiAE2ejVOwmVnouTkbzaeTkPYt 7fHSrzU5qbx8ttIvTAeqe1KyNcMOh/Oeb+8pieiuUUK294TSCM8rftziTvRzFRPBqyab kAutvZ4TtRllUWC5PWVrwRQJA7NkKqBpTT2vXhvAKmER0TmmGJMoTYspse5Ry1rK3FZH Hvlmiz9HbAeno6nkwJXmPxs+6yoUKW0Hx1J5osQsirOEvJAJCh0Tjt9qviejN4+wOqyZ PTZ7bNzKZr4CE75J4RhX6G88wM+qdRz9C6zyOBDR8hA9BRH9QpDl/4rwm8BTU/5ZG7Mb OIJw== 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=+Iiijpk/0H1FHN64iXKPcoSknydrOsuXD4FslxeKlzc=; fh=5XVN7hYDrjkwKFw4bFXRK8oy6VkSo1QEqyD70rM4SXo=; b=XuQa1g+VkHQlzNoRlmwqOTsUzzr1RaJ+IaIsDArDH70TNzQJofF6o5duJYRTtbtSWP DzASbOy8nzwcuLNXuE8aZecvgO0JT2aIgXWLLcn+EAW4h4mw12L33obpu3kEnTLiWonC x2g5ZD+AhJEn2bmp39V3C2MMhpZkZfJrhg9KUDRHGnHB/L+pUFBUdNgqtvckwf+5CPoj yzM7UQsu7XczUVOPStnHBb20MSv0Mx3s+Ka72t41mQ+fxTJ4FOsP0JdzvTkeOn1irViM 8oErf3gucweTXRwh6KU17f44H7sn8qrkEy0Xxsv+gGufosYBEerETvni7s8wY6rP9M/Z yWdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fFTOq4h4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id so10-20020a17090b1f8a00b00279020d1fb0si5868646pjb.129.2023.11.13.03.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 03:07:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fFTOq4h4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2DDA3804706A; Mon, 13 Nov 2023 03:07:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230216AbjKMLHg (ORCPT + 29 others); Mon, 13 Nov 2023 06:07:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbjKMLH3 (ORCPT ); Mon, 13 Nov 2023 06:07:29 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D89210F0 for ; Mon, 13 Nov 2023 03:07:26 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FF6AC433C7; Mon, 13 Nov 2023 11:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699873646; bh=ZR/DMZiyPsFy+qz8rEgRfcpH4vlRg6uq7If8iaVqgDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFTOq4h4BIeRZgABsCAYrICCROmZWg0yTLFR3qD5fmh+i5iCyUQPRjfQQGloe+CVs lbKAIqSv4CnJYPudxvm8kyBTs91R49XO6RJ6A2xp5He0htSmV9aVPldmxwsGB8rwrZ Ng8UTO3zR9LsV/fzOKooOF7ko/kbkiFsvfyj7jMGh0DDWKpUhwwuaLNF4zO8uCl6mk 7mkAxj25in57JrKMZ1+nhdbOpPMNwNOH3pkhgAqZbg/8E2U7YhD6qVQ/Xkna2IHyOZ UIiwbsQI2ssUJURO2STSw9ZqQUUHJSBYnoN4h68JvpsNEGGhTmEknEc0p1n/tGDMMo rSYeDRj26szDg== From: Roger Quadros To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: vladimir.oltean@nxp.com, s-vadapalli@ti.com, r-gunasekaran@ti.com, srk@ti.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Roger Quadros Subject: [PATCH net-next 3/3] net: ethernet: am65-cpsw: Error out if Enable TX/RX channel fails Date: Mon, 13 Nov 2023 13:07:08 +0200 Message-Id: <20231113110708.137379-4-rogerq@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231113110708.137379-1-rogerq@kernel.org> References: <20231113110708.137379-1-rogerq@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 03:07:45 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782446729774293473 X-GMAIL-MSGID: 1782446729774293473 k3_udma_glue_enable_rx/tx_chn returns error code on failure. Bail out on error while enabling TX/RX channel. Signed-off-by: Roger Quadros Reviewed-by: Andrew Lunn --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 33 +++++++++++++++++++----- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 7c440899c93c..340f25bf33b1 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -372,7 +372,7 @@ static void am65_cpsw_init_port_emac_ale(struct am65_cpsw_port *port); static int am65_cpsw_nuss_common_open(struct am65_cpsw_common *common) { struct am65_cpsw_host *host_p = am65_common_get_host(common); - int port_idx, i, ret; + int port_idx, i, ret, tx; struct sk_buff *skb; u32 val, port_mask; @@ -453,13 +453,22 @@ static int am65_cpsw_nuss_common_open(struct am65_cpsw_common *common) } kmemleak_not_leak(skb); } - k3_udma_glue_enable_rx_chn(common->rx_chns.rx_chn); - for (i = 0; i < common->tx_ch_num; i++) { - ret = k3_udma_glue_enable_tx_chn(common->tx_chns[i].tx_chn); - if (ret) - return ret; - napi_enable(&common->tx_chns[i].napi_tx); + ret = k3_udma_glue_enable_rx_chn(common->rx_chns.rx_chn); + if (ret) { + dev_err(common->dev, "couldn't enable rx chn: %d\n", ret); + return ret; + } + + for (tx = 0; tx < common->tx_ch_num; tx++) { + ret = k3_udma_glue_enable_tx_chn(common->tx_chns[tx].tx_chn); + if (ret) { + dev_err(common->dev, "couldn't enable tx chn %d: %d\n", + tx, ret); + tx--; + goto fail_tx; + } + napi_enable(&common->tx_chns[tx].napi_tx); } napi_enable(&common->napi_rx); @@ -470,6 +479,16 @@ static int am65_cpsw_nuss_common_open(struct am65_cpsw_common *common) dev_dbg(common->dev, "cpsw_nuss started\n"); return 0; + +fail_tx: + while (tx >= 0) { + napi_disable(&common->tx_chns[tx].napi_tx); + k3_udma_glue_disable_tx_chn(common->tx_chns[tx].tx_chn); + tx--; + } + + k3_udma_glue_disable_rx_chn(common->rx_chns.rx_chn); + return ret; } static void am65_cpsw_nuss_tx_cleanup(void *data, dma_addr_t desc_dma);