From patchwork Fri Mar 9 21:47:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10272005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 32A546016D for ; Fri, 9 Mar 2018 21:54:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2103D2A00D for ; Fri, 9 Mar 2018 21:54:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1195F2A010; Fri, 9 Mar 2018 21:54:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 664DD2A00D for ; Fri, 9 Mar 2018 21:54:35 +0000 (UTC) Received: from localhost ([::1]:48255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euPyE-0004tp-96 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 09 Mar 2018 16:54:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euPrF-0007mH-NR for qemu-devel@nongnu.org; Fri, 09 Mar 2018 16:47:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1euPrE-000110-L1 for qemu-devel@nongnu.org; Fri, 09 Mar 2018 16:47:21 -0500 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:38515) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1euPr6-0000yL-Ed; Fri, 09 Mar 2018 16:47:12 -0500 Received: by mail-pl0-x244.google.com with SMTP id m22-v6so5943401pls.5; Fri, 09 Mar 2018 13:47:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=xhborW+vJ12oySCHu5Z2LSdKIUebBdfHzN933ENyTF4=; b=EZI3Pgm/PbTr63LQRpQVuO/266hmgZwA4lRYlmM4sEz0xUhpOcYuuEGllBxTVPXGl0 26P+8Zu224W0hi9wjTfWhuMSKDmE/sWnYm2t+bVig8dbJB6kILAE25dG9H6Ro7fiDiBa 87fSykFgG/MK4slZMYROo4JBxEzX6hJkLfRh3/EGPlbO1oLl16SxgAZy0Npn6yUKLPPR FJnGuVINiIOoTAvsHuNd0JnSEinEe23QzXDf6aJArqcycNfLDeA0jLC5cqr4r8isuYrs uCsd9A+Ne9FgDYH5IitomQzrcfpisILBAndOMdcw3qmGsOgwmPeXIMfhMj0MwKsq34Jv 6r6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=xhborW+vJ12oySCHu5Z2LSdKIUebBdfHzN933ENyTF4=; b=d7dfZWOZmrMa+GNjhK9tOZCC3SZmkVE1yWvVHv/SXKGjF1MCti++t7QLCNjaHz8aQ+ LVLpbNLZF2krBkUX96it2Lt9L9pj8vOklXjtNndvFJpNweuk9IOlqwZH5v+hmG3d2KyB tRfyXneBDn6ttWFYUdNxHVXeZeuX/i0yuTpwWyGrF0LXVKIvLSqSnDeSUJ/jH7Hicwsb 1FlQVLNt3m7g+YwKFHQaYADsbC6iCvZTycAI0Q3omPUb4Th6xrxP4xikiya7ZDDJBXf4 alM4FHwjNQST5KU3Kl8eZ/cY5b58g1S70gvrGrRAxkhi49Gl0tnWfs4LDY1WozCsg3gK 44EQ== X-Gm-Message-State: APf1xPADRynwkLnuxeMxWnSHql9GPGnZRKKyHfftu1KQXoVhcxewx4Gd ElCZSQYEE+1iM3Qgs97pBQU= X-Google-Smtp-Source: AG47ELufMCX9XjV5264ajWYlhAhJGcZj/edAxokw8OxCzm9W8v4jTifo72U9O8eEdmS7rRn+WvdMLA== X-Received: by 2002:a17:902:7b92:: with SMTP id w18-v6mr28554900pll.159.1520632029882; Fri, 09 Mar 2018 13:47:09 -0800 (PST) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id h67sm5801054pfk.184.2018.03.09.13.47.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Mar 2018 13:47:09 -0800 (PST) From: Guenter Roeck To: Peter Maydell Date: Fri, 9 Mar 2018 13:47:03 -0800 Message-Id: <1520632024-31535-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [PATCH v2] fsl-imx6: Swap Ethernet interrupt defines 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: , Cc: Bill Paul , Andrey Smirnov , Jason Wang , qemu-devel@nongnu.org, qemu-arm@nongnu.org, Peter Chubb , Guenter Roeck , Chris Healy Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The sabrelite machine model used by qemu-system-arm is based on the Freescale/NXP i.MX6Q processor. This SoC has an on-board ethernet controller which is supported in QEMU using the imx_fec.c module (actually called imx.enet for this model.) The include/hw/arm/fsm-imx6.h file defines the interrupt vectors for the imx.enet device like this: #define FSL_IMX6_ENET_MAC_1588_IRQ 118 #define FSL_IMX6_ENET_MAC_IRQ 119 According to https://www.nxp.com/docs/en/reference-manual/IMX6DQRM.pdf, page 225, in Table 3-1. ARM Cortex A9 domain interrupt summary, interrupts are as follows. 150 ENET MAC 0 IRQ 151 ENET MAC 0 1588 Timer interrupt where 150 - 32 == 118 151 - 32 == 119 In other words, the vector definitions in the fsl-imx6.h file are reversed. Fixing the interrupts alone causes problems with older Linux kernels: The Ethernet interface will fail to probe with Linux v4.9 and earlier. Linux v4.1 and earlier will crash due to a bug in Ethernet driver probe error handling. This is a Linux kernel problem, not a qemu problem: the Linux kernel only worked by accident since it requested both interrupts. For backward compatibility, generate the Ethernet interrupt on both interrupt lines. This was shown to work from all Linux kernel releases starting with v3.16. Link: https://bugs.launchpad.net/qemu/+bug/1753309 Signed-off-by: Guenter Roeck --- v2: Generate Ethernet interrupts on both interrupt lines hw/net/imx_fec.c | 7 ++++++- include/hw/arm/fsl-imx6.h | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c index 9506f9b..d3ae7db 100644 --- a/hw/net/imx_fec.c +++ b/hw/net/imx_fec.c @@ -417,7 +417,12 @@ static void imx_enet_write_bd(IMXENETBufDesc *bd, dma_addr_t addr) static void imx_eth_update(IMXFECState *s) { - if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & ENET_INT_TS_TIMER) { + /* + * Generate ENET_INT_MAC interrrupts on both interrupt lines for + * backward compatibility with Linux kernel versions 4.9 and older. + */ + if (s->regs[ENET_EIR] & s->regs[ENET_EIMR] & + (ENET_INT_MAC | ENET_INT_TS_TIMER)) { qemu_set_irq(s->irq[1], 1); } else { qemu_set_irq(s->irq[1], 0); diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h index ec6c509..06f8aae 100644 --- a/include/hw/arm/fsl-imx6.h +++ b/include/hw/arm/fsl-imx6.h @@ -438,8 +438,8 @@ typedef struct FslIMX6State { #define FSL_IMX6_HDMI_MASTER_IRQ 115 #define FSL_IMX6_HDMI_CEC_IRQ 116 #define FSL_IMX6_MLB150_LOW_IRQ 117 -#define FSL_IMX6_ENET_MAC_1588_IRQ 118 -#define FSL_IMX6_ENET_MAC_IRQ 119 +#define FSL_IMX6_ENET_MAC_IRQ 118 +#define FSL_IMX6_ENET_MAC_1588_IRQ 119 #define FSL_IMX6_PCIE1_IRQ 120 #define FSL_IMX6_PCIE2_IRQ 121 #define FSL_IMX6_PCIE3_IRQ 122