From patchwork Mon Oct 2 10:52:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 9980693 X-Patchwork-Delegate: bhelgaas@google.com 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 0912C60365 for ; Mon, 2 Oct 2017 10:50:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F07DA287FD for ; Mon, 2 Oct 2017 10:50:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4A3E2896F; Mon, 2 Oct 2017 10:50:41 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CFCE287FD for ; Mon, 2 Oct 2017 10:50:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751010AbdJBKuP (ORCPT ); Mon, 2 Oct 2017 06:50:15 -0400 Received: from foss.arm.com ([217.140.101.70]:35412 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846AbdJBKuO (ORCPT ); Mon, 2 Oct 2017 06:50:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E55A31529; Mon, 2 Oct 2017 03:50:13 -0700 (PDT) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.206.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1B1663F53D; Mon, 2 Oct 2017 03:50:11 -0700 (PDT) From: Lorenzo Pieralisi To: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org, Lorenzo Pieralisi , Bjorn Helgaas , Richard Henderson , Ivan Kokshaysky , "David S. Miller" , Guenter Roeck , Matt Turner Subject: [PATCH v2] drivers/ide/pci: Fix legacy IRQ assignment Date: Mon, 2 Oct 2017 11:52:47 +0100 Message-Id: <1506941567-10762-1-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.4.12 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Through struct pci_host_bridge->{map/swizzle}_irq() hooks is now possible to define IRQ mapping functions on a per PCI host bridge basis. Actual IRQ allocation is carried out by the pci_assign_irq() function in pci_device_probe() - to make sure a device is assigned an IRQ only if it is probed (ie match a driver); it retrieves a struct pci_host_bridge* for a given PCI device and through {map/swizzle}_irq() it carries out the PCI IRQ allocation. The code conversion to struct pci_host_bridge {map/swizzle}_irq() hooks and pci_assign_irq() to deal with legacy IRQs in commit 30fdfb929e82 ("PCI: Add a call to pci_assign_irq() in pci_device_probe()") did not take into account that the IDE subsystem relies on a special purpose IDE PCI layer, configured by CONFIG_IDEPCI_PCIBUS_ORDER to force devices probe ordering by sidestepping the core PCI bus layer entirely (and therefore pci_device_probe()) by executing the registered IDE PCI drivers probe routines (ie registered with ide_pci_register_driver()) through ide_scan_pcidev(). Since this IDE PCI specific probe mechanism bypasses the PCI core code generic probing (ie pci_device_probe()) it also misses the pci_assign_irq() call (among other PCI initialization functions); this triggers IDE PCI devices initialization failures caused by the missing IRQ allocation: ide0: disabled, no IRQ ide0: failed to initialize IDE interface ide0: disabling port cmd64x 0000:00:02.0: IDE controller (0x1095:0x0646 rev 0x07) CMD64x_IDE 0000:00:02.0: BAR 0: can't reserve [io 0x8050-0x8057] cmd64x 0000:00:02.0: can't reserve resources CMD64x_IDE: probe of 0000:00:02.0 failed with error -16 ide_generic: please use "probe_mask=0x3f" module parameter for probing all legacy ISA IDE ports ------------[ cut here ]------------ WARNING: CPU: 0 PID: 1 at fs/sysfs/dir.c:31 sysfs_warn_dup+0x94/0xd0 sysfs: cannot create duplicate filename '/class/ide_port/ide0' ... Trace: [] __warn+0x160/0x190 [] sysfs_warn_dup+0x94/0xd0 [] warn_slowpath_fmt+0x58/0x70 [] sysfs_warn_dup+0x94/0xd0 [] kernfs_path_from_node+0x30/0x60 [] kernfs_put+0x16c/0x2c0 [] kernfs_put+0x16c/0x2c0 [] sysfs_do_create_link_sd.isra.2+0x100/0x120 [] device_add+0x2a4/0x7c0 [] device_create_groups_vargs+0x14c/0x170 [] device_create_groups_vargs+0x98/0x170 [] device_create+0x50/0x70 [] ide_host_register+0x48c/0xa00 [] ide_host_register+0x450/0xa00 [] device_register+0x20/0x50 [] ide_host_register+0x450/0xa00 [] ide_host_add+0x64/0xe0 [] kobject_uevent_env+0x16c/0x710 [] do_one_initcall+0x68/0x260 [] kernel_init+0x1c/0x1a0 [] kernel_init+0x0/0x1a0 [] ret_from_kernel_thread+0x18/0x20 [] kernel_init+0x0/0x1a0 ---[ end trace 24a70433c3e4d374 ]--- ide0: disabling port Fix the IRQ allocation issue by adding a pci_assign_irq() call in the ide_scan_pcidev() function before probing the IDE PCI drivers, so that IRQs for a given PCI device are allocated for the IDE PCI drivers to use them for device configuration. Fixes: 30fdfb929e82 ("PCI: Add a call to pci_assign_irq() in pci_device_probe()") Link: http://lkml.kernel.org/r/32ec730f-c1b0-5584-cd35-f8a809122b96@roeck-us.net Signed-off-by: Lorenzo Pieralisi Reported-by: Guenter Roeck Cc: Bjorn Helgaas Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: David S. Miller Cc: Guenter Roeck Cc: Matt Turner Tested-by: Guenter Roeck Acked-by: Bjorn Helgaas Acked-by: David S. Miller Reviewed-by: Bartlomiej Zolnierkiewicz --- v1->v2 - Moved fix from PCI core code to IDE subsystem following further debugging and mailing list discussions - Rebased against v4.14-rc3 drivers/ide/ide-scan-pci.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/ide/ide-scan-pci.c b/drivers/ide/ide-scan-pci.c index 86aa88a..acf8748 100644 --- a/drivers/ide/ide-scan-pci.c +++ b/drivers/ide/ide-scan-pci.c @@ -56,6 +56,7 @@ static int __init ide_scan_pcidev(struct pci_dev *dev) { struct list_head *l; struct pci_driver *d; + int ret; list_for_each(l, &ide_pci_drivers) { d = list_entry(l, struct pci_driver, node); @@ -63,10 +64,14 @@ static int __init ide_scan_pcidev(struct pci_dev *dev) const struct pci_device_id *id = pci_match_id(d->id_table, dev); - if (id != NULL && d->probe(dev, id) >= 0) { - dev->driver = d; - pci_dev_get(dev); - return 1; + if (id != NULL) { + pci_assign_irq(dev); + ret = d->probe(dev, id); + if (ret >= 0) { + dev->driver = d; + pci_dev_get(dev); + return 1; + } } } }