Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4164119ybl; Tue, 21 Jan 2020 14:13:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxn6s6j1jokFfi2JkMd7OUbg0VCeTKtgyz5zNqGEERopNxE7EVAKwos+AfYG6Mv1KrSz8sr X-Received: by 2002:a05:6808:9a4:: with SMTP id e4mr4748711oig.127.1579644805176; Tue, 21 Jan 2020 14:13:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579644805; cv=none; d=google.com; s=arc-20160816; b=Jk/RdFaLaVJvDpc/R2jE2hq492qEBsStjqtV3hZfI1GT5s56lMmX1DtAXz5Ci3ifWY eIE2VIHcsR7pLbRFS3YOH1D7iJLWSVIQ92gWojyss8qHxYcDs36fHMrToWWdhA2GHDqK In8ay/g518xO0jSy7toiRzK0XJRtb3eQCXD+lcdcLmpBCgbiiMSqkxuUp04+UzJA1Ga/ VtXNKQtMM3APKG4TUVPfcFabZku5MNW4JyLobZMSaj+jrqxF5SUzi8RHup4cfr0lMMHY BhXSqgblIXgLNObvW9X5AIjpc5RNd7DF55edMe+nfaS3B/Rhx0GzVT6zegZCkDOWBDDM 9xTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:from:references:in-reply-to :message-id:cc:to; bh=6eT7a3mnGSqim/nA6uIF22TMiftIv7s+dm8A7+ZTQfE=; b=OKvVANmnocUtG3hCASP3nkf7mzrghFupwIlvKPnGfyAYRXNPDxs9CoWQmsF2zUyWkO I7M94+O6NnT26vhymq2GRuDKYuuMTjTKtcihLCEznhIOP4wGy/OkZKI+89ybaZWm8iVN LuQzDh6D9l8NKAfBoZnyponZV2NEBDFKjTzeayZmN3R6NvRlQzV+40vW3yLJ8kMSi3/T wkvFzGD3L2AdJZiCQmcULkcEziTc5/i/nTeBs4WK0AUULzv4Cn472Z4W1ZMDqEFJlcZZ tI31uHsEROblBs305LecgrJfK18C/cpcQJWT+6LmcK0G28pWu/KY2raUM6aknIhJoD/N /zRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g22si20960988otp.55.2020.01.21.14.13.12; Tue, 21 Jan 2020 14:13:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729247AbgAUWKi (ORCPT + 99 others); Tue, 21 Jan 2020 17:10:38 -0500 Received: from kvm5.telegraphics.com.au ([98.124.60.144]:44800 "EHLO kvm5.telegraphics.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729094AbgAUWKh (ORCPT ); Tue, 21 Jan 2020 17:10:37 -0500 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 62FC022D7F; Tue, 21 Jan 2020 17:10:36 -0500 (EST) To: "David S. Miller" Cc: Thomas Bogendoerfer , Chris Zankel , Laurent Vivier , Geert Uytterhoeven , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: <0a1ecf29f4d0f876aa3ba2691264e24b026a0732.1579641728.git.fthain@telegraphics.com.au> In-Reply-To: References: From: Finn Thain Subject: [PATCH net v2 07/12] net/sonic: Improve receive descriptor status flag check Date: Wed, 22 Jan 2020 08:22:08 +1100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After sonic_tx_timeout() calls sonic_init(), it can happen that sonic_rx() will subsequently encounter a receive descriptor with no flags set. Remove the comment that says that this can't happen. When giving a receive descriptor to the SONIC, clear the descriptor status field. That way, any rx descriptor with flags set can only be a newly received packet. Don't process a descriptor without the LPKT bit set. The buffer is still in use by the SONIC. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Tested-by: Stan Johnson Signed-off-by: Finn Thain --- drivers/net/ethernet/natsemi/sonic.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/natsemi/sonic.c b/drivers/net/ethernet/natsemi/sonic.c index 431a6e46c08c..bec06f357011 100644 --- a/drivers/net/ethernet/natsemi/sonic.c +++ b/drivers/net/ethernet/natsemi/sonic.c @@ -430,7 +430,6 @@ static inline int index_from_addr(struct sonic_local *lp, dma_addr_t addr, static void sonic_rx(struct net_device *dev) { struct sonic_local *lp = netdev_priv(dev); - int status; int entry = lp->cur_rx; int prev_entry = lp->eol_rx; @@ -441,9 +440,11 @@ static void sonic_rx(struct net_device *dev) u16 bufadr_l; u16 bufadr_h; int pkt_len; + u16 status = sonic_rda_get(dev, entry, SONIC_RD_STATUS); + + /* If the RD has LPKT set, the chip has finished with the RB */ - status = sonic_rda_get(dev, entry, SONIC_RD_STATUS); - if (status & SONIC_RCR_PRX) { + if ((status & SONIC_RCR_PRX) && (status & SONIC_RCR_LPKT)) { u32 addr = (sonic_rda_get(dev, entry, SONIC_RD_PKTPTR_H) << 16) | sonic_rda_get(dev, entry, SONIC_RD_PKTPTR_L); @@ -491,10 +492,6 @@ static void sonic_rx(struct net_device *dev) bufadr_h = (unsigned long)new_laddr >> 16; sonic_rra_put(dev, i, SONIC_RR_BUFADR_L, bufadr_l); sonic_rra_put(dev, i, SONIC_RR_BUFADR_H, bufadr_h); - } else { - /* This should only happen, if we enable accepting broken packets. */ - } - if (status & SONIC_RCR_LPKT) { /* * this was the last packet out of the current receive buffer * give the buffer back to the SONIC @@ -507,12 +504,11 @@ static void sonic_rx(struct net_device *dev) __func__); SONIC_WRITE(SONIC_ISR, SONIC_INT_RBE); /* clear the flag */ } - } else - printk(KERN_ERR "%s: rx desc without RCR_LPKT. Shouldn't happen !?\n", - dev->name); + } /* * give back the descriptor */ + sonic_rda_put(dev, entry, SONIC_RD_STATUS, 0); sonic_rda_put(dev, entry, SONIC_RD_IN_USE, 1); prev_entry = entry; -- 2.24.1