diff options
author | Ursula Braun <ursula.braun@de.ibm.com> | 2009-06-16 04:30:42 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2009-06-16 04:31:17 -0400 |
commit | 672e405b603af0bed99a4c173cdfce9bbf81c963 (patch) | |
tree | 25c0498b3a25a39f65914396feea32ea4d4d8eef /net/iucv | |
parent | 6c005961c15ff85fe1047c197d50b843567c89f8 (diff) |
[S390] pm: iucv power management callbacks.
Patch calls the PM callback functions of iucv-bus devices, which are
responsible for removal of their established iucv pathes.
The PM freeze callback for the first iucv-bus device disables all iucv
interrupts except the connection severed interrupt.
The PM freeze callback for the last iucv-bus device shuts down iucv.
The PM thaw callback for the first iucv-bus device re-enables iucv
if it has been shut down during freeze. If freezing has been interrupted,
it re-enables iucv interrupts according to the needs of iucv-exploiters.
The PM restore callback for the first iucv-bus device re-enables iucv.
Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'net/iucv')
-rw-r--r-- | net/iucv/iucv.c | 179 |
1 files changed, 179 insertions, 0 deletions
diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c index 0e9f212dd928..c833481d32e3 100644 --- a/net/iucv/iucv.c +++ b/net/iucv/iucv.c | |||
@@ -11,6 +11,8 @@ | |||
11 | * Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com) | 11 | * Fritz Elfert (elfert@de.ibm.com, felfert@millenux.com) |
12 | * Rewritten for af_iucv: | 12 | * Rewritten for af_iucv: |
13 | * Martin Schwidefsky <schwidefsky@de.ibm.com> | 13 | * Martin Schwidefsky <schwidefsky@de.ibm.com> |
14 | * PM functions: | ||
15 | * Ursula Braun (ursula.braun@de.ibm.com) | ||
14 | * | 16 | * |
15 | * Documentation used: | 17 | * Documentation used: |
16 | * The original source | 18 | * The original source |
@@ -77,9 +79,24 @@ static int iucv_bus_match(struct device *dev, struct device_driver *drv) | |||
77 | return 0; | 79 | return 0; |
78 | } | 80 | } |
79 | 81 | ||
82 | static int iucv_pm_prepare(struct device *); | ||
83 | static void iucv_pm_complete(struct device *); | ||
84 | static int iucv_pm_freeze(struct device *); | ||
85 | static int iucv_pm_thaw(struct device *); | ||
86 | static int iucv_pm_restore(struct device *); | ||
87 | |||
88 | static struct dev_pm_ops iucv_pm_ops = { | ||
89 | .prepare = iucv_pm_prepare, | ||
90 | .complete = iucv_pm_complete, | ||
91 | .freeze = iucv_pm_freeze, | ||
92 | .thaw = iucv_pm_thaw, | ||
93 | .restore = iucv_pm_restore, | ||
94 | }; | ||
95 | |||
80 | struct bus_type iucv_bus = { | 96 | struct bus_type iucv_bus = { |
81 | .name = "iucv", | 97 | .name = "iucv", |
82 | .match = iucv_bus_match, | 98 | .match = iucv_bus_match, |
99 | .pm = &iucv_pm_ops, | ||
83 | }; | 100 | }; |
84 | EXPORT_SYMBOL(iucv_bus); | 101 | EXPORT_SYMBOL(iucv_bus); |
85 | 102 | ||
@@ -149,6 +166,7 @@ enum iucv_command_codes { | |||
149 | IUCV_RESUME = 14, | 166 | IUCV_RESUME = 14, |
150 | IUCV_SEVER = 15, | 167 | IUCV_SEVER = 15, |
151 | IUCV_SETMASK = 16, | 168 | IUCV_SETMASK = 16, |
169 | IUCV_SETCONTROLMASK = 17, | ||
152 | }; | 170 | }; |
153 | 171 | ||
154 | /* | 172 | /* |
@@ -366,6 +384,18 @@ static void iucv_allow_cpu(void *data) | |||
366 | parm->set_mask.ipmask = 0xf8; | 384 | parm->set_mask.ipmask = 0xf8; |
367 | iucv_call_b2f0(IUCV_SETMASK, parm); | 385 | iucv_call_b2f0(IUCV_SETMASK, parm); |
368 | 386 | ||
387 | /* | ||
388 | * Enable all iucv control interrupts. | ||
389 | * ipmask contains bits for the different interrupts | ||
390 | * 0x80 - Flag to allow pending connections interrupts | ||
391 | * 0x40 - Flag to allow connection complete interrupts | ||
392 | * 0x20 - Flag to allow connection severed interrupts | ||
393 | * 0x10 - Flag to allow connection quiesced interrupts | ||
394 | * 0x08 - Flag to allow connection resumed interrupts | ||
395 | */ | ||
396 | memset(parm, 0, sizeof(union iucv_param)); | ||
397 | parm->set_mask.ipmask = 0xf8; | ||
398 | iucv_call_b2f0(IUCV_SETCONTROLMASK, parm); | ||
369 | /* Set indication that iucv interrupts are allowed for this cpu. */ | 399 | /* Set indication that iucv interrupts are allowed for this cpu. */ |
370 | cpu_set(cpu, iucv_irq_cpumask); | 400 | cpu_set(cpu, iucv_irq_cpumask); |
371 | } | 401 | } |
@@ -391,6 +421,31 @@ static void iucv_block_cpu(void *data) | |||
391 | } | 421 | } |
392 | 422 | ||
393 | /** | 423 | /** |
424 | * iucv_block_cpu_almost | ||
425 | * @data: unused | ||
426 | * | ||
427 | * Allow connection-severed interrupts only on this cpu. | ||
428 | */ | ||
429 | static void iucv_block_cpu_almost(void *data) | ||
430 | { | ||
431 | int cpu = smp_processor_id(); | ||
432 | union iucv_param *parm; | ||
433 | |||
434 | /* Allow iucv control interrupts only */ | ||
435 | parm = iucv_param_irq[cpu]; | ||
436 | memset(parm, 0, sizeof(union iucv_param)); | ||
437 | parm->set_mask.ipmask = 0x08; | ||
438 | iucv_call_b2f0(IUCV_SETMASK, parm); | ||
439 | /* Allow iucv-severed interrupt only */ | ||
440 | memset(parm, 0, sizeof(union iucv_param)); | ||
441 | parm->set_mask.ipmask = 0x20; | ||
442 | iucv_call_b2f0(IUCV_SETCONTROLMASK, parm); | ||
443 | |||
444 | /* Clear indication that iucv interrupts are allowed for this cpu. */ | ||
445 | cpu_clear(cpu, iucv_irq_cpumask); | ||
446 | } | ||
447 | |||
448 | /** | ||
394 | * iucv_declare_cpu | 449 | * iucv_declare_cpu |
395 | * @data: unused | 450 | * @data: unused |
396 | * | 451 | * |
@@ -1766,6 +1821,130 @@ static void iucv_external_interrupt(u16 code) | |||
1766 | spin_unlock(&iucv_queue_lock); | 1821 | spin_unlock(&iucv_queue_lock); |
1767 | } | 1822 | } |
1768 | 1823 | ||
1824 | static int iucv_pm_prepare(struct device *dev) | ||
1825 | { | ||
1826 | int rc = 0; | ||
1827 | |||
1828 | #ifdef CONFIG_PM_DEBUG | ||
1829 | printk(KERN_INFO "iucv_pm_prepare\n"); | ||
1830 | #endif | ||
1831 | if (dev->driver && dev->driver->pm && dev->driver->pm->prepare) | ||
1832 | rc = dev->driver->pm->prepare(dev); | ||
1833 | return rc; | ||
1834 | } | ||
1835 | |||
1836 | static void iucv_pm_complete(struct device *dev) | ||
1837 | { | ||
1838 | #ifdef CONFIG_PM_DEBUG | ||
1839 | printk(KERN_INFO "iucv_pm_complete\n"); | ||
1840 | #endif | ||
1841 | if (dev->driver && dev->driver->pm && dev->driver->pm->complete) | ||
1842 | dev->driver->pm->complete(dev); | ||
1843 | } | ||
1844 | |||
1845 | /** | ||
1846 | * iucv_path_table_empty() - determine if iucv path table is empty | ||
1847 | * | ||
1848 | * Returns 0 if there are still iucv pathes defined | ||
1849 | * 1 if there are no iucv pathes defined | ||
1850 | */ | ||
1851 | int iucv_path_table_empty(void) | ||
1852 | { | ||
1853 | int i; | ||
1854 | |||
1855 | for (i = 0; i < iucv_max_pathid; i++) { | ||
1856 | if (iucv_path_table[i]) | ||
1857 | return 0; | ||
1858 | } | ||
1859 | return 1; | ||
1860 | } | ||
1861 | |||
1862 | /** | ||
1863 | * iucv_pm_freeze() - Freeze PM callback | ||
1864 | * @dev: iucv-based device | ||
1865 | * | ||
1866 | * disable iucv interrupts | ||
1867 | * invoke callback function of the iucv-based driver | ||
1868 | * shut down iucv, if no iucv-pathes are established anymore | ||
1869 | */ | ||
1870 | static int iucv_pm_freeze(struct device *dev) | ||
1871 | { | ||
1872 | int cpu; | ||
1873 | int rc = 0; | ||
1874 | |||
1875 | #ifdef CONFIG_PM_DEBUG | ||
1876 | printk(KERN_WARNING "iucv_pm_freeze\n"); | ||
1877 | #endif | ||
1878 | for_each_cpu_mask_nr(cpu, iucv_irq_cpumask) | ||
1879 | smp_call_function_single(cpu, iucv_block_cpu_almost, NULL, 1); | ||
1880 | if (dev->driver && dev->driver->pm && dev->driver->pm->freeze) | ||
1881 | rc = dev->driver->pm->freeze(dev); | ||
1882 | if (iucv_path_table_empty()) | ||
1883 | iucv_disable(); | ||
1884 | return rc; | ||
1885 | } | ||
1886 | |||
1887 | /** | ||
1888 | * iucv_pm_thaw() - Thaw PM callback | ||
1889 | * @dev: iucv-based device | ||
1890 | * | ||
1891 | * make iucv ready for use again: allocate path table, declare interrupt buffers | ||
1892 | * and enable iucv interrupts | ||
1893 | * invoke callback function of the iucv-based driver | ||
1894 | */ | ||
1895 | static int iucv_pm_thaw(struct device *dev) | ||
1896 | { | ||
1897 | int rc = 0; | ||
1898 | |||
1899 | #ifdef CONFIG_PM_DEBUG | ||
1900 | printk(KERN_WARNING "iucv_pm_thaw\n"); | ||
1901 | #endif | ||
1902 | if (!iucv_path_table) { | ||
1903 | rc = iucv_enable(); | ||
1904 | if (rc) | ||
1905 | goto out; | ||
1906 | } | ||
1907 | if (cpus_empty(iucv_irq_cpumask)) { | ||
1908 | if (iucv_nonsmp_handler) | ||
1909 | /* enable interrupts on one cpu */ | ||
1910 | iucv_allow_cpu(NULL); | ||
1911 | else | ||
1912 | /* enable interrupts on all cpus */ | ||
1913 | iucv_setmask_mp(); | ||
1914 | } | ||
1915 | if (dev->driver && dev->driver->pm && dev->driver->pm->thaw) | ||
1916 | rc = dev->driver->pm->thaw(dev); | ||
1917 | out: | ||
1918 | return rc; | ||
1919 | } | ||
1920 | |||
1921 | /** | ||
1922 | * iucv_pm_restore() - Restore PM callback | ||
1923 | * @dev: iucv-based device | ||
1924 | * | ||
1925 | * make iucv ready for use again: allocate path table, declare interrupt buffers | ||
1926 | * and enable iucv interrupts | ||
1927 | * invoke callback function of the iucv-based driver | ||
1928 | */ | ||
1929 | static int iucv_pm_restore(struct device *dev) | ||
1930 | { | ||
1931 | int rc = 0; | ||
1932 | |||
1933 | #ifdef CONFIG_PM_DEBUG | ||
1934 | printk(KERN_WARNING "iucv_pm_restore %p\n", iucv_path_table); | ||
1935 | #endif | ||
1936 | if (cpus_empty(iucv_irq_cpumask)) { | ||
1937 | rc = iucv_query_maxconn(); | ||
1938 | rc = iucv_enable(); | ||
1939 | if (rc) | ||
1940 | goto out; | ||
1941 | } | ||
1942 | if (dev->driver && dev->driver->pm && dev->driver->pm->restore) | ||
1943 | rc = dev->driver->pm->restore(dev); | ||
1944 | out: | ||
1945 | return rc; | ||
1946 | } | ||
1947 | |||
1769 | /** | 1948 | /** |
1770 | * iucv_init | 1949 | * iucv_init |
1771 | * | 1950 | * |