From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753429AbbJaQDd (ORCPT ); Sat, 31 Oct 2015 12:03:33 -0400 Received: from unicorn.mansr.com ([81.2.72.234]:36577 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbbJaQDa convert rfc822-to-8bit (ORCPT ); Sat, 31 Oct 2015 12:03:30 -0400 From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: Francois Romieu Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v4] net: ethernet: add driver for Aurora VLSI NB8800 Ethernet controller References: <1446137333-1822-1-git-send-email-mans@mansr.com> <20151030222841.GA24712@electric-eye.fr.zoreil.com> Date: Sat, 31 Oct 2015 16:03:26 +0000 In-Reply-To: <20151030222841.GA24712@electric-eye.fr.zoreil.com> (Francois Romieu's message of "Fri, 30 Oct 2015 23:28:42 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Francois Romieu writes: >> +static int nb8800_poll(struct napi_struct *napi, int budget) >> +{ >> + struct net_device *dev = napi->dev; >> + struct nb8800_priv *priv = netdev_priv(dev); >> + struct nb8800_dma_desc *rx; >> + int work = 0; >> + int last = priv->rx_eoc; >> + int next; >> + >> + while (work < budget) { >> + struct rx_buf *rx_buf; >> + u32 report; >> + int len; >> + >> + next = (last + 1) & (RX_DESC_COUNT - 1); >> + >> + rx_buf = &priv->rx_bufs[next]; >> + rx = &priv->rx_descs[next]; >> + report = rx->report; >> + >> + if (!report) >> + break; >> + >> + if (IS_RX_ERROR(report)) { >> + nb8800_rx_error(dev, report); >> + } else if (likely(rx_buf->page)) { >> + len = RX_BYTES_TRANSFERRED(report); >> + nb8800_receive(dev, next, len); >> + } >> + >> + rx->report = 0; >> + if (!rx_buf->page) >> + nb8800_alloc_rx(dev, next, true); > > It looks like it receives, then tries to allocate new resources. If so > it may deplete the ring and you should instead consider allocating new > resources first, then receive data if alloc + map suceeded. The hardware receives a frame and stores it in the provided DMA buffer, then raises an interrupt and moves on to the next buffer. When a buffer is handed over to the network stack, a new one has to take its place in the DMA queue. I'm not sure how you're suggesting this be done differently. -- Måns Rullgård mans@mansr.com