Linux-PCI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths
@ 2012-07-09 21:35 Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 1/8] PCI: Restructure 'pci_do_fixups()' Myron Stowe
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Myron Stowe @ 2012-07-09 21:35 UTC (permalink / raw)
  To: bhelgaas
  Cc: linux-pci, rth, ink, mattst88, ralf, tglx, mingo, hpa, yinghai,
	linux-kernel

PCI's final quirks (pci_fixup_final) are currently invoked by
pci_apply_final_quirk() which traverses the platform's list of PCI
devices.  The calling mechanism, and to some point the use of the device
list, limits the quirk invocations to a single instance during boot.  As
such, hot-plugable devices do not have their associated final quirks
called upon hot-plug events.

This series implements a interim solution to integrate pci_fixup_final
quirks into the various hot-plug event paths[1].

The series basis is
git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next

  -v2: Re-worked PATCH 1/9 based on Bjorn's suggestion:
       http://marc.info/?l=linux-pci&m=134074984925361&w=2
       There is some more opportunity to clean this up even further
       if we re-work the script that gathers initcall data to accept
       'dev_dbg()' structured output.

       Replaced PATCHes 3/9-8/9 with 3/8-7/8 (I don't know what I
       was thinking with the original set).


[1] I intended to come up with a single, uniform, solution that would
satisfy both the boot path and the various hot-plug event paths with
respect to final quirks.  From an architectural perspective, the proper
placement for the final quirks is somewhere just prior to when drivers can
probe and attach which would be the device_add path: pci_bus_add_devices
or pci_bus_add device.

I originally started with that approach but eventually realized that there
are issues with moving the quirks into the device_add path with respect to
booting.  Using the 'initcall_debug' boot command instrumentation, one
can see that moving the final quirks into the device_add path would cause
the quirks to be called substantially earlier during boot.  While there
may be additional issues, two that were especially concerning were that
the final quirks would be called *before* both 'pci_subsys_init' and
'pcibios_assign_resources'.

Calling the quirks prior to resource assignment seems fraught with
potential issues so I started looking into the various hot-plug paths and
quickly noticed asymmetry with respect to PCI device setup between the
boot path and the hot-plug paths.

Currently, the boot path scans the PCI devices, adds the devices, assigns
resources, and then call the final quirks whereas the hot-plug paths scan,
assign resources, and then add the devices which is better sequencing with
respect to the assignment of resources and the addition of devices (i.e.
resource assignment occurs *before* a driver can probe and attach).

All of this suggests that we should change PCI device setup in the boot
path to be more like hot-plug: scan, assign resources, (final fixups,)
then add.  While I think that is the correct approach, and something that
we should be addressing, it will require a lot of work.  So until that
occurs, this series should serve as a stop-gap solution for the interim.

When the boot path's PCI device setup is addressed we should end up with a
single, uniform, device_add based solution for applying final quirks
after:
  o  removing 'fs_initcall_sync(pci_apply_final_quirks);',
  o  removing the global variable 'pci_fixup_final_inited' and all
     of its usages,
  o  renaming, and moving, the 'pci_cache_line_size' related code
     currently embedded in 'pci_apply_final_quirks()'.

Note: I do not have a cross-compile environment so I have only tested x86.
---

Myron Stowe (8):
      PCI: Integrate 'pci_fixup_final' quirks into hot-plug paths
      PCI: Move final fixup quirks from __init to __devinit
      x86/PCI: Move final fixup quirks from __init to __devinit
      MIPS/PCI: Move final fixup quirks from __init to __devinit
      alpha/PCI: Move final fixup quirks from __init to __devinit
      PCI: Adjust section annotations of various quirks
      PCI: release temporary reference in __nv_msi_ht_cap_quirk()
      PCI: Restructure 'pci_do_fixups()'


 arch/alpha/kernel/pci.c         |    2 -
 arch/mips/mti-malta/malta-pci.c |    2 -
 arch/mips/pci/ops-tx4927.c      |    2 -
 arch/mips/txx9/generic/pci.c    |    4 +
 arch/x86/kernel/quirks.c        |    2 -
 drivers/pci/bus.c               |    4 +
 drivers/pci/quirks.c            |  107 ++++++++++++++++++++++++++-------------
 7 files changed, 81 insertions(+), 42 deletions(-)

