Skip to contentSkip to conversation

PCI fixes for 2.6.0-test6

PATCH New Greg KH 1 participant 10 messages Sep 30, 2003

Subsystems (4)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 PCI fixes for 2.6.0-test6

Hi,

Here are some PCI patches against 2.6.0-test6. They mainly clean up the pci power code by removing it entirely, as it is now done by the driver core. There are a few other minor janitorial fixes in here too.

Please pull from:

	bk://kernel.bkbits.net/gregkh/linux/pci-2.6

thanks,

greg k-h

p.s. I'll send these as patches in response to this email to lkml for those who want to see them.

 drivers/pci/power.c                    |  159 ---------------------------------
 drivers/ide/pci/sc1200.c               |   61 ++++++------
 drivers/net/irda/vlsi_ir.c             |   10 --
 drivers/pci/Makefile                   |    1 
 drivers/pci/hotplug/cpqphp.h           |    1 
 drivers/pci/hotplug/pci_hotplug.h      |    1 
 drivers/pci/hotplug/pci_hotplug_core.c |   15 +--
 drivers/pci/pool.c                     |    1 
 drivers/pci/quirks.c                   |    3 
 drivers/scsi/nsp32.c                   |   10 --
 include/linux/pci.h                    |    1 
 11 files changed, 42 insertions(+), 221 deletions(-)

-----

<lxiep:us.ibm.com>:
o PCI Hotplug: export hotplug_slots subsys

<rtjohnso:eecs.berkeley.edu>:
o PCI: __init documetation

Alexey Dobriyan:
o PCI: Remove setting TASK_RUNNING after schedule_timeout in /drivers/pci/

Patrick Mochel:
o Remove ->save_state() in sc1200.c
o Remove ->save_state() from vlsi_ir.c
o Remove ->save_state() in nsp32.c
o [pci] Really delete drivers/pci/power.c
o [pci] Remove ->save_state() from struct pci_driver
o [pci] Remove drivers/pci/power.c

author
#1 lore raw

PATCH 1/1 PCI fixes for 2.6.0-test6

ChangeSet 1.1305.5.1, 2003/09/26 09:11:22-07:00, [email protected]

[pci] Remove drivers/pci/power.c

The old-school method of power management, using the pm_send() interface, is superceded by the centralized driver model, which handles walking the tree and calling each device's suspend/resume methods.

 drivers/pci/Makefile |    1 -
 1 files changed, 1 deletion(-)
drivers/pci/Makefile +0 -1
diff -Nru a/drivers/pci/Makefile b/drivers/pci/Makefile
@@ -4,7 +4,6 @@
 
 obj-y		+= access.o bus.o probe.o remove.o pci.o pool.o quirks.o \
 			names.o pci-driver.o search.o pci-sysfs.o
-obj-$(CONFIG_PM)  += power.o
 obj-$(CONFIG_PROC_FS) += proc.o
 
 ifndef CONFIG_SPARC64
author
#2 lore raw

ChangeSet 1.1305.5.2, 2003/09/26 09:18:44-07:00, [email protected]

[pci] Remove ->save_state() from struct pci_driver.

It is not called, and unused.

 include/linux/pci.h |    1 -
 1 files changed, 1 deletion(-)
include/linux/pci.h +0 -1
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
@@ -515,7 +515,6 @@
 	const struct pci_device_id *id_table;	/* must be non-NULL for probe to be called */
 	int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);	/* New device inserted */
 	void (*remove) (struct pci_dev *dev);	/* Device removed (NULL if not a hot-plug capable driver) */
-	int  (*save_state) (struct pci_dev *dev, u32 state);    /* Save Device Context */
 	int  (*suspend) (struct pci_dev *dev, u32 state);	/* Device suspended */
 	int  (*resume) (struct pci_dev *dev);	                /* Device woken up */
 	int  (*enable_wake) (struct pci_dev *dev, u32 state, int enable);   /* Enable wake event */
author
#3 lore raw

ChangeSet 1.1305.5.3, 2003/09/26 09:38:37-07:00, [email protected]

[pci] Really delete drivers/pci/power.c

 drivers/pci/power.c |  159 ----------------------------------------------------
 1 files changed, 159 deletions(-)
