From patchwork Thu Jan 28 21:25:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8154011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D26659F818 for ; Thu, 28 Jan 2016 21:31:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0465F202F8 for ; Thu, 28 Jan 2016 21:31:59 +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 EC11A2020F for ; Thu, 28 Jan 2016 21:31:57 +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 1aOu8w-0007DM-4d; Thu, 28 Jan 2016 21:30:18 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aOu7G-0005qH-Hw for linux-arm-kernel@lists.infradead.org; Thu, 28 Jan 2016 21:28:40 +0000 Received: by mail-pa0-x22f.google.com with SMTP id cy9so29198608pac.0 for ; Thu, 28 Jan 2016 13:28:14 -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=DwuH5bu6IOimS/ruqoTjfCKa0QOTN1C04lAw9/O8BzI=; b=oUQ0CGTZa2TIpNM0ViDqK4yt1HG9a95X8vBLT/Kg2yVj8gIck4825pDikKz3CQuTVw L8q4tvILh0kWp2V5KwxQMJ+NcrhT2IuRx7fiXMVcFc+th1+3pcXMd61ynH7brHS727xe JWyNTP/XtXytRf1nS1+gcMQohVnMkRBajF8YWUSTflE5YFop9meBecg0G3HuWqPE4Syb rGlO/48B2OyFILq9nPXi6JLU1Qs44hwFjvMemDYE3cIWfOqwwlxw4LgYpsTUXmdvpMXt LMt5LspFP8k7gde2phN4asbg63JhipR1t4ksnUp2pdjwizG0PlwbfQksEoAMTwmPPYkX CiFw== 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=DwuH5bu6IOimS/ruqoTjfCKa0QOTN1C04lAw9/O8BzI=; b=U7hAQUZDCJnb+dAiLCDJr56qaCRy+dZVGXsiLC7wMejG5dYI1WT1xszoCKaTvX2UOK nvdgFloCCdb1l7AfP4QB061GpGDERDWF/DaIEPH1iYQGKiT9utu+WplC60ag9LIcaw/C GXMvHLiM7YktBCwOGYLBdGE8obgZ+/lw6/pm2XFOdyWmMPkYshbqaTP2LPBzbpvqpJtl aJHVvgT8LzVlnewQ4awdUhNqgz7MleiqMK9570znruyr1Rdpq4WC4guwzpuL1OsmH6uE 2ZrlroFqAbPdQgMhKwkZWivRVrOz4B0zf+3wIJRPFbeL4JLk2Q7UpaDadkDSZbSO24GM jSPg== X-Gm-Message-State: AG10YORNvNtpN22F9hcgRJBmL5sNBkZSbQrMqiWG5oj1ub1Vbijf6+f3yvXpPO1IxsgVxQ== X-Received: by 10.66.218.225 with SMTP id pj1mr7778789pac.40.1454016493915; Thu, 28 Jan 2016 13:28:13 -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 c90sm18583190pfd.31.2016.01.28.13.28.12 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jan 2016 13:28:13 -0800 (PST) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, B38611@freescale.com Subject: [PATCH net-next 03/40] net: fec: fix fec_enet_get_free_txdesc_num Date: Thu, 28 Jan 2016 14:25:27 -0700 Message-Id: <1454016364-30985-4-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> References: <1454016364-30985-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160128_132834_851223_9F36FF4B X-CRM114-Status: UNSURE ( 9.99 ) 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, Troy Kisky , laci@boundarydevices.com, 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.1 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 620834f..8e1f2a6 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)