All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Li RongQing <lirongqing@baidu.com>,
	Kurt Kanzenbach <kurt@linutronix.de>,
	Vikram Pandita <vikram.pandita@ti.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH 4.19 40/97] serial: 8250: Check UPF_IRQ_SHARED in advance
Date: Thu, 27 Feb 2020 14:36:48 +0100	[thread overview]
Message-ID: <20200227132221.097160479@linuxfoundation.org> (raw)
In-Reply-To: <20200227132214.553656188@linuxfoundation.org>

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

commit 7febbcbc48fc92e3f33863b32ed715ba4aff18c4 upstream.

The commit 54e53b2e8081
  ("tty: serial: 8250: pass IRQ shared flag to UART ports")
nicely explained the problem:

---8<---8<---

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 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 routines 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 stack trace by performing `echo 1 > /dev/ttyS2` on a non-patched system:

|irq 85: nobody cared (try booting with the "irqpoll" option)
| [...]
|handlers:
|[<ffff0000080fc628>] irq_default_primary_handler threaded [<ffff00000855fbb8>] serial8250_interrupt
|Disabling IRQ #85

---8<---8<---

But unfortunately didn't fix the root cause. Let's try again here by moving
IRQ flag assignment from serial_link_irq_chain() to serial8250_do_startup().

This should fix the similar issue reported for 8250_pnp case.

Since this change we don't need to have custom solutions in 8250_aspeed_vuart
and 8250_of drivers, thus, drop them.

Fixes: 1c2f04937b3e ("serial: 8250: add IRQ trigger support")
Reported-by: Li RongQing <lirongqing@baidu.com>
Cc: Kurt Kanzenbach <kurt@linutronix.de>
Cc: Vikram Pandita <vikram.pandita@ti.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
Link: https://lore.kernel.org/r/20200211135559.85960-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/tty/serial/8250/8250_aspeed_vuart.c |    1 -
 drivers/tty/serial/8250/8250_core.c         |    5 ++---
 drivers/tty/serial/8250/8250_of.c           |    1 -
 drivers/tty/serial/8250/8250_port.c         |    4 ++++
 4 files changed, 6 insertions(+), 5 deletions(-)

