From patchwork Fri Feb 5 21:52:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8239871 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 23C4BBEEE5 for ; Fri, 5 Feb 2016 21:57:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 438E4203B8 for ; Fri, 5 Feb 2016 21:57:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7738B203B4 for ; Fri, 5 Feb 2016 21:57:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aRoMD-0004eS-3V; Fri, 05 Feb 2016 21:56:01 +0000 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aRoLi-0004JR-EM for linux-arm-kernel@lists.infradead.org; Fri, 05 Feb 2016 21:55:31 +0000 Received: by mail-pf0-x22e.google.com with SMTP id o185so75229517pfb.1 for ; Fri, 05 Feb 2016 13:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boundarydevices-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u8VmL2viEtA/WKfZ5KHiaOoCfiCpqymal5qa2zndPLs=; b=YztURqwr5g5hFZuRkR1n/8NZjpquht3x+/z/5/N9tHWI51h6Ubg9Y63f9T1VmKSZsg zbFi0uhpW7zK7XR+qBh78FvJHY0OAQfLB7w2nchsAG79itB7OySpkL8Q+ddHhNcalGax KVnwPCpsIpjduw6s+cOlBeo/PpAF2i9ABGOlQrY9WNW2sCmUOvRP3yHrseeMX5eqOHRX ypqhmF373v0Qqy7NHBpNhg3GjS8uLULDll65WioFyzB6TBV2SAv9HtvC41aS2nVQvgBL 5vNlOxARyqRxVShV03YPoVMpmp/d8KjsVyRKIxF93XV+AN3UInJRMFnL4baLZRq+rrsh JGFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u8VmL2viEtA/WKfZ5KHiaOoCfiCpqymal5qa2zndPLs=; b=JpHCVinIDnAxKVzbD8/d4eFtlC8m8OFEwnMoeSvI9MPTyHPxx3/olLnYzBTwgJsGdD Yjtrd6cJEdybFwRgh28cN/PEqzWVmLXRdo4tBt6MR1FLNEdi3AKz2xEvb8WLyV4v4R/e MNNYarEWrBQsZhNQHP7loTAnSgduz5atBeTGprkV90CDo2GeNRMNsuy4h/Fa3OAElQSj 60Y0AaVXNCejHG7N8eSbM0qHl17RhQouTIHicHsVgGPNdGTDbh9A/7g4Mhft6Rbz1J1n qHihVneQT6kVbbcCQ3FacpmRpq8MMJXuXzq2ZMKObOoYUgNypu/96uZo4iWjgV/u6IpC l8Yg== X-Gm-Message-State: AG10YOTUWNDnvOqa2hlkIZMTH6alJ7NrYqJ8PATmSIzp+VRH9XEEEumD6vY5SoyQuxzr3g== X-Received: by 10.98.74.202 with SMTP id c71mr23333851pfj.25.1454709309762; Fri, 05 Feb 2016 13:55:09 -0800 (PST) Received: from localhost.localdomain (wsip-70-184-93-199.ph.ph.cox.net. [70.184.93.199]) by smtp.googlemail.com with ESMTPSA id v75sm26628688pfa.39.2016.02.05.13.55.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Feb 2016 13:55:09 -0800 (PST) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, B38611@freescale.com Subject: [PATCH net-next V2 3/8] net: fec: fix fec_enet_get_free_txdesc_num Date: Fri, 5 Feb 2016 14:52:45 -0700 Message-Id: <1454709170-19527-4-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454709170-19527-1-git-send-email-troy.kisky@boundarydevices.com> References: <1454709170-19527-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160205_135530_671399_3A2AB7A3 X-CRM114-Status: UNSURE ( 9.75 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fabio.estevam@freescale.com, andrew@lunn.ch, linux@arm.linux.org.uk, arnd@arndb.de, Troy Kisky , laci@boundarydevices.com, johannes@sipsolutions.net, l.stach@pengutronix.de, shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, tremyfr@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When first initialized, cur_tx points to the 1st entry in the queue, and dirty_tx points to the last. At this point, fec_enet_get_free_txdesc_num will return tx_ring_size -2. If tx_ring_size -2 entries are now queued, then fec_enet_get_free_txdesc_num should return 0, but it returns tx_ring_size instead. Signed-off-by: Troy Kisky --- drivers/net/ethernet/freescale/fec_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 162fa59..adbddfd 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -296,7 +296,7 @@ static int fec_enet_get_free_txdesc_num(struct fec_enet_private *fep, entries = ((const char *)txq->dirty_tx - (const char *)txq->cur_tx) / fep->bufdesc_size - 1; - return entries > 0 ? entries : entries + txq->tx_ring_size; + return entries >= 0 ? entries : entries + txq->tx_ring_size; } static void swap_buffer(void *bufaddr, int len)