-- 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH -v2 1/8] PCI: Restructure 'pci_do_fixups()'
  2012-07-09 21:35 [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
@ 2012-07-09 21:36 ` Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 2/8] PCI: release temporary reference in __nv_msi_ht_cap_quirk() Myron Stowe
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Myron Stowe @ 2012-07-09 21:36 UTC (permalink / raw)
  To: bhelgaas
  Cc: linux-pci, rth, ink, mattst88, ralf, tglx, mingo, hpa, yinghai,
	linux-kernel

It's a bit ugly that we have two possible call sites for the quirk: either
inside do_one_fixup_debug() or directly in pci_do_fixups().

This patch restructures pci_do_fixups()'s quirk invocations in the style
of initcall_debug_start() and initcall_debug_report().

Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
---

 drivers/pci/quirks.c |   46 ++++++++++++++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 194b243..0f5ca86 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2879,20 +2879,34 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f9, quirk_intel_mc_errata);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65fa, quirk_intel_mc_errata);
 
 
-static void do_one_fixup_debug(void (*fn)(struct pci_dev *dev), struct pci_dev *dev)
+static ktime_t fixup_debug_start(struct pci_dev *dev,
+				 void (*fn)(struct pci_dev *dev))
 {
-	ktime_t calltime, delta, rettime;
+	ktime_t calltime = ktime_set(0, 0);
+
+	dev_dbg(&dev->dev, "calling %pF\n", fn);
+	if (initcall_debug) {
+		pr_debug("calling  %pF @ %i for %s\n",
+			 fn, task_pid_nr(current), dev_name(&dev->dev));
+		calltime = ktime_get();
+	}
+
+	return calltime;
+}
+
+static void fixup_debug_report(struct pci_dev *dev, ktime_t calltime,
+			       void (*fn)(struct pci_dev *dev))
+{
+	ktime_t delta, rettime;
 	unsigned long long duration;
 
-	printk(KERN_DEBUG "calling  %pF @ %i for %s\n",
-			fn, task_pid_nr(current), dev_name(&dev->dev));
-	calltime = ktime_get();
-	fn(dev);
-	rettime = ktime_get();
-	delta = ktime_sub(rettime, calltime);
-	duration = (unsigned long long) ktime_to_ns(delta) >> 10;
-	printk(KERN_DEBUG "pci fixup %pF returned after %lld usecs for %s\n",
-			fn, duration, dev_name(&dev->dev));
+	if (initcall_debug) {
+		rettime = ktime_get();
+		delta = ktime_sub(rettime, calltime);
+		duration = (unsigned long long) ktime_to_ns(delta) >> 10;
+		pr_debug("pci fixup %pF returned after %lld usecs for %s\n",
+			 fn, duration, dev_name(&dev->dev));
+	}
 }
 
 /*
@@ -2958,6 +2972,8 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1c2d, asus_ehci_no_d3);
 static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
 			  struct pci_fixup *end)
 {
+	ktime_t calltime;
+
 	for (; f < end; f++)
 		if ((f->class == (u32) (dev->class >> f->class_shift) ||
 		     f->class == (u32) PCI_ANY_ID) &&
@@ -2965,11 +2981,9 @@ static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
 		     f->vendor == (u16) PCI_ANY_ID) &&
 		    (f->device == dev->device ||
 		     f->device == (u16) PCI_ANY_ID)) {
-			dev_dbg(&dev->dev, "calling %pF\n", f->hook);
-			if (initcall_debug)
-				do_one_fixup_debug(f->hook, dev);
-			else
-				f->hook(dev);
+			calltime = fixup_debug_start(dev, f->hook);
+			f->hook(dev);
+			fixup_debug_report(dev, calltime, f->hook);
 		}
 }
 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH -v2 2/8] PCI: release temporary reference in __nv_msi_ht_cap_quirk()
  2012-07-09 21:35 [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 1/8] PCI: Restructure 'pci_do_fixups()' Myron Stowe
@ 2012-07-09 21:36 ` Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 3/8] PCI: Adjust section annotations of various quirks Myron Stowe
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Myron Stowe @ 2012-07-09 21:36 UTC (permalink / raw)
  To: bhelgaas
  Cc: linux-pci, rth, ink, mattst88, ralf, tglx, mingo, hpa, yinghai,
	linux-kernel

__nv_msi_ht_cap_quirk() acquires a temporary reference via
'pci_get_bus_and_slot()' that is never released.

This patch releases the temporary reference.

Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
---

 drivers/pci/quirks.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 0f5ca86..8b2d553 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -2541,15 +2541,18 @@ static void __devinit __nv_msi_ht_cap_quirk(struct pci_dev *dev, int all)
 			else
 				nv_ht_enable_msi_mapping(dev);
 		}
-		return;
+		goto out;
 	}
 
 	/* HT MSI is not enabled */
 	if (found == 1)
-		return;
+		goto out;
 
 	/* Host bridge is not to HT, disable HT MSI mapping on this device */
 	ht_disable_msi_mapping(dev);
