Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4557910ybv; Mon, 17 Feb 2020 01:20:44 -0800 (PST) X-Google-Smtp-Source: APXvYqx2ThIb1tRzmItOZKyY9rR7QSyxymeWlIXWGhcm1YwPPSyZgrPia3f1E2B7/lKGwB4ni2Mu X-Received: by 2002:a05:6808:64e:: with SMTP id z14mr8922156oih.79.1581931244569; Mon, 17 Feb 2020 01:20:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581931244; cv=none; d=google.com; s=arc-20160816; b=hsyC81Vdeu+o/+49fJ3hCnsVJCROLWHpyJXJuyVc6KyRJBdr4SFln1msYyDJDIsXze N4lGxz63mIsHqH7qlLaQ1x0GaVKIJqEVKlXkF42mXqinOPcGuTQi066XUAyPxsNA9o7K w/xytRUgsB6qHvjt+F5ecmD7RHTN6OyeR8n3voswbSZE2QbMMq9j4OdJZ4el0dy8cKvm +Ad84pJmi1io5TBUOxbGlOMBAlmxCjCCec3HDDbg2kbI3+QKo70J9tYPFt74IbKurtSR 83oBAgkL6b3MkHUGhbSOE+NHxxOsl3+H9iYVh2Z0yU/HqqEmFUxqNyEx0pY5Dw/xr9lQ PZTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=rtlBbq47Jc7ABSQBxB5uJi+mvU1gapR6WCupjIRNi9g=; b=GfoJdtJMIcYB/Rdo5FTqZ6/M2t9GeNJ6HCkUWAfT0ufLROvBpBkXlxoIr9nELPRx5C Noa+pX81q5d4w7lf9ip5MiExAtUgCTLxkN/n+NDO/K3yhGvYooizX7hunjazyy89xDTt g3CU8Ra3XXRZG+Dl3HAOYw2fnY3RLByHvPydTIwZrUCFw9uKmWBIViNkX2Ft2a/yznT7 xNbHbyYFz3rGg9yF1a3C9KDX+hFUVWPrah5sc1K/b9Th7lZfrqyR3jjSOS2858yGlr8j 9hfGi5WKNXpdm8G/H6W7DGty8OqbHZoeo4ljEwZzsTU0twIEl2Dv9eOIHcpum0XeBguI phmQ== 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 b6si6718267oie.181.2020.02.17.01.20.31; Mon, 17 Feb 2020 01:20:44 -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 S1728787AbgBQJUJ (ORCPT + 99 others); Mon, 17 Feb 2020 04:20:09 -0500 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:50513 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728272AbgBQJUJ (ORCPT ); Mon, 17 Feb 2020 04:20:09 -0500 X-Originating-IP: 90.65.102.129 Received: from localhost (lfbn-lyo-1-1670-129.w90-65.abo.wanadoo.fr [90.65.102.129]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id BAC8320005; Mon, 17 Feb 2020 09:20:06 +0000 (UTC) Date: Mon, 17 Feb 2020 10:20:06 +0100 From: Alexandre Belloni To: Horatiu Vultur Cc: UNGLinuxDriver@microchip.com, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: mscc: fix in frame extraction Message-ID: <20200217092006.GA3634@piout.net> References: <20200217083133.20828-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200217083133.20828-1-horatiu.vultur@microchip.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/02/2020 09:31:33+0100, Horatiu Vultur wrote: > Each extracted frame on Ocelot has an IFH. The frame and IFH are extracted > by reading chuncks of 4 bytes from a register. > > In case the IFH and frames were read corretly it would try to read the next > frame. In case there are no more frames in the queue, it checks if there > were any previous errors and in that case clear the queue. But this check > will always succeed also when there are no errors. Because when extracting > the IFH the error is checked against 4(number of bytes read) and then the > error is set only if the extraction of the frame failed. So in a happy case > where there are no errors the err variable is still 4. So it could be > a case where after the check that there are no more frames in the queue, a > frame will arrive in the queue but because the error is not reseted, it > would try to flush the queue. So the frame will be lost. > > The fix consist in resetting the error after reading the IFH. > > Signed-off-by: Horatiu Vultur Acked-by: Alexandre Belloni > --- > drivers/net/ethernet/mscc/ocelot_board.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c > index b38820849faa..1135a18019c7 100644 > --- a/drivers/net/ethernet/mscc/ocelot_board.c > +++ b/drivers/net/ethernet/mscc/ocelot_board.c > @@ -114,6 +114,14 @@ static irqreturn_t ocelot_xtr_irq_handler(int irq, void *arg) > if (err != 4) > break; > > + /* At this point the IFH was read correctly, so it is safe to > + * presume that there is no error. The err needs to be reset > + * otherwise a frame could come in CPU queue between the while > + * condition and the check for error later on. And in that case > + * the new frame is just removed and not processed. > + */ > + err = 0; > + > ocelot_parse_ifh(ifh, &info); > > ocelot_port = ocelot->ports[info.port]; > -- > 2.17.1 > -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com