Received: by 10.213.65.68 with SMTP id h4csp329400imn; Fri, 16 Mar 2018 04:33:40 -0700 (PDT) X-Google-Smtp-Source: AG47ELvnEQBrb3fkZH2/YF4ireid5xnSvn6n1V1KaAq4xMT1GTcZCOySVDubpiEQy4e2Bv0kUe3r X-Received: by 2002:a17:902:b183:: with SMTP id s3-v6mr1774334plr.108.1521200020189; Fri, 16 Mar 2018 04:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521200020; cv=none; d=google.com; s=arc-20160816; b=gD0C6T6lVB/rcvBIpa3wWd1CnYRU7+MXetIYU+pGQtSWOcIwKSPWVfcmdLwT1INsp3 aTjGZuL8zpA4HVQ8ZpcwiaEL3h2ofeqRhKXCjNxD0w+8ZXYYwPknFbr+vEIB0aHALqST IATougKwetNAdLKup7GsGqmHTjd3gKmB7cjHjGNRYfW52GFRM/OdiDwBE6+Be3Zw1rF/ DpIp5uCV8vXlpPLVWD8N3dOBPwOXfW3mrLeP2HXWusblDYuLpu60XuqAQrh/5XLGLMKd GzWTpzx1KXwYOWVitXFtceOc4xIqxrEXEKQjKrsDqLb781AjWvPnlV0z2vXhuW96uPf2 BpIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=9slBi4wXOzc2hu8Yr5JDprYlXpfsPbA0Jg0wNWGtxKo=; b=Gw5Um8I6EkVqj0tpp+sPe+Yk/BuhYH3bS+/2otEyOXRJdutL/xtZAs09+NWQ4j3U7O RWbVn+xExcZdeStOp5vorcDHBU8VIjFEFj+wA49kCtOLSJv22eS/LgPBHOyFSp4B0Ee8 SqwTO4FrPs4fBRY4oQ570OJ5kFR1rgBxAv9rMkdGdjrqc7OhhkcvhYANCWi2DamEwut+ jKbPf7bRlErBWi2gWEiN7f0KnYi525AKXYZjI77pRyfR4pwI/4O09h/1TPw36X6Br4wo 4rTmRfeRc5zVz2eFqci0KwF468vI8Wygl+Mr4LvKZny0apQMq6zgfDpS6lYazKdipFuo OFFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s2si4897755pgo.626.2018.03.16.04.33.19; Fri, 16 Mar 2018 04:33:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753875AbeCPLav (ORCPT + 99 others); Fri, 16 Mar 2018 07:30:51 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:55484 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753138AbeCPLar (ORCPT ); Fri, 16 Mar 2018 07:30:47 -0400 Received: from hsi-kbw-5-158-153-52.hsi19.kabel-badenwuerttemberg.de ([5.158.153.52] helo=kurt.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1ewnZM-0007uf-B7; Fri, 16 Mar 2018 12:30:44 +0100 From: Kurt Kanzenbach To: gregkh@linuxfoundation.org Cc: kurt@linutronix.de, tglx@linutronix.de, jslaby@suse.com, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] tty: serial: 8250: pass IRQ shared flag to UART ports Date: Fri, 16 Mar 2018 12:31:58 +0100 Message-Id: <20180316113158.10298-1-kurt@linutronix.de> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On some systems IRQ lines between multiple UARTs might be shared. If so, the irqflags have to be configured accordingly. The reason is: The 8250 port startup code performs IRQ tests *before* the IRQ handler for that particular port is registered. This is performed in serial8250_do_startup(). This function checks whether IRQF_SHARED is configured and only then disables the IRQ line while testing. This test is performed upon each open() of the UART device. Imagine two UARTs share the same IRQ line: On is already opened and the IRQ is active. When the second UART is opened, the IRQ line has to be disabled while performing IRQ tests. Otherwise an IRQ might handler might be invoked, but the the IRQ itself cannot be handled, because the corresponding handler isn't registered, yet. That's because the 8250 code uses a chain-handler and invokes the corresponding port's IRQ handling rountines himself. Unfortunately this IRQF_SHARED flag isn't configured for UARTs probed via device tree even if the IRQs are shared. This way, the actual and shared IRQ line isn't disabled while performing tests and the kernel correctly detects a spurious IRQ. So, adding this flag to the DT probe solves the issue. Note: The UPF_SHARE_IRQ flag is configured unconditionally. Therefore, the IRQF_SHARED flag can be set unconditionally as well. Example stacktrace by performing echo 1 > /dev/ttyS2 on a non-patched system: |irq 85: nobody cared (try booting with the "irqpoll" option) | [...] |handlers: |[] irq_default_primary_handler threaded [] serial8250_interrupt |Disabling IRQ #85 Signed-off-by: Kurt Kanzenbach --- drivers/tty/serial/8250/8250_of.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c index 160b8906d9b9..575f91e04770 100644 --- a/drivers/tty/serial/8250/8250_of.c +++ b/drivers/tty/serial/8250/8250_of.c @@ -149,6 +149,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev, port->uartclk = clk; port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_FIXED_PORT | UPF_FIXED_TYPE; + port->irqflags |= IRQF_SHARED; if (of_property_read_bool(np, "no-loopback-test")) port->flags |= UPF_SKIP_TEST; -- 2.11.0