linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Lukas Wunner <lukas@wunner.de>, Frank Pavlic <f.pavlic@kunbus.de>,
	Ben Dooks <ben.dooks@codethink.co.uk>,
	Tristram Ha <Tristram.Ha@microchip.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.9 12/29] net: ks8851: Dequeue RX packets explicitly
Date: Mon, 22 Apr 2019 15:48:31 -0400	[thread overview]
Message-ID: <20190422194848.13049-12-sashal@kernel.org> (raw)
In-Reply-To: <20190422194848.13049-1-sashal@kernel.org>

From: Lukas Wunner <lukas@wunner.de>

[ 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 <lukas@wunner.de>
Cc: Frank Pavlic <f.pavlic@kunbus.de>
Cc: Ben Dooks <ben.dooks@codethink.co.uk>
Cc: Tristram Ha <Tristram.Ha@microchip.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
 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 1edc973df4c4..247a3377b951 100644
--- a/drivers/net/ethernet/micrel/ks8851.c
+++ b/drivers/net/ethernet/micrel/ks8851.c
@@ -547,9 +547,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;
@@ -580,7 +579,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


  parent reply	other threads:[~2019-04-22 19:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-22 19:48 [PATCH AUTOSEL 4.9 01/29] ARM: dts: bcm283x: Fix hdmi hpd gpio pull Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 02/29] s390: limit brk randomization to 32MB Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 03/29] qlcnic: Avoid potential NULL pointer dereference Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 04/29] netfilter: nft_set_rbtree: check for inactive element after flag mismatch Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 05/29] netfilter: bridge: set skb transport_header before entering NF_INET_PRE_ROUTING Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 06/29] sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init() Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 07/29] serial: ar933x_uart: Fix build failure with disabled console Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 08/29] usb: gadget: net2280: Fix overrun of OUT messages Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 09/29] usb: gadget: net2280: Fix net2280_dequeue() Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 10/29] usb: gadget: net2272: Fix net2272_dequeue() Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 11/29] ARM: dts: pfla02: increase phy reset duration Sasha Levin
2019-04-22 19:48 ` Sasha Levin [this message]
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 13/29] net: ks8851: Reassert reset pin if chip ID check fails Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 14/29] net: ks8851: Delay requesting IRQ until opened Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 15/29] net: ks8851: Set initial carrier state to down Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 16/29] staging: rtl8712: uninitialized memory in read_bbreg_hdl() Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 17/29] NFS: Fix a typo in nfs_init_timeout_values() Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 18/29] net: xilinx: fix possible object reference leak Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 19/29] net: ibm: " Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 20/29] net: ethernet: ti: " Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 21/29] scsi: qla4xxx: fix a potential NULL pointer dereference Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 22/29] usb: u132-hcd: fix resource leak Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 23/29] tty: fix NULL pointer issue when tty_port ops is not set Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 24/29] ceph: fix use-after-free on symlink traversal Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 25/29] scsi: zfcp: reduce flood of fcrscn1 trace records on multi-element RSCN Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 26/29] libata: fix using DMA buffers on stack Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 27/29] gpio: of: Fix of_gpiochip_add() error path Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 28/29] kconfig/[mn]conf: handle backspace (^H) key Sasha Levin
2019-04-22 19:48 ` [PATCH AUTOSEL 4.9 29/29] leds: pca9532: fix a potential NULL pointer dereference Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190422194848.13049-12-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Tristram.Ha@microchip.com \
    --cc=ben.dooks@codethink.co.uk \
    --cc=davem@davemloft.net \
    --cc=f.pavlic@kunbus.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).