Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7375332yba; Thu, 2 May 2019 08:49:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyL6hpoQi4OU4h/hYDqb30wcIKXdbBiWjlhw/KZVmUC+F1fhhwexgfgqIPEyRUInMkdsKUY X-Received: by 2002:a17:902:b948:: with SMTP id h8mr4521594pls.39.1556812155477; Thu, 02 May 2019 08:49:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556812155; cv=none; d=google.com; s=arc-20160816; b=W9xMYo4rWhRtkJY4CF4r7CqmH9eG1EckZuNWBPG8jvQg5FA0dixYL2Rp5OSSrXTNLn 1tGC25r58gYRD/p5XTrrqocySRBY7dJcjcwS5IJUSk4awGOwCtqF5kZ/P/RSoxZs+08S zYO7l0HpEvkuppc9/BbhfCf5KjoLBztqx3fVS77uaOvP90WxhyuxS0xcKuACGN3O7YFt W16ZA+BOhzW5PtSQA7X7gBIUUzJPY2jEMrbxPyEt7cZ55637UMHzp1+S3UAhVY3a0mb5 NxrfB4LiEc1PCaR/qCRygyf0sU7ffVRuNzF/yDlrXPjvVWM8zFGjhk5f7WOZ591fMBiF erqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=++nSBwpst4bCNEOmob85dV5mn8Yzncb7XT9GJm2T4CM=; b=jenccxFQQRCn/hG91bdPXMzM1Kvhz+wiUA3raEWcDVRDIF6LI0P41gl+vGMPi2W3xh Xui/N5oeWyyZ+Ik48uLea7OOG/2sTEVuSyeNAMeQWUeR87ajWS7u/Y3ViTkt2bVirF/b Ql/M2d/v1crFcuglHgGj68MIvaVszWC02Mn9WPKXbyk5UlrGziRvySKLj4N/WRSkj56E 9un9rxfljfMwz/1e8CiuxMEKNHCKgR1BxZBRX8wEm7YwtHMfvNUHXXPlke7K8fQy91zt ghbK5U3lsTd9Dts8OPaN6p0tS/um/02erPjC553855VA7WBrGd0L+acTj1BX7mkq3zGc fcZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Sg7bQtb; 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 z13si41360411pgp.376.2019.05.02.08.48.59; Thu, 02 May 2019 08:49:15 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=0Sg7bQtb; 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 S1727284AbfEBPrr (ORCPT + 99 others); Thu, 2 May 2019 11:47:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:39688 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbfEBPX4 (ORCPT ); Thu, 2 May 2019 11:23:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7AA4A20C01; Thu, 2 May 2019 15:23:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556810636; bh=RNnUtR82YtqJxHxbf9Jh3sB4wZIjls/mwrVbcsuQkXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Sg7bQtbKqB9GxBe4Vd5WFSduZAs99QsoQuhZKvPXd0EAWU66hfbQL1T1Bh+NUxh8 hlqeSFiplUVmhgrXVWnkIfP6CqrvRmVbNJVYgAC/h8f43M4D8ww4z1j6nOPn8bK1GJ OoiXm3kjOfB5eVvc5dF0qOM9bXogMYmDoKAo+7ak= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Frank Pavlic , Ben Dooks , Tristram Ha , "David S. Miller" , "Sasha Levin (Microsoft)" Subject: [PATCH 4.14 21/49] net: ks8851: Dequeue RX packets explicitly Date: Thu, 2 May 2019 17:20:58 +0200 Message-Id: <20190502143326.627107032@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190502143323.397051088@linuxfoundation.org> References: <20190502143323.397051088@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 536d3680fd2dab5c39857d62a3e084198fc74ff9 ] The ks8851 driver lets the chip auto-dequeue received packets once they have been read in full. It achieves that by setting the ADRFE flag in the RXQCR register ("Auto-Dequeue RXQ Frame Enable"). However if allocation of a packet's socket buffer or retrieval of the packet over the SPI bus fails, the packet will not have been read in full and is not auto-dequeued. Such partial retrieval of a packet confuses the chip's RX queue management: On the next RX interrupt, the first packet read from the queue will be the one left there previously and this one can be retrieved without issues. But for any newly received packets, the frame header status and byte count registers (RXFHSR and RXFHBCR) contain bogus values, preventing their retrieval. The chip allows explicitly dequeueing a packet from the RX queue by setting the RRXEF flag in the RXQCR register ("Release RX Error Frame"). This could be used to dequeue the packet in case of an error, but if that error is a failed SPI transfer, it is unknown if the packet was transferred in full and was auto-dequeued or if it was only transferred in part and requires an explicit dequeue. The safest approach is thus to always dequeue packets explicitly and forgo auto-dequeueing. Without this change, I've witnessed packet retrieval break completely when an SPI DMA transfer fails, requiring a chip reset. Explicit dequeueing magically fixes this and makes packet retrieval absolutely robust for me. The chip's documentation suggests auto-dequeuing and uses the RRXEF flag only to dequeue error frames which the driver doesn't want to retrieve. But that seems to be a fair-weather approach. Signed-off-by: Lukas Wunner Cc: Frank Pavlic Cc: Ben Dooks Cc: Tristram Ha Signed-off-by: David S. Miller Signed-off-by: Sasha Levin (Microsoft) --- drivers/net/ethernet/micrel/ks8851.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/micrel/ks8851.c b/drivers/net/ethernet/micrel/ks8851.c index 2fe96f1f3fe5..556666b0d756 100644 --- a/drivers/net/ethernet/micrel/ks8851.c +++ b/drivers/net/ethernet/micrel/ks8851.c @@ -526,9 +526,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) /* set dma read address */ ks8851_wrreg16(ks, KS_RXFDPR, RXFDPR_RXFPAI | 0x00); - /* start the packet dma process, and set auto-dequeue rx */ - ks8851_wrreg16(ks, KS_RXQCR, - ks->rc_rxqcr | RXQCR_SDA | RXQCR_ADRFE); + /* start DMA access */ + ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_SDA); if (rxlen > 4) { unsigned int rxalign; @@ -559,7 +558,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) } } - ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr); + /* end DMA access and dequeue packet */ + ks8851_wrreg16(ks, KS_RXQCR, ks->rc_rxqcr | RXQCR_RRXEF); } } -- 2.19.1