drivers/pci/power.c deleted +0 -159
diff -Nru a/drivers/pci/power.c b/drivers/pci/power.c
@@ -1,159 +0,0 @@
-#include <linux/pci.h>
-#include <linux/pm.h>
-#include <linux/init.h>
-
-/*
- * PCI Power management..
- *
- * This needs to be done centralized, so that we power manage PCI
- * devices in the right order: we should not shut down PCI bridges
- * before we've shut down the devices behind them, and we should
- * not wake up devices before we've woken up the bridge to the
- * device.. Eh?
- *
- * We do not touch devices that don't have a driver that exports
- * a suspend/resume function. That is just too dangerous. If the default
- * PCI suspend/resume functions work for a device, the driver can
- * easily implement them (ie just have a suspend function that calls
- * the pci_set_power_state() function).
- */
-
-static int pci_pm_save_state_device(struct pci_dev *dev, u32 state)
-{
-	int error = 0;
-	if (dev) {
-		struct pci_driver *driver = dev->driver;
-		if (driver && driver->save_state) 
-			error = driver->save_state(dev,state);
-	}
-	return error;
-}
-
-static int pci_pm_suspend_device(struct pci_dev *dev, u32 state)
-{
-	int error = 0;
-	if (dev) {
-		struct pci_driver *driver = dev->driver;
-		if (driver && driver->suspend)
-			error = driver->suspend(dev,state);
-	}
-	return error;
-}
-
-static int pci_pm_resume_device(struct pci_dev *dev)
-{
-	int error = 0;
-	if (dev) {
-		struct pci_driver *driver = dev->driver;
-		if (driver && driver->resume)
-			error = driver->resume(dev);
-	}
-	return error;
-}
-
-static int pci_pm_save_state_bus(struct pci_bus *bus, u32 state)
-{
-	struct list_head *list;
-	int error = 0;
-
-	list_for_each(list, &bus->children) {
-		error = pci_pm_save_state_bus(pci_bus_b(list),state);
-		if (error) return error;
-	}
-	list_for_each(list, &bus->devices) {
-		error = pci_pm_save_state_device(pci_dev_b(list),state);
-		if (error) return error;
-	}
-	return 0;
-}
-
-static int pci_pm_suspend_bus(struct pci_bus *bus, u32 state)
-{
-	struct list_head *list;
-
-	/* Walk the bus children list */
-	list_for_each(list, &bus->children) 
-		pci_pm_suspend_bus(pci_bus_b(list),state);
-
-	/* Walk the device children list */
-	list_for_each(list, &bus->devices)
-		pci_pm_suspend_device(pci_dev_b(list),state);
-	return 0;
-}
-
-static int pci_pm_resume_bus(struct pci_bus *bus)
-{
-	struct list_head *list;
-
-	/* Walk the device children list */
-	list_for_each(list, &bus->devices)
-		pci_pm_resume_device(pci_dev_b(list));
-
-	/* And then walk the bus children */
-	list_for_each(list, &bus->children)
-		pci_pm_resume_bus(pci_bus_b(list));
-	return 0;
-}
-
-static int pci_pm_save_state(u32 state)
-{
-	struct pci_bus *bus = NULL;
-	int error = 0;
-
-	while ((bus = pci_find_next_bus(bus)) != NULL) {
-		error = pci_pm_save_state_bus(bus,state);
-		if (!error)
-			error = pci_pm_save_state_device(bus->self,state);
-	}
-	return error;
-}
-
-static int pci_pm_suspend(u32 state)
-{
-	struct pci_bus *bus = NULL;
-
-	while ((bus = pci_find_next_bus(bus)) != NULL) {
-		pci_pm_suspend_bus(bus,state);
-		pci_pm_suspend_device(bus->self,state);
-	}
-	return 0;
-}
-
-static int pci_pm_resume(void)
-{
-	struct pci_bus *bus = NULL;
-
-	while ((bus = pci_find_next_bus(bus)) != NULL) {
-		pci_pm_resume_device(bus->self);
-		pci_pm_resume_bus(bus);
-	}
-	return 0;
-}
-
-static int 
-pci_pm_callback(struct pm_dev *pm_device, pm_request_t rqst, void *data)
-{
-	int error = 0;
-
-	switch (rqst) {
-	case PM_SAVE_STATE:
-		error = pci_pm_save_state((unsigned long)data);
-		break;
-	case PM_SUSPEND:
-		error = pci_pm_suspend((unsigned long)data);
-		break;
-	case PM_RESUME:
-		error = pci_pm_resume();
-		break;
-	default: break;
-	}
-	return error;
-}
-
-static int __init pci_pm_init(void)
-{
-	pm_register(PM_PCI_DEV, 0, pci_pm_callback);
-	return 0;
-}
-
-subsys_initcall(pci_pm_init);
author
#4 lore raw

