From patchwork Wed Jul 9 17:08:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Minter X-Patchwork-Id: 4518771 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B077CBEEAA for ; Wed, 9 Jul 2014 17:12:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0497C20179 for ; Wed, 9 Jul 2014 17:12:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 674CB20172 for ; Wed, 9 Jul 2014 17:12:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X4vMC-0004OV-DQ; Wed, 09 Jul 2014 17:08:36 +0000 Received: from mail-lb0-f172.google.com ([209.85.217.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X4vM8-0004KK-Tb for linux-arm-kernel@lists.infradead.org; Wed, 09 Jul 2014 17:08:33 +0000 Received: by mail-lb0-f172.google.com with SMTP id c11so5255514lbj.17 for ; Wed, 09 Jul 2014 10:08:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=IT+A5MurF6rCvfd2SjEdwHcSphRUoRS2DP+FjNAzzl4=; b=Z8vAvaDWV7iJntiXqkzEe0daqWTxRx1OhdnoVap8wU38fMjS33FoXVDHB2LMqdryJU o7WhOGdNxbkO6f3fIPZVf0LEIKH8a8U9ZCfqqgBXQjAC7aXFdWRb46qF7JaxNDuOTKcM wnLovTFbD5gHE8QMYSXcov4yyPyf6QE7/D5k1CI2mUc5IGYxf2KPgTaWMzMXhrJYyXpz 9Me8iOhgbDrFJxV9XL+XYX7xy1QUMDQSyxmLr5EO3iGLpY5fa7MUgleJHHlq/mZxjmNP cNIyOr6j/rEirFqrCUfsDH8JSC+9eWfXVdnx/GWZTADfmWeW96cBlct3tZDHFA7kcxJq eSBQ== X-Gm-Message-State: ALoCoQkck0wzYZcAEKCcXF/XfpuuQSFLAWu0+0nNqlgPwbFIde+z244mCZPc4+BIoLdTakQaeTanPaYOTs3XlLXieUaF8M4GvAMFL4eF3Sziu0SF3Yeyx64gATk+NZuL09TrB8KQ7HGZ MIME-Version: 1.0 X-Received: by 10.112.154.134 with SMTP id vo6mr2101103lbb.92.1404925687979; Wed, 09 Jul 2014 10:08:07 -0700 (PDT) Received: by 10.112.18.73 with HTTP; Wed, 9 Jul 2014 10:08:07 -0700 (PDT) Date: Wed, 9 Jul 2014 18:08:07 +0100 Message-ID: Subject: [PATCH RFC] Armada XP (mvebu) Hot-plug issues continued From: Matthew Minter To: linux-arm-kernel , Jason Gunthorpe , Thomas Petazzoni , Gregory CLEMENT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140709_100833_138337_7CCC9034 X-CRM114-Status: GOOD ( 18.01 ) X-Spam-Score: -1.4 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,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 Hi Guys, This is something of a follow up to my previous thread: Armada XP (mvebu) PCIe memory (BAR/window) re-allocation Thanks to the helpful patches provided to the mvebu PCIe subsystem, hot-plug PCIe devices worked much better on this board, however I have discovered one remaining issue regarding them, due to the fact the legacy style IRQ is assigned during the fake "PCI BIOS" phase, devices which are plugged after boot will not be given an IRQ and thus if they do not support MSI/MSI-X will fail to initialize. This seems a fairly simple problem to squash and as such I have written a small patch which helps solve this, however I am unsure if I am doing this in a sensible way or if a different kind of rework is needed here. Also, if this is the wrong mailing list to ask about this please say so. Any comments regarding this patch or a better way to achieve this would be greatly appreciated. Patch follows (sorry if the format is off, still getting used to git format-patch). Many thanks, Matthew From 54c95ae3939870e922659d0385cca9fca72d3524 Mon Sep 17 00:00:00 2001 From: matthew_minter Date: Wed, 9 Jul 2014 17:51:07 +0100 Subject: [PATCH RFC] Added code to ensure hot-added PCI devices are given an IRQ on rescan To: linux-arm-kernel@lists.infradead.org Signed-off-by: matthew_minter --- drivers/pci/bus.c | 11 +++++++++++ drivers/pci/setup-irq.c | 2 +- include/linux/pci.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) #define HAVE_PCI_REQ_REGIONS 2 diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c index 73aef51..eb4f93c 100644 --- a/drivers/pci/bus.c +++ b/drivers/pci/bus.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -245,6 +246,16 @@ void pci_bus_add_device(struct pci_dev *dev) * are not assigned yet for some devices. */ pci_fixup_device(pci_fixup_final, dev); + /* + * Devices which are hot-added after boot have not + * been assigned an irq by the bios. + */ + if (unlikely(!dev->irq)) { + dev_dbg(&dev->dev, + "PCI device missing IRQ, attempting to assign one\n"); + pdev_fixup_irq(dev, pci_common_swizzle, + of_irq_parse_and_map_pci); + } pci_create_sysfs_dev_files(dev); pci_proc_attach_device(dev); diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c index 4e2d595..38c96c8 100644 --- a/drivers/pci/setup-irq.c +++ b/drivers/pci/setup-irq.c @@ -22,7 +22,7 @@ void __weak pcibios_update_irq(struct pci_dev *dev, int irq) pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); } -static void pdev_fixup_irq(struct pci_dev *dev, +void pdev_fixup_irq(struct pci_dev *dev, u8 (*swizzle)(struct pci_dev *, u8 *), int (*map_irq)(const struct pci_dev *, u8, u8)) { diff --git a/include/linux/pci.h b/include/linux/pci.h index 466bcd1..4c1b1b3 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1056,6 +1056,8 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus); void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus); void pdev_enable_device(struct pci_dev *); int pci_enable_resources(struct pci_dev *, int mask); +void pdev_fixup_irq(struct pci_dev *, u8 (*)(struct pci_dev *, u8 *), + int (*)(const struct pci_dev *, u8, u8)); void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), int (*)(const struct pci_dev *, u8, u8));