+
+out:
+	pci_dev_put(host_bridge);
 }
 
 static void __devinit nv_msi_ht_cap_quirk_all(struct pci_dev *dev)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH -v2 3/8] PCI: Adjust section annotations of various quirks
  2012-07-09 21:35 [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 1/8] PCI: Restructure 'pci_do_fixups()' Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 2/8] PCI: release temporary reference in __nv_msi_ht_cap_quirk() Myron Stowe
@ 2012-07-09 21:36 ` Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 4/8] alpha/PCI: Move final fixup quirks from __init to __devinit Myron Stowe
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Myron Stowe @ 2012-07-09 21:36 UTC (permalink / raw)
  To: bhelgaas
  Cc: linux-pci, rth, ink, mattst88, ralf, tglx, mingo, hpa, yinghai,
	linux-kernel

PCI's quirk types 'pci_fixup_enable', 'pci_fixup_resume',
'pci_fixup_suspend', and 'pci_fixup_resume_early' can not be __init or
__devinit; they must be in normal text because they can be called at any
time.

This patch removes the '__init' section annotation of such quirks.

Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
---

 drivers/pci/quirks.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 8b2d553..8014091 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1039,7 +1039,7 @@ static void quirk_disable_pxb(struct pci_dev *pdev)
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_82454NX,	quirk_disable_pxb);
 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL,	PCI_DEVICE_ID_INTEL_82454NX,	quirk_disable_pxb);
 
-static void __devinit quirk_amd_ide_mode(struct pci_dev *pdev)
+static void quirk_amd_ide_mode(struct pci_dev *pdev)
 {
 	/* set SBX00/Hudson-2 SATA in IDE mode to AHCI mode */
 	u8 tmp;
@@ -2104,7 +2104,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM,
 			PCI_DEVICE_ID_NX2_5709S,
 			quirk_brcm_570x_limit_vpd);
 
-static void __devinit quirk_brcm_5719_limit_mrrs(struct pci_dev *dev)
+static void quirk_brcm_5719_limit_mrrs(struct pci_dev *dev)
 {
 	u32 rev;
 
@@ -2217,7 +2217,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x9601, quirk_amd_780_apc_msi);
 
 /* Go through the list of Hypertransport capabilities and
  * return 1 if a HT MSI capability is found and enabled */
-static int __devinit msi_ht_cap_enabled(struct pci_dev *dev)
+static int msi_ht_cap_enabled(struct pci_dev *dev)
 {
 	int pos, ttl = 48;
 
@@ -2241,7 +2241,7 @@ static int __devinit msi_ht_cap_enabled(struct pci_dev *dev)
 }
 
 /* Check the hypertransport MSI mapping to know whether MSI is enabled or not */
-static void __devinit quirk_msi_ht_cap(struct pci_dev *dev)
+static void quirk_msi_ht_cap(struct pci_dev *dev)
 {
 	if (dev->subordinate && !msi_ht_cap_enabled(dev)) {
 		dev_warn(&dev->dev, "MSI quirk detected; "
@@ -2255,7 +2255,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT2
 /* The nVidia CK804 chipset may have 2 HT MSI mappings.
  * MSI are supported if the MSI capability set in any of these mappings.
  */
-static void __devinit quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev)
+static void quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev)
 {
 	struct pci_dev *pdev;
 
@@ -2279,7 +2279,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE,
 			quirk_nvidia_ck804_msi_ht_cap);
 
 /* Force enable MSI mapping capability on HT bridges */
-static void __devinit ht_enable_msi_mapping(struct pci_dev *dev)
+static void ht_enable_msi_mapping(struct pci_dev *dev)
 {
 	int pos, ttl = 48;
 
@@ -2359,7 +2359,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA,
 			PCI_DEVICE_ID_NVIDIA_MCP55_BRIDGE_V4,
 			nvbridge_check_legacy_irq_routing);
 
-static int __devinit ht_check_msi_mapping(struct pci_dev *dev)
+static int ht_check_msi_mapping(struct pci_dev *dev)
 {
 	int pos, ttl = 48;
 	int found = 0;
@@ -2387,7 +2387,7 @@ static int __devinit ht_check_msi_mapping(struct pci_dev *dev)
 	return found;
 }
 
-static int __devinit host_bridge_with_leaf(struct pci_dev *host_bridge)
+static int host_bridge_with_leaf(struct pci_dev *host_bridge)
 {
 	struct pci_dev *dev;
 	int pos;
@@ -2421,7 +2421,7 @@ static int __devinit host_bridge_with_leaf(struct pci_dev *host_bridge)
 #define PCI_HT_CAP_SLAVE_CTRL0     4    /* link control */
 #define PCI_HT_CAP_SLAVE_CTRL1     8    /* link control to */
 
-static int __devinit is_end_of_ht_chain(struct pci_dev *dev)
+static int is_end_of_ht_chain(struct pci_dev *dev)
 {
 	int pos, ctrl_off;
 	int end = 0;
@@ -2445,7 +2445,7 @@ out:
 	return end;
 }
 
-static void __devinit nv_ht_enable_msi_mapping(struct pci_dev *dev)
+static void nv_ht_enable_msi_mapping(struct pci_dev *dev)
 {
 	struct pci_dev *host_bridge;
 	int pos;
@@ -2484,7 +2484,7 @@ out:
 	pci_dev_put(host_bridge);
 }
 
-static void __devinit ht_disable_msi_mapping(struct pci_dev *dev)
+static void ht_disable_msi_mapping(struct pci_dev *dev)
 {
 	int pos, ttl = 48;
 
@@ -2504,7 +2504,7 @@ static void __devinit ht_disable_msi_mapping(struct pci_dev *dev)
 	}
 }
 
-static void __devinit __nv_msi_ht_cap_quirk(struct pci_dev *dev, int all)
+static void __nv_msi_ht_cap_quirk(struct pci_dev *dev, int all)
 {
 	struct pci_dev *host_bridge;
 	int pos;
@@ -2555,12 +2555,12 @@ out:
 	pci_dev_put(host_bridge);
 }
 
-static void __devinit nv_msi_ht_cap_quirk_all(struct pci_dev *dev)
+static void nv_msi_ht_cap_quirk_all(struct pci_dev *dev)
 {
 	return __nv_msi_ht_cap_quirk(dev, 1);
 }
 
-static void __devinit nv_msi_ht_cap_quirk_leaf(struct pci_dev *dev)
+static void nv_msi_ht_cap_quirk_leaf(struct pci_dev *dev)
 {
 	return __nv_msi_ht_cap_quirk(dev, 0);
 }


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH -v2 4/8] alpha/PCI: Move final fixup quirks from __init to __devinit
  2012-07-09 21:35 [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
                   ` (2 preceding siblings ...)
  2012-07-09 21:36 ` [PATCH -v2 3/8] PCI: Adjust section annotations of various quirks Myron Stowe
@ 2012-07-09 21:36 ` Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 5/8] MIPS/PCI: " Myron Stowe
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Myron Stowe @ 2012-07-09 21:36 UTC (permalink / raw)
  To: bhelgaas
  Cc: linux-pci, rth, ink, mattst88, ralf, tglx, mingo, hpa, yinghai,
	linux-kernel

