Received: by 10.223.176.46 with SMTP id f43csp2657769wra; Mon, 22 Jan 2018 01:02:39 -0800 (PST) X-Google-Smtp-Source: AH8x227bVY2HIkVCk6M9PVBb5W4O0QGE2Fq7MNMzWTzLK/O85gK5KxOVylDNxaOO5sWa5ArpDp33 X-Received: by 2002:a17:902:203:: with SMTP id 3-v6mr3133880plc.413.1516611759671; Mon, 22 Jan 2018 01:02:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516611759; cv=none; d=google.com; s=arc-20160816; b=NqDwEwLkUYO6OLGoQuRcm7pqkvDavubJDAeT7KildMzUPsi3s3d8MK2AG0K/sXmDF/ pdqpt+ycwj/92HAReKVgfRCfx0CEKc67RmTkmjoTEKwNt+pArtAMxG3oMqn/UOfr1tdQ xRXEZA3CoSqca4YqyhXLfArVDeUsIFBjziWpPae0cn3eAM4hIC2duT/IiKHyMoYDP1/a WfrqPGMkeJwHMj/Oa32zAOpIeNO9mhraJZQn0ptrG6tpxjKS0i5oRGsB8MRDwVHofUk5 DE36Zxm9ZoH1BTqrP0X5HdOrJcFCxKPn9QX71e0ITkXuUqD7webI8WefpRWVWboXUuw0 dAGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=K9B0Dpl545WxT5RLVWFAkeYWtEYPELIBBBc/p4pIRSY=; b=oPVCbWv9VbW4M4U4a20t4FOhVesMPk1+Q9lT1Hbgqm04j69FxbLD5BHaJN+kJZN/4j 38yqAH11BTzp2aTWeZYKJGg/lZxZSV7AOORW+iur8T+imdGJw2/ev3pbxzXfpdXpXs+j 8s8SuNe9LUOu0DLh0mMugVO2eFh8U6BQooyU/9xwl9ACk7FMxJH1SdztRF44AX4TwR5U bQEzV/daiuHeQa0SpARQgaPX2ORfBHFTzYwLe+ns3mPbMo7096LY79Sl///24smX8sQ8 79zT9hJn60G2zoRjBSPdGqBPK0m6W4WjVylvrLPMGS/yQR9p7eQV2yZku0GlFAthbWtO FbzQ== 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 f64-v6si1502186plb.817.2018.01.22.01.02.25; Mon, 22 Jan 2018 01:02:39 -0800 (PST) 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 S1753761AbeAVJAY (ORCPT + 99 others); Mon, 22 Jan 2018 04:00:24 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:34036 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753575AbeAVIxk (ORCPT ); Mon, 22 Jan 2018 03:53:40 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3B730F2B; Mon, 22 Jan 2018 08:53:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Lorenzo Pieralisi , Bjorn Helgaas , Richard Henderson , Ivan Kokshaysky , Meelis Roos , Matt Turner Subject: [PATCH 4.14 77/89] alpha/PCI: Fix noname IRQ level detection Date: Mon, 22 Jan 2018 09:45:57 +0100 Message-Id: <20180122084002.154056652@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083954.683903493@linuxfoundation.org> References: <20180122083954.683903493@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lorenzo Pieralisi commit 86be89939d11a84800f66e2a283b915b704bf33d upstream. The conversion of the alpha architecture PCI host bridge legacy IRQ mapping/swizzling to the new PCI host bridge map/swizzle hooks carried out through: commit 0e4c2eeb758a ("alpha/PCI: Replace pci_fixup_irqs() call with host bridge IRQ mapping hooks") implies that IRQ for devices are now allocated through pci_assign_irq() function in pci_device_probe() that is called when a driver matching a device is found in order to probe the device through the device driver. Alpha noname platforms required IRQ level programming to be executed in sio_fixup_irq_levels(), that is called in noname_init_pci(), a platform hook called within a subsys_initcall. In noname_init_pci(), present IRQs are detected through sio_collect_irq_levels() that check the struct pci_dev->irq number to detect if an IRQ has been allocated for the device. By the time sio_collect_irq_levels() is called, some devices may still have not a matching driver loaded to match them (eg loadable module) therefore their IRQ allocation is still pending - which means that sio_collect_irq_levels() does not programme the correct IRQ level for those devices, causing their IRQ handling to be broken when the device driver is actually loaded and the device is probed. Fix the issue by adding code in the noname map_irq() function (noname_map_irq()) that, whilst mapping/swizzling the IRQ line, it also ensures that the correct IRQ level programming is executed at platform level, fixing the issue. Fixes: 0e4c2eeb758a ("alpha/PCI: Replace pci_fixup_irqs() call with host bridge IRQ mapping hooks") Reported-by: Mikulas Patocka Signed-off-by: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Mikulas Patocka Cc: Meelis Roos Signed-off-by: Matt Turner Signed-off-by: Greg Kroah-Hartman --- arch/alpha/kernel/sys_sio.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) --- a/arch/alpha/kernel/sys_sio.c +++ b/arch/alpha/kernel/sys_sio.c @@ -102,6 +102,15 @@ sio_pci_route(void) alpha_mv.sys.sio.route_tab); } +static bool sio_pci_dev_irq_needs_level(const struct pci_dev *dev) +{ + if ((dev->class >> 16 == PCI_BASE_CLASS_BRIDGE) && + (dev->class >> 8 != PCI_CLASS_BRIDGE_PCMCIA)) + return false; + + return true; +} + static unsigned int __init sio_collect_irq_levels(void) { @@ -110,8 +119,7 @@ sio_collect_irq_levels(void) /* Iterate through the devices, collecting IRQ levels. */ for_each_pci_dev(dev) { - if ((dev->class >> 16 == PCI_BASE_CLASS_BRIDGE) && - (dev->class >> 8 != PCI_CLASS_BRIDGE_PCMCIA)) + if (!sio_pci_dev_irq_needs_level(dev)) continue; if (dev->irq) @@ -120,8 +128,7 @@ sio_collect_irq_levels(void) return level_bits; } -static void __init -sio_fixup_irq_levels(unsigned int level_bits) +static void __sio_fixup_irq_levels(unsigned int level_bits, bool reset) { unsigned int old_level_bits; @@ -139,12 +146,21 @@ sio_fixup_irq_levels(unsigned int level_ */ old_level_bits = inb(0x4d0) | (inb(0x4d1) << 8); - level_bits |= (old_level_bits & 0x71ff); + if (reset) + old_level_bits &= 0x71ff; + + level_bits |= old_level_bits; outb((level_bits >> 0) & 0xff, 0x4d0); outb((level_bits >> 8) & 0xff, 0x4d1); } +static inline void +sio_fixup_irq_levels(unsigned int level_bits) +{ + __sio_fixup_irq_levels(level_bits, true); +} + static inline int noname_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { @@ -181,7 +197,14 @@ noname_map_irq(const struct pci_dev *dev const long min_idsel = 6, max_idsel = 14, irqs_per_slot = 5; int irq = COMMON_TABLE_LOOKUP, tmp; tmp = __kernel_extbl(alpha_mv.sys.sio.route_tab, irq); - return irq >= 0 ? tmp : -1; + + irq = irq >= 0 ? tmp : -1; + + /* Fixup IRQ level if an actual IRQ mapping is detected */ + if (sio_pci_dev_irq_needs_level(dev) && irq >= 0) + __sio_fixup_irq_levels(1 << irq, false); + + return irq; } static inline int