ChangeSet 1.1344, 2003/09/26 16:33:35-07:00, [email protected]

[PATCH] Remove ->save_state() in nsp32.c

Remove the uncalled and unneeded struct pci_driver::save_state() in drivers/scsi/nsp32.c

 drivers/scsi/nsp32.c |   10 ----------
 1 files changed, 10 deletions(-)
drivers/scsi/nsp32.c +0 -10
diff -Nru a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
@@ -3435,15 +3435,6 @@
  * Power Management
  */
 #ifdef CONFIG_PM
-/* Save Device Context */
-static int nsp32_save_state(struct pci_dev *pdev, u32 state)
-{
-	struct Scsi_Host *host = pci_get_drvdata(pdev);
-
-	nsp32_msg(KERN_INFO, "pci-save_state: stub, pdev=0x%p, state=%ld, slot=%s, host=0x%p", pdev, state, pci_name(pdev), host);
-
-	return 0;
-}
 
 /* Device suspended */
 static int nsp32_suspend(struct pci_dev *pdev, u32 state)
@@ -3573,7 +3564,6 @@
 	.probe		= nsp32_probe,
 	.remove		= __devexit_p(nsp32_remove),
 #ifdef CONFIG_PM
-	.save_state     = nsp32_save_state,
 	.suspend	= nsp32_suspend, 
 	.resume		= nsp32_resume, 
 	.enable_wake    = nsp32_enable_wake,
author
#5 lore raw

ChangeSet 1.1345, 2003/09/26 16:34:09-07:00, [email protected]

[PATCH] Remove ->save_state() from vlsi_ir.c

Remove the unneeded and uncalled struct pci_driver::save_state().

 drivers/net/irda/vlsi_ir.c |   10 ----------
 1 files changed, 10 deletions(-)
drivers/net/irda/vlsi_ir.c +0 -10
diff -Nru a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
@@ -1859,15 +1859,6 @@
  * otherwise we might get cheated by pci-pm.
  */
 
-static int vlsi_irda_save_state(struct pci_dev *pdev, u32 state)
-{
-	if (state < 1 || state > 3 ) {
-		ERROR("%s - %s: invalid pm state request: %u\n",
-			__FUNCTION__, PCIDEV_NAME(pdev), state);
-		return -1;
-	}
-	return 0;
-}
 
 static int vlsi_irda_suspend(struct pci_dev *pdev, u32 state)
 {
@@ -1970,7 +1961,6 @@
 	.probe		= vlsi_irda_probe,
 	.remove		= __devexit_p(vlsi_irda_remove),
 #ifdef CONFIG_PM
-	.save_state	= vlsi_irda_save_state,
 	.suspend	= vlsi_irda_suspend,
 	.resume		= vlsi_irda_resume,
 #endif
author
#6 lore raw

ChangeSet 1.1346, 2003/09/26 16:34:55-07:00, [email protected]

[PATCH] Remove ->save_state() in sc1200.c

This removes the uncalled and unneeded method struct pci_driver::save_state(). The contents of ->save_state() were folded into ->suspend(), though the semantics don't seem exactly right - the hwifs should not be iterated over there; the driver core should take care of that. But, that code will never get executed as is, since neither function should ever be called with (state == 0).

 drivers/ide/pci/sc1200.c |   61 +++++++++++++++++++++++------------------------
 1 files changed, 30 insertions(+), 31 deletions(-)
drivers/ide/pci/sc1200.c +30 -31
diff -Nru a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
@@ -396,44 +396,44 @@
 	__u32		regs[4];
 } sc1200_saved_state_t;
 
