From patchwork Tue May 30 22:51:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1788004 X-Patchwork-Delegate: rfried.dev@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=K0ru8xq2; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=RMz/YHnF; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QW7533BJFz20QB for ; Wed, 31 May 2023 08:54:47 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1E5A1861C1; Wed, 31 May 2023 00:52:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="K0ru8xq2"; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="RMz/YHnF"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 89BE18609C; Wed, 31 May 2023 00:51:58 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [IPv6:2001:67c:2050:0:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3CDB68607F for ; Wed, 31 May 2023 00:51:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut+renesas@mailbox.org Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4QW71m0clFz9snK; Wed, 31 May 2023 00:51:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1685487116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5YOILTuWnb+o0t2VR0ZKg1rbKQiaH8veL621f+Bcb2I=; b=K0ru8xq25zjgRTY8lDLPu4kddGpn1eZ16H+z0dT/gBqlLQpNp4k/CM1vxYCo7h7lqsuXbq AXp735Rx5FaIpZdb1B4CITpEuV2lVU/PFcp8TcVNIU62fCF027VA0gcEMGoqIoMWg3que5 p1ewg+NhVFnxNpY5DVgCmGl+B/Bh8jEQGGUuSubMMBW7xCq0r60tzjSe1Xgq1pTTja62X1 HJkStxK7yeczDLhVFcEc9stEt+cA1sOx8ZtJlT7XEok56IqUqAwORnX2oYF8CIFT8SYCBO utYipxHnNlECE3nbfCxl/jfnUWrhNtcOt39jDWYPqgOIO63tGmzZIW7A04eSIg== From: Marek Vasut DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1685487114; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5YOILTuWnb+o0t2VR0ZKg1rbKQiaH8veL621f+Bcb2I=; b=RMz/YHnFde6/G9iCCEtZsC9Emv3S0kWtetj78GvGy6BuuRPEs22D1UCf/rM97LtPZ9eEIC V1kgvhKSd7hucxMQLXEaPa8MZnhaeKDA1/+7aKw9ABke6OGx7Qgb/bSzIDZs8qd7O7Y8HJ Fey2+kWOy5zOdqq+3Fb3G9wSr5w/uGh8ax92Aa531dTNUmmjOQhAKG+TlL0xRibzxt/btB Y4NZYN5zGCS8xt/6xhB3IruDvbdpD6lL4OUzaBOKp/TRVRzHSdMJFwNbkPnr+HCqWft4gU VgcknK5xOJN7Qn0AtZ3ITwz9DiyD8kvvAMDofRxxstbAONwLO7XviRfH9PlmkA== To: u-boot@lists.denx.de Cc: Valentine Barshak , Marek Vasut , Geert Uytterhoeven , Joe Hershberger , Michal Simek , Nishanth Menon , Ramon Fried Subject: [PATCH 14/14] net: sh_eth: Fix RX error handling Date: Wed, 31 May 2023 00:51:31 +0200 Message-Id: <20230530225131.949721-14-marek.vasut+renesas@mailbox.org> In-Reply-To: <20230530225131.949721-1-marek.vasut+renesas@mailbox.org> References: <20230530225131.949721-1-marek.vasut+renesas@mailbox.org> MIME-Version: 1.0 X-MBO-RS-ID: e3adb2f2567f5994252 X-MBO-RS-META: ff9qmni5zffk67gfozp9c81skshrg3ui X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Valentine Barshak In case RX error occurs, and the RD_RFE bit is set, the descriptor is never returned back to the queue. Make sh_eth_recv_start return zero length in this case so that the descriptor can be released and pushed back to the list. Also return the more appropriate -EAGAIN instead of -EINVAL if the descriptor is not ready yet. Signed-off-by: Valentine Barshak Reviewed-by: Marek Vasut Reviewed-by: Ramon Fried --- Cc: Geert Uytterhoeven Cc: Joe Hershberger Cc: Michal Simek Cc: Nishanth Menon Cc: Ramon Fried --- drivers/net/sh_eth.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 7314caadfdc..7b1f59dc498 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -129,11 +129,11 @@ static int sh_eth_recv_start(struct sh_eth_dev *eth) /* Check if the rx descriptor is ready */ invalidate_cache(port_info->rx_desc_cur, sizeof(struct rx_desc_s)); if (port_info->rx_desc_cur->rd0 & RD_RACT) - return -EINVAL; + return -EAGAIN; /* Check for errors */ if (port_info->rx_desc_cur->rd0 & RD_RFE) - return -EINVAL; + return 0; return port_info->rx_desc_cur->rd1 & 0xffff; } @@ -556,15 +556,13 @@ static int sh_ether_recv(struct udevice *dev, int flags, uchar **packetp) *packetp = packet; return len; - } else { - len = 0; + } - /* Restart the receiver if disabled */ - if (!(sh_eth_read(port_info, EDRRR) & EDRRR_R)) - sh_eth_write(port_info, EDRRR_R, EDRRR); + /* Restart the receiver if disabled */ + if (!(sh_eth_read(port_info, EDRRR) & EDRRR_R)) + sh_eth_write(port_info, EDRRR_R, EDRRR); - return -EAGAIN; - } + return len; } static int sh_ether_free_pkt(struct udevice *dev, uchar *packet, int length)