From patchwork Thu Jan 25 13:43:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 125844 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp1126431ljf; Thu, 25 Jan 2018 05:53:30 -0800 (PST) X-Google-Smtp-Source: AH8x225YoI4WLXPSqnMol3BMgR2XZSCpzyW8XiaQcDhv3P/+l9qibrc4x2c4vgBlHfZKicz5ybSl X-Received: by 10.129.136.129 with SMTP id y123mr8479206ywf.12.1516888409875; Thu, 25 Jan 2018 05:53:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516888409; cv=none; d=google.com; s=arc-20160816; b=A9d6xQgywMnhQeQYSysCMulWdnlfLBrLm4rQ+EMIT92UgTPDuG1DFpCD4EVcfHdUvJ NtXhZBoOCdWsTiifs7Kmz8ebem9xrxFVDFFAhYf3iyhPuuq+kS8zCB2wi9xQFhXH/SwR 9EPqR/xB5C3S7qZi5mUO+Cikd3Gan3TNVhc9RxQkU7bUb3fZ/eENlHSU7hWZoIjbAPPj oPb4zXd3gwIrgs370nwM7yJCUFmeDBb7WR0u2XvU7fnQNnsgIqGnlGcA8nZiSYoxA7Nl zeVbkGMwNQiEPCtQShBH5Fpy3C63c1mNIrx8vTbZjPPzEWBhsD4Pb2z0ZqWU2j1DnYQz hl5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=12eboDsrOy12KiO9L46DruekutAjLH9Zq1WumaXtdGI=; b=uaW07epacrcW6EhQs0rki11alyOwPVYZyfMZXnc+/A1DJWMBMEewOdNvTKcAsccubK /ysfEkcqPbmm/xVaZ1/xXVKy/41JWBK8Oz2i8UYudXLUNKm0adF/28rhQRvuMvtVvsnJ T0GbRwFzIGotkww3/XM487skLvLIqkzDRednytLG0LLgWGMxa7PafkTRxLqRDv8RX658 uC8u7Dr5DCHk0FgYL6KcRsGTtkLhJjDt18zY/ErqXiGuUZ+dn2i7JefSlI+gF4eAeJWr cze9ss6/8mZv34CptTIbwmAYsqz8ABsX36JDX2fwoiRhcw1pkU4j6dw6pia8MKEVPeUr 0oXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z10si482098ywi.467.2018.01.25.05.53.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 25 Jan 2018 05:53:29 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41434 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eehy5-0002Sb-5W for patch@linaro.org; Thu, 25 Jan 2018 08:53:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eehog-0003Eh-BT for qemu-devel@nongnu.org; Thu, 25 Jan 2018 08:43:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eehof-00038F-39 for qemu-devel@nongnu.org; Thu, 25 Jan 2018 08:43:46 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:45982) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eehoe-00030M-Rw for qemu-devel@nongnu.org; Thu, 25 Jan 2018 08:43:45 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eehoS-0006px-8z for qemu-devel@nongnu.org; Thu, 25 Jan 2018 13:43:32 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 25 Jan 2018 13:43:10 +0000 Message-Id: <1516887809-6265-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516887809-6265-1-git-send-email-peter.maydell@linaro.org> References: <1516887809-6265-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 02/21] i.MX: Fix FEC/ENET receive funtions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Jean-Christophe Dubois The actual imx_eth_enable_rx() function is buggy. It updates s->regs[ENET_RDAR] after calling qemu_flush_queued_packets(). qemu_flush_queued_packets() is going to call imx_XXX_receive() which itself is going to call imx_eth_enable_rx(). By updating s->regs[ENET_RDAR] after calling qemu_flush_queued_packets() we end up updating the register with an outdated value which might lead to disabling the receive function in the i.MX FEC/ENET device. This patch change the place where the register update is done so that the register value stays up to date and the receive function can keep running. Reported-by: Fyleo Tested-by: Fyleo Signed-off-by: Jean-Christophe Dubois Message-id: 20180113113445.2705-1-jcd@tribudubois.net Reviewed-by: Peter Maydell Reviewed-by: Andrey Smirnov Tested-by: Andrey Smirnov Signed-off-by: Peter Maydell --- hw/net/imx_fec.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index 4fb48f6..9506f9b 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -595,19 +595,16 @@ static void imx_eth_do_tx(IMXFECState *s, uint32_t index) static void imx_eth_enable_rx(IMXFECState *s, bool flush) { IMXFECBufDesc bd; - bool rx_ring_full; imx_fec_read_bd(&bd, s->rx_descriptor); - rx_ring_full = !(bd.flags & ENET_BD_E); + s->regs[ENET_RDAR] = (bd.flags & ENET_BD_E) ? ENET_RDAR_RDAR : 0; - if (rx_ring_full) { + if (!s->regs[ENET_RDAR]) { FEC_PRINTF("RX buffer full\n"); } else if (flush) { qemu_flush_queued_packets(qemu_get_queue(s->nic)); } - - s->regs[ENET_RDAR] = rx_ring_full ? 0 : ENET_RDAR_RDAR; } static void imx_eth_reset(DeviceState *d) @@ -866,7 +863,6 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, case ENET_RDAR: if (s->regs[ENET_ECR] & ENET_ECR_ETHEREN) { if (!s->regs[index]) { - s->regs[index] = ENET_RDAR_RDAR; imx_eth_enable_rx(s, true); } } else {