The PCI subsystem's final fixups are executed once during boot, after the
pci-device is found.  As long as the system does not support hot-plug,
specifying __init is fine.

With hot-plug, either physically based hot-plug events or pseudo hot-plug
events such as "echo 1 > /sys/bus/pci/rescan", it is possible to remove a
PCI bus during run time and have it rediscovered which will require the
call of the fixups again in order for the device to function properly.

This patch prepares specific quirk(s) for use with hot-plug events.

Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
---

 arch/alpha/kernel/pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 1a62963..a4681fe 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -106,7 +106,7 @@ quirk_cypress(struct pci_dev *dev)
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693, quirk_cypress);
 
 /* Called for each device after PCI setup is done. */
-static void __init
+static void __devinit
 pcibios_fixup_final(struct pci_dev *dev)
 {
 	unsigned int class = dev->class >> 8;


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH -v2 5/8] MIPS/PCI: Move final fixup quirks from __init to __devinit
  2012-07-09 21:35 [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
                   ` (3 preceding siblings ...)
  2012-07-09 21:36 ` [PATCH -v2 4/8] alpha/PCI: Move final fixup quirks from __init to __devinit Myron Stowe
@ 2012-07-09 21:36 ` Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 6/8] x86/PCI: " Myron Stowe
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Myron Stowe @ 2012-07-09 21:36 UTC (permalink / raw)
  To: bhelgaas
  Cc: linux-pci, rth, ink, mattst88, ralf, tglx, mingo, hpa, yinghai,
	linux-kernel

The PCI subsystem's final fixups are executed once during boot, after the
pci-device is found.  As long as the system does not support hot-plug,
specifying __init is fine.

With hot-plug, either physically based hot-plug events or pseudo hot-plug
events such as "echo 1 > /sys/bus/pci/rescan", it is possible to remove a
PCI bus during run time and have it rediscovered which will require the
call of the fixups again in order for the device to function properly.

This patch prepares specific quirk(s) for use with hot-plug events.

Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
---

 arch/mips/mti-malta/malta-pci.c |    2 +-
 arch/mips/pci/ops-tx4927.c      |    2 +-
 arch/mips/txx9/generic/pci.c    |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/mips/mti-malta/malta-pci.c b/arch/mips/mti-malta/malta-pci.c
index bf80921..b663402 100644
--- a/arch/mips/mti-malta/malta-pci.c
+++ b/arch/mips/mti-malta/malta-pci.c
@@ -253,7 +253,7 @@ void __init mips_pcibios_init(void)
 }
 
 /* Enable PCI 2.1 compatibility in PIIX4 */
-static void __init quirk_dlcsetup(struct pci_dev *dev)
+static void __devinit quirk_dlcsetup(struct pci_dev *dev)
 {
 	u8 odlc, ndlc;
 	(void) pci_read_config_byte(dev, 0x82, &odlc);
diff --git a/arch/mips/pci/ops-tx4927.c b/arch/mips/pci/ops-tx4927.c
index a1e7e6d..bc13e29 100644
--- a/arch/mips/pci/ops-tx4927.c
+++ b/arch/mips/pci/ops-tx4927.c
@@ -495,7 +495,7 @@ irqreturn_t tx4927_pcierr_interrupt(int irq, void *dev_id)
 }
 
 #ifdef CONFIG_TOSHIBA_FPCIB0
-static void __init tx4927_quirk_slc90e66_bridge(struct pci_dev *dev)
+static void __devinit tx4927_quirk_slc90e66_bridge(struct pci_dev *dev)
 {
 	struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(dev->bus);
 
diff --git a/arch/mips/txx9/generic/pci.c b/arch/mips/txx9/generic/pci.c
index 682efb0..ce1ee50 100644
--- a/arch/mips/txx9/generic/pci.c
+++ b/arch/mips/txx9/generic/pci.c
@@ -256,7 +256,7 @@ static irqreturn_t i8259_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int __init
+static int __devinit
 txx9_i8259_irq_setup(int irq)
 {
 	int err;
@@ -269,7 +269,7 @@ txx9_i8259_irq_setup(int irq)
 	return err;
 }
 
-static void __init quirk_slc90e66_bridge(struct pci_dev *dev)
+static void __devinit quirk_slc90e66_bridge(struct pci_dev *dev)
 {
 	int irq;	/* PCI/ISA Bridge interrupt */
 	u8 reg_64;


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH -v2 6/8] x86/PCI: Move final fixup quirks from __init to __devinit
  2012-07-09 21:35 [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
                   ` (4 preceding siblings ...)
  2012-07-09 21:36 ` [PATCH -v2 5/8] MIPS/PCI: " Myron Stowe
@ 2012-07-09 21:36 ` Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 7/8] PCI: " Myron Stowe
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Myron Stowe @ 2012-07-09 21:36 UTC (permalink / raw)
  To: bhelgaas
  Cc: linux-pci, rth, ink, mattst88, ralf, tglx, mingo, hpa, yinghai,
	linux-kernel