--- a/drivers/tty/serial/8250/8250_aspeed_vuart.c
+++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c
@@ -375,7 +375,6 @@ static int aspeed_vuart_probe(struct pla
 		port.port.line = rc;
 
 	port.port.irq = irq_of_parse_and_map(np, 0);
-	port.port.irqflags = IRQF_SHARED;
 	port.port.handle_irq = aspeed_vuart_handle_irq;
 	port.port.iotype = UPIO_MEM;
 	port.port.type = PORT_16550A;
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -177,7 +177,7 @@ static int serial_link_irq_chain(struct
 	struct hlist_head *h;
 	struct hlist_node *n;
 	struct irq_info *i;
-	int ret, irq_flags = up->port.flags & UPF_SHARE_IRQ ? IRQF_SHARED : 0;
+	int ret;
 
 	mutex_lock(&hash_mutex);
 
@@ -212,9 +212,8 @@ static int serial_link_irq_chain(struct
 		INIT_LIST_HEAD(&up->list);
 		i->head = &up->list;
 		spin_unlock_irq(&i->lock);
-		irq_flags |= up->port.irqflags;
 		ret = request_irq(up->port.irq, serial8250_interrupt,
-				  irq_flags, up->port.name, i);
+				  up->port.irqflags, up->port.name, i);
 		if (ret < 0)
 			serial_do_unlink(i, up);
 	}
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -171,7 +171,6 @@ static int of_platform_serial_setup(stru
 
 	port->type = type;
 	port->uartclk = clk;
-	port->irqflags |= IRQF_SHARED;
 
 	if (of_property_read_bool(np, "no-loopback-test"))
 		port->flags |= UPF_SKIP_TEST;
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -2253,6 +2253,10 @@ int serial8250_do_startup(struct uart_po
 		}
 	}
 
+	/* Check if we need to have shared IRQs */
+	if (port->irq && (up->port.flags & UPF_SHARE_IRQ))
+		up->port.irqflags |= IRQF_SHARED;
+
 	if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) {
 		unsigned char iir1;
 		/*



  parent reply	other threads:[~2020-02-27 14:31 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-27 13:36 [PATCH 4.19 00/97] 4.19.107-stable review Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 01/97] iommu/qcom: Fix bogus detach logic Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 02/97] ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 03/97] ALSA: hda/realtek - Apply quirk for MSI GP63, too Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 04/97] ALSA: hda/realtek - Apply quirk for yet another MSI laptop Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 05/97] ASoC: sun8i-codec: Fix setting DAI data format Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 06/97] ecryptfs: fix a memory leak bug in parse_tag_1_packet() Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 07/97] ecryptfs: fix a memory leak bug in ecryptfs_init_messaging() Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 08/97] thunderbolt: Prevent crash if non-active NVMem file is read Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 09/97] USB: misc: iowarrior: add support for 2 OEMed devices Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 10/97] USB: misc: iowarrior: add support for the 28 and 28L devices Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 11/97] USB: misc: iowarrior: add support for the 100 device Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 12/97] floppy: check FDC index for errors before assigning it Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 13/97] vt: fix scrollback flushing on background consoles Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 14/97] vt: selection, handle pending signals in paste_selection Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 15/97] vt: selection, close sel_buffer race Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 16/97] vt: vt_ioctl: fix race in VT_RESIZEX Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 17/97] staging: android: ashmem: Disallow ashmem memory from being remapped Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 18/97] staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 19/97] xhci: Force Maximum Packet size for Full-speed bulk devices to valid range Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 20/97] xhci: fix runtime pm enabling for quirky Intel hosts Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 21/97] xhci: Fix memory leak when caching protocol extended capability PSI tables - take 2 Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 22/97] usb: host: xhci: update event ring dequeue pointer on purpose Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 23/97] USB: core: add endpoint-blacklist quirk Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 24/97] USB: quirks: blacklist duplicate ep on Sound Devices USBPre2 Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 25/97] usb: uas: fix a plug & unplug racing Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 26/97] USB: Fix novation SourceControl XL after suspend Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 27/97] USB: hub: Dont record a connect-change event during reset-resume Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 28/97] USB: hub: Fix the broken detection of USB3 device in SMSC hub Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 29/97] usb: dwc2: Fix SET/CLEAR_FEATURE and GET_STATUS flows Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 30/97] usb: dwc3: gadget: Check for IOC/LST bit in TRB->ctrl fields Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 31/97] staging: rtl8188eu: Fix potential security hole Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 32/97] staging: rtl8188eu: Fix potential overuse of kernel memory Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 33/97] staging: rtl8723bs: Fix potential security hole Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 34/97] staging: rtl8723bs: Fix potential overuse of kernel memory Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 35/97] powerpc/tm: Fix clearing MSR[TS] in current when reclaiming on signal delivery Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 36/97] jbd2: fix ocfs2 corrupt when clearing block group bits Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 37/97] x86/mce/amd: Publish the bank pointer only after setup has succeeded Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 38/97] x86/mce/amd: Fix kobject lifetime Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 39/97] x86/cpu/amd: Enable the fixed Instructions Retired counter IRPERF Greg Kroah-Hartman
2020-02-27 13:36 ` Greg Kroah-Hartman [this message]
2020-02-27 13:36 ` [PATCH 4.19 41/97] tty/serial: atmel: manage shutdown in case of RS485 or ISO7816 mode Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 42/97] tty: serial: imx: setup the correct sg entry for tx dma Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 43/97] serdev: ttyport: restore client ops on deregistration Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 44/97] MAINTAINERS: Update drm/i915 bug filing URL Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 45/97] Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()" Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 46/97] mm/memcontrol.c: lost css_put in memcg_expand_shrinker_maps() Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 47/97] nvme-multipath: Fix memory leak with ana_log_buf Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 48/97] genirq/irqdomain: Make sure all irq domain flags are distinct Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 49/97] mm/vmscan.c: dont round up scan size for online memory cgroup Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 50/97] drm/amdgpu/soc15: fix xclk for raven Greg Kroah-Hartman
2020-02-27 13:36 ` [PATCH 4.19 51/97] xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 52/97] KVM: nVMX: Dont emulate instructions in guest mode Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 53/97] KVM: x86: dont notify userspace IOAPIC on edge-triggered interrupt EOI Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 54/97] tty: serial: qcom_geni_serial: Fix UART hang Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 55/97] tty: serial: qcom_geni_serial: Remove interrupt storm Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 56/97] tty: serial: qcom_geni_serial: Remove use of *_relaxed() and mb() Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 57/97] tty: serial: qcom_geni_serial: Remove set_rfr_wm() and related variables Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 58/97] tty: serial: qcom_geni_serial: Remove xfer_mode variable Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 59/97] tty: serial: qcom_geni_serial: Fix RX cancel command failure Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 60/97] lib/stackdepot: Fix outdated comments Greg Kroah-Hartman
2020-02-28 13:05   ` Pavel Machek
2020-02-28 13:24     ` Greg Kroah-Hartman
2020-02-28 13:30       ` Greg Kroah-Hartman
2020-02-28 18:05         ` Sasha Levin
2020-02-27 13:37 ` [PATCH 4.19 61/97] lib/stackdepot.c: fix global out-of-bounds in stack_slabs Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 62/97] drm/nouveau/kms/gv100-: Re-set LUT after clearing for modesets Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 63/97] ext4: fix a data race in EXT4_I(inode)->i_disksize Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 64/97] ext4: add cond_resched() to __ext4_find_entry() Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 65/97] ext4: fix potential race between online resizing and write operations Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 66/97] ext4: fix potential race between s_group_info online resizing and access Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 67/97] ext4: fix potential race between s_flex_groups " Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 68/97] ext4: fix mount failure with quota configured as module Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 69/97] ext4: rename s_journal_flag_rwsem to s_writepages_rwsem Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 70/97] ext4: fix race between writepages and enabling EXT4_EXTENTS_FL Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 71/97] KVM: nVMX: Refactor IO bitmap checks into helper function Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 72/97] KVM: nVMX: Check IO instruction VM-exit conditions Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 73/97] KVM: nVMX: handle nested posted interrupts when apicv is disabled for L1 Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 74/97] KVM: apic: avoid calculating pending eoi from an uninitialized val Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 75/97] btrfs: fix bytes_may_use underflow in prealloc error condtition Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 76/97] btrfs: reset fs_root to NULL on error in open_ctree Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 77/97] btrfs: do not check delayed items are empty for single transaction cleanup Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 78/97] Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 79/97] Revert "dmaengine: imx-sdma: Fix memory leak" Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 80/97] scsi: Revert "RDMA/isert: Fix a recently introduced regression related to logout" Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 81/97] scsi: Revert "target: iscsi: Wait for all commands to finish before freeing a session" Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 82/97] usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 83/97] usb: dwc2: Fix in ISOC request length checking Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 84/97] staging: rtl8723bs: fix copy of overlapping memory Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 85/97] staging: greybus: use after free in gb_audio_manager_remove_all() Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 86/97] ecryptfs: replace BUG_ON with error handling code Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 87/97] iommu/vt-d: Fix compile warning from intel-svm.h Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 88/97] genirq/proc: Reject invalid affinity masks (again) Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 89/97] bpf, offload: Replace bitwise AND by logical AND in bpf_prog_offload_info_fill Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 90/97] ALSA: rawmidi: Avoid bit fields for state flags Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 91/97] ALSA: seq: Avoid concurrent access to queue flags Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 92/97] ALSA: seq: Fix concurrent access to queue current tick/time Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 93/97] netfilter: xt_hashlimit: limit the max size of hashtable Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 94/97] rxrpc: Fix call RCU cleanup using non-bh-safe locks Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 95/97] ata: ahci: Add shutdown to freeze hardware resources of ahci Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 96/97] xen: Enable interrupts when calling _cond_resched() Greg Kroah-Hartman
2020-02-27 13:37 ` [PATCH 4.19 97/97] s390/mm: Explicitly compare PAGE_DEFAULT_KEY against zero in storage_key_init_range Greg Kroah-Hartman
2020-02-27 15:51 ` [PATCH 4.19 00/97] 4.19.107-stable review Chris Paterson
2020-02-28 13:51   ` Greg Kroah-Hartman
     [not found] ` <20200227132214.553656188-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>
2020-02-27 18:52   ` Jon Hunter
2020-02-27 18:52     ` Jon Hunter
2020-02-27 19:41 ` Guenter Roeck
2020-02-28  3:35 ` Naresh Kamboju
2020-02-28  3:39 ` shuah

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200227132221.097160479@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=kurt@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=stable@vger.kernel.org \
    --cc=vikram.pandita@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.