s390: Dynamic subchannel mapping of ccw devices.
Subsystems (2)
PATCH 5/5 s390: Dynamic subchannel mapping of ccw devices.
From: Cornelia Huck <[email protected]>
Support for disconnected devices reappearing on another subchannel:
- create a 'pseudo_subchannel' per channel subsystem (the 'orphanage')
- use the orphanage as a shelter for ccw_devices that can't remain on the same subchannel
Signed-off-by Cornelia Huck <[email protected]>
--- drivers/s390/cio/cio.c | 6 drivers/s390/cio/cio.h | 2 drivers/s390/cio/css.c | 37 ++++- drivers/s390/cio/css.h | 4 drivers/s390/cio/device.c | 294 +++++++++++++++++++++++++++++++++++------- drivers/s390/cio/device.h | 2 drivers/s390/cio/device_fsm.c | 17 +- 7 files changed, 306 insertions(+), 56 deletions(-)
drivers/s390/cio/cio.c +5 -1
@@ -413,6 +413,8 @@ cio_enable_subchannel (struct subchannelCIO_TRACE_EVENT (2 ,"ensch" );CIO_TRACE_EVENT (2 , sch->dev.bus_id); +if (sch_is_pseudo_sch (sch)) +return -EINVAL ; ccode =stsch (sch->schid, &sch->schib);if (ccode)return -ENODEV ;
@@ -460,6 +462,8 @@ cio_disable_subchannel (struct subchanneCIO_TRACE_EVENT (2 ,"dissch" );CIO_TRACE_EVENT (2 , sch->dev.bus_id); +if (sch_is_pseudo_sch (sch)) +return 0 ; ccode =stsch (sch->schid, &sch->schib);if (ccode ==3 )/* Not operational. */ return -ENODEV ;
@@ -494,7 +498,7 @@ cio_disable_subchannel (struct subchannereturn ret; } -static int cio_create_sch_lock (struct subchannel *sch) +int cio_create_sch_lock (struct subchannel *sch) { sch->lock =kmalloc (sizeof (spinlock_t),GFP_KERNEL );if (!sch->lock)
drivers/s390/cio/css.c +33 -4
@@ -581,12 +581,24 @@ css_cm_enable_store(struct device *dev, static DEVICE_ATTR(cm_enable, 0644, css_cm_enable_show, css_cm_enable_store); -static inline void __init -setup_css (int nr) +static inline int __init setup_css (int nr) {u32 tod_high; +int ret;memset (css[nr],0 ,sizeof (struct channel_subsystem )); + css[nr]->pseudo_subchannel = +kzalloc (sizeof (*css[nr]->pseudo_subchannel),GFP_KERNEL ); +if (!css[nr]->pseudo_subchannel) +return -ENOMEM ; + css[nr]->pseudo_subchannel->dev.parent = &css[nr]->device; + css[nr]->pseudo_subchannel->dev.release = css_subchannel_release; +sprintf (css[nr]->pseudo_subchannel->dev.bus_id,"defunct" ); + ret =cio_create_sch_lock (css[nr]->pseudo_subchannel); +if (ret) { +kfree (css[nr]->pseudo_subchannel); +return ret; + }mutex_init (&css[nr]->mutex); css[nr]->valid =1 ; css[nr]->cssid = nr;
@@ -594,6 +606,7 @@ setup_css(int nr) css[nr]->device.release = channel_subsystem_release; tod_high = (u32) (get_clock () >>32 );css_generate_pgid (css[nr], tod_high); +return 0 ; }/*
@@ -630,10 +643,12 @@ init_channel_subsystem (void) ret = -ENOMEM ; goto out_unregister; } -setup_css (i); - ret =device_register (&css[i]->device); + ret =setup_css (i);if (ret) goto out_free; + ret =device_register (&css[i]->device); +if (ret) + goto out_free_all;if (css_characteristics_avail && css_chsc_characteristics.secm) { ret = device_create_file(&css[i]->device,
@@ -641,6 +656,9 @@ init_channel_subsystem (void)if (ret) goto out_device; } + ret =device_register (&css[i]->pseudo_subchannel->dev); +if (ret) + goto out_file; } css_init_done =1 ;
@@ -648,13 +666,19 @@ init_channel_subsystem (void)for_each_subchannel (__init_channel_subsystem,NULL );return 0 ; +out_file: +device_remove_file (&css[i]->device, &dev_attr_cm_enable); out_device:device_unregister (&css[i]->device); +out_free_all: +kfree (css[i]->pseudo_subchannel->lock); +kfree (css[i]->pseudo_subchannel); out_free:kfree (css[i]); out_unregister:while (i >0 ) { i--; +device_unregister (&css[i]->pseudo_subchannel->dev);if (css_characteristics_avail && css_chsc_characteristics.secm)device_remove_file (&css[i]->device, &dev_attr_cm_enable);
@@ -666,6 +690,11 @@ out:return ret; } +int sch_is_pseudo_sch (struct subchannel *sch) +{ +return sch ==to_css (sch->dev.parent)->pseudo_subchannel; +} +/* * find a driver for a subchannel. They identify by the subchannel * type with the exception that the console subchannel driver has its own
drivers/s390/cio/css.h +4 -0
@@ -157,6 +157,8 @@ struct channel_subsystem {int cm_enabled;void *cub_addr1;void *cub_addr2; +/* for orphaned ccw devices */ +struct subchannel *pseudo_subchannel; };#define to_css (dev) container_of(dev, struct channel_subsystem, device)
@@ -182,6 +184,8 @@ void css_clear_subchannel_slow_list(voidint css_slow_subchannels_exist (void );extern int need_rescan; +int sch_is_pseudo_sch (struct subchannel *); +extern struct workqueue_struct *slow_path_wq;extern struct work_struct slow_path_work;
drivers/s390/cio/device.c +247 -47
378 lines not on this page · raw message
drivers/s390/cio/device.h +2 -0
@@ -80,6 +80,8 @@ int ccw_device_cancel_halt_clear(structvoid ccw_device_do_unreg_rereg (void *);void ccw_device_call_sch_unregister (void *); +void ccw_device_move_to_orphanage (void *); +int ccw_device_is_orphan (struct ccw_device *);int ccw_device_recognition (struct ccw_device *);int ccw_device_online (struct ccw_device *);
drivers/s390/cio/device_fsm.c +13 -4
@@ -165,13 +165,12 @@ ccw_device_handle_oper(struct ccw_device/* * Check if cu type and device type still match. If * not, it is certainly another device and we have to -* de- and re-register. Also check here for non-matching devno. +* de- and re-register. */ if (cdev->id.cu_type != cdev->private->senseid.cu_type || cdev->id.cu_model != cdev->private->senseid.cu_model || cdev->id.dev_type != cdev->private->senseid.dev_type || - cdev->id.dev_model != cdev->private->senseid.dev_model || - cdev->private->dev_id.devno != sch->schib.pmcw.dev) { + cdev->id.dev_model != cdev->private->senseid.dev_model) {PREPARE_WORK (&cdev->private->kick_work, ccw_device_do_unreg_rereg, cdev);queue_work (ccw_device_work, &cdev->private->kick_work);
@@ -653,6 +652,10 @@ ccw_device_offline(struct ccw_device *cd {struct subchannel *sch; +if (ccw_device_is_orphan (cdev)) { +ccw_device_done (cdev,DEV_STATE_OFFLINE ); +return 0 ; + } sch =to_subchannel (cdev->dev.parent);if (stsch (sch->schid, &sch->schib) || !sch->schib.pmcw.dnv)return -ENODEV ;
@@ -1092,7 +1095,13 @@ device_trigger_reprobe(struct subchannel sch->schib.pmcw.mp =1 ; sch->schib.pmcw.intparm = (__u32 )(unsigned long )sch;/* We should also udate ssd info, but this has to wait. */ -ccw_device_start_id (cdev,0 ); +/* Check if this is another device which appeared on the same sch. */ +if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) { +PREPARE_WORK (&cdev->private->kick_work, + ccw_device_move_to_orphanage, cdev); +queue_work (ccw_device_work, &cdev->private->kick_work); + }else +ccw_device_start_id (cdev,0 ); } static void
drivers/s390/cio/cio.h +2 -0
@@ -131,6 +131,8 @@ extern int cio_set_options (struct subchextern int cio_get_options (struct subchannel *);extern int cio_modify (struct subchannel *); +int cio_create_sch_lock (struct subchannel *); +/* Use with care. */ #ifdef CONFIG_CCW_CONSOLE extern struct subchannel *cio_probe_console (void );