-static int sc1200_save_state (struct pci_dev *dev, u32 state)
+
+static int sc1200_suspend (struct pci_dev *dev, u32 state)
 {
 	ide_hwif_t		*hwif = NULL;
 
-printk("SC1200: save_state(%u)\n", state);
-	if (state != 0)
-		return 0;	// we only save state when going from full power to less
-	//
-	// Loop over all interfaces that are part of this PCI device:
-	//
-	while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) {
-		sc1200_saved_state_t	*ss;
-		unsigned int		basereg, r;
-		//
-		// allocate a permanent save area, if not already allocated
-		//
-		ss = (sc1200_saved_state_t *)hwif->config_data;
-		if (ss == NULL) {
-			ss = kmalloc(sizeof(sc1200_saved_state_t), GFP_KERNEL);
-			if (ss == NULL)
-				return -ENOMEM;
-			(sc1200_saved_state_t *)hwif->config_data = ss;
-		}
-		ss = (sc1200_saved_state_t *)hwif->config_data;
+	printk("SC1200: suspend(%u)\n", state);
+
+	if (state == 0) {
+		// we only save state when going from full power to less
+
 		//
-		// Save timing registers:  this may be unnecessary if BIOS also does it
+		// Loop over all interfaces that are part of this PCI device:
 		//
-		basereg = hwif->channel ? 0x50 : 0x40;
-		for (r = 0; r < 4; ++r) {
-			pci_read_config_dword (hwif->pci_dev, basereg + (r<<2), &ss->regs[r]);
+		while ((hwif = lookup_pci_dev(hwif, dev)) != NULL) {
+			sc1200_saved_state_t	*ss;
+			unsigned int		basereg, r;
+			//
+			// allocate a permanent save area, if not already allocated
+			//
+			ss = (sc1200_saved_state_t *)hwif->config_data;
+			if (ss == NULL) {
+				ss = kmalloc(sizeof(sc1200_saved_state_t), GFP_KERNEL);
+				if (ss == NULL)
+					return -ENOMEM;
+				(sc1200_saved_state_t *)hwif->config_data = ss;
+			}
+			ss = (sc1200_saved_state_t *)hwif->config_data;
+			//
+			// Save timing registers:  this may be unnecessary if 
+			// BIOS also does it
+			//
+			basereg = hwif->channel ? 0x50 : 0x40;
+			for (r = 0; r < 4; ++r) {
+				pci_read_config_dword (hwif->pci_dev, basereg + (r<<2), &ss->regs[r]);
+			}
 		}
 	}
-	return 0;
-}
 
-static int sc1200_suspend (struct pci_dev *dev, u32 state)
-{
-	printk("SC1200: suspend(%u)\n", state);
 	/* You don't need to iterate over disks -- sysfs should have done that for you already */ 
 
 	pci_disable_device(dev);
@@ -572,7 +572,6 @@
 	.name		= "SC1200 IDE",
 	.id_table	= sc1200_pci_tbl,
 	.probe		= sc1200_init_one,
-	.save_state	= sc1200_save_state,
 	.suspend	= sc1200_suspend,
 	.resume		= sc1200_resume,
 };
author
#7 lore raw

ChangeSet 1.1347, 2003/09/29 12:23:22-07:00, [email protected]

[PATCH] PCI Hotplug: export hotplug_slots subsys

This is needed for the PPC64 PCI hotplug driver.

 drivers/pci/hotplug/pci_hotplug.h      |    1 +
 drivers/pci/hotplug/pci_hotplug_core.c |   15 ++++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)
drivers/pci/hotplug/pci_hotplug.h +1 -0
diff -Nru a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h
@@ -145,6 +145,7 @@
 extern int pci_hp_deregister		(struct hotplug_slot *slot);
 extern int pci_hp_change_slot_info	(struct hotplug_slot *slot,
 					 struct hotplug_slot_info *info);
+extern struct subsystem pci_hotplug_slots_subsys;
 
 #endif
 
drivers/pci/hotplug/pci_hotplug_core.c +8 -7
diff -Nru a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -69,7 +69,7 @@
 
 static LIST_HEAD(pci_hotplug_slot_list);
 
-static struct subsystem hotplug_slots_subsys;
+struct subsystem pci_hotplug_slots_subsys;
 
 static ssize_t hotplug_slot_attr_show(struct kobject *kobj,
 		struct attribute *attr, char *buf)
@@ -104,7 +104,7 @@
 	.release = &hotplug_slot_release,
 };
 
-static decl_subsys(hotplug_slots, &hotplug_slot_ktype, NULL);
+decl_subsys(pci_hotplug_slots, &hotplug_slot_ktype, NULL);
 
 
 /* these strings match up with the values in pci_bus_speed */
@@ -534,7 +534,7 @@
 		return -EINVAL;
 
 	strlcpy(slot->kobj.name, slot->name, KOBJ_NAME_LEN);
-	kobj_set_kset_s(slot, hotplug_slots_subsys);
+	kobj_set_kset_s(slot, pci_hotplug_slots_subsys);
 
 	/* this can fail if we have already registered a slot with the same name */
 	if (kobject_register(&slot->kobj)) {
@@ -629,8 +629,8 @@
 {
 	int result;
 
-	kset_set_kset_s(&hotplug_slots_subsys, pci_bus_type.subsys);
-	result = subsystem_register(&hotplug_slots_subsys);
+	kset_set_kset_s(&pci_hotplug_slots_subsys, pci_bus_type.subsys);
+	result = subsystem_register(&pci_hotplug_slots_subsys);
 	if (result) {
 		err("Register subsys with error %d\n", result);
 		goto exit;
@@ -645,7 +645,7 @@
 	goto exit;
 	
 err_subsys:
-	subsystem_unregister(&hotplug_slots_subsys);
+	subsystem_unregister(&pci_hotplug_slots_subsys);
 exit:
 	return result;
 }
@@ -653,7 +653,7 @@
 static void __exit pci_hotplug_exit (void)
 {
 	cpci_hotplug_exit();
-	subsystem_unregister(&hotplug_slots_subsys);
+	subsystem_unregister(&pci_hotplug_slots_subsys);
 }
 
 module_init(pci_hotplug_init);
@@ -665,6 +665,7 @@
 MODULE_PARM(debug, "i");
 MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
 
+EXPORT_SYMBOL_GPL(pci_hotplug_slots_subsys);
 EXPORT_SYMBOL_GPL(pci_hp_register);
 EXPORT_SYMBOL_GPL(pci_hp_deregister);
 EXPORT_SYMBOL_GPL(pci_hp_change_slot_info);
author
#8 lore raw

ChangeSet 1.1349, 2003/09/29 12:48:49-07:00, [email protected]

[PATCH] PCI: Remove setting TASK_RUNNING after schedule_timeout in /drivers/pci/

 drivers/pci/hotplug/cpqphp.h |    1 -
 drivers/pci/pool.c           |    1 -
 2 files changed, 2 deletions(-)
drivers/pci/hotplug/cpqphp.h +0 -1
diff -Nru a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
@@ -766,7 +766,6 @@
 	set_current_state(TASK_INTERRUPTIBLE);
 	/* Sleep for up to 1 second to wait for the LED to change. */
 	schedule_timeout(1*HZ);
-	set_current_state(TASK_RUNNING);
 	remove_wait_queue(&ctrl->queue, &wait);
 	if (signal_pending(current))
 		retval =  -EINTR;
drivers/pci/pool.c +0 -1
diff -Nru a/drivers/pci/pool.c b/drivers/pci/pool.c
@@ -296,7 +296,6 @@
 
 			schedule_timeout (POOL_TIMEOUT_JIFFIES);
 
-			current->state = TASK_RUNNING;
 			remove_wait_queue (&pool->waitq, &wait);
 			goto restart;
 		}
author
#9 lore raw

ChangeSet 1.1351, 2003/09/30 15:19:11-07:00, [email protected]

[PATCH] PCI: __init documetation

It might not have prevented me from reporting the potential bug, but I would've known you'd thought about it, it might help future developers, and it's unlikely to become dangerously wrong.

 drivers/pci/quirks.c |    3 +++
 1 files changed, 3 insertions(+)
drivers/pci/quirks.c +3 -0
diff -Nru a/drivers/pci/quirks.c b/drivers/pci/quirks.c
@@ -750,6 +750,9 @@
 
 /*
  *  The main table of quirks.
+ *
+ *  Note: any hooks for hotpluggable devices in this table must _NOT_
+ *        be declared __init.
  */
 
 static struct pci_fixup pci_fixups[] __devinitdata = {