Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp83889ybx; Thu, 31 Oct 2019 16:21:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEO6egSiuN4X6hQ7pqf+qgl5Psm3l4fqYkrpv/fNvFSttiUa5Egcumv1GpbBbwEvISlGbb X-Received: by 2002:a50:b536:: with SMTP id y51mr9253161edd.271.1572564079794; Thu, 31 Oct 2019 16:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572564079; cv=none; d=google.com; s=arc-20160816; b=NE5WGM03E0ylZtgpxY2+Vg2WEGjGh2Kd6JxOgzkkhBgNitbeQ9lajdORaCoNzEQACE N5Q/+4V3Q0F7vIuav2mTWlTnMNZjb/8vEIL/4mlDqy8OauHvZUFnZD4lX8p11pR11PwP ZGcHk7AUEr7Mv5ICbV1/g083nNfRwsW/YVR4cvDYtOXMRKVOcoc17i1XSTbbXgkvnhTu Tz2FpVM03cmqMNjKmPHPD2bIcsU3oY+9CnmiQ2QMtNS6YA8ZNmT+FivZRtxN9MborzgL mUFe3ovr+IQ6fPdxwK4Ddt7H0g+s7mnSY51rC73kx8/+XYc7uL6hSJ3BG9H9VLeub5zW Nglw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=BWwCoCUZCYs69Qx0mUwwrIF+/sbykgsm3vywLso9kX8=; b=z/b9gBxp2xQHpqm652wguJ9apx8Swi/B7d1E5nZdAR81r9uPBXnwqe9lx99Zlga5uG xh9Xp0tSj/D36u3ICGFV4G9QZAOFbPETncWd6vhpVsorE+2iesjbeQwAfE5YlDMMRqRU +0JXPwZXqGRYn5jDaSoqux8tRtBhgeRyoJWZaFarXEhka9pviHVIjQa7YSh+a/qy89UY mjfK4H+WCXyfihRe8qOdweLgMSDD7CWkP6xqFiHZ0fSQRJnOKNW91OwKYPd5mY/JPTNA ZqlXHJIigvbFT0KhAxGIb+62JRShJpVT30nMna23quEZV4/UVJmpl5CZWXEQrj/7P5xG omPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=L3xc+mry; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e25si5622025ede.335.2019.10.31.16.20.56; Thu, 31 Oct 2019 16:21:19 -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; dkim=pass header.i=@kernel.org header.s=default header.b=L3xc+mry; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728474AbfJaXFf (ORCPT + 99 others); Thu, 31 Oct 2019 19:05:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:60546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726602AbfJaXFf (ORCPT ); Thu, 31 Oct 2019 19:05:35 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 469D62080F; Thu, 31 Oct 2019 23:05:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572563134; bh=4z2WuELNukNwKuKrFR1f3kQfDOncbIyk/+Kn5OAHdec=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=L3xc+mry460+mKLDYMYkBOhGK+f+eRRMzhLD3aBVcDSwHy5hy+uJ44c7lwaBi7qoB 5h4rUMRCnK4Mv96EKpJWUkIToZgZiAhhwC67d28eUGe20yFziukgpXzAiE0veeh28K 42ADyhYQRSM6yuofTjj2JfBrWqYYQCAv8XwBwXOQ= Date: Thu, 31 Oct 2019 18:05:32 -0500 From: Bjorn Helgaas To: Kar Hin Ong Cc: linux-rt-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-x86_64@vger.kernel.org, linux-pci@vger.kernel.org, Thomas Gleixner Subject: Re: "oneshot" interrupt causes another interrupt to be fired erroneously in Haswell system Message-ID: <20191031230532.GA170712@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [+cc Thomas, IRQ maintainer] On Thu, Oct 31, 2019 at 03:53:50AM +0000, Kar Hin Ong wrote: > Hi, > > I've an Intel Haswell system running Linux kernel v4.14 with > preempt_rt patch. The system contain 2 IOAPICs: IOAPIC 1 is on the > PCH where IOAPIC 2 is on the CPU. > > I observed that whenever a PCI device is firing interrupt (INTx) to > Pin 20 of IOAPIC 2 (GSI 44); the kernel will receives 2 interrupts: > 1. Interrupt from Pin 20 of IOAPIC 2 -> Expected > 2. Interrupt from Pin 19 of IOAPIC 1 -> UNEXPECTED, erroneously > triggered > > The unexpected interrupt is unhandled eventually. When this scenario > happen more than 99,000 times, kernel disables the interrupt line > (Pin 19 of IOAPIC 1) and causing device that has requested it become > malfunction. > > I managed to also reproduced this issue on RHEL 8 and Ubuntu 19-04 > (without preempt_rt patch) after added "threadirqs" to the kernel > command line. > > After digging further, I noticed that the said issue is happened > whenever an interrupt pin on IOAPIC 2 is masked: > - Masking Pin 20 of IOAPIC 2 triggers Pin 19 of IOAPIC 1 > - Masking Pin 22 of IOAPIC 2 triggers Pin 18 of IOAPIC 1 > > I also noticed that kernel will explicitly mask a specific interrupt > pin before execute its handler, if the interrupt is configured as > "oneshot" (i.e. threaded). See > https://elixir.bootlin.com/linux/v4.14/source/kernel/irq/chip.c#L695 > This explained why it only happened on RTOS and Desktop Linux with > "threadirqs" flag, because these configurations force the interrupt > handler to be threaded. > > From Intel Xeon Processor E5/E7 v3 Product Family External Design > Specification (EDS), Volume One: Architecture, section 13.1 (Legacy > PCI Interrupt Handling), it mention: "If the I/OxAPIC entry is > masked (via the 'mask' bit in the corresponding Redirection Table > Entry), then the corresponding PCI Express interrupt(s) is forwarded > to the legacy PCH" > > My interpretation is: when kernel receive a "oneshot" interrupt, it > mask the line before start handling it (or sending the eoi signal). > At this moment, if the interrupt line is still asserting, then the > interrupt signal will be routed to the IOAPIC in PCH, and hence > causing another interrupt to be fired erroneously. > > I would like to understand if my interpretation is make sense. If > yes, should the "oneshot" algorithm need to be updated to support > Haswell system? Just to make sure this hasn't already been fixed, can you reproduce the problem on a current kernel, e.g., v5.3 or v5.4-rc5? Bjorn