power management / hibernate support for s390
Subsystems (15)
PATCH 31/38 pm: hvc_iucv power management callbacks
In reply to Martin SchwidefskyFrom: Hendrik Brueckner <[email protected]>
The patch adds supporting for suspending and resuming IUCV HVC terminal devices from disk. The obligatory Linux device driver interfaces has been added by registering a device driver on the IUCV bus. For each IUCV HVC terminal device the driver creates a respective device on the IUCV bus.
To support suspend and resume, the PM freeze callback severs any established IUCV communication path and triggers a HVC tty hang-up when the system image is restored.
IUCV communication path are no longer valid when the z/VM guest is halted.
The device driver initialization has been updated to register devices and the a new routine has been extracted to facilitate the hang-up of IUCV HVC terminal devices.
--- drivers/char/hvc_iucv.c | 204 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 161 insertions(+), 43 deletions(-)
drivers/char/hvc_iucv.c +161 -43
@@ -4,7 +4,7 @@* This HVC device driver provides terminal access using * z/VM IUCV communication paths. * -* Copyright IBM Corp. 2008 +* Copyright IBM Corp. 2008, 2009 * * Author(s): Hendrik Brueckner <[email protected]> */
@@ -15,6 +15,7 @@#include <asm/ebcdic.h> #include <linux/ctype.h> #include <linux/delay.h> +#include <linux/device.h> #include <linux/init.h> #include <linux/mempool.h> #include <linux/moduleparam.h>
@@ -74,6 +75,7 @@ struct hvc_iucv_private {wait_queue_head_t sndbuf_waitq;/* wait for send completion */ struct list_head tty_outqueue;/* outgoing IUCV messages */ struct list_head tty_inqueue;/* incoming IUCV messages */ +struct device *dev;/* device structure */ };struct iucv_tty_buffer {
@@ -542,7 +544,68 @@ static void flush_sndbuf_sync(struct hvcif (sync_wait)wait_event_timeout (priv->sndbuf_waitq, -tty_outqueue_empty (priv),HZ ); +tty_outqueue_empty (priv),HZ /10 ); +} + +/** +* hvc_iucv_hangup() - Sever IUCV path and schedule hvc tty hang up +* @priv: Pointer to hvc_iucv_private structure +* +* This routine severs an existing IUCV communication path and hangs +* up the underlying HVC terminal device. +* The hang-up occurs only if an IUCV communication path is established; +* otherwise there is no need to hang up the terminal device. +* +* The IUCV HVC hang-up is separated into two steps: +* 1. After the IUCV path has been severed, the iucv_state is set to +* IUCV_SEVERED. +* 2. Later, when the HVC thread calls hvc_iucv_get_chars(), the +* IUCV_SEVERED state causes the tty hang-up in the HVC layer. +* +* If the tty has not yet been opened, clean up the hvc_iucv_private +* structure to allow re-connects. +* If the tty has been opened, let get_chars() return -EPIPE to signal +* the HVC layer to hang up the tty and, if so, wake up the HVC thread +* to call get_chars()... +* +* Special notes on hanging up a HVC terminal instantiated as console: +* Hang-up: 1. do_tty_hangup() replaces file ops (= hung_up_tty_fops) +* 2. do_tty_hangup() calls tty->ops->close() for console_filp +* => no hangup notifier is called by HVC (default) +* 2. hvc_close() returns because of tty_hung_up_p(filp) +* => no delete notifier is called! +* Finally, the back-end is not being notified, thus, the tty session is +* kept active (TTY_OPEN) to be ready for re-connects. +* +* Locking: spin_lock(&priv->lock) w/o disabling bh +*/ +static void hvc_iucv_hangup (struct hvc_iucv_private *priv) +{ +struct iucv_path *path; + + path =NULL ; +spin_lock (&priv->lock); +if (priv->iucv_state ==IUCV_CONNECTED ) { + path = priv->path; + priv->path =NULL ; + priv->iucv_state =IUCV_SEVERED ; +if (priv->tty_state ==TTY_CLOSED ) +hvc_iucv_cleanup (priv); +else +/* console is special (see above) */ +if (priv->is_console) { +hvc_iucv_cleanup (priv); + priv->tty_state =TTY_OPENED ; + }else +hvc_kick (); + } +spin_unlock (&priv->lock); + +/* finally sever path (outside of priv->lock due to lock ordering) */ +if (path) { +iucv_path_sever (path,NULL ); +iucv_path_free (path); + } }/**
@@ -735,11 +798,8 @@ out_path_handled:* @ipuser: User specified data for this path * (AF_IUCV: port/service name and originator port) * -* The function also severs the path (as required by the IUCV protocol) and -* sets the iucv state to IUCV_SEVERED for the associated struct -* hvc_iucv_private instance. Later, the IUCV_SEVERED state triggers a tty -* hangup (hvc_iucv_get_chars() / hvc_iucv_write()). -* If tty portion of the HVC is closed, clean up the outqueue. +* This function calls the hvc_iucv_hangup() function for the +* respective IUCV HVC terminal. * * Locking: struct hvc_iucv_private->lock */
@@ -747,33 +807,7 @@ static void hvc_iucv_path_severed(struct {struct hvc_iucv_private *priv = path->private; -spin_lock (&priv->lock); - priv->iucv_state =IUCV_SEVERED ; - -/* If the tty has not yet been opened, clean up the hvc_iucv_private -* structure to allow re-connects. -* This is also done for our console device because console hangups -* are handled specially and no notifier is called by HVC. -* The tty session is active (TTY_OPEN) and ready for re-connects... -* -* If it has been opened, let get_chars() return -EPIPE to signal the -* HVC layer to hang up the tty. -* If so, we need to wake up the HVC thread to call get_chars()... -*/ - priv->path =NULL ; -if (priv->tty_state ==TTY_CLOSED ) -hvc_iucv_cleanup (priv); -else -if (priv->is_console) { -hvc_iucv_cleanup (priv); - priv->tty_state =TTY_OPENED ; - }else -hvc_kick (); -spin_unlock (&priv->lock); - -/* finally sever path (outside of priv->lock due to lock ordering) */ -iucv_path_sever (path, ipuser); -iucv_path_free (path); +hvc_iucv_hangup (priv); }/**
@@ -853,6 +887,37 @@ static void hvc_iucv_msg_complete(structdestroy_tty_buffer_list (&list_remove); } +/** +* hvc_iucv_pm_freeze() - Freeze PM callback +* @dev: IUVC HVC terminal device +* +* Sever an established IUCV communication path and +* trigger a hang-up of the underlying HVC terminal. +*/ +static int hvc_iucv_pm_freeze (struct device *dev) +{ +struct hvc_iucv_private *priv =dev_get_drvdata (dev); + +local_bh_disable (); +hvc_iucv_hangup (priv); +local_bh_enable (); + +return 0 ; +} + +/** +* hvc_iucv_pm_restore_thaw() - Thaw and restore PM callback +* @dev: IUVC HVC terminal device +* +* Wake up the HVC thread to trigger hang-up and respective +* HVC back-end notifier invocations. +*/ +static int hvc_iucv_pm_restore_thaw (struct device *dev) +{ +hvc_kick (); +return 0 ; +} +/* HVC operations */ static struct hv_ops hvc_iucv_ops = {
@@ -863,6 +928,20 @@ static struct hv_ops hvc_iucv_ops = { .notifier_hangup = hvc_iucv_notifier_hangup, }; +/* Suspend / resume device operations */ +static struct dev_pm_ops hvc_iucv_pm_ops = { + .freeze = hvc_iucv_pm_freeze, + .thaw = hvc_iucv_pm_restore_thaw, + .restore = hvc_iucv_pm_restore_thaw, +}; + +/* IUCV HVC device driver */ +static struct device_driver hvc_iucv_driver = { + .name =KMSG_COMPONENT , + .bus = &iucv_bus, + .pm = &hvc_iucv_pm_ops, +}; +/** * hvc_iucv_alloc() - Allocates a new struct hvc_iucv_private instance * @id: hvc_iucv_table index
@@ -897,14 +976,12 @@ static int __init hvc_iucv_alloc(int id,/* set console flag */ priv->is_console = is_console; -/* finally allocate hvc */ +/* allocate hvc device */ priv->hvc =hvc_alloc (HVC_IUCV_MAGIC + id,/* PAGE_SIZE */ HVC_IUCV_MAGIC + id, &hvc_iucv_ops,256 );if (IS_ERR (priv->hvc)) { rc =PTR_ERR (priv->hvc); -free_page ((unsigned long ) priv->sndbuf); -kfree (priv); -return rc; + goto out_error_hvc; }/* notify HVC thread instead of using polling */
@@ -915,8 +992,45 @@ static int __init hvc_iucv_alloc(int id,memcpy (priv->srv_name, name,8 );ASCEBC (priv->srv_name,8 ); +/* create and setup device */ + priv->dev =kzalloc (sizeof (*priv->dev),GFP_KERNEL ); +if (!priv->dev) { + rc = -ENOMEM ; + goto out_error_dev; + } +dev_set_name (priv->dev,"hvc_iucv%d" , id); +dev_set_drvdata (priv->dev, priv); + priv->dev->bus = &iucv_bus; + priv->dev->parent = iucv_root; + priv->dev->driver = &hvc_iucv_driver; + priv->dev->release = (void (*)(struct device *)) kfree; + rc =device_register (priv->dev); +if (rc) { +kfree (priv->dev); + goto out_error_dev; + } + hvc_iucv_table[id] = priv;return 0 ; + +out_error_dev: +hvc_remove (priv->hvc); +out_error_hvc: +free_page ((unsigned long ) priv->sndbuf); +kfree (priv); + +return rc; +} + +/** +* hvc_iucv_destroy() - Destroy and free hvc_iucv_private instances +*/ +static void __init hvc_iucv_destroy (struct hvc_iucv_private *priv) +{ +hvc_remove (priv->hvc); +device_unregister (priv->dev); +free_page ((unsigned long ) priv->sndbuf); +kfree (priv); }/**
@@ -1109,6 +1223,11 @@ static int __init hvc_iucv_init(void) goto out_error; } +/* register IUCV HVC device driver */ + rc =driver_register (&hvc_iucv_driver); +if (rc) + goto out_error; +/* parse hvc_iucv_allow string and create z/VM user ID filter list */ if (hvc_iucv_filter_string) { rc =hvc_iucv_setup_filter (hvc_iucv_filter_string);
@@ -1183,15 +1302,14 @@ out_error_iucv:iucv_unregister (&hvc_iucv_handler,0 ); out_error_hvc:for (i =0 ; i < hvc_iucv_devices; i++) -if (hvc_iucv_table[i]) { -if (hvc_iucv_table[i]->hvc) -hvc_remove (hvc_iucv_table[i]->hvc); -kfree (hvc_iucv_table[i]); - } +if (hvc_iucv_table[i]) +hvc_iucv_destroy (hvc_iucv_table[i]); out_error_memory:mempool_destroy (hvc_iucv_mempool);kmem_cache_destroy (hvc_iucv_buffer_cache); out_error: +if (hvc_iucv_filter) +kfree (hvc_iucv_filter); hvc_iucv_devices =0 ;/* ensure that we do not provide any device */ return rc; }
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 31/38 pm: hvc_iucv power management callbacks
In reply to Martin SchwidefskyFrom: Hendrik Brueckner <[email protected]>
The patch adds supporting for suspending and resuming IUCV HVC terminal devices from disk. The obligatory Linux device driver interfaces has been added by registering a device driver on the IUCV bus. For each IUCV HVC terminal device the driver creates a respective device on the IUCV bus.
To support suspend and resume, the PM freeze callback severs any established IUCV communication path and triggers a HVC tty hang-up when the system image is restored.
IUCV communication path are no longer valid when the z/VM guest is halted.
The device driver initialization has been updated to register devices and the a new routine has been extracted to facilitate the hang-up of IUCV HVC terminal devices.
--- drivers/char/hvc_iucv.c | 204 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 161 insertions(+), 43 deletions(-)
drivers/char/hvc_iucv.c +161 -43
@@ -4,7 +4,7 @@* This HVC device driver provides terminal access using * z/VM IUCV communication paths. * -* Copyright IBM Corp. 2008 +* Copyright IBM Corp. 2008, 2009 * * Author(s): Hendrik Brueckner <[email protected]> */
@@ -15,6 +15,7 @@#include <asm/ebcdic.h> #include <linux/ctype.h> #include <linux/delay.h> +#include <linux/device.h> #include <linux/init.h> #include <linux/mempool.h> #include <linux/moduleparam.h>
@@ -74,6 +75,7 @@ struct hvc_iucv_private {wait_queue_head_t sndbuf_waitq;/* wait for send completion */ struct list_head tty_outqueue;/* outgoing IUCV messages */ struct list_head tty_inqueue;/* incoming IUCV messages */ +struct device *dev;/* device structure */ };struct iucv_tty_buffer {
@@ -542,7 +544,68 @@ static void flush_sndbuf_sync(struct hvcif (sync_wait)wait_event_timeout (priv->sndbuf_waitq, -tty_outqueue_empty (priv),HZ ); +tty_outqueue_empty (priv),HZ /10 ); +} + +/** +* hvc_iucv_hangup() - Sever IUCV path and schedule hvc tty hang up +* @priv: Pointer to hvc_iucv_private structure +* +* This routine severs an existing IUCV communication path and hangs +* up the underlying HVC terminal device. +* The hang-up occurs only if an IUCV communication path is established; +* otherwise there is no need to hang up the terminal device. +* +* The IUCV HVC hang-up is separated into two steps: +* 1. After the IUCV path has been severed, the iucv_state is set to +* IUCV_SEVERED. +* 2. Later, when the HVC thread calls hvc_iucv_get_chars(), the +* IUCV_SEVERED state causes the tty hang-up in the HVC layer. +* +* If the tty has not yet been opened, clean up the hvc_iucv_private +* structure to allow re-connects. +* If the tty has been opened, let get_chars() return -EPIPE to signal +* the HVC layer to hang up the tty and, if so, wake up the HVC thread +* to call get_chars()... +* +* Special notes on hanging up a HVC terminal instantiated as console: +* Hang-up: 1. do_tty_hangup() replaces file ops (= hung_up_tty_fops) +* 2. do_tty_hangup() calls tty->ops->close() for console_filp +* => no hangup notifier is called by HVC (default) +* 2. hvc_close() returns because of tty_hung_up_p(filp) +* => no delete notifier is called! +* Finally, the back-end is not being notified, thus, the tty session is +* kept active (TTY_OPEN) to be ready for re-connects. +* +* Locking: spin_lock(&priv->lock) w/o disabling bh +*/ +static void hvc_iucv_hangup (struct hvc_iucv_private *priv) +{ +struct iucv_path *path; + + path =NULL ; +spin_lock (&priv->lock); +if (priv->iucv_state ==IUCV_CONNECTED ) { + path = priv->path; + priv->path =NULL ; + priv->iucv_state =IUCV_SEVERED ; +if (priv->tty_state ==TTY_CLOSED ) +hvc_iucv_cleanup (priv); +else +/* console is special (see above) */ +if (priv->is_console) { +hvc_iucv_cleanup (priv); + priv->tty_state =TTY_OPENED ; + }else +hvc_kick (); + } +spin_unlock (&priv->lock); + +/* finally sever path (outside of priv->lock due to lock ordering) */ +if (path) { +iucv_path_sever (path,NULL ); +iucv_path_free (path); + } }/**
@@ -735,11 +798,8 @@ out_path_handled:* @ipuser: User specified data for this path * (AF_IUCV: port/service name and originator port) * -* The function also severs the path (as required by the IUCV protocol) and -* sets the iucv state to IUCV_SEVERED for the associated struct -* hvc_iucv_private instance. Later, the IUCV_SEVERED state triggers a tty -* hangup (hvc_iucv_get_chars() / hvc_iucv_write()). -* If tty portion of the HVC is closed, clean up the outqueue. +* This function calls the hvc_iucv_hangup() function for the +* respective IUCV HVC terminal. * * Locking: struct hvc_iucv_private->lock */
@@ -747,33 +807,7 @@ static void hvc_iucv_path_severed(struct {struct hvc_iucv_private *priv = path->private; -spin_lock (&priv->lock); - priv->iucv_state =IUCV_SEVERED ; - -/* If the tty has not yet been opened, clean up the hvc_iucv_private -* structure to allow re-connects. -* This is also done for our console device because console hangups -* are handled specially and no notifier is called by HVC. -* The tty session is active (TTY_OPEN) and ready for re-connects... -* -* If it has been opened, let get_chars() return -EPIPE to signal the -* HVC layer to hang up the tty. -* If so, we need to wake up the HVC thread to call get_chars()... -*/ - priv->path =NULL ; -if (priv->tty_state ==TTY_CLOSED ) -hvc_iucv_cleanup (priv); -else -if (priv->is_console) { -hvc_iucv_cleanup (priv); - priv->tty_state =TTY_OPENED ; - }else -hvc_kick (); -spin_unlock (&priv->lock); - -/* finally sever path (outside of priv->lock due to lock ordering) */ -iucv_path_sever (path, ipuser); -iucv_path_free (path); +hvc_iucv_hangup (priv); }/**
@@ -853,6 +887,37 @@ static void hvc_iucv_msg_complete(structdestroy_tty_buffer_list (&list_remove); } +/** +* hvc_iucv_pm_freeze() - Freeze PM callback +* @dev: IUVC HVC terminal device +* +* Sever an established IUCV communication path and +* trigger a hang-up of the underlying HVC terminal. +*/ +static int hvc_iucv_pm_freeze (struct device *dev) +{ +struct hvc_iucv_private *priv =dev_get_drvdata (dev); + +local_bh_disable (); +hvc_iucv_hangup (priv); +local_bh_enable (); + +return 0 ; +} + +/** +* hvc_iucv_pm_restore_thaw() - Thaw and restore PM callback +* @dev: IUVC HVC terminal device +* +* Wake up the HVC thread to trigger hang-up and respective +* HVC back-end notifier invocations. +*/ +static int hvc_iucv_pm_restore_thaw (struct device *dev) +{ +hvc_kick (); +return 0 ; +} +/* HVC operations */ static struct hv_ops hvc_iucv_ops = {
@@ -863,6 +928,20 @@ static struct hv_ops hvc_iucv_ops = { .notifier_hangup = hvc_iucv_notifier_hangup, }; +/* Suspend / resume device operations */ +static struct dev_pm_ops hvc_iucv_pm_ops = { + .freeze = hvc_iucv_pm_freeze, + .thaw = hvc_iucv_pm_restore_thaw, + .restore = hvc_iucv_pm_restore_thaw, +}; + +/* IUCV HVC device driver */ +static struct device_driver hvc_iucv_driver = { + .name =KMSG_COMPONENT , + .bus = &iucv_bus, + .pm = &hvc_iucv_pm_ops, +}; +/** * hvc_iucv_alloc() - Allocates a new struct hvc_iucv_private instance * @id: hvc_iucv_table index
@@ -897,14 +976,12 @@ static int __init hvc_iucv_alloc(int id,/* set console flag */ priv->is_console = is_console; -/* finally allocate hvc */ +/* allocate hvc device */ priv->hvc =hvc_alloc (HVC_IUCV_MAGIC + id,/* PAGE_SIZE */ HVC_IUCV_MAGIC + id, &hvc_iucv_ops,256 );if (IS_ERR (priv->hvc)) { rc =PTR_ERR (priv->hvc); -free_page ((unsigned long ) priv->sndbuf); -kfree (priv); -return rc; + goto out_error_hvc; }/* notify HVC thread instead of using polling */
@@ -915,8 +992,45 @@ static int __init hvc_iucv_alloc(int id,memcpy (priv->srv_name, name,8 );ASCEBC (priv->srv_name,8 ); +/* create and setup device */ + priv->dev =kzalloc (sizeof (*priv->dev),GFP_KERNEL ); +if (!priv->dev) { + rc = -ENOMEM ; + goto out_error_dev; + } +dev_set_name (priv->dev,"hvc_iucv%d" , id); +dev_set_drvdata (priv->dev, priv); + priv->dev->bus = &iucv_bus; + priv->dev->parent = iucv_root; + priv->dev->driver = &hvc_iucv_driver; + priv->dev->release = (void (*)(struct device *)) kfree; + rc =device_register (priv->dev); +if (rc) { +kfree (priv->dev); + goto out_error_dev; + } + hvc_iucv_table[id] = priv;return 0 ; + +out_error_dev: +hvc_remove (priv->hvc); +out_error_hvc: +free_page ((unsigned long ) priv->sndbuf); +kfree (priv); + +return rc; +} + +/** +* hvc_iucv_destroy() - Destroy and free hvc_iucv_private instances +*/ +static void __init hvc_iucv_destroy (struct hvc_iucv_private *priv) +{ +hvc_remove (priv->hvc); +device_unregister (priv->dev); +free_page ((unsigned long ) priv->sndbuf); +kfree (priv); }/**
@@ -1109,6 +1223,11 @@ static int __init hvc_iucv_init(void) goto out_error; } +/* register IUCV HVC device driver */ + rc =driver_register (&hvc_iucv_driver); +if (rc) + goto out_error; +/* parse hvc_iucv_allow string and create z/VM user ID filter list */ if (hvc_iucv_filter_string) { rc =hvc_iucv_setup_filter (hvc_iucv_filter_string);
@@ -1183,15 +1302,14 @@ out_error_iucv:iucv_unregister (&hvc_iucv_handler,0 ); out_error_hvc:for (i =0 ; i < hvc_iucv_devices; i++) -if (hvc_iucv_table[i]) { -if (hvc_iucv_table[i]->hvc) -hvc_remove (hvc_iucv_table[i]->hvc); -kfree (hvc_iucv_table[i]); - } +if (hvc_iucv_table[i]) +hvc_iucv_destroy (hvc_iucv_table[i]); out_error_memory:mempool_destroy (hvc_iucv_mempool);kmem_cache_destroy (hvc_iucv_buffer_cache); out_error: +if (hvc_iucv_filter) +kfree (hvc_iucv_filter); hvc_iucv_devices =0 ;/* ensure that we do not provide any device */ return rc; }
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 32/38 pm: smsgiucv power management callbacks.
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
Create dummy iucv-device to get control when the system is suspended and resumed. Server the smsg iucv path on suspend, reestablish the path on resume.
--- drivers/s390/net/smsgiucv.c | 63 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-)
drivers/s390/net/smsgiucv.c +60 -3
@@ -1,7 +1,8 @@/* * IUCV special message driver * -* Copyright 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Copyright IBM Corp. 2003, 2009 +* * Author(s): Martin Schwidefsky ([email protected]) * * This program is free software; you can redistribute it and/or modify
@@ -40,6 +41,8 @@ MODULE_AUTHORMODULE_DESCRIPTION ("Linux for S/390 IUCV special message driver" );static struct iucv_path *smsg_path; +/* dummy device used as trigger for PM functions */ +static struct device *smsg_dev;static DEFINE_SPINLOCK (smsg_list_lock);static LIST_HEAD (smsg_list);
@@ -132,14 +135,51 @@ void smsg_unregister_callback(char *prefkfree (cb); } +static int smsg_pm_freeze (struct device *dev) +{ +#ifdef CONFIG_PM_DEBUG +printk (KERN_WARNING "smsg_pm_freeze\n" ); +#endif +if (smsg_path) +iucv_path_sever (smsg_path,NULL ); +return 0 ; +} + +static int smsg_pm_restore_thaw (struct device *dev) +{ +int rc; + +#ifdef CONFIG_PM_DEBUG +printk (KERN_WARNING "smsg_pm_restore_thaw\n" ); +#endif +if (smsg_path) { +memset (smsg_path,0 ,sizeof (*smsg_path)); + smsg_path->msglim =255 ; + smsg_path->flags =0 ; + rc =iucv_path_connect (smsg_path, &smsg_handler,"*MSG " , +NULL ,NULL ,NULL ); +printk (KERN_ERR "iucv_path_connect returned with rc %i\n" , rc); + } +return 0 ; +} + +static struct dev_pm_ops smsg_pm_ops = { + .freeze = smsg_pm_freeze, + .thaw = smsg_pm_restore_thaw, + .restore = smsg_pm_restore_thaw, +}; +static struct device_driver smsg_driver = { + .owner =THIS_MODULE , .name ="SMSGIUCV" , .bus = &iucv_bus, + .pm = &smsg_pm_ops, }; static void __exit smsg_exit(void) {cpcmd ("SET SMSG IUCV" ,NULL ,0 ,NULL ); +device_unregister (smsg_dev);iucv_unregister (&smsg_handler,1 );driver_unregister (&smsg_driver); }
@@ -166,12 +206,29 @@ static int __init smsg_init(void) rc =iucv_path_connect (smsg_path, &smsg_handler,"*MSG " ,NULL ,NULL ,NULL );if (rc) - goto out_free; + goto out_free_path; + smsg_dev =kzalloc (sizeof (struct device ),GFP_KERNEL ); +if (!smsg_dev) { + rc = -ENOMEM ; + goto out_free_path; + } +dev_set_name (smsg_dev,"smsg_iucv" ); + smsg_dev->bus = &iucv_bus; + smsg_dev->parent = iucv_root; + smsg_dev->release = (void (*)(struct device *))kfree; + smsg_dev->driver = &smsg_driver; + rc =device_register (smsg_dev); +if (rc) + goto out_free_dev; +cpcmd ("SET SMSG IUCV" ,NULL ,0 ,NULL );return 0 ; -out_free: +out_free_dev: +kfree (smsg_dev); +out_free_path:iucv_path_free (smsg_path); + smsg_path =NULL ; out_register:iucv_unregister (&smsg_handler,1 ); out_driver:
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 32/38 pm: smsgiucv power management callbacks.
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
Create dummy iucv-device to get control when the system is suspended and resumed. Server the smsg iucv path on suspend, reestablish the path on resume.
--- drivers/s390/net/smsgiucv.c | 63 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-)
drivers/s390/net/smsgiucv.c +60 -3
@@ -1,7 +1,8 @@/* * IUCV special message driver * -* Copyright 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Copyright IBM Corp. 2003, 2009 +* * Author(s): Martin Schwidefsky ([email protected]) * * This program is free software; you can redistribute it and/or modify
@@ -40,6 +41,8 @@ MODULE_AUTHORMODULE_DESCRIPTION ("Linux for S/390 IUCV special message driver" );static struct iucv_path *smsg_path; +/* dummy device used as trigger for PM functions */ +static struct device *smsg_dev;static DEFINE_SPINLOCK (smsg_list_lock);static LIST_HEAD (smsg_list);
@@ -132,14 +135,51 @@ void smsg_unregister_callback(char *prefkfree (cb); } +static int smsg_pm_freeze (struct device *dev) +{ +#ifdef CONFIG_PM_DEBUG +printk (KERN_WARNING "smsg_pm_freeze\n" ); +#endif +if (smsg_path) +iucv_path_sever (smsg_path,NULL ); +return 0 ; +} + +static int smsg_pm_restore_thaw (struct device *dev) +{ +int rc; + +#ifdef CONFIG_PM_DEBUG +printk (KERN_WARNING "smsg_pm_restore_thaw\n" ); +#endif +if (smsg_path) { +memset (smsg_path,0 ,sizeof (*smsg_path)); + smsg_path->msglim =255 ; + smsg_path->flags =0 ; + rc =iucv_path_connect (smsg_path, &smsg_handler,"*MSG " , +NULL ,NULL ,NULL ); +printk (KERN_ERR "iucv_path_connect returned with rc %i\n" , rc); + } +return 0 ; +} + +static struct dev_pm_ops smsg_pm_ops = { + .freeze = smsg_pm_freeze, + .thaw = smsg_pm_restore_thaw, + .restore = smsg_pm_restore_thaw, +}; +static struct device_driver smsg_driver = { + .owner =THIS_MODULE , .name ="SMSGIUCV" , .bus = &iucv_bus, + .pm = &smsg_pm_ops, }; static void __exit smsg_exit(void) {cpcmd ("SET SMSG IUCV" ,NULL ,0 ,NULL ); +device_unregister (smsg_dev);iucv_unregister (&smsg_handler,1 );driver_unregister (&smsg_driver); }
@@ -166,12 +206,29 @@ static int __init smsg_init(void) rc =iucv_path_connect (smsg_path, &smsg_handler,"*MSG " ,NULL ,NULL ,NULL );if (rc) - goto out_free; + goto out_free_path; + smsg_dev =kzalloc (sizeof (struct device ),GFP_KERNEL ); +if (!smsg_dev) { + rc = -ENOMEM ; + goto out_free_path; + } +dev_set_name (smsg_dev,"smsg_iucv" ); + smsg_dev->bus = &iucv_bus; + smsg_dev->parent = iucv_root; + smsg_dev->release = (void (*)(struct device *))kfree; + smsg_dev->driver = &smsg_driver; + rc =device_register (smsg_dev); +if (rc) + goto out_free_dev; +cpcmd ("SET SMSG IUCV" ,NULL ,0 ,NULL );return 0 ; -out_free: +out_free_dev: +kfree (smsg_dev); +out_free_path:iucv_path_free (smsg_path); + smsg_path =NULL ; out_register:iucv_unregister (&smsg_handler,1 ); out_driver:
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 33/38 pm: con3270 power management callbacks.
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
Introduce the power management callbacks to the 3270 driver. On suspend the current 3270 view is deactivated and for non-console 3270 device the release callback is done. This disconnects the current tty / fullscreen application from the 3270 device. On resume the current view is reactivated, on the tty you get a fresh login.
If the system panics before the 3270 device has been resumed, the ccw device for the 3270 console is reactivated with ccw_device_force_console.
--- drivers/s390/char/con3270.c | 12 +++--- drivers/s390/char/fs3270.c | 16 +++++--- drivers/s390/char/raw3270.c | 84 ++++++++++++++++++++++++++++++++++++++------ drivers/s390/char/raw3270.h | 12 +++--- 4 files changed, 95 insertions(+), 29 deletions(-)
drivers/s390/char/raw3270.c +73 -11
@@ -1,11 +1,10 @@/* -* drivers/s390/char/raw3270.c -* IBM/3270 Driver - core functions. +* IBM/3270 Driver - core functions. * -* Author(s): -* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) -* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> -* -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Author(s): +* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) +* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> +* Copyright IBM Corp. 2003, 2009 */ #include <linux/bootmem.h>
@@ -61,6 +60,7 @@ struct raw3270 {#define RAW3270_FLAGS_ATTN 2/* Device sent an ATTN interrupt */ #define RAW3270_FLAGS_READY 4/* Device is useable by views */ #define RAW3270_FLAGS_CONSOLE 8/* Device is the console. */ +#define RAW3270_FLAGS_FROZEN 16/* set if 3270 is frozen for suspend */ /* Semaphore to protect global data of raw3270 (devices, views, etc). */ static DEFINE_MUTEX (raw3270_mutex);
@@ -306,7 +306,8 @@ raw3270_start(struct raw3270_view *view,spin_lock_irqsave (get_ccwdev_lock (view->dev->cdev), flags); rp = view->dev; -if (!rp || rp->view != view) +if (!rp || rp->view != view || +test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) rc = -EACCES ;else if (!test_bit (RAW3270_FLAGS_READY , &rp->flags)) rc = -ENODEV ;
@@ -323,7 +324,8 @@ raw3270_start_locked(struct raw3270_viewint rc; rp = view->dev; -if (!rp || rp->view != view) +if (!rp || rp->view != view || +test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) rc = -EACCES ;else if (!test_bit (RAW3270_FLAGS_READY , &rp->flags)) rc = -ENODEV ;
@@ -764,7 +766,8 @@ raw3270_reset(struct raw3270_view *view)int rc; rp = view->dev; -if (!rp || rp->view != view) +if (!rp || rp->view != view || +test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) rc = -EACCES ;else if (!test_bit (RAW3270_FLAGS_READY , &rp->flags)) rc = -ENODEV ;
@@ -922,6 +925,8 @@ raw3270_activate_view(struct raw3270_vie rc =0 ; else if (!test_bit(RAW3270_FLAGS_READY, &rp->flags)) rc = -ENODEV ; + else if (test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) + rc = -EACCES ; else { oldview =NULL ;if (rp->view) {
@@ -969,7 +974,8 @@ raw3270_deactivate_view(struct raw3270_vlist_del_init (&view->list);list_add_tail (&view->list, &rp->view_list);/* Try to activate another view. */ -if (test_bit (RAW3270_FLAGS_READY , &rp->flags)) { +if (test_bit (RAW3270_FLAGS_READY , &rp->flags) && + !test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) {list_for_each_entry (view, &rp->view_list, list) { rp->view = view;if (view->fn->activate (view) ==0 )
@@ -1068,7 +1074,8 @@ raw3270_del_view(struct raw3270_view *vi rp->view =NULL ; }list_del_init (&view->list); -if (!rp->view &&test_bit (RAW3270_FLAGS_READY , &rp->flags)) { +if (!rp->view &&test_bit (RAW3270_FLAGS_READY , &rp->flags) && + !test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) {/* Try to activate another view. */ list_for_each_entry (nv, &rp->view_list, list) {if (nv->fn->activate (nv) ==0 ) {
@@ -1337,6 +1344,58 @@ raw3270_set_offline (struct ccw_device *return 0 ; } +static int raw3270_pm_stop (struct ccw_device *cdev) +{ +struct raw3270 *rp; +struct raw3270_view *view; +unsigned long flags; + + rp = cdev->dev.driver_data; +if (!rp) +return 0 ; +spin_lock_irqsave (get_ccwdev_lock (rp->cdev), flags); +if (rp->view) + rp->view->fn->deactivate (rp->view); +if (!test_bit (RAW3270_FLAGS_CONSOLE , &rp->flags)) { +/* +* Release tty and fullscreen for all non-console +* devices. +*/ +list_for_each_entry (view, &rp->view_list, list) { +if (view->fn->release) + view->fn->release (view); + } + } +set_bit (RAW3270_FLAGS_FROZEN , &rp->flags); +spin_unlock_irqrestore (get_ccwdev_lock (rp->cdev), flags); +return 0 ; +} + +static int raw3270_pm_start (struct ccw_device *cdev) +{ +struct raw3270 *rp; +unsigned long flags; + + rp = cdev->dev.driver_data; +if (!rp) +return 0 ; +spin_lock_irqsave (get_ccwdev_lock (rp->cdev), flags); +clear_bit (RAW3270_FLAGS_FROZEN , &rp->flags); +if (rp->view) + rp->view->fn->activate (rp->view); +spin_unlock_irqrestore (get_ccwdev_lock (rp->cdev), flags); +return 0 ; +} + +void raw3270_pm_unfreeze (struct raw3270_view *view) +{ +struct raw3270 *rp; + + rp = view->dev; +if (rp &&test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) +ccw_device_force_console (); +} +static struct ccw_device_id raw3270_id[] = { {CCW_DEVICE (0x3270 ,0 ) }, {CCW_DEVICE (0x3271 ,0 ) },
@@ -1360,6 +1419,9 @@ static struct ccw_driver raw3270_ccw_dri .remove = &raw3270_remove, .set_online = &raw3270_set_online, .set_offline = &raw3270_set_offline, + .freeze = &raw3270_pm_stop, + .thaw = &raw3270_pm_start, + .restore = &raw3270_pm_start, }; static int
drivers/s390/char/con3270.c +6 -6
@@ -1,11 +1,10 @@/* -* drivers/s390/char/con3270.c -* IBM/3270 Driver - console view. +* IBM/3270 Driver - console view. * -* Author(s): -* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) -* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> -* -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Author(s): +* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) +* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> +* Copyright IBM Corp. 2003, 2009 */ #include <linux/bootmem.h>
@@ -530,6 +529,7 @@ con3270_flush(void) cp = condev;if (!cp->view.dev)return ; +raw3270_pm_unfreeze (&cp->view);spin_lock_irqsave (&cp->view.lock, flags);con3270_wait_write (cp); cp->nr_up =0 ;
drivers/s390/char/fs3270.c +10 -6
@@ -1,11 +1,10 @@/* -* drivers/s390/char/fs3270.c -* IBM/3270 Driver - fullscreen driver. +* IBM/3270 Driver - fullscreen driver. * -* Author(s): -* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) -* Rewritten for 2.5/2.6 by Martin Schwidefsky <[email protected]> -* -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Author(s): +* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) +* Rewritten for 2.5/2.6 by Martin Schwidefsky <[email protected]> +* Copyright IBM Corp. 2003, 2009 */ #include <linux/bootmem.h>
@@ -399,6 +398,11 @@ fs3270_free_view(struct raw3270_view *vistatic void fs3270_release (struct raw3270_view *view) { +struct fs3270 *fp; + + fp = (struct fs3270 *) view; +if (fp->fs_pid) +kill_pid (fp->fs_pid,SIGHUP ,1 ); }/* View to a 3270 device. Can be console, tty or fullscreen. */
drivers/s390/char/raw3270.h +6 -6
@@ -1,11 +1,10 @@/* -* drivers/s390/char/raw3270.h -* IBM/3270 Driver +* IBM/3270 Driver * -* Author(s): -* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) -* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> -* -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Author(s): +* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) +* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> +* Copyright IBM Corp. 2003, 2009 */ #include <asm/idals.h>
@@ -195,6 +194,7 @@ void raw3270_wait_cons_dev(struct raw327/* Notifier for device addition/removal */ int raw3270_register_notifier (void (*notifier)(int ,int ));void raw3270_unregister_notifier (void (*notifier)(int ,int )); +void raw3270_pm_unfreeze (struct raw3270_view *);/* * Little memory allocator for string objects.
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 33/38 pm: con3270 power management callbacks.
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
Introduce the power management callbacks to the 3270 driver. On suspend the current 3270 view is deactivated and for non-console 3270 device the release callback is done. This disconnects the current tty / fullscreen application from the 3270 device. On resume the current view is reactivated, on the tty you get a fresh login.
If the system panics before the 3270 device has been resumed, the ccw device for the 3270 console is reactivated with ccw_device_force_console.
--- drivers/s390/char/con3270.c | 12 +++--- drivers/s390/char/fs3270.c | 16 +++++--- drivers/s390/char/raw3270.c | 84 ++++++++++++++++++++++++++++++++++++++------ drivers/s390/char/raw3270.h | 12 +++--- 4 files changed, 95 insertions(+), 29 deletions(-)
drivers/s390/char/raw3270.c +73 -11
@@ -1,11 +1,10 @@/* -* drivers/s390/char/raw3270.c -* IBM/3270 Driver - core functions. +* IBM/3270 Driver - core functions. * -* Author(s): -* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) -* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> -* -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Author(s): +* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) +* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> +* Copyright IBM Corp. 2003, 2009 */ #include <linux/bootmem.h>
@@ -61,6 +60,7 @@ struct raw3270 {#define RAW3270_FLAGS_ATTN 2/* Device sent an ATTN interrupt */ #define RAW3270_FLAGS_READY 4/* Device is useable by views */ #define RAW3270_FLAGS_CONSOLE 8/* Device is the console. */ +#define RAW3270_FLAGS_FROZEN 16/* set if 3270 is frozen for suspend */ /* Semaphore to protect global data of raw3270 (devices, views, etc). */ static DEFINE_MUTEX (raw3270_mutex);
@@ -306,7 +306,8 @@ raw3270_start(struct raw3270_view *view,spin_lock_irqsave (get_ccwdev_lock (view->dev->cdev), flags); rp = view->dev; -if (!rp || rp->view != view) +if (!rp || rp->view != view || +test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) rc = -EACCES ;else if (!test_bit (RAW3270_FLAGS_READY , &rp->flags)) rc = -ENODEV ;
@@ -323,7 +324,8 @@ raw3270_start_locked(struct raw3270_viewint rc; rp = view->dev; -if (!rp || rp->view != view) +if (!rp || rp->view != view || +test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) rc = -EACCES ;else if (!test_bit (RAW3270_FLAGS_READY , &rp->flags)) rc = -ENODEV ;
@@ -764,7 +766,8 @@ raw3270_reset(struct raw3270_view *view)int rc; rp = view->dev; -if (!rp || rp->view != view) +if (!rp || rp->view != view || +test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) rc = -EACCES ;else if (!test_bit (RAW3270_FLAGS_READY , &rp->flags)) rc = -ENODEV ;
@@ -922,6 +925,8 @@ raw3270_activate_view(struct raw3270_vie rc =0 ; else if (!test_bit(RAW3270_FLAGS_READY, &rp->flags)) rc = -ENODEV ; + else if (test_bit(RAW3270_FLAGS_FROZEN, &rp->flags)) + rc = -EACCES ; else { oldview =NULL ;if (rp->view) {
@@ -969,7 +974,8 @@ raw3270_deactivate_view(struct raw3270_vlist_del_init (&view->list);list_add_tail (&view->list, &rp->view_list);/* Try to activate another view. */ -if (test_bit (RAW3270_FLAGS_READY , &rp->flags)) { +if (test_bit (RAW3270_FLAGS_READY , &rp->flags) && + !test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) {list_for_each_entry (view, &rp->view_list, list) { rp->view = view;if (view->fn->activate (view) ==0 )
@@ -1068,7 +1074,8 @@ raw3270_del_view(struct raw3270_view *vi rp->view =NULL ; }list_del_init (&view->list); -if (!rp->view &&test_bit (RAW3270_FLAGS_READY , &rp->flags)) { +if (!rp->view &&test_bit (RAW3270_FLAGS_READY , &rp->flags) && + !test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) {/* Try to activate another view. */ list_for_each_entry (nv, &rp->view_list, list) {if (nv->fn->activate (nv) ==0 ) {
@@ -1337,6 +1344,58 @@ raw3270_set_offline (struct ccw_device *return 0 ; } +static int raw3270_pm_stop (struct ccw_device *cdev) +{ +struct raw3270 *rp; +struct raw3270_view *view; +unsigned long flags; + + rp = cdev->dev.driver_data; +if (!rp) +return 0 ; +spin_lock_irqsave (get_ccwdev_lock (rp->cdev), flags); +if (rp->view) + rp->view->fn->deactivate (rp->view); +if (!test_bit (RAW3270_FLAGS_CONSOLE , &rp->flags)) { +/* +* Release tty and fullscreen for all non-console +* devices. +*/ +list_for_each_entry (view, &rp->view_list, list) { +if (view->fn->release) + view->fn->release (view); + } + } +set_bit (RAW3270_FLAGS_FROZEN , &rp->flags); +spin_unlock_irqrestore (get_ccwdev_lock (rp->cdev), flags); +return 0 ; +} + +static int raw3270_pm_start (struct ccw_device *cdev) +{ +struct raw3270 *rp; +unsigned long flags; + + rp = cdev->dev.driver_data; +if (!rp) +return 0 ; +spin_lock_irqsave (get_ccwdev_lock (rp->cdev), flags); +clear_bit (RAW3270_FLAGS_FROZEN , &rp->flags); +if (rp->view) + rp->view->fn->activate (rp->view); +spin_unlock_irqrestore (get_ccwdev_lock (rp->cdev), flags); +return 0 ; +} + +void raw3270_pm_unfreeze (struct raw3270_view *view) +{ +struct raw3270 *rp; + + rp = view->dev; +if (rp &&test_bit (RAW3270_FLAGS_FROZEN , &rp->flags)) +ccw_device_force_console (); +} +static struct ccw_device_id raw3270_id[] = { {CCW_DEVICE (0x3270 ,0 ) }, {CCW_DEVICE (0x3271 ,0 ) },
@@ -1360,6 +1419,9 @@ static struct ccw_driver raw3270_ccw_dri .remove = &raw3270_remove, .set_online = &raw3270_set_online, .set_offline = &raw3270_set_offline, + .freeze = &raw3270_pm_stop, + .thaw = &raw3270_pm_start, + .restore = &raw3270_pm_start, }; static int
drivers/s390/char/con3270.c +6 -6
@@ -1,11 +1,10 @@/* -* drivers/s390/char/con3270.c -* IBM/3270 Driver - console view. +* IBM/3270 Driver - console view. * -* Author(s): -* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) -* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> -* -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Author(s): +* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) +* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> +* Copyright IBM Corp. 2003, 2009 */ #include <linux/bootmem.h>
@@ -530,6 +529,7 @@ con3270_flush(void) cp = condev;if (!cp->view.dev)return ; +raw3270_pm_unfreeze (&cp->view);spin_lock_irqsave (&cp->view.lock, flags);con3270_wait_write (cp); cp->nr_up =0 ;
drivers/s390/char/fs3270.c +10 -6
@@ -1,11 +1,10 @@/* -* drivers/s390/char/fs3270.c -* IBM/3270 Driver - fullscreen driver. +* IBM/3270 Driver - fullscreen driver. * -* Author(s): -* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) -* Rewritten for 2.5/2.6 by Martin Schwidefsky <[email protected]> -* -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Author(s): +* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) +* Rewritten for 2.5/2.6 by Martin Schwidefsky <[email protected]> +* Copyright IBM Corp. 2003, 2009 */ #include <linux/bootmem.h>
@@ -399,6 +398,11 @@ fs3270_free_view(struct raw3270_view *vistatic void fs3270_release (struct raw3270_view *view) { +struct fs3270 *fp; + + fp = (struct fs3270 *) view; +if (fp->fs_pid) +kill_pid (fp->fs_pid,SIGHUP ,1 ); }/* View to a 3270 device. Can be console, tty or fullscreen. */
drivers/s390/char/raw3270.h +6 -6
@@ -1,11 +1,10 @@/* -* drivers/s390/char/raw3270.h -* IBM/3270 Driver +* IBM/3270 Driver * -* Author(s): -* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) -* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> -* -- Copyright (C) 2003 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Author(s): +* Original 3270 Code for 2.4 written by Richard Hitt (UTS Global) +* Rewritten for 2.5 by Martin Schwidefsky <[email protected]> +* Copyright IBM Corp. 2003, 2009 */ #include <asm/idals.h>
@@ -195,6 +194,7 @@ void raw3270_wait_cons_dev(struct raw327/* Notifier for device addition/removal */ int raw3270_register_notifier (void (*notifier)(int ,int ));void raw3270_unregister_notifier (void (*notifier)(int ,int )); +void raw3270_pm_unfreeze (struct raw3270_view *);/* * Little memory allocator for string objects.
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 34/38 pm: memory hotplug power management callbacks
In reply to Martin SchwidefskyFrom: Gerald Schaefer <[email protected]>
--- drivers/s390/char/sclp_cmd.c | 42 ++++++++++++++++++++++++++++++++++++++---- mm/Kconfig | 4 ++-- 2 files changed, 40 insertions(+), 6 deletions(-)
mm/Kconfig +2 -2
@@ -128,11 +128,11 @@ config SPARSEMEM_VMEMMAP config MEMORY_HOTPLUG bool "Allow for memory hot-add" depends on SPARSEMEM || X86_64_ACPI_NUMA - depends on HOTPLUG && !HIBERNATION && ARCH_ENABLE_MEMORY_HOTPLUG + depends on HOTPLUG && !(HIBERNATION && !S390) && ARCH_ENABLE_MEMORY_HOTPLUG depends on (IA64 || X86 || PPC64 || SUPERH || S390) comment "Memory hotplug is currently incompatible with Software Suspend" - depends on SPARSEMEM && HOTPLUG && HIBERNATION + depends on SPARSEMEM && HOTPLUG && HIBERNATION && !S390 config MEMORY_HOTPLUG_SPARSE def_bool y
drivers/s390/char/sclp_cmd.c +38 -4
91 lines not on this page · raw message
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 34/38 pm: memory hotplug power management callbacks
In reply to Martin SchwidefskyFrom: Gerald Schaefer <[email protected]>
--- drivers/s390/char/sclp_cmd.c | 42 ++++++++++++++++++++++++++++++++++++++---- mm/Kconfig | 4 ++-- 2 files changed, 40 insertions(+), 6 deletions(-)
mm/Kconfig +2 -2
@@ -128,11 +128,11 @@ config SPARSEMEM_VMEMMAP config MEMORY_HOTPLUG bool "Allow for memory hot-add" depends on SPARSEMEM || X86_64_ACPI_NUMA - depends on HOTPLUG && !HIBERNATION && ARCH_ENABLE_MEMORY_HOTPLUG + depends on HOTPLUG && !(HIBERNATION && !S390) && ARCH_ENABLE_MEMORY_HOTPLUG depends on (IA64 || X86 || PPC64 || SUPERH || S390) comment "Memory hotplug is currently incompatible with Software Suspend" - depends on SPARSEMEM && HOTPLUG && HIBERNATION + depends on SPARSEMEM && HOTPLUG && HIBERNATION && !S390 config MEMORY_HOTPLUG_SPARSE def_bool y
drivers/s390/char/sclp_cmd.c +38 -4
91 lines not on this page · raw message
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 35/38 pm: monwriter power management callbacks.
In reply to Martin SchwidefskyFrom: Gerald Schaefer <[email protected]>
--- drivers/s390/char/monwriter.c | 98 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 6 deletions(-)
drivers/s390/char/monwriter.c +92 -6
@@ -1,9 +1,7 @@/* -* drivers/s390/char/monwriter.c -* * Character device driver for writing z/VM *MONITOR service records. * -* Copyright (C) IBM Corp. 2006 +* Copyright IBM Corp. 2006, 2009 * * Author(s): Melissa Howland <[email protected]> */
@@ -22,6 +20,7 @@#include <linux/ctype.h> #include <linux/poll.h> #include <linux/mutex.h> +#include <linux/platform_device.h> #include <asm/uaccess.h> #include <asm/ebcdic.h> #include <asm/io.h>
@@ -40,7 +39,10 @@ struct mon_buf {char *data; }; +static LIST_HEAD (mon_priv_list); +struct mon_private { +struct list_head priv_list;struct list_head list;struct monwrite_hdr hdr;size_t hdr_to_read;
@@ -188,6 +190,7 @@ static int monwrite_open(struct inode *i monpriv->hdr_to_read =sizeof (monpriv->hdr);mutex_init (&monpriv->thread_mutex); filp->private_data = monpriv; +list_add_tail (&monpriv->priv_list, &mon_priv_list);unlock_kernel ();return nonseekable_open (inode, filp); }
@@ -206,6 +209,7 @@ static int monwrite_close(struct inode *kfree (entry->data);kfree (entry); } +list_del (&monpriv->priv_list);kfree (monpriv);return 0 ; }
@@ -281,20 +285,102 @@ static struct miscdevice mon_dev = { };/* +* suspend/resume +*/ + +static int monwriter_freeze (struct device *dev) +{ +struct mon_private *monpriv; +struct mon_buf *monbuf; + +list_for_each_entry (monpriv, &mon_priv_list, priv_list) { +list_for_each_entry (monbuf, &monpriv->list, list) { +if (monbuf->hdr.mon_function !=MONWRITE_GEN_EVENT ) +monwrite_diag (&monbuf->hdr, monbuf->data, +APPLDATA_STOP_REC ); + } + } +return 0 ; +} + +static int monwriter_restore (struct device *dev) +{ +struct mon_private *monpriv; +struct mon_buf *monbuf; + +list_for_each_entry (monpriv, &mon_priv_list, priv_list) { +list_for_each_entry (monbuf, &monpriv->list, list) { +if (monbuf->hdr.mon_function ==MONWRITE_START_INTERVAL ) +monwrite_diag (&monbuf->hdr, monbuf->data, +APPLDATA_START_INTERVAL_REC ); +if (monbuf->hdr.mon_function ==MONWRITE_START_CONFIG ) +monwrite_diag (&monbuf->hdr, monbuf->data, +APPLDATA_START_CONFIG_REC ); + } + } +return 0 ; +} + +static int monwriter_thaw (struct device *dev) +{ +return monwriter_restore (dev); +} + +static struct dev_pm_ops monwriter_pm_ops = { + .freeze = monwriter_freeze, + .thaw = monwriter_thaw, + .restore = monwriter_restore, +}; + +static struct platform_driver monwriter_pdrv = { + .driver = { + .name ="monwriter" , + .owner =THIS_MODULE , + .pm = &monwriter_pm_ops, + }, +}; + +static struct platform_device *monwriter_pdev; + +/* * module init/exit */ static int __init mon_init (void ) { -if (MACHINE_IS_VM ) -return misc_register (&mon_dev); -else +int rc; + +if (!MACHINE_IS_VM )return -ENODEV ; + + rc =platform_driver_register (&monwriter_pdrv); +if (rc) +return rc; + + monwriter_pdev =platform_device_register_simple ("monwriter" ,-1 ,NULL , +0 ); +if (IS_ERR (monwriter_pdev)) { + rc =PTR_ERR (monwriter_pdev); + goto out_driver; + } + + rc =misc_register (&mon_dev); +if (rc) + goto out_device; +return 0 ; + +out_device: +platform_device_unregister (monwriter_pdev); +out_driver: +platform_driver_unregister (&monwriter_pdrv); +return rc; } static void __exit mon_exit(void) {WARN_ON (misc_deregister (&mon_dev) !=0 ); +platform_device_unregister (monwriter_pdev); +platform_driver_unregister (&monwriter_pdrv); }module_init (mon_init);
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 35/38 pm: monwriter power management callbacks.
In reply to Martin SchwidefskyFrom: Gerald Schaefer <[email protected]>
--- drivers/s390/char/monwriter.c | 98 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 6 deletions(-)
drivers/s390/char/monwriter.c +92 -6
@@ -1,9 +1,7 @@/* -* drivers/s390/char/monwriter.c -* * Character device driver for writing z/VM *MONITOR service records. * -* Copyright (C) IBM Corp. 2006 +* Copyright IBM Corp. 2006, 2009 * * Author(s): Melissa Howland <[email protected]> */
@@ -22,6 +20,7 @@#include <linux/ctype.h> #include <linux/poll.h> #include <linux/mutex.h> +#include <linux/platform_device.h> #include <asm/uaccess.h> #include <asm/ebcdic.h> #include <asm/io.h>
@@ -40,7 +39,10 @@ struct mon_buf {char *data; }; +static LIST_HEAD (mon_priv_list); +struct mon_private { +struct list_head priv_list;struct list_head list;struct monwrite_hdr hdr;size_t hdr_to_read;
@@ -188,6 +190,7 @@ static int monwrite_open(struct inode *i monpriv->hdr_to_read =sizeof (monpriv->hdr);mutex_init (&monpriv->thread_mutex); filp->private_data = monpriv; +list_add_tail (&monpriv->priv_list, &mon_priv_list);unlock_kernel ();return nonseekable_open (inode, filp); }
@@ -206,6 +209,7 @@ static int monwrite_close(struct inode *kfree (entry->data);kfree (entry); } +list_del (&monpriv->priv_list);kfree (monpriv);return 0 ; }
@@ -281,20 +285,102 @@ static struct miscdevice mon_dev = { };/* +* suspend/resume +*/ + +static int monwriter_freeze (struct device *dev) +{ +struct mon_private *monpriv; +struct mon_buf *monbuf; + +list_for_each_entry (monpriv, &mon_priv_list, priv_list) { +list_for_each_entry (monbuf, &monpriv->list, list) { +if (monbuf->hdr.mon_function !=MONWRITE_GEN_EVENT ) +monwrite_diag (&monbuf->hdr, monbuf->data, +APPLDATA_STOP_REC ); + } + } +return 0 ; +} + +static int monwriter_restore (struct device *dev) +{ +struct mon_private *monpriv; +struct mon_buf *monbuf; + +list_for_each_entry (monpriv, &mon_priv_list, priv_list) { +list_for_each_entry (monbuf, &monpriv->list, list) { +if (monbuf->hdr.mon_function ==MONWRITE_START_INTERVAL ) +monwrite_diag (&monbuf->hdr, monbuf->data, +APPLDATA_START_INTERVAL_REC ); +if (monbuf->hdr.mon_function ==MONWRITE_START_CONFIG ) +monwrite_diag (&monbuf->hdr, monbuf->data, +APPLDATA_START_CONFIG_REC ); + } + } +return 0 ; +} + +static int monwriter_thaw (struct device *dev) +{ +return monwriter_restore (dev); +} + +static struct dev_pm_ops monwriter_pm_ops = { + .freeze = monwriter_freeze, + .thaw = monwriter_thaw, + .restore = monwriter_restore, +}; + +static struct platform_driver monwriter_pdrv = { + .driver = { + .name ="monwriter" , + .owner =THIS_MODULE , + .pm = &monwriter_pm_ops, + }, +}; + +static struct platform_device *monwriter_pdev; + +/* * module init/exit */ static int __init mon_init (void ) { -if (MACHINE_IS_VM ) -return misc_register (&mon_dev); -else +int rc; + +if (!MACHINE_IS_VM )return -ENODEV ; + + rc =platform_driver_register (&monwriter_pdrv); +if (rc) +return rc; + + monwriter_pdev =platform_device_register_simple ("monwriter" ,-1 ,NULL , +0 ); +if (IS_ERR (monwriter_pdev)) { + rc =PTR_ERR (monwriter_pdev); + goto out_driver; + } + + rc =misc_register (&mon_dev); +if (rc) + goto out_device; +return 0 ; + +out_device: +platform_device_unregister (monwriter_pdev); +out_driver: +platform_driver_unregister (&monwriter_pdrv); +return rc; } static void __exit mon_exit(void) {WARN_ON (misc_deregister (&mon_dev) !=0 ); +platform_device_unregister (monwriter_pdev); +platform_driver_unregister (&monwriter_pdrv); }module_init (mon_init);
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 36/38 pm: monreader power management callbacks.
In reply to Martin SchwidefskyFrom: Gerald Schaefer <[email protected]>
--- drivers/s390/char/monreader.c | 140 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 128 insertions(+), 12 deletions(-)
drivers/s390/char/monreader.c +128 -12
@@ -1,10 +1,9 @@/* -* drivers/s390/char/monreader.c -* * Character device driver for reading z/VM *MONITOR service records. * -* Copyright IBM Corp. 2004, 2008 -* Author: Gerald Schaefer <[email protected]> +* Copyright IBM Corp. 2004, 2009 +* +* Author: Gerald Schaefer <[email protected]> */ #define KMSG_COMPONENT "monreader"
@@ -22,6 +21,7 @@#include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/poll.h> +#include <linux/device.h> #include <net/iucv/iucv.h> #include <asm/uaccess.h> #include <asm/ebcdic.h>
@@ -78,6 +78,7 @@ static u8 user_data_sever[16] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; +static struct device *monreader_device;/****************************************************************************** * helper functions *
@@ -319,11 +320,12 @@ static int mon_open(struct inode *inode, goto out_path; } filp->private_data = monpriv; + monreader_device->driver_data = monpriv;unlock_kernel ();return nonseekable_open (inode, filp); out_path: -kfree (monpriv->path); +iucv_path_free (monpriv->path); out_priv:mon_free_mem (monpriv); out_use:
@@ -341,10 +343,13 @@ static int mon_close(struct inode *inode/* * Close IUCV connection and unregister */ - rc =iucv_path_sever (monpriv->path, user_data_sever); -if (rc) -pr_warning ("Disconnecting the z/VM *MONITOR system service " -"failed with rc=%i\n" , rc); +if (monpriv->path) { + rc =iucv_path_sever (monpriv->path, user_data_sever); +if (rc) +pr_warning ("Disconnecting the z/VM *MONITOR system " +"service failed with rc=%i\n" , rc); +iucv_path_free (monpriv->path); + }atomic_set (&monpriv->iucv_severed,0 );atomic_set (&monpriv->iucv_connected,0 );
@@ -452,6 +457,94 @@ static struct miscdevice mon_dev = { .minor = MISC_DYNAMIC_MINOR, }; + +/****************************************************************************** +* suspend / resume * +*****************************************************************************/ +static int monreader_freeze (struct device *dev) +{ +struct mon_private *monpriv = dev->driver_data; +int rc; + +if (!monpriv) +return 0 ; +if (monpriv->path) { + rc =iucv_path_sever (monpriv->path, user_data_sever); +if (rc) +pr_warning ("Disconnecting the z/VM *MONITOR system " +"service failed with rc=%i\n" , rc); +iucv_path_free (monpriv->path); + } +atomic_set (&monpriv->iucv_severed,0 ); +atomic_set (&monpriv->iucv_connected,0 ); +atomic_set (&monpriv->read_ready,0 ); +atomic_set (&monpriv->msglim_count,0 ); + monpriv->write_index =0 ; + monpriv->read_index =0 ; + monpriv->path =NULL ; +return 0 ; +} + +static int monreader_thaw (struct device *dev) +{ +struct mon_private *monpriv = dev->driver_data; +int rc; + +if (!monpriv) +return 0 ; + rc = -ENOMEM ; + monpriv->path =iucv_path_alloc (MON_MSGLIM ,IUCV_IPRMDATA ,GFP_KERNEL ); +if (!monpriv->path) + goto out; + rc =iucv_path_connect (monpriv->path, &monreader_iucv_handler, +MON_SERVICE ,NULL , user_data_connect, monpriv); +if (rc) { +pr_err ("Connecting to the z/VM *MONITOR system service " +"failed with rc=%i\n" , rc); + goto out_path; + } +wait_event (mon_conn_wait_queue, +atomic_read (&monpriv->iucv_connected) || +atomic_read (&monpriv->iucv_severed)); +if (atomic_read (&monpriv->iucv_severed)) + goto out_path; +return 0 ; +out_path: + rc = -EIO ; +iucv_path_free (monpriv->path); + monpriv->path =NULL ; +out: +atomic_set (&monpriv->iucv_severed,1 ); +return rc; +} + +static int monreader_restore (struct device *dev) +{ +int rc; + +segment_unload (mon_dcss_name); + rc =segment_load (mon_dcss_name,SEGMENT_SHARED , + &mon_dcss_start, &mon_dcss_end); +if (rc <0 ) { +segment_warning (rc, mon_dcss_name); +panic ("fatal monreader resume error: no monitor dcss\n" ); + } +return monreader_thaw (dev); +} + +static struct dev_pm_ops monreader_pm_ops = { + .freeze = monreader_freeze, + .thaw = monreader_thaw, + .restore = monreader_restore, +}; + +static struct device_driver monreader_driver = { + .name ="monreader" , + .bus = &iucv_bus, + .pm = &monreader_pm_ops, +}; + +/****************************************************************************** * module init/exit * *****************************************************************************/
@@ -475,16 +568,33 @@ static int __init mon_init(void)return rc; } + rc =driver_register (&monreader_driver); +if (rc) + goto out_iucv; + monreader_device =kzalloc (sizeof (struct device ),GFP_KERNEL ); +if (!monreader_device) + goto out_driver; +dev_set_name (monreader_device,"monreader-dev" ); + monreader_device->bus = &iucv_bus; + monreader_device->parent = iucv_root; + monreader_device->driver = &monreader_driver; + monreader_device->release = (void (*)(struct device *))kfree; + rc =device_register (monreader_device); +if (rc) { +kfree (monreader_device); + goto out_driver; + } + rc =segment_type (mon_dcss_name);if (rc <0 ) {segment_warning (rc, mon_dcss_name); - goto out_iucv; + goto out_device; }if (rc !=SEG_TYPE_SC ) {pr_err ("The specified *MONITOR DCSS %s does not have the " "required type SC\n" , mon_dcss_name); rc = -EINVAL ; - goto out_iucv; + goto out_device; } rc = segment_load(mon_dcss_name, SEGMENT_SHARED,
@@ -492,7 +602,7 @@ static int __init mon_init(void)if (rc <0 ) {segment_warning (rc, mon_dcss_name); rc = -EINVAL ; - goto out_iucv; + goto out_device; }dcss_mkname (mon_dcss_name, &user_data_connect[8 ]);
@@ -503,6 +613,10 @@ static int __init mon_init(void) out:segment_unload (mon_dcss_name); +out_device: +device_unregister (monreader_device); +out_driver: +driver_unregister (&monreader_driver); out_iucv:iucv_unregister (&monreader_iucv_handler,1 );return rc;
@@ -512,6 +626,8 @@ static void __exit mon_exit(void) {segment_unload (mon_dcss_name);WARN_ON (misc_deregister (&mon_dev) !=0 ); +device_unregister (monreader_device); +driver_unregister (&monreader_driver);iucv_unregister (&monreader_iucv_handler,1 );return ; }
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 36/38 pm: monreader power management callbacks.
In reply to Martin SchwidefskyFrom: Gerald Schaefer <[email protected]>
--- drivers/s390/char/monreader.c | 140 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 128 insertions(+), 12 deletions(-)
drivers/s390/char/monreader.c +128 -12
@@ -1,10 +1,9 @@/* -* drivers/s390/char/monreader.c -* * Character device driver for reading z/VM *MONITOR service records. * -* Copyright IBM Corp. 2004, 2008 -* Author: Gerald Schaefer <[email protected]> +* Copyright IBM Corp. 2004, 2009 +* +* Author: Gerald Schaefer <[email protected]> */ #define KMSG_COMPONENT "monreader"
@@ -22,6 +21,7 @@#include <linux/spinlock.h> #include <linux/interrupt.h> #include <linux/poll.h> +#include <linux/device.h> #include <net/iucv/iucv.h> #include <asm/uaccess.h> #include <asm/ebcdic.h>
@@ -78,6 +78,7 @@ static u8 user_data_sever[16] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; +static struct device *monreader_device;/****************************************************************************** * helper functions *
@@ -319,11 +320,12 @@ static int mon_open(struct inode *inode, goto out_path; } filp->private_data = monpriv; + monreader_device->driver_data = monpriv;unlock_kernel ();return nonseekable_open (inode, filp); out_path: -kfree (monpriv->path); +iucv_path_free (monpriv->path); out_priv:mon_free_mem (monpriv); out_use:
@@ -341,10 +343,13 @@ static int mon_close(struct inode *inode/* * Close IUCV connection and unregister */ - rc =iucv_path_sever (monpriv->path, user_data_sever); -if (rc) -pr_warning ("Disconnecting the z/VM *MONITOR system service " -"failed with rc=%i\n" , rc); +if (monpriv->path) { + rc =iucv_path_sever (monpriv->path, user_data_sever); +if (rc) +pr_warning ("Disconnecting the z/VM *MONITOR system " +"service failed with rc=%i\n" , rc); +iucv_path_free (monpriv->path); + }atomic_set (&monpriv->iucv_severed,0 );atomic_set (&monpriv->iucv_connected,0 );
@@ -452,6 +457,94 @@ static struct miscdevice mon_dev = { .minor = MISC_DYNAMIC_MINOR, }; + +/****************************************************************************** +* suspend / resume * +*****************************************************************************/ +static int monreader_freeze (struct device *dev) +{ +struct mon_private *monpriv = dev->driver_data; +int rc; + +if (!monpriv) +return 0 ; +if (monpriv->path) { + rc =iucv_path_sever (monpriv->path, user_data_sever); +if (rc) +pr_warning ("Disconnecting the z/VM *MONITOR system " +"service failed with rc=%i\n" , rc); +iucv_path_free (monpriv->path); + } +atomic_set (&monpriv->iucv_severed,0 ); +atomic_set (&monpriv->iucv_connected,0 ); +atomic_set (&monpriv->read_ready,0 ); +atomic_set (&monpriv->msglim_count,0 ); + monpriv->write_index =0 ; + monpriv->read_index =0 ; + monpriv->path =NULL ; +return 0 ; +} + +static int monreader_thaw (struct device *dev) +{ +struct mon_private *monpriv = dev->driver_data; +int rc; + +if (!monpriv) +return 0 ; + rc = -ENOMEM ; + monpriv->path =iucv_path_alloc (MON_MSGLIM ,IUCV_IPRMDATA ,GFP_KERNEL ); +if (!monpriv->path) + goto out; + rc =iucv_path_connect (monpriv->path, &monreader_iucv_handler, +MON_SERVICE ,NULL , user_data_connect, monpriv); +if (rc) { +pr_err ("Connecting to the z/VM *MONITOR system service " +"failed with rc=%i\n" , rc); + goto out_path; + } +wait_event (mon_conn_wait_queue, +atomic_read (&monpriv->iucv_connected) || +atomic_read (&monpriv->iucv_severed)); +if (atomic_read (&monpriv->iucv_severed)) + goto out_path; +return 0 ; +out_path: + rc = -EIO ; +iucv_path_free (monpriv->path); + monpriv->path =NULL ; +out: +atomic_set (&monpriv->iucv_severed,1 ); +return rc; +} + +static int monreader_restore (struct device *dev) +{ +int rc; + +segment_unload (mon_dcss_name); + rc =segment_load (mon_dcss_name,SEGMENT_SHARED , + &mon_dcss_start, &mon_dcss_end); +if (rc <0 ) { +segment_warning (rc, mon_dcss_name); +panic ("fatal monreader resume error: no monitor dcss\n" ); + } +return monreader_thaw (dev); +} + +static struct dev_pm_ops monreader_pm_ops = { + .freeze = monreader_freeze, + .thaw = monreader_thaw, + .restore = monreader_restore, +}; + +static struct device_driver monreader_driver = { + .name ="monreader" , + .bus = &iucv_bus, + .pm = &monreader_pm_ops, +}; + +/****************************************************************************** * module init/exit * *****************************************************************************/
@@ -475,16 +568,33 @@ static int __init mon_init(void)return rc; } + rc =driver_register (&monreader_driver); +if (rc) + goto out_iucv; + monreader_device =kzalloc (sizeof (struct device ),GFP_KERNEL ); +if (!monreader_device) + goto out_driver; +dev_set_name (monreader_device,"monreader-dev" ); + monreader_device->bus = &iucv_bus; + monreader_device->parent = iucv_root; + monreader_device->driver = &monreader_driver; + monreader_device->release = (void (*)(struct device *))kfree; + rc =device_register (monreader_device); +if (rc) { +kfree (monreader_device); + goto out_driver; + } + rc =segment_type (mon_dcss_name);if (rc <0 ) {segment_warning (rc, mon_dcss_name); - goto out_iucv; + goto out_device; }if (rc !=SEG_TYPE_SC ) {pr_err ("The specified *MONITOR DCSS %s does not have the " "required type SC\n" , mon_dcss_name); rc = -EINVAL ; - goto out_iucv; + goto out_device; } rc = segment_load(mon_dcss_name, SEGMENT_SHARED,
@@ -492,7 +602,7 @@ static int __init mon_init(void)if (rc <0 ) {segment_warning (rc, mon_dcss_name); rc = -EINVAL ; - goto out_iucv; + goto out_device; }dcss_mkname (mon_dcss_name, &user_data_connect[8 ]);
@@ -503,6 +613,10 @@ static int __init mon_init(void) out:segment_unload (mon_dcss_name); +out_device: +device_unregister (monreader_device); +out_driver: +driver_unregister (&monreader_driver); out_iucv:iucv_unregister (&monreader_iucv_handler,1 );return rc;
@@ -512,6 +626,8 @@ static void __exit mon_exit(void) {segment_unload (mon_dcss_name);WARN_ON (misc_deregister (&mon_dev) !=0 ); +device_unregister (monreader_device); +driver_unregister (&monreader_driver);iucv_unregister (&monreader_iucv_handler,1 );return ; }
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 37/38 pm: dcssblk power management callbacks.
In reply to Martin SchwidefskyFrom: Gerald Schaefer <[email protected]>
--- drivers/s390/block/dcssblk.c | 132 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 115 insertions(+), 17 deletions(-)
drivers/s390/block/dcssblk.c +115 -17
@@ -14,10 +14,11 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/blkdev.h> -#include <asm/extmem.h> -#include <asm/io.h> #include <linux/completion.h> #include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <asm/extmem.h> +#include <asm/io.h> #define DCSSBLK_NAME "dcssblk"#define DCSSBLK_MINORS_PER_DISK 1
@@ -940,11 +941,94 @@ dcssblk_check_params(void) }/* +* Suspend / Resume +*/ +static int dcssblk_freeze (struct device *dev) +{ +struct dcssblk_dev_info *dev_info; +int rc =0 ; + +list_for_each_entry (dev_info, &dcssblk_devices, lh) { +switch (dev_info->segment_type) { +case SEG_TYPE_SR : +case SEG_TYPE_ER : +case SEG_TYPE_SC : +if (!dev_info->is_shared) + rc = -EINVAL ; +break ; +default : + rc = -EINVAL ; +break ; + } +if (rc) +break ; + } +if (rc) +pr_err ("Suspend failed because device %s is writeable.\n" , + dev_info->segment_name); +return rc; +} + +static int dcssblk_restore (struct device *dev) +{ +struct dcssblk_dev_info *dev_info; +struct segment_info *entry; +unsigned long start, end; +int rc =0 ; + +list_for_each_entry (dev_info, &dcssblk_devices, lh) { +list_for_each_entry (entry, &dev_info->seg_list, lh) { +segment_unload (entry->segment_name); + rc =segment_load (entry->segment_name,SEGMENT_SHARED , + &start, &end); +if (rc <0 ) { +// TODO in_use check ? +segment_warning (rc, entry->segment_name); + goto out_panic; + } +if (start != entry->start || end != entry->end) { +pr_err ("Mismatch of start / end address after " +"resuming device %s\n" , + entry->segment_name); + goto out_panic; + } + } + } +return 0 ; +out_panic: +panic ("fatal dcssblk resume error\n" ); +} + +static int dcssblk_thaw (struct device *dev) +{ +return 0 ; +} + +static struct dev_pm_ops dcssblk_pm_ops = { + .freeze = dcssblk_freeze, + .thaw = dcssblk_thaw, + .restore = dcssblk_restore, +}; + +static struct platform_driver dcssblk_pdrv = { + .driver = { + .name ="dcssblk" , + .owner =THIS_MODULE , + .pm = &dcssblk_pm_ops, + }, +}; + +static struct platform_device *dcssblk_pdev; + + +/* * The init/exit functions. */ static void __exitdcssblk_exit (void ) { +platform_device_unregister (dcssblk_pdev); +platform_driver_unregister (&dcssblk_pdrv);root_device_unregister (dcssblk_root_dev);unregister_blkdev (dcssblk_major,DCSSBLK_NAME ); }
@@ -954,30 +1038,44 @@ dcssblk_init(void) {int rc; - dcssblk_root_dev =root_device_register ("dcssblk" ); -if (IS_ERR (dcssblk_root_dev)) -return PTR_ERR (dcssblk_root_dev); - rc =device_create_file (dcssblk_root_dev, &dev_attr_add); -if (rc) { -root_device_unregister (dcssblk_root_dev); + rc =platform_driver_register (&dcssblk_pdrv); +if (rc)return rc; + + dcssblk_pdev =platform_device_register_simple ("dcssblk" ,-1 ,NULL , +0 ); +if (IS_ERR (dcssblk_pdev)) { + rc =PTR_ERR (dcssblk_pdev); + goto out_pdrv; } - rc =device_create_file (dcssblk_root_dev, &dev_attr_remove); -if (rc) { -root_device_unregister (dcssblk_root_dev); -return rc; + + dcssblk_root_dev =root_device_register ("dcssblk" ); +if (IS_ERR (dcssblk_root_dev)) { + rc =PTR_ERR (dcssblk_root_dev); + goto out_pdev; } + rc =device_create_file (dcssblk_root_dev, &dev_attr_add); +if (rc) + goto out_root; + rc =device_create_file (dcssblk_root_dev, &dev_attr_remove); +if (rc) + goto out_root; rc =register_blkdev (0 ,DCSSBLK_NAME ); -if (rc <0 ) { -root_device_unregister (dcssblk_root_dev); -return rc; - } +if (rc <0 ) + goto out_root; dcssblk_major = rc;init_rwsem (&dcssblk_devices_sem);dcssblk_check_params (); -return 0 ; + +out_root: +root_device_unregister (dcssblk_root_dev); +out_pdev: +platform_device_unregister (dcssblk_pdev); +out_pdrv: +platform_driver_unregister (&dcssblk_pdrv); +return rc; }module_init (dcssblk_init);
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 37/38 pm: dcssblk power management callbacks.
In reply to Martin SchwidefskyFrom: Gerald Schaefer <[email protected]>
--- drivers/s390/block/dcssblk.c | 132 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 115 insertions(+), 17 deletions(-)
drivers/s390/block/dcssblk.c +115 -17
@@ -14,10 +14,11 @@#include <linux/init.h> #include <linux/slab.h> #include <linux/blkdev.h> -#include <asm/extmem.h> -#include <asm/io.h> #include <linux/completion.h> #include <linux/interrupt.h> +#include <linux/platform_device.h> +#include <asm/extmem.h> +#include <asm/io.h> #define DCSSBLK_NAME "dcssblk"#define DCSSBLK_MINORS_PER_DISK 1
@@ -940,11 +941,94 @@ dcssblk_check_params(void) }/* +* Suspend / Resume +*/ +static int dcssblk_freeze (struct device *dev) +{ +struct dcssblk_dev_info *dev_info; +int rc =0 ; + +list_for_each_entry (dev_info, &dcssblk_devices, lh) { +switch (dev_info->segment_type) { +case SEG_TYPE_SR : +case SEG_TYPE_ER : +case SEG_TYPE_SC : +if (!dev_info->is_shared) + rc = -EINVAL ; +break ; +default : + rc = -EINVAL ; +break ; + } +if (rc) +break ; + } +if (rc) +pr_err ("Suspend failed because device %s is writeable.\n" , + dev_info->segment_name); +return rc; +} + +static int dcssblk_restore (struct device *dev) +{ +struct dcssblk_dev_info *dev_info; +struct segment_info *entry; +unsigned long start, end; +int rc =0 ; + +list_for_each_entry (dev_info, &dcssblk_devices, lh) { +list_for_each_entry (entry, &dev_info->seg_list, lh) { +segment_unload (entry->segment_name); + rc =segment_load (entry->segment_name,SEGMENT_SHARED , + &start, &end); +if (rc <0 ) { +// TODO in_use check ? +segment_warning (rc, entry->segment_name); + goto out_panic; + } +if (start != entry->start || end != entry->end) { +pr_err ("Mismatch of start / end address after " +"resuming device %s\n" , + entry->segment_name); + goto out_panic; + } + } + } +return 0 ; +out_panic: +panic ("fatal dcssblk resume error\n" ); +} + +static int dcssblk_thaw (struct device *dev) +{ +return 0 ; +} + +static struct dev_pm_ops dcssblk_pm_ops = { + .freeze = dcssblk_freeze, + .thaw = dcssblk_thaw, + .restore = dcssblk_restore, +}; + +static struct platform_driver dcssblk_pdrv = { + .driver = { + .name ="dcssblk" , + .owner =THIS_MODULE , + .pm = &dcssblk_pm_ops, + }, +}; + +static struct platform_device *dcssblk_pdev; + + +/* * The init/exit functions. */ static void __exitdcssblk_exit (void ) { +platform_device_unregister (dcssblk_pdev); +platform_driver_unregister (&dcssblk_pdrv);root_device_unregister (dcssblk_root_dev);unregister_blkdev (dcssblk_major,DCSSBLK_NAME ); }
@@ -954,30 +1038,44 @@ dcssblk_init(void) {int rc; - dcssblk_root_dev =root_device_register ("dcssblk" ); -if (IS_ERR (dcssblk_root_dev)) -return PTR_ERR (dcssblk_root_dev); - rc =device_create_file (dcssblk_root_dev, &dev_attr_add); -if (rc) { -root_device_unregister (dcssblk_root_dev); + rc =platform_driver_register (&dcssblk_pdrv); +if (rc)return rc; + + dcssblk_pdev =platform_device_register_simple ("dcssblk" ,-1 ,NULL , +0 ); +if (IS_ERR (dcssblk_pdev)) { + rc =PTR_ERR (dcssblk_pdev); + goto out_pdrv; } - rc =device_create_file (dcssblk_root_dev, &dev_attr_remove); -if (rc) { -root_device_unregister (dcssblk_root_dev); -return rc; + + dcssblk_root_dev =root_device_register ("dcssblk" ); +if (IS_ERR (dcssblk_root_dev)) { + rc =PTR_ERR (dcssblk_root_dev); + goto out_pdev; } + rc =device_create_file (dcssblk_root_dev, &dev_attr_add); +if (rc) + goto out_root; + rc =device_create_file (dcssblk_root_dev, &dev_attr_remove); +if (rc) + goto out_root; rc =register_blkdev (0 ,DCSSBLK_NAME ); -if (rc <0 ) { -root_device_unregister (dcssblk_root_dev); -return rc; - } +if (rc <0 ) + goto out_root; dcssblk_major = rc;init_rwsem (&dcssblk_devices_sem);dcssblk_check_params (); -return 0 ; + +out_root: +root_device_unregister (dcssblk_root_dev); +out_pdev: +platform_device_unregister (dcssblk_pdev); +out_pdrv: +platform_driver_unregister (&dcssblk_pdrv); +return rc; }module_init (dcssblk_init);
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 38/38 pm: ap bus power management callbacks
In reply to Martin SchwidefskyFrom: Felix Beck <[email protected]>
--- drivers/s390/crypto/ap_bus.c | 85 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 2 deletions(-)
drivers/s390/crypto/ap_bus.c +83 -2
@@ -54,6 +54,12 @@ static int ap_poll_thread_start(void);static void ap_poll_thread_stop (void );static void ap_request_timeout (unsigned long );static inline void ap_schedule_poll_timer (void ); +static int __ap_poll_device (struct ap_device *ap_dev,unsigned long *flags); +static int ap_device_remove (struct device *dev); +static int ap_device_probe (struct device *dev); +static void ap_interrupt_handler (void *unused1,void *unused2); +static void ap_reset (struct ap_device *ap_dev); +static void ap_config_timeout (unsigned long ptr);/* * Module description.
@@ -101,6 +107,10 @@ static struct hrtimer ap_poll_timer;* If z/VM change to 1500000 nanoseconds to adjust to z/VM polling.*/ static unsigned long long poll_timeout =250000 ; +/* Suspend flag */ +static int ap_suspend_flag; +static struct bus_type ap_bus_type; +/** * ap_using_interrupts() - Returns non-zero if interrupt support is * available.
@@ -617,10 +627,79 @@ static int ap_uevent (struct device *devreturn retval; } +static int ap_bus_suspend (struct device *dev,pm_message_t state) +{ +struct ap_device *ap_dev =to_ap_dev (dev); +unsigned long flags; + +if (!ap_suspend_flag) { + ap_suspend_flag =1 ; + +/* Disable scanning for devices, thus we do not want to scan +* for them after removing. +*/ +del_timer_sync (&ap_config_timer); +if (ap_work_queue !=NULL ) { +destroy_workqueue (ap_work_queue); + ap_work_queue =NULL ; + } +tasklet_disable (&ap_tasklet); + } +/* Poll on the device until all requests are finished. */ +do { + flags =0 ; +__ap_poll_device (ap_dev, &flags); + }while ((flags &1 ) || (flags &2 )); + +ap_device_remove (dev); +return 0 ; +} + +static int ap_bus_resume (struct device *dev) +{ +int rc =0 ; +struct ap_device *ap_dev =to_ap_dev (dev); + +if (ap_suspend_flag) { + ap_suspend_flag =0 ; +if (!ap_interrupts_available ()) + ap_interrupt_indicator =NULL ; +ap_device_probe (dev); +ap_reset (ap_dev); +setup_timer (&ap_dev->timeout, ap_request_timeout, + (unsigned long ) ap_dev); +ap_scan_bus (NULL ); +init_timer (&ap_config_timer); + ap_config_timer.function = ap_config_timeout; + ap_config_timer.data =0 ; + ap_config_timer.expires = jiffies + ap_config_time *HZ ; +add_timer (&ap_config_timer); + ap_work_queue =create_singlethread_workqueue ("kapwork" ); +if (!ap_work_queue) +return -ENOMEM ; +tasklet_enable (&ap_tasklet); +if (!ap_using_interrupts ()) +ap_schedule_poll_timer (); +else +tasklet_schedule (&ap_tasklet); +if (ap_thread_flag) + rc =ap_poll_thread_start (); + }else { +ap_device_probe (dev); +ap_reset (ap_dev); +setup_timer (&ap_dev->timeout, ap_request_timeout, + (unsigned long ) ap_dev); + } + +return rc; +} +static struct bus_type ap_bus_type = { .name ="ap" , .match = &ap_bus_match, .uevent = &ap_uevent, + .suspend = ap_bus_suspend, + .resume = ap_bus_resume };static int ap_device_probe (struct device *dev)
@@ -1066,7 +1145,7 @@ ap_config_timeout(unsigned long ptr)*/ static inline void ap_schedule_poll_timer (void ) { -if (ap_using_interrupts ()) +if (ap_using_interrupts () || ap_suspend_flag)return ;if (hrtimer_is_queued (&ap_poll_timer))return ;
@@ -1384,6 +1463,8 @@ static int ap_poll_thread(void *data)set_user_nice (current,19 );while (1 ) { +if (ap_suspend_flag) +return 0 ;if (need_resched ()) {schedule ();continue ;
@@ -1414,7 +1495,7 @@ static int ap_poll_thread_start(void) {int rc; -if (ap_using_interrupts ()) +if (ap_using_interrupts () || ap_suspend_flag)return 0 ;mutex_lock (&ap_poll_thread_mutex);if (!ap_poll_kthread) {
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 38/38 pm: ap bus power management callbacks
In reply to Martin SchwidefskyFrom: Felix Beck <[email protected]>
--- drivers/s390/crypto/ap_bus.c | 85 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 2 deletions(-)
drivers/s390/crypto/ap_bus.c +83 -2
@@ -54,6 +54,12 @@ static int ap_poll_thread_start(void);static void ap_poll_thread_stop (void );static void ap_request_timeout (unsigned long );static inline void ap_schedule_poll_timer (void ); +static int __ap_poll_device (struct ap_device *ap_dev,unsigned long *flags); +static int ap_device_remove (struct device *dev); +static int ap_device_probe (struct device *dev); +static void ap_interrupt_handler (void *unused1,void *unused2); +static void ap_reset (struct ap_device *ap_dev); +static void ap_config_timeout (unsigned long ptr);/* * Module description.
@@ -101,6 +107,10 @@ static struct hrtimer ap_poll_timer;* If z/VM change to 1500000 nanoseconds to adjust to z/VM polling.*/ static unsigned long long poll_timeout =250000 ; +/* Suspend flag */ +static int ap_suspend_flag; +static struct bus_type ap_bus_type; +/** * ap_using_interrupts() - Returns non-zero if interrupt support is * available.
@@ -617,10 +627,79 @@ static int ap_uevent (struct device *devreturn retval; } +static int ap_bus_suspend (struct device *dev,pm_message_t state) +{ +struct ap_device *ap_dev =to_ap_dev (dev); +unsigned long flags; + +if (!ap_suspend_flag) { + ap_suspend_flag =1 ; + +/* Disable scanning for devices, thus we do not want to scan +* for them after removing. +*/ +del_timer_sync (&ap_config_timer); +if (ap_work_queue !=NULL ) { +destroy_workqueue (ap_work_queue); + ap_work_queue =NULL ; + } +tasklet_disable (&ap_tasklet); + } +/* Poll on the device until all requests are finished. */ +do { + flags =0 ; +__ap_poll_device (ap_dev, &flags); + }while ((flags &1 ) || (flags &2 )); + +ap_device_remove (dev); +return 0 ; +} + +static int ap_bus_resume (struct device *dev) +{ +int rc =0 ; +struct ap_device *ap_dev =to_ap_dev (dev); + +if (ap_suspend_flag) { + ap_suspend_flag =0 ; +if (!ap_interrupts_available ()) + ap_interrupt_indicator =NULL ; +ap_device_probe (dev); +ap_reset (ap_dev); +setup_timer (&ap_dev->timeout, ap_request_timeout, + (unsigned long ) ap_dev); +ap_scan_bus (NULL ); +init_timer (&ap_config_timer); + ap_config_timer.function = ap_config_timeout; + ap_config_timer.data =0 ; + ap_config_timer.expires = jiffies + ap_config_time *HZ ; +add_timer (&ap_config_timer); + ap_work_queue =create_singlethread_workqueue ("kapwork" ); +if (!ap_work_queue) +return -ENOMEM ; +tasklet_enable (&ap_tasklet); +if (!ap_using_interrupts ()) +ap_schedule_poll_timer (); +else +tasklet_schedule (&ap_tasklet); +if (ap_thread_flag) + rc =ap_poll_thread_start (); + }else { +ap_device_probe (dev); +ap_reset (ap_dev); +setup_timer (&ap_dev->timeout, ap_request_timeout, + (unsigned long ) ap_dev); + } + +return rc; +} +static struct bus_type ap_bus_type = { .name ="ap" , .match = &ap_bus_match, .uevent = &ap_uevent, + .suspend = ap_bus_suspend, + .resume = ap_bus_resume };static int ap_device_probe (struct device *dev)
@@ -1066,7 +1145,7 @@ ap_config_timeout(unsigned long ptr)*/ static inline void ap_schedule_poll_timer (void ) { -if (ap_using_interrupts ()) +if (ap_using_interrupts () || ap_suspend_flag)return ;if (hrtimer_is_queued (&ap_poll_timer))return ;
@@ -1384,6 +1463,8 @@ static int ap_poll_thread(void *data)set_user_nice (current,19 );while (1 ) { +if (ap_suspend_flag) +return 0 ;if (need_resched ()) {schedule ();continue ;
@@ -1414,7 +1495,7 @@ static int ap_poll_thread_start(void) {int rc; -if (ap_using_interrupts ()) +if (ap_using_interrupts () || ap_suspend_flag)return 0 ;mutex_lock (&ap_poll_thread_mutex);if (!ap_poll_kthread) {
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.