10 #include <linux/slab.h>
12 #include <linux/device.h>
13 #include <linux/module.h>
18 #include <asm/compat.h>
32 #define CHSC_MSG(imp, args...) do { \
33 debug_sprintf_event(chsc_debug_msg_id, imp , ##args); \
36 #define CHSC_LOG(imp, txt) do { \
37 debug_text_event(chsc_debug_log_id, imp , txt); \
43 debug_event(chsc_debug_log_id, level, data, length);
44 length -= chsc_debug_log_id->
buf_size;
60 CHSC_LOG_HEX(4, irb,
sizeof(*irb));
65 CHSC_MSG(0,
"Interrupt on sch 0.%x.%04x with no request\n",
69 private->request =
NULL;
76 static int chsc_subchannel_probe(
struct subchannel *sch)
81 CHSC_MSG(6,
"Detected chsc subchannel 0.%x.%04x\n",
84 private = kzalloc(
sizeof(*
private),
GFP_KERNEL);
90 CHSC_MSG(0,
"Failed to enable 0.%x.%04x: %d\n",
95 if (dev_get_uevent_suppress(&sch->
dev)) {
96 dev_set_uevent_suppress(&sch->
dev, 0);
103 static int chsc_subchannel_remove(
struct subchannel *sch)
110 if (private->request) {
111 complete(&private->request->completion);
118 static void chsc_subchannel_shutdown(
struct subchannel *sch)
123 static int chsc_subchannel_prepare(
struct subchannel *sch)
138 static int chsc_subchannel_freeze(
struct subchannel *sch)
143 static int chsc_subchannel_restore(
struct subchannel *sch)
154 static struct css_driver chsc_subchannel_driver = {
157 .name =
"chsc_subchannel",
159 .subchannel_type = chsc_subchannel_ids,
160 .irq = chsc_subchannel_irq,
161 .probe = chsc_subchannel_probe,
162 .remove = chsc_subchannel_remove,
163 .shutdown = chsc_subchannel_shutdown,
164 .prepare = chsc_subchannel_prepare,
165 .freeze = chsc_subchannel_freeze,
166 .thaw = chsc_subchannel_restore,
167 .restore = chsc_subchannel_restore,
170 static int __init chsc_init_dbfs(
void)
174 if (!chsc_debug_msg_id)
179 if (!chsc_debug_log_id)
185 if (chsc_debug_msg_id)
190 static void chsc_remove_dbfs(
void)
196 static int __init chsc_init_sch_driver(
void)
201 static void chsc_cleanup_sch_driver(
void)
208 static int chsc_subchannel_match_next_free(
struct device *
dev,
void *
data)
212 return sch->
schib.pmcw.ena && !scsw_fctl(&sch->
schib.scsw);
221 chsc_subchannel_match_next_free);
249 while ((sch = chsc_get_next_subchannel(sch))) {
250 spin_lock(sch->
lock);
252 if (private->request) {
253 spin_unlock(sch->
lock);
259 CHSC_LOG_HEX(2, &sch->
schid,
sizeof(sch->
schid));
260 cc = chsc(chsc_area);
278 spin_unlock(sch->
lock);
279 CHSC_MSG(2,
"chsc on 0.%x.%04x returned cc=%d\n",
296 CHSC_LOG_HEX(0, chsc_area, 32);
299 static int chsc_examine_irb(
struct chsc_request *request)
307 if (scsw_cstat(&request->
irb.scsw) == 0)
322 static int chsc_ioctl_start(
void __user *user_area)
335 request = kzalloc(
sizeof(*request),
GFP_KERNEL);
345 chsc_log_command(chsc_area);
346 spin_lock_irq(&chsc_lock);
347 ret = chsc_async(chsc_area, request);
348 spin_unlock_irq(&chsc_lock);
351 ret = chsc_examine_irb(request);
365 static int chsc_ioctl_info_channel_path(
void __user *user_cd)
397 scpcd_area->request.length = 0x0010;
398 scpcd_area->request.code = 0x0028;
399 scpcd_area->m = cd->
m;
400 scpcd_area->fmt1 = cd->
fmt;
401 scpcd_area->cssid = cd->
chpid.cssid;
402 scpcd_area->first_chpid = cd->
chpid.id;
403 scpcd_area->last_chpid = cd->
chpid.id;
405 ccode = chsc(scpcd_area);
410 if (scpcd_area->response.code != 0x0001) {
412 CHSC_MSG(0,
"scpcd: response code=%x\n",
413 scpcd_area->response.code);
416 memcpy(&cd->
cpcb, &scpcd_area->response, scpcd_area->response.length);
427 static int chsc_ioctl_info_cu(
void __user *user_cd)
459 scucd_area->request.length = 0x0010;
460 scucd_area->request.code = 0x0028;
461 scucd_area->m = cd->
m;
462 scucd_area->fmt1 = cd->
fmt;
463 scucd_area->cssid = cd->
cssid;
464 scucd_area->first_cun = cd->
cun;
465 scucd_area->last_cun = cd->
cun;
467 ccode = chsc(scucd_area);
472 if (scucd_area->response.code != 0x0001) {
474 CHSC_MSG(0,
"scucd: response code=%x\n",
475 scucd_area->response.code);
478 memcpy(&cd->
cucb, &scucd_area->response, scucd_area->response.length);
489 static int chsc_ioctl_info_sch_cu(
void __user *user_cud)
522 sscud_area->request.length = 0x0010;
523 sscud_area->request.code = 0x0006;
524 sscud_area->m = cud->
schid.m;
525 sscud_area->fmt1 = cud->
fmt;
526 sscud_area->ssid = cud->
schid.ssid;
527 sscud_area->first_sch = cud->
schid.sch_no;
528 sscud_area->cssid = cud->
schid.cssid;
529 sscud_area->last_sch = cud->
schid.sch_no;
531 ccode = chsc(sscud_area);
536 if (sscud_area->response.code != 0x0001) {
538 CHSC_MSG(0,
"sscud: response code=%x\n",
539 sscud_area->response.code);
542 memcpy(&cud->
scub, &sscud_area->response, sscud_area->response.length);
553 static int chsc_ioctl_conf_info(
void __user *user_ci)
584 sci_area->request.length = 0x0010;
585 sci_area->request.code = 0x0012;
586 sci_area->m = ci->
id.m;
587 sci_area->fmt1 = ci->
fmt;
588 sci_area->cssid = ci->
id.cssid;
589 sci_area->ssid = ci->
id.ssid;
591 ccode = chsc(sci_area);
596 if (sci_area->response.code != 0x0001) {
598 CHSC_MSG(0,
"sci: response code=%x\n",
599 sci_area->response.code);
602 memcpy(&ci->
scid, &sci_area->response, sci_area->response.length);
613 static int chsc_ioctl_conf_comp_list(
void __user *user_ccl)
655 sccl_area->request.length = 0x0020;
656 sccl_area->request.code = 0x0030;
657 sccl_area->fmt = ccl->
req.fmt;
658 sccl_area->ctype = ccl->
req.ctype;
659 switch (sccl_area->ctype) {
662 chpid_parm = (
void *)&sccl_area->list_parm;
663 chpid_parm->m = ccl->
req.chpid.m;
664 chpid_parm->cssid = ccl->
req.chpid.chp.cssid;
665 chpid_parm->chpid = ccl->
req.chpid.chp.id;
668 case CCL_CSS_IMG_CONF_CHAR:
669 cssids_parm = (
void *)&sccl_area->list_parm;
670 cssids_parm->f_cssid = ccl->
req.cssids.f_cssid;
671 cssids_parm->l_cssid = ccl->
req.cssids.l_cssid;
674 ccode = chsc(sccl_area);
679 if (sccl_area->response.code != 0x0001) {
681 CHSC_MSG(0,
"sccl: response code=%x\n",
682 sccl_area->response.code);
685 memcpy(&ccl->
sccl, &sccl_area->response, sccl_area->response.length);
696 static int chsc_ioctl_chpd(
void __user *user_chpd)
704 if (!scpd_area || !chpd) {
713 chpd->
rfmt, chpd->
c, chpd->
m,
726 static int chsc_ioctl_dcal(
void __user *user_dcal)
755 sdcal_area->request.length = 0x0020;
756 sdcal_area->request.code = 0x0034;
757 sdcal_area->atype = dcal->
req.atype;
758 sdcal_area->fmt = dcal->
req.fmt;
759 memcpy(&sdcal_area->list_parm, &dcal->
req.list_parm,
760 sizeof(sdcal_area->list_parm));
762 ccode = chsc(sdcal_area);
767 if (sdcal_area->response.code != 0x0001) {
769 CHSC_MSG(0,
"sdcal: response code=%x\n",
770 sdcal_area->response.code);
774 sdcal_area->response.length);
785 static long chsc_ioctl(
struct file *filp,
unsigned int cmd,
790 CHSC_MSG(2,
"chsc_ioctl called, cmd=%x\n", cmd);
792 argp = compat_ptr(arg);
794 argp = (
void __user *)arg;
797 return chsc_ioctl_start(argp);
799 return chsc_ioctl_info_channel_path(argp);
801 return chsc_ioctl_info_cu(argp);
803 return chsc_ioctl_info_sch_cu(argp);
805 return chsc_ioctl_conf_info(argp);
807 return chsc_ioctl_conf_comp_list(argp);
809 return chsc_ioctl_chpd(argp);
811 return chsc_ioctl_dcal(argp);
820 .unlocked_ioctl = chsc_ioctl,
821 .compat_ioctl = chsc_ioctl,
831 static int __init chsc_misc_init(
void)
836 static void chsc_misc_cleanup(
void)
841 static int __init chsc_sch_init(
void)
845 ret = chsc_init_dbfs();
849 ret = chsc_init_sch_driver();
852 ret = chsc_misc_init();
857 chsc_cleanup_sch_driver();
864 static void __exit chsc_sch_exit(
void)
867 chsc_cleanup_sch_driver();