From patchwork Tue Sep 8 07:26:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 7138761 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 11B679F1D5 for ; Tue, 8 Sep 2015 07:23:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ACCEF20663 for ; Tue, 8 Sep 2015 07:23:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1E2020650 for ; Tue, 8 Sep 2015 07:23:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753561AbbIHHXa (ORCPT ); Tue, 8 Sep 2015 03:23:30 -0400 Received: from mga03.intel.com ([134.134.136.65]:44302 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752115AbbIHHX3 (ORCPT ); Tue, 8 Sep 2015 03:23:29 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 08 Sep 2015 00:23:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,488,1437462000"; d="scan'208";a="557362549" Received: from gerry-dev.bj.intel.com ([10.238.158.61]) by FMSMGA003.fm.intel.com with ESMTP; 08 Sep 2015 00:23:25 -0700 From: Jiang Liu To: Thomas Gleixner , Bjorn Helgaas , Arthur Marsh , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Cc: Jiang Liu , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-scsi@vger.kernel.org Subject: [Bugfix] PCI, x86: Correctly allocate IRQs for PCI devices managed by non-PCI drivers Date: Tue, 8 Sep 2015 15:26:29 +0800 Message-Id: <1441697190-27993-1-git-send-email-jiang.liu@linux.intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <55EE8106.6060100@internode.on.net> References: <55EE8106.6060100@internode.on.net> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 991de2e59090 ("PCI, x86: Implement pcibios_alloc_irq() and pcibios_free_irq()") changes the way to allocate PCI legacy IRQ for PCI devices on x86 platforms. Instead of allocating PCI legacy IRQs when pcibios_enable_device() gets called, now pcibios_alloc_irq() will be called by pci_device_probe() to allocate PCI legacy IRQs when binding PCI drivers to PCI devices. But some device drivers, such as eata, directly access PCI devices without implementing corresponding PCI drivers, so pcibios_alloc_irq() won't be called for those PCI devices and wrong IRQ number may be used to manage the PCI device. So detect such a case in pcibios_enable_device() by checking pci_dev->driver is NULL and call pcibios_alloc_irq() to allocate PCI legacy IRQs. Signed-off-by: Jiang Liu --- arch/x86/pci/common.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 09d3afc0a181..60b237783582 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c @@ -685,6 +685,16 @@ void pcibios_free_irq(struct pci_dev *dev) int pcibios_enable_device(struct pci_dev *dev, int mask) { + /* + * By design, pcibios_alloc_irq() will be called by pci_device_probe() + * when binding a PCI device to a PCI driver. But some device drivers, + * such as eata, directly make use of PCI devices without implementing + * PCI device drivers, so pcibios_alloc_irq() won't be called for those + * PCI devices. + */ + if (!dev->driver) + pcibios_alloc_irq(dev); + return pci_enable_resources(dev, mask); }