···7 |-- 0000:17:00.08 | |-- class9 | |-- config10- | |-- detach_state11 | |-- device12 | |-- irq13 | |-- local_cpus···18 | |-- subsystem_device19 | |-- subsystem_vendor20 | `-- vendor21- `-- detach_state2223The topmost element describes the PCI domain and bus number. In this case,24the domain number is 0000 and the bus number is 17 (both values are in hex).···30 ---- --------31 class PCI class (ascii, ro)32 config PCI config space (binary, rw)33- detach_state connection status (bool, rw)34 device PCI device (ascii, ro)35 irq IRQ number (ascii, ro)36 local_cpus nearby CPU mask (cpumask, ro)
···7 |-- 0000:17:00.08 | |-- class9 | |-- config010 | |-- device11 | |-- irq12 | |-- local_cpus···19 | |-- subsystem_device20 | |-- subsystem_vendor21 | `-- vendor22+ `-- ...2324The topmost element describes the PCI domain and bus number. In this case,25the domain number is 0000 and the bus number is 17 (both values are in hex).···31 ---- --------32 class PCI class (ascii, ro)33 config PCI config space (binary, rw)034 device PCI device (ascii, ro)35 irq IRQ number (ascii, ro)36 local_cpus nearby CPU mask (cpumask, ro)
-21
Documentation/power/devices.txt
···207#READY_AFTER_RESUME208#209210-Driver Detach Power Management211-212-The kernel now supports the ability to place a device in a low-power213-state when it is detached from its driver, which happens when its214-module is removed. 215-216-Each device contains a 'detach_state' file in its sysfs directory217-which can be used to control this state. Reading from this file218-displays what the current detach state is set to. This is 0 (On) by219-default. A user may write a positive integer value to this file in the220-range of 1-4 inclusive. 221-222-A value of 1-3 will indicate the device should be placed in that223-low-power state, which will cause ->suspend() to be called for that224-device. A value of 4 indicates that the device should be shutdown, so225-->shutdown() will be called for that device. 226-227-The driver is responsible for reinitializing the device when the228-module is re-inserted during it's ->probe() (or equivalent) method. 229-The driver core will not call any extra functions when binding the230-device to the driver. 231232pm_message_t meaning233
···347looks like the following:348349 Pow5:/sys/bus/vio/drivers/hvcs/30000004 # ls350- . current_vty devspec name partner_vtys351- .. detach_state index partner_clcs vterm_state352353Each entry is provided, by default with a "name" attribute. Reading the354"name" attribute will reveal the device type as shown in the following
···347looks like the following:348349 Pow5:/sys/bus/vio/drivers/hvcs/30000004 # ls350+ . current_vty devspec name partner_vtys351+ .. index partner_clcs vterm_state352353Each entry is provided, by default with a "name" attribute. Reading the354"name" attribute will reveal the device type as shown in the following
+1-1
drivers/base/Makefile
···1# Makefile for the Linux device tree23-obj-y := core.o sys.o interface.o bus.o \4 driver.o class.o class_simple.o platform.o \5 cpu.o firmware.o init.o map.o dmapool.o \6 attribute_container.o transport_class.o
···1# Makefile for the Linux device tree23+obj-y := core.o sys.o bus.o \4 driver.o class.o class_simple.o platform.o \5 cpu.o firmware.o init.o map.o dmapool.o \6 attribute_container.o transport_class.o
···1-/*2- * drivers/base/interface.c - common driverfs interface that's exported to3- * the world for all devices.4- *5- * Copyright (c) 2002-3 Patrick Mochel6- * Copyright (c) 2002-3 Open Source Development Labs7- *8- * This file is released under the GPLv29- *10- */11-12-#include <linux/device.h>13-#include <linux/err.h>14-#include <linux/stat.h>15-#include <linux/string.h>16-17-/**18- * detach_state - control the default power state for the device.19- *20- * This is the state the device enters when it's driver module is21- * unloaded. The value is an unsigned integer, in the range of 0-4.22- * '0' indicates 'On', so no action will be taken when the driver is23- * unloaded. This is the default behavior.24- * '4' indicates 'Off', meaning the driver core will call the driver's25- * shutdown method to quiesce the device.26- * 1-3 indicate a low-power state for the device to enter via the27- * driver's suspend method.28- */29-30-static ssize_t detach_show(struct device * dev, char * buf)31-{32- return sprintf(buf, "%u\n", dev->detach_state);33-}34-35-static ssize_t detach_store(struct device * dev, const char * buf, size_t n)36-{37- u32 state;38- state = simple_strtoul(buf, NULL, 10);39- if (state > 4)40- return -EINVAL;41- dev->detach_state = state;42- return n;43-}44-45-static DEVICE_ATTR(detach_state, 0644, detach_show, detach_store);46-47-48-struct attribute * dev_default_attrs[] = {49- &dev_attr_detach_state.attr,50- NULL,51-};
···2223int resume_device(struct device * dev)24{25+ if (dev->power.pm_parent26+ && dev->power.pm_parent->power.power_state) {27+ dev_err(dev, "PM: resume from %d, parent %s still %d\n",28+ dev->power.power_state,29+ dev->power.pm_parent->bus_id,30+ dev->power.pm_parent->power.power_state);31+ }32+ if (dev->bus && dev->bus->resume) {33+ dev_dbg(dev,"resuming\n");34 return dev->bus->resume(dev);35+ }36 return 0;37}38
+4-19
drivers/base/power/shutdown.c
···19extern struct subsystem devices_subsys;202122-int device_detach_shutdown(struct device * dev)23-{24- if (!dev->detach_state)25- return 0;26-27- if (dev->detach_state == DEVICE_PM_OFF) {28- if (dev->driver && dev->driver->shutdown)29- dev->driver->shutdown(dev);30- return 0;31- }32- return dpm_runtime_suspend(dev, dev->detach_state);33-}34-35-36/**37 * We handle system devices differently - we suspend and shut them38 * down last and resume them first. That way, we don't do anything stupid like···38 struct device * dev;3940 down_write(&devices_subsys.rwsem);41- list_for_each_entry_reverse(dev, &devices_subsys.kset.list, kobj.entry) {42- pr_debug("shutting down %s: ", dev->bus_id);43 if (dev->driver && dev->driver->shutdown) {44- pr_debug("Ok\n");45 dev->driver->shutdown(dev);46- } else47- pr_debug("Ignored.\n");48 }49 up_write(&devices_subsys.rwsem);50
···19extern struct subsystem devices_subsys;20210000000000000022/**23 * We handle system devices differently - we suspend and shut them24 * down last and resume them first. That way, we don't do anything stupid like···52 struct device * dev;5354 down_write(&devices_subsys.rwsem);55+ list_for_each_entry_reverse(dev, &devices_subsys.kset.list,56+ kobj.entry) {57 if (dev->driver && dev->driver->shutdown) {58+ dev_dbg(dev, "shutdown\n");59 dev->driver->shutdown(dev);60+ }061 }62 up_write(&devices_subsys.rwsem);63
···52 if ((buffer_size - length <= 0) || (i >= num_envp))53 return -ENOMEM;54000000000055 envp[i] = NULL;5657 return 0;58}59-60-static int pci_visit_bus (struct pci_visit * fn, struct pci_bus_wrapped *wrapped_bus, struct pci_dev_wrapped *wrapped_parent)61-{62- struct list_head *ln;63- struct pci_dev *dev;64- struct pci_dev_wrapped wrapped_dev;65- int result = 0;66-67- pr_debug("PCI: Scanning bus %04x:%02x\n", pci_domain_nr(wrapped_bus->bus),68- wrapped_bus->bus->number);69-70- if (fn->pre_visit_pci_bus) {71- result = fn->pre_visit_pci_bus(wrapped_bus, wrapped_parent);72- if (result)73- return result;74- }75-76- ln = wrapped_bus->bus->devices.next; 77- while (ln != &wrapped_bus->bus->devices) {78- dev = pci_dev_b(ln);79- ln = ln->next;80-81- memset(&wrapped_dev, 0, sizeof(struct pci_dev_wrapped));82- wrapped_dev.dev = dev;83-84- result = pci_visit_dev(fn, &wrapped_dev, wrapped_bus);85- if (result)86- return result;87- }88-89- if (fn->post_visit_pci_bus)90- result = fn->post_visit_pci_bus(wrapped_bus, wrapped_parent);91-92- return result;93-}94-95-static int pci_visit_bridge (struct pci_visit * fn,96- struct pci_dev_wrapped *wrapped_dev,97- struct pci_bus_wrapped *wrapped_parent)98-{99- struct pci_bus *bus;100- struct pci_bus_wrapped wrapped_bus;101- int result = 0;102-103- pr_debug("PCI: Scanning bridge %s\n", pci_name(wrapped_dev->dev));104-105- if (fn->visit_pci_dev) {106- result = fn->visit_pci_dev(wrapped_dev, wrapped_parent);107- if (result)108- return result;109- }110-111- bus = wrapped_dev->dev->subordinate;112- if (bus) {113- memset(&wrapped_bus, 0, sizeof(struct pci_bus_wrapped));114- wrapped_bus.bus = bus;115-116- result = pci_visit_bus(fn, &wrapped_bus, wrapped_dev);117- }118- return result;119-}120-121-/**122- * pci_visit_dev - scans the pci buses.123- * @fn: callback functions that are called while visiting124- * @wrapped_dev: the device to scan125- * @wrapped_parent: the bus where @wrapped_dev is connected to126- *127- * Every bus and every function is presented to a custom128- * function that can act upon it.129- */130-int pci_visit_dev(struct pci_visit *fn, struct pci_dev_wrapped *wrapped_dev,131- struct pci_bus_wrapped *wrapped_parent)132-{133- struct pci_dev* dev = wrapped_dev ? wrapped_dev->dev : NULL;134- int result = 0;135-136- if (!dev)137- return 0;138-139- if (fn->pre_visit_pci_dev) {140- result = fn->pre_visit_pci_dev(wrapped_dev, wrapped_parent);141- if (result)142- return result;143- }144-145- switch (dev->class >> 8) {146- case PCI_CLASS_BRIDGE_PCI:147- result = pci_visit_bridge(fn, wrapped_dev,148- wrapped_parent);149- if (result)150- return result;151- break;152- default:153- pr_debug("PCI: Scanning device %s\n", pci_name(dev));154- if (fn->visit_pci_dev) {155- result = fn->visit_pci_dev (wrapped_dev,156- wrapped_parent);157- if (result)158- return result;159- }160- }161-162- if (fn->post_visit_pci_dev)163- result = fn->post_visit_pci_dev(wrapped_dev, wrapped_parent);164-165- return result;166-}167-EXPORT_SYMBOL(pci_visit_dev);
···130 u8 slot_bus; /* Bus where the slots handled by this controller sit */131 u8 ctrlcap;132 u16 vendor_id;0133};134135struct irq_mapping {
···130 u8 slot_bus; /* Bus where the slots handled by this controller sit */131 u8 ctrlcap;132 u16 vendor_id;133+ u8 cap_base;134};135136struct irq_mapping {
···32extern unsigned char pci_bus_max_busnr(struct pci_bus *bus);33extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap);3435-struct pci_dev_wrapped {36- struct pci_dev *dev;37- void *data;38-};39-40-struct pci_bus_wrapped {41- struct pci_bus *bus;42- void *data;43-};44-45-struct pci_visit {46- int (* pre_visit_pci_bus) (struct pci_bus_wrapped *,47- struct pci_dev_wrapped *);48- int (* post_visit_pci_bus) (struct pci_bus_wrapped *,49- struct pci_dev_wrapped *);50-51- int (* pre_visit_pci_dev) (struct pci_dev_wrapped *,52- struct pci_bus_wrapped *);53- int (* visit_pci_dev) (struct pci_dev_wrapped *,54- struct pci_bus_wrapped *);55- int (* post_visit_pci_dev) (struct pci_dev_wrapped *,56- struct pci_bus_wrapped *);57-};58-59-extern int pci_visit_dev(struct pci_visit *fn,60- struct pci_dev_wrapped *wrapped_dev,61- struct pci_bus_wrapped *wrapped_parent);62extern void pci_remove_legacy_files(struct pci_bus *bus);6364/* Lock for read/write access to pci device and bus lists */
···32extern unsigned char pci_bus_max_busnr(struct pci_bus *bus);33extern int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap);3400000000000000000000000000035extern void pci_remove_legacy_files(struct pci_bus *bus);3637/* Lock for read/write access to pci device and bus lists */
···225 int errno)226{227 char nbuf[16];228+ const char *errstr;229230+ /* Special case: if the error is EROFS, and we're not already231+ * inside a transaction, then there's really no point in logging232+ * an error. */233+ if (errno == -EROFS && journal_current_handle() == NULL &&234+ (sb->s_flags & MS_RDONLY))235+ return;236+237+ errstr = ext3_decode_error(sb, errno, nbuf);238 printk (KERN_CRIT "EXT3-fs error (device %s) in %s: %s\n",239 sb->s_id, function, errstr);240
-3
include/linux/device.h
···273 BIOS data relevant to device) */274 struct dev_pm_info power;275276- u32 detach_state; /* State to enter when device is277- detached from its driver. */278-279 u64 *dma_mask; /* dma mask (if dma'able device) */280 u64 coherent_dma_mask;/* Like dma_mask, but for281 alloc_coherent mappings as
···273 BIOS data relevant to device) */274 struct dev_pm_info power;275000276 u64 *dma_mask; /* dma mask (if dma'able device) */277 u64 coherent_dma_mask;/* Like dma_mask, but for278 alloc_coherent mappings as
+3-3
kernel/power/main.c
···156 goto Unlock;157 }158159- pr_debug("PM: Preparing system for suspend\n");160 if ((error = suspend_prepare(state)))161 goto Unlock;162163- pr_debug("PM: Entering state.\n");164 error = suspend_enter(state);165166- pr_debug("PM: Finishing up.\n");167 suspend_finish(state);168 Unlock:169 up(&pm_sem);
···1244 addr = mm->free_area_cache;12451246 /* make sure it can fit in the remaining address space */1247- if (addr >= len) {1248 vma = find_vma(mm, addr-len);1249 if (!vma || addr <= vma->vm_start)1250 /* remember the address as a hint for next time */···12661267 /* try just below the current vma->vm_start */1268 addr = vma->vm_start-len;1269- } while (len <= vma->vm_start);12701271 /*1272 * A failed mmap() very likely causes application failure,
···1244 addr = mm->free_area_cache;12451246 /* make sure it can fit in the remaining address space */1247+ if (addr > len) {1248 vma = find_vma(mm, addr-len);1249 if (!vma || addr <= vma->vm_start)1250 /* remember the address as a hint for next time */···12661267 /* try just below the current vma->vm_start */1268 addr = vma->vm_start-len;1269+ } while (len < vma->vm_start);12701271 /*1272 * A failed mmap() very likely causes application failure,