The PCI subsystem's final fixups are executed once during boot, after the
pci-device is found.  As long as the system does not support hot-plug,
specifying __init is fine.

With hot-plug, either physically based hot-plug events or pseudo hot-plug
events such as "echo 1 > /sys/bus/pci/rescan", it is possible to remove a
PCI bus during run time and have it rediscovered which will require the
call of the fixups again in order for the device to function properly.

This patch prepares specific quirk(s) for use with hot-plug events.

Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
---

 arch/x86/kernel/quirks.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index 03920a1..1b27de5 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -512,7 +512,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
 
 #if defined(CONFIG_PCI) && defined(CONFIG_NUMA)
 /* Set correct numa_node information for AMD NB functions */
-static void __init quirk_amd_nb_node(struct pci_dev *dev)
+static void __devinit quirk_amd_nb_node(struct pci_dev *dev)
 {
 	struct pci_dev *nb_ht;
 	unsigned int devfn;


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH -v2 7/8] PCI: Move final fixup quirks from __init to __devinit
  2012-07-09 21:35 [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
                   ` (5 preceding siblings ...)
  2012-07-09 21:36 ` [PATCH -v2 6/8] x86/PCI: " Myron Stowe
@ 2012-07-09 21:36 ` Myron Stowe
  2012-07-09 21:36 ` [PATCH -v2 8/8] PCI: Integrate 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
  2012-07-10  3:22 ` [PATCH -v2 0/8] PCI: Add " Bjorn Helgaas
  8 siblings, 0 replies; 10+ messages in thread
From: Myron Stowe @ 2012-07-09 21:36 UTC (permalink / raw)
  To: bhelgaas
  Cc: linux-pci, rth, ink, mattst88, ralf, tglx, mingo, hpa, yinghai,
	linux-kernel

The PCI subsystem's final fixups are executed once during boot, after the
pci-device is found.  As long as the system does not support hot-plug,
specifying __init is fine.

With hot-plug, either physically based hot-plug events or pseudo hot-plug
events such as "echo 1 > /sys/bus/pci/rescan", it is possible to remove a
PCI bus during run time and have it rediscovered which will require the
call of the fixups again in order for the device to function properly.

This patch prepares specific quirk(s) for use with hot-plug events.

Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
---

 drivers/pci/quirks.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 8014091..d19e522 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -253,7 +253,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C576,	quirk_vsfx)
  *	workaround applied too
  *	[Info kindly provided by ALi]
  */	
-static void __init quirk_alimagik(struct pci_dev *dev)
+static void __devinit quirk_alimagik(struct pci_dev *dev)
 {
 	if ((pci_pci_problems&PCIPCI_ALIMAGIK)==0) {
 		dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
@@ -789,7 +789,7 @@ static void __devinit quirk_amd_ioapic(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD,	PCI_DEVICE_ID_AMD_VIPER_7410,	quirk_amd_ioapic);
 
-static void __init quirk_ioapic_rmw(struct pci_dev *dev)
+static void __devinit quirk_ioapic_rmw(struct pci_dev *dev)
 {
 	if (dev->devfn == 0 && dev->bus->number == 0)
 		sis_apic_bug = 1;
@@ -801,7 +801,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI,	PCI_ANY_ID,			quirk_ioapic_rmw);
  * Some settings of MMRBC can lead to data corruption so block changes.
  * See AMD 8131 HyperTransport PCI-X Tunnel Revision Guide
  */
-static void __init quirk_amd_8131_mmrbc(struct pci_dev *dev)
+static void __devinit quirk_amd_8131_mmrbc(struct pci_dev *dev)
 {
 	if (dev->subordinate && dev->revision <= 0x12) {
 		dev_info(&dev->dev, "AMD8131 rev %x detected; "
@@ -2169,7 +2169,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_PLX, 0x8624, quirk_tile_plx_gen1);
  * aware of it.  Instead of setting the flag on all busses in the
  * machine, simply disable MSI globally.
  */
-static void __init quirk_disable_all_msi(struct pci_dev *dev)
+static void __devinit quirk_disable_all_msi(struct pci_dev *dev)
 {
 	pci_no_msi();
 	dev_warn(&dev->dev, "MSI quirk detected; MSI disabled\n");


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH -v2 8/8] PCI: Integrate 'pci_fixup_final' quirks into hot-plug paths
  2012-07-09 21:35 [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
                   ` (6 preceding siblings ...)
  2012-07-09 21:36 ` [PATCH -v2 7/8] PCI: " Myron Stowe
@ 2012-07-09 21:36 ` Myron Stowe
  2012-07-10  3:22 ` [PATCH -v2 0/8] PCI: Add " Bjorn Helgaas
  8 siblings, 0 replies; 10+ messages in thread
From: Myron Stowe @ 2012-07-09 21:36 UTC (permalink / raw)
  To: bhelgaas
  Cc: linux-pci, rth, ink, mattst88, ralf, tglx, mingo, hpa, yinghai,
	linux-kernel

PCI's final quirks (pci_fixup_final) are currently invoked by
pci_apply_final_quirk() which traverses the platform's list of PCI
devices.  The calling mechanism limits the quirk invocations to a single
instance during boot.  As such, hot-plugable devices do not have their
associated final quirks called upon hot-plug events.

This series implements a interim solution[1] to integrate pci_fixup_final
quirks into the various hot-plug event paths.

As I intend for the global variable introduced by this patch to be
temporary I purposely chose not to include its 'extern' declaration within
a header file (i.e. include/linux/pci.h).


[1] I intended to come up with a single, uniform, solution that would
satisfy both the boot path and the various hot-plug event paths with
respect to final quirks.  From an architectural perspective, the proper
placement for the final quirks is somewhere just prior to, or within, the
device_add path.

I originally started with that approach but eventually realized that there
are issues with moving the quirks into the device_add path with respect to
the boot path.  Currently, the boot path scans the PCI devices, adds the
devices, assigns resources, and then call the final quirks whereas the
hot-plug paths scan, assign resources, and then add the devices which is
better sequencing with respect to the assignment of resources and the
addition of devices.

All of this suggests that we should change PCI device setup in the boot
path to be more like hot-plug: scan, assign resources, (final fixups),
then add.  While I think that is the correct approach, and something that
we should be addressing, it will require a lot of work.  So until that
occurs, this series should serve as a stop-gap solution for the interim by
keeping the current boot path sequencing in place and then adding the
final quirk processing into the device_add path for hot-plug events via a
(temporary) global variable qualifier.

When the boot path's PCI device setup is addressed we should end up with a
single, uniform, device_add based solution for applying final quirks
by:
  o  removing 'fs_initcall_sync(pci_apply_final_quirks);',
  o  removing the global variable 'pci_fixup_final_inited' and all
     of its usages,
  o  renaming, and moving, the 'pci_cache_line_size' related code
     currently embedded in 'pci_apply_final_quirks()'.

Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
---

 drivers/pci/bus.c    |    4 ++++
 drivers/pci/quirks.c |   18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 4ce5ef2..b511bd4 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -164,6 +164,10 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
 int pci_bus_add_device(struct pci_dev *dev)
 {
 	int retval;
+	extern bool pci_fixup_final_inited;
+
+	if (pci_fixup_final_inited)
+		pci_fixup_device(pci_fixup_final, dev);
 	retval = device_add(&dev->dev);
 	if (retval)
 		return retval;
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index d19e522..1850eb5 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3054,6 +3054,22 @@ void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev)
 }
 EXPORT_SYMBOL(pci_fixup_device);
 
+
+/*
+ * The global variable 'pci_fixup_final_inited' is being used as a interim
+ * solution for calling the final quirks only during hot-plug events (not
+ * during boot processing).
+ *
+ * When the boot path's PCI device setup sequencing is addressed, we can
+ * remove the instance, and usages of, 'pci_fixup_final_inited' along with
+ * removing 'fs_initcall_sync(pci_apply_final_quirks);' and end up with a
+ * single, uniform, solution that satisfies both the boot path and the
+ * various hot-plug event paths.
+ *
+ * ToDo: Remove 'pci_fixup_final_inited'
+ */
+bool pci_fixup_final_inited;
+
 static int __init pci_apply_final_quirks(void)
 {
 	struct pci_dev *dev = NULL;
@@ -3084,6 +3100,8 @@ static int __init pci_apply_final_quirks(void)
 			pci_cache_line_size = pci_dfl_cache_line_size;
 		}
 	}
+	pci_fixup_final_inited = 1;
+
 	if (!pci_cache_line_size) {
 		printk(KERN_DEBUG "PCI: CLS %u bytes, default %u\n",
 		       cls << 2, pci_dfl_cache_line_size << 2);


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths
  2012-07-09 21:35 [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
                   ` (7 preceding siblings ...)
  2012-07-09 21:36 ` [PATCH -v2 8/8] PCI: Integrate 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
@ 2012-07-10  3:22 ` Bjorn Helgaas
  8 siblings, 0 replies; 10+ messages in thread
From: Bjorn Helgaas @ 2012-07-10  3:22 UTC (permalink / raw)
  To: Myron Stowe
  Cc: linux-pci, rth, ink, mattst88, ralf, tglx, mingo, hpa, yinghai,
	linux-kernel

On Mon, Jul 9, 2012 at 3:35 PM, Myron Stowe <myron.stowe@redhat.com> wrote:
> PCI's final quirks (pci_fixup_final) are currently invoked by
> pci_apply_final_quirk() which traverses the platform's list of PCI
> devices.  The calling mechanism, and to some point the use of the device
> list, limits the quirk invocations to a single instance during boot.  As
> such, hot-plugable devices do not have their associated final quirks
> called upon hot-plug events.
>
> This series implements a interim solution to integrate pci_fixup_final
> quirks into the various hot-plug event paths[1].
>
> The series basis is
> git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
>
>   -v2: Re-worked PATCH 1/9 based on Bjorn's suggestion:
>        http://marc.info/?l=linux-pci&m=134074984925361&w=2
>        There is some more opportunity to clean this up even further
>        if we re-work the script that gathers initcall data to accept
>        'dev_dbg()' structured output.
>
>        Replaced PATCHes 3/9-8/9 with 3/8-7/8 (I don't know what I
>        was thinking with the original set).
>
>
> [1] I intended to come up with a single, uniform, solution that would
> satisfy both the boot path and the various hot-plug event paths with
> respect to final quirks.  From an architectural perspective, the proper
> placement for the final quirks is somewhere just prior to when drivers can
> probe and attach which would be the device_add path: pci_bus_add_devices
> or pci_bus_add device.
>
> I originally started with that approach but eventually realized that there
> are issues with moving the quirks into the device_add path with respect to
> booting.  Using the 'initcall_debug' boot command instrumentation, one
> can see that moving the final quirks into the device_add path would cause
> the quirks to be called substantially earlier during boot.  While there
> may be additional issues, two that were especially concerning were that
> the final quirks would be called *before* both 'pci_subsys_init' and
> 'pcibios_assign_resources'.
>
> Calling the quirks prior to resource assignment seems fraught with
> potential issues so I started looking into the various hot-plug paths and
> quickly noticed asymmetry with respect to PCI device setup between the
> boot path and the hot-plug paths.
>
> Currently, the boot path scans the PCI devices, adds the devices, assigns
> resources, and then call the final quirks whereas the hot-plug paths scan,
> assign resources, and then add the devices which is better sequencing with
> respect to the assignment of resources and the addition of devices (i.e.
> resource assignment occurs *before* a driver can probe and attach).
>
> All of this suggests that we should change PCI device setup in the boot
> path to be more like hot-plug: scan, assign resources, (final fixups,)
> then add.  While I think that is the correct approach, and something that
> we should be addressing, it will require a lot of work.  So until that
> occurs, this series should serve as a stop-gap solution for the interim.
>
> When the boot path's PCI device setup is addressed we should end up with a
> single, uniform, device_add based solution for applying final quirks
> after:
>   o  removing 'fs_initcall_sync(pci_apply_final_quirks);',
>   o  removing the global variable 'pci_fixup_final_inited' and all
>      of its usages,
>   o  renaming, and moving, the 'pci_cache_line_size' related code
>      currently embedded in 'pci_apply_final_quirks()'.
>
> Note: I do not have a cross-compile environment so I have only tested x86.
> ---
>
> Myron Stowe (8):
>       PCI: Integrate 'pci_fixup_final' quirks into hot-plug paths
>       PCI: Move final fixup quirks from __init to __devinit
>       x86/PCI: Move final fixup quirks from __init to __devinit
>       MIPS/PCI: Move final fixup quirks from __init to __devinit
>       alpha/PCI: Move final fixup quirks from __init to __devinit
>       PCI: Adjust section annotations of various quirks
>       PCI: release temporary reference in __nv_msi_ht_cap_quirk()
>       PCI: Restructure 'pci_do_fixups()'
>
>
>  arch/alpha/kernel/pci.c         |    2 -
>  arch/mips/mti-malta/malta-pci.c |    2 -
>  arch/mips/pci/ops-tx4927.c      |    2 -
>  arch/mips/txx9/generic/pci.c    |    4 +
>  arch/x86/kernel/quirks.c        |    2 -
>  drivers/pci/bus.c               |    4 +
>  drivers/pci/quirks.c            |  107 ++++++++++++++++++++++++++-------------
>  7 files changed, 81 insertions(+), 42 deletions(-)
>
> --

Thanks, I added this to my "next" branch and pushed it.

The alpha quirks fix was already in my "next" branch, so I dropped that patch:
http://git.kernel.org/?p=linux/kernel/git/helgaas/pci.git;a=commitdiff;h=8ff255afb022b8e183c7aa1ecc4ba8d0563e1e17

Bjorn

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, back to index

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-09 21:35 [PATCH -v2 0/8] PCI: Add 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
2012-07-09 21:36 ` [PATCH -v2 1/8] PCI: Restructure 'pci_do_fixups()' Myron Stowe
2012-07-09 21:36 ` [PATCH -v2 2/8] PCI: release temporary reference in __nv_msi_ht_cap_quirk() Myron Stowe
2012-07-09 21:36 ` [PATCH -v2 3/8] PCI: Adjust section annotations of various quirks Myron Stowe
2012-07-09 21:36 ` [PATCH -v2 4/8] alpha/PCI: Move final fixup quirks from __init to __devinit Myron Stowe
2012-07-09 21:36 ` [PATCH -v2 5/8] MIPS/PCI: " Myron Stowe
2012-07-09 21:36 ` [PATCH -v2 6/8] x86/PCI: " Myron Stowe
2012-07-09 21:36 ` [PATCH -v2 7/8] PCI: " Myron Stowe
2012-07-09 21:36 ` [PATCH -v2 8/8] PCI: Integrate 'pci_fixup_final' quirks into hot-plug paths Myron Stowe
2012-07-10  3:22 ` [PATCH -v2 0/8] PCI: Add " Bjorn Helgaas

Linux-PCI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-pci/0 linux-pci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pci linux-pci/ https://lore.kernel.org/linux-pci \
		linux-pci@vger.kernel.org
	public-inbox-index linux-pci

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-pci


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git