int
for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *data)
{ struct subchannel_id schid; int ret;
init_subchannel_id(&schid); do { do {
ret = fn(schid, data); if (ret) break;
} while (schid.sch_no++ < __MAX_SUBCHANNEL);
schid.sch_no = 0;
} while (schid.ssid++ < max_ssid); return ret;
}
struct cb_data { void *data; struct idset *set; int (*fn_known_sch)(struct subchannel *, void *); int (*fn_unknown_sch)(struct subchannel_id, void *);
};
INIT_WORK(&sch->todo_work, css_sch_todo);
sch->dev.release = &css_subchannel_release;
sch->dev.dma_mask = &sch->dma_mask;
device_initialize(&sch->dev); /* * The physical addresses for some of the dma structures that can * belong to a subchannel need to fit 31 bit width (e.g. ccw).
*/
ret = dma_set_coherent_mask(&sch->dev, DMA_BIT_MASK(31)); if (ret) goto err; /* * But we don't have such restrictions imposed on the stuff that * is handled by the streaming API.
*/
ret = dma_set_mask(&sch->dev, DMA_BIT_MASK(64)); if (ret) goto err;
return sch;
err:
kfree(sch); return ERR_PTR(ret);
}
staticint css_sch_device_register(struct subchannel *sch)
{ int ret;
if (sch->st == SUBCHANNEL_TYPE_IO)
sch->dev.type = &io_subchannel_type;
css_update_ssd_info(sch); /* make it known to the system */
ret = css_sch_device_register(sch); if (ret) {
CIO_MSG_EVENT(0, "Could not register sch 0.%x.%04x: %d\n",
sch->schid.ssid, sch->schid.sch_no, ret); return ret;
} return ret;
}
dev = bus_find_device(&css_bus_type, NULL,
&schid, check_subchannel);
return dev ? to_subchannel(dev) : NULL;
}
/** * css_sch_is_valid() - check if a subchannel is valid * @schib: subchannel information block for the subchannel
*/ int css_sch_is_valid(struct schib *schib)
{ if ((schib->pmcw.st == SUBCHANNEL_TYPE_IO) && !schib->pmcw.dnv) return 0; if ((schib->pmcw.st == SUBCHANNEL_TYPE_MSG) && !schib->pmcw.w) return 0; return 1;
}
EXPORT_SYMBOL_GPL(css_sch_is_valid);
staticint css_evaluate_new_subchannel(struct subchannel_id schid, int slow)
{ struct schib schib; int ccode;
if (!slow) { /* Will be done on the slow path. */ return -EAGAIN;
} /* * The first subchannel that is not-operational (ccode==3) * indicates that there aren't any more devices available. * If stsch gets an exception, it means the current subchannel set * is not valid.
*/
ccode = stsch(schid, &schib); if (ccode) return (ccode == 3) ? -ENXIO : ccode;
return css_probe_device(schid, &schib);
}
staticint css_evaluate_known_subchannel(struct subchannel *sch, int slow)
{ int ret = 0;
if (sch->driver) { if (sch->driver->sch_event)
ret = sch->driver->sch_event(sch, slow); else
dev_dbg(&sch->dev, "Got subchannel machine check but " "no sch_event handler provided.\n");
} if (ret != 0 && ret != -EAGAIN) {
CIO_MSG_EVENT(2, "eval: sch 0.%x.%04x, rc=%d\n",
sch->schid.ssid, sch->schid.sch_no, ret);
} return ret;
}
staticvoid css_evaluate_subchannel(struct subchannel_id schid, int slow)
{ struct subchannel *sch; int ret;
sch = get_subchannel_by_schid(schid); if (sch) {
ret = css_evaluate_known_subchannel(sch, slow);
put_device(&sch->dev);
} else
ret = css_evaluate_new_subchannel(schid, slow); if (ret == -EAGAIN)
css_schedule_eval(schid);
}
/** * css_sched_sch_todo - schedule a subchannel operation * @sch: subchannel * @todo: todo * * Schedule the operation identified by @todo to be performed on the slow path * workqueue. Do nothing if another operation with higher priority is already * scheduled. Needs to be called with subchannel lock held.
*/ void css_sched_sch_todo(struct subchannel *sch, enum sch_todo todo)
{
CIO_MSG_EVENT(4, "sch_todo: sched sch=0.%x.%04x todo=%d\n",
sch->schid.ssid, sch->schid.sch_no, todo); if (sch->todo >= todo) return; /* Get workqueue ref. */ if (!get_device(&sch->dev)) return;
sch->todo = todo; if (!queue_work(cio_work_q, &sch->todo_work)) { /* Already queued, release workqueue ref. */
put_device(&sch->dev);
}
}
EXPORT_SYMBOL_GPL(css_sched_sch_todo);
staticint slow_eval_known_fn(struct subchannel *sch, void *data)
{ int eval; int rc;
spin_lock_irq(&slow_subchannel_lock);
eval = idset_sch_contains(slow_subchannel_set, sch->schid);
idset_sch_del(slow_subchannel_set, sch->schid);
spin_unlock_irq(&slow_subchannel_lock); if (eval) {
rc = css_evaluate_known_subchannel(sch, 1); if (rc == -EAGAIN)
css_schedule_eval(sch->schid); /* * The loop might take long time for platforms with lots of * known devices. Allow scheduling here.
*/
cond_resched();
} return 0;
}
staticint slow_eval_unknown_fn(struct subchannel_id schid, void *data)
{ int eval; int rc = 0;
spin_lock_irq(&slow_subchannel_lock);
eval = idset_sch_contains(slow_subchannel_set, schid);
idset_sch_del(slow_subchannel_set, schid);
spin_unlock_irq(&slow_subchannel_lock); if (eval) {
rc = css_evaluate_new_subchannel(schid, 1); switch (rc) { case -EAGAIN:
css_schedule_eval(schid);
rc = 0; break; case -ENXIO: case -ENOMEM: case -EIO: /* These should abort looping */
spin_lock_irq(&slow_subchannel_lock);
idset_sch_del_subseq(slow_subchannel_set, schid);
spin_unlock_irq(&slow_subchannel_lock); break; default:
rc = 0;
} /* Allow scheduling here since the containing loop might
* take a while. */
cond_resched();
} return rc;
}
/* Here we want to make sure that we are considering only those subchannels * which do not have an operational device attached to it. This can be found * with the help of PAM and POM values of pmcw. OPM provides the information * about any path which is currently vary-off, so that we should not consider.
*/ if (sch->st == SUBCHANNEL_TYPE_IO &&
(sch->opm & pmcw->pam & pmcw->pom))
idset_sch_del(set, sch->schid);
/* Schedule reprobing of all subchannels with no valid operational path. */ void css_schedule_reprobe(void)
{ /* Schedule with a delay to allow merging of subsequent calls. */
css_schedule_eval_cond(CSS_EVAL_NO_PATH, 1 * HZ);
}
EXPORT_SYMBOL_GPL(css_schedule_reprobe);
/* * Called from the machine check handler for subchannel report words.
*/ staticvoid css_process_crw(struct crw *crw0, struct crw *crw1, int overflow)
{ struct subchannel_id mchk_schid; struct subchannel *sch;
if (crw0->erc == CRW_ERC_PMOD) {
sch = get_subchannel_by_schid(mchk_schid); if (sch) {
css_update_ssd_info(sch);
put_device(&sch->dev);
}
} /* * Since we are always presented with IPI in the CRW, we have to * use stsch() to find out if the subchannel in question has come * or gone.
*/
css_evaluate_subchannel(mchk_schid, 0);
}
staticint __init setup_css(int nr)
{ struct channel_subsystem *css; int ret;
css = kzalloc(sizeof(*css), GFP_KERNEL); if (!css) return -ENOMEM;
channel_subsystems[nr] = css;
dev_set_name(&css->device, "css%x", nr);
css->device.groups = cssdev_attr_groups;
css->device.release = channel_subsystem_release; /* * We currently allocate notifier bits with this (using * css->device as the device argument with the DMA API) * and are fine with 64 bit addresses.
*/
ret = dma_coerce_mask_and_coherent(&css->device, DMA_BIT_MASK(64)); if (ret) {
kfree(css); goto out_err;
}
ret = NOTIFY_DONE;
for_each_css(css) {
mutex_lock(&css->mutex); if (css->cm_enabled) if (chsc_secm(css, 0))
ret = NOTIFY_BAD;
mutex_unlock(&css->mutex);
}
void cio_gp_dma_destroy(struct gen_pool *gp_dma, struct device *dma_dev)
{ if (!gp_dma) return; /* this is quite ugly but no better idea */
gen_pool_for_each_chunk(gp_dma, __gp_dma_free_dma, dma_dev);
gen_pool_destroy(gp_dma);
}
staticint cio_dma_pool_init(void)
{ /* No need to free up the resources: compiled in */
cio_dma_pool = cio_gp_dma_create(cio_get_dma_css_dev(), 1); if (!cio_dma_pool) return -ENOMEM; return 0;
}
/* * Allocate dma memory from the css global pool. Intended for memory not * specific to any single device within the css. The allocated memory * is not guaranteed to be 31-bit addressable. * * Caution: Not suitable for early stuff like console.
*/ void *cio_dma_zalloc(size_t size)
{ return cio_gp_dma_zalloc(cio_dma_pool, cio_get_dma_css_dev(), size);
}
/* * Now that the driver core is running, we can setup our channel subsystem. * The struct subchannel's are created during probing.
*/ staticint __init css_bus_init(void)
{ int ret, i;
ret = chsc_init(); if (ret) return ret;
chsc_determine_css_characteristics(); /* Try to enable MSS. */
ret = chsc_enable_facility(CHSC_SDA_OC_MSS); if (ret)
max_ssid = 0; else/* Success. */
max_ssid = __MAX_SSID;
ret = slow_subchannel_init(); if (ret) goto out;
ret = crw_register_handler(CRW_RSC_SCH, css_process_crw); if (ret) goto out;
if ((ret = bus_register(&css_bus_type))) goto out;
/* Setup css structure. */ for (i = 0; i <= MAX_CSS_IDX; i++) {
ret = setup_css(i); if (ret) goto out_unregister;
}
ret = register_reboot_notifier(&css_reboot_notifier); if (ret) goto out_unregister;
ret = cio_dma_pool_init(); if (ret) goto out_unregister_rn;
airq_init();
css_init_done = 1;
/* Enable default isc for I/O subchannels. */
isc_register(IO_SCH_ISC);
staticint __init channel_subsystem_init(void)
{ int ret;
ret = css_bus_init(); if (ret) return ret;
cio_work_q = create_singlethread_workqueue("cio"); if (!cio_work_q) {
ret = -ENOMEM; goto out_bus;
}
ret = io_subchannel_init(); if (ret) goto out_wq;
/* Register subchannels which are already in use. */
cio_register_early_subchannels(); /* Start initial subchannel evaluation. */
css_schedule_eval_all();
if (cssdrv->settle) return cssdrv->settle(); return 0;
}
int css_complete_work(void)
{ int ret;
/* Wait for the evaluation of subchannels to finish. */
ret = wait_event_interruptible(css_eval_wq,
atomic_read(&css_eval_scheduled) == 0); if (ret) return -EINTR;
flush_workqueue(cio_work_q); /* Wait for the subchannel type specific initialization to finish */ return bus_for_each_drv(&css_bus_type, NULL, NULL, css_settle);
}
/* * Wait for the initialization of devices to finish, to make sure we are * done with our setup if the search for the root device starts.
*/ staticint __init channel_subsystem_init_sync(void)
{
css_complete_work(); return 0;
}
subsys_initcall_sync(channel_subsystem_init_sync);
/** * css_driver_register - register a css driver * @cdrv: css driver to register * * This is mainly a wrapper around driver_register that sets name * and bus_type in the embedded struct device_driver correctly.
*/ int css_driver_register(struct css_driver *cdrv)
{
cdrv->drv.bus = &css_bus_type; return driver_register(&cdrv->drv);
}
EXPORT_SYMBOL_GPL(css_driver_register);
/** * css_driver_unregister - unregister a css driver * @cdrv: css driver to unregister * * This is a wrapper around driver_unregister.
*/ void css_driver_unregister(struct css_driver *cdrv)
{
driver_unregister(&cdrv->drv);
}
EXPORT_SYMBOL_GPL(css_driver_unregister);
Messung V0.5
¤ Dauer der Verarbeitung: 0.15 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.