Lines Matching +full:no +full:- +full:poll +full:- +full:on +full:- +full:init
1 // SPDX-License-Identifier: GPL-2.0+
19 #include <linux/init.h>
48 int ap_domain_index = -1; /* Adjunct Processor Domain Index */
56 MODULE_PARM_DESC(poll_thread, "Turn on/off poll thread, default is 0 (off).");
68 MODULE_PARM_DESC(useirq, "Use interrupt if available, default is 1 (on).");
75 /* Hashtable of all queue devices on the AP bus */
86 /* # of bus scans since init */
89 /* # of bindings complete since init */
122 * In LPAR poll with 4kHz frequency. Poll every 250000 nanoseconds.
152 * ap_airq_ptr() - Get the address of the adapter interrupt indicator
154 * Returns the address of the local-summary-indicator of the adapter
205 return ap_qci_info->qact; in ap_qact_available()
217 return ap_qci_info->apsb; in ap_sb_available()
222 * ap_is_se_guest(): Check for SE guest with AP pass-through support.
234 * On success 0 is returned, on failure a negative errno
236 * available, the return value will be -EOPNOTSUPP.
241 return -EOPNOTSUPP; in ap_fetch_qci_info()
243 return -EINVAL; in ap_fetch_qci_info()
277 if (ap_qci_info->apxa) { in ap_init_qci_info()
278 if (ap_qci_info->na) { in ap_init_qci_info()
279 ap_max_adapter_id = ap_qci_info->na; in ap_init_qci_info()
283 if (ap_qci_info->nd) { in ap_init_qci_info()
284 ap_max_domain_id = ap_qci_info->nd; in ap_init_qci_info()
314 return ap_test_config(ap_qci_info->apm, id); in ap_test_config_card_id()
331 return ap_test_config(ap_qci_info->aqm, domain); in ap_test_config_usage_domain()
348 return ap_test_config(ap_qci_info->adm, domain); in ap_test_config_ctrl_domain()
355 * 0 if APQN seems to exist but there is no info
357 * -1 invalid APQN, TAPQ error or AP queue status which
358 * indicates there is no APQN.
365 hwinfo->value = 0; in ap_queue_info()
370 return -1; in ap_queue_info()
372 /* call TAPQ on this APQN */ in ap_queue_info()
384 /* On a pending async error the info should be available */ in ap_queue_info()
386 return -1; in ap_queue_info()
391 if (WARN_ON_ONCE(!hwinfo->value)) in ap_queue_info()
442 spin_lock_bh(&aq->lock); in ap_request_timeout()
444 spin_unlock_bh(&aq->lock); in ap_request_timeout()
460 * ap_interrupt_handler() - Schedule ap_tasklet on interrupt
472 * ap_tasklet_fn(): Tasklet to poll all AP devices.
475 * Poll all AP devices on the bus.
485 * important that no requests on any AP get lost. in ap_tasklet_fn()
492 spin_lock_bh(&aq->lock); in ap_tasklet_fn()
494 spin_unlock_bh(&aq->lock); in ap_tasklet_fn()
508 if (aq->queue_count == 0) in ap_pending_requests()
521 * AP bus poll thread. The purpose of this thread is to poll for
522 * finished requests in a loop if there is a "free" cpu - that is
578 #define is_card_dev(x) ((x)->parent == ap_root_device)
579 #define is_queue_dev(x) ((x)->parent != ap_root_device)
597 for (id = ap_drv->ids; id->match_flags; id++) { in ap_bus_match()
599 id->match_flags & AP_DEVICE_ID_MATCH_CARD_TYPE && in ap_bus_match()
600 id->dev_type == to_ap_dev(dev)->device_type) in ap_bus_match()
603 id->match_flags & AP_DEVICE_ID_MATCH_QUEUE_TYPE && in ap_bus_match()
604 id->dev_type == to_ap_dev(dev)->device_type) in ap_bus_match()
628 struct ap_card *ac = to_ap_card(&ap_dev->device); in ap_uevent()
631 rc = add_uevent_var(env, "DEV_TYPE=%04X", ap_dev->device_type); in ap_uevent()
635 rc = add_uevent_var(env, "MODALIAS=ap:t%02X", ap_dev->device_type); in ap_uevent()
640 if (ac->hwinfo.accel) in ap_uevent()
642 else if (ac->hwinfo.cca) in ap_uevent()
644 else if (ac->hwinfo.ep11) in ap_uevent()
649 struct ap_queue *aq = to_ap_queue(&ap_dev->device); in ap_uevent()
652 if (aq->card->hwinfo.accel) in ap_uevent()
654 else if (aq->card->hwinfo.cca) in ap_uevent()
656 else if (aq->card->hwinfo.ep11) in ap_uevent()
669 kobject_uevent_env(&ap_root_device->kobj, KOBJ_CHANGE, envp); in ap_send_init_scan_done_uevent()
679 kobject_uevent_env(&ap_root_device->kobj, KOBJ_CHANGE, envp); in ap_send_bindings_complete_uevent()
689 kobject_uevent_env(&ap_dev->device.kobj, KOBJ_CHANGE, envp); in ap_send_config_uevent()
700 kobject_uevent_env(&ap_dev->device.kobj, KOBJ_CHANGE, envp); in ap_send_online_uevent()
719 kobject_uevent_env(&ap_root_device->kobj, KOBJ_CHANGE, envp); in ap_send_mask_changed_uevent()
736 pctrs->apqns++; in __ap_calc_helper()
737 if (dev->driver) in __ap_calc_helper()
738 pctrs->bound++; in __ap_calc_helper()
779 * on a condition with wait_for_completion_interruptible_timeout().
782 * -ETIME is returned. On failures negative return values are
799 return l == -ERESTARTSYS ? -EINTR : l; in ap_wait_init_apqn_bindings_complete()
801 return -ETIME; in ap_wait_init_apqn_bindings_complete()
810 AP_QID_CARD(to_ap_queue(dev)->qid) == (int)(long)data) in __ap_queue_devices_with_id_unregister()
820 card = AP_QID_CARD(to_ap_queue(dev)->qid); in __ap_revise_reserved()
821 queue = AP_QID_QUEUE(to_ap_queue(dev)->qid); in __ap_revise_reserved()
826 drvres = to_ap_drv(dev->driver)->flags in __ap_revise_reserved()
862 return -EINVAL; in ap_owned_by_def_drv()
904 struct ap_driver *ap_drv = to_ap_drv(dev->driver); in ap_device_probe()
905 int card, queue, devres, drvres, rc = -ENODEV; in ap_device_probe()
917 card = AP_QID_CARD(to_ap_queue(dev)->qid); in ap_device_probe()
918 queue = AP_QID_QUEUE(to_ap_queue(dev)->qid); in ap_device_probe()
923 drvres = ap_drv->flags & AP_DRIVER_FLAG_DEFAULT; in ap_device_probe()
931 hash_add(ap_queues, &to_ap_queue(dev)->hnode, in ap_device_probe()
932 to_ap_queue(dev)->qid); in ap_device_probe()
935 rc = ap_drv->probe ? ap_drv->probe(ap_dev) : -ENODEV; in ap_device_probe()
940 hash_del(&to_ap_queue(dev)->hnode); in ap_device_probe()
955 struct ap_driver *ap_drv = to_ap_drv(dev->driver); in ap_device_remove()
962 if (ap_drv->remove) in ap_device_remove()
963 ap_drv->remove(ap_dev); in ap_device_remove()
972 hash_del(&to_ap_queue(dev)->hnode); in ap_device_remove()
985 if (aq->qid == qid) { in ap_get_qdev()
986 get_device(&aq->ap_dev.device); in ap_get_qdev()
1000 struct device_driver *drv = &ap_drv->driver; in ap_driver_register()
1002 drv->bus = &ap_bus_type; in ap_driver_register()
1003 drv->owner = owner; in ap_driver_register()
1004 drv->name = name; in ap_driver_register()
1011 driver_unregister(&ap_drv->driver); in ap_driver_unregister()
1039 * hex2bitmap() - parse hex mask string and set bitmap.
1041 * Rest of the bitmap to the right is padded with 0. No spaces allowed
1052 return -EINVAL; in hex2bitmap()
1070 return -EINVAL; in hex2bitmap()
1075 * modify_bitmap() - parse bitmask argument and modify an existing
1078 * +<bitnr>[-<bitnr>] or -<bitnr>[-<bitnr>]
1080 * 0...bits-1; the leading + or - is required. Here are some examples:
1081 * +0-15,+32,-128,-0xFF
1082 * -0-255,+1-16,+0x128
1083 * +1,+2,+3,+4,-5,-7-10
1088 * +0-255,-128 = first bits 0-255 will be set, then bit 128 will be
1098 return -EINVAL; in modify_bitmap()
1102 if (sign != '+' && sign != '-') in modify_bitmap()
1103 return -EINVAL; in modify_bitmap()
1106 return -EINVAL; in modify_bitmap()
1108 if (*str == '-') { in modify_bitmap()
1111 return -EINVAL; in modify_bitmap()
1133 if (*str == '+' || *str == '-') { in ap_parse_bitmap_str()
1152 return -EINVAL; in ap_parse_mask_str()
1157 return -ENOMEM; in ap_parse_mask_str()
1160 return -ERESTARTSYS; in ap_parse_mask_str()
1188 return -EINVAL; in ap_domain_store()
1208 ap_qci_info->adm[0], ap_qci_info->adm[1], in ap_control_domain_mask_show()
1209 ap_qci_info->adm[2], ap_qci_info->adm[3], in ap_control_domain_mask_show()
1210 ap_qci_info->adm[4], ap_qci_info->adm[5], in ap_control_domain_mask_show()
1211 ap_qci_info->adm[6], ap_qci_info->adm[7]); in ap_control_domain_mask_show()
1222 ap_qci_info->aqm[0], ap_qci_info->aqm[1], in ap_usage_domain_mask_show()
1223 ap_qci_info->aqm[2], ap_qci_info->aqm[3], in ap_usage_domain_mask_show()
1224 ap_qci_info->aqm[4], ap_qci_info->aqm[5], in ap_usage_domain_mask_show()
1225 ap_qci_info->aqm[6], ap_qci_info->aqm[7]); in ap_usage_domain_mask_show()
1236 ap_qci_info->apm[0], ap_qci_info->apm[1], in ap_adapter_mask_show()
1237 ap_qci_info->apm[2], ap_qci_info->apm[3], in ap_adapter_mask_show()
1238 ap_qci_info->apm[4], ap_qci_info->apm[5], in ap_adapter_mask_show()
1239 ap_qci_info->apm[6], ap_qci_info->apm[7]); in ap_adapter_mask_show()
1262 return -EINVAL; in config_time_store()
1313 /* 120 seconds = maximum poll interval */ in poll_timeout_store()
1315 return -EINVAL; in poll_timeout_store()
1349 return -ERESTARTSYS; in apmask_show()
1368 if (!try_module_get(drv->owner)) in __verify_card_reservations()
1371 if (ap_drv->in_use) { in __verify_card_reservations()
1372 rc = ap_drv->in_use(newapm, ap_perms.aqm); in __verify_card_reservations()
1374 rc = -EBUSY; in __verify_card_reservations()
1378 module_put(drv->owner); in __verify_card_reservations()
1390 * result in queues being removed from non-default drivers in apmask_commit()
1411 return -ERESTARTSYS; in apmask_store()
1441 return -ERESTARTSYS; in aqmask_show()
1460 if (!try_module_get(drv->owner)) in __verify_queue_reservations()
1463 if (ap_drv->in_use) { in __verify_queue_reservations()
1464 rc = ap_drv->in_use(ap_perms.apm, newaqm); in __verify_queue_reservations()
1466 rc = -EBUSY; in __verify_queue_reservations()
1470 module_put(drv->owner); in __verify_queue_reservations()
1482 * result in queues being removed from non-default drivers in aqmask_commit()
1503 return -ERESTARTSYS; in aqmask_store()
1566 return sysfs_emit(buf, "-\n"); in features_show()
1568 if (ap_qci_info->apsc) in features_show()
1570 if (ap_qci_info->apxa) in features_show()
1572 if (ap_qci_info->qact) in features_show()
1574 if (ap_qci_info->rc8a) in features_show()
1576 if (ap_qci_info->apsb) in features_show()
1579 sysfs_emit_at(buf, n == 0 ? 0 : n - 1, "\n"); in features_show()
1713 return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long)(void *)data; in __match_card_device_with_id()
1722 return is_queue_dev(dev) && to_ap_queue(dev)->qid == (int)(long)data; in __match_queue_device_with_qid()
1732 AP_QID_QUEUE(to_ap_queue(dev)->qid) == (int)(long)data; in __match_queue_device_with_queue_id()
1740 if (try_module_get(drv->owner)) { in __drv_notify_config_changed()
1741 if (ap_drv->on_config_changed) in __drv_notify_config_changed()
1742 ap_drv->on_config_changed(ap_qci_info, ap_qci_info_old); in __drv_notify_config_changed()
1743 module_put(drv->owner); in __drv_notify_config_changed()
1761 if (try_module_get(drv->owner)) { in __drv_notify_scan_complete()
1762 if (ap_drv->on_scan_complete) in __drv_notify_scan_complete()
1763 ap_drv->on_scan_complete(ap_qci_info, in __drv_notify_scan_complete()
1765 module_put(drv->owner); in __drv_notify_scan_complete()
1785 (void *)(long)ac->id, in ap_scan_rm_card_dev_and_queue_devs()
1787 device_unregister(&ac->ap_dev.device); in ap_scan_rm_card_dev_and_queue_devs()
1811 qid = AP_MKQID(ac->id, dom); in ap_scan_domains()
1819 __func__, ac->id, dom); in ap_scan_domains()
1827 case -1: in ap_scan_domains()
1830 __func__, ac->id, dom); in ap_scan_domains()
1839 /* if no queue device exists, create a new one */ in ap_scan_domains()
1841 aq = ap_queue_create(qid, ac->ap_dev.device_type); in ap_scan_domains()
1844 __func__, ac->id, dom); in ap_scan_domains()
1847 aq->card = ac; in ap_scan_domains()
1848 aq->config = !decfg; in ap_scan_domains()
1849 aq->chkstop = chkstop; in ap_scan_domains()
1850 aq->se_bstate = hwinfo.bs; in ap_scan_domains()
1851 dev = &aq->ap_dev.device; in ap_scan_domains()
1852 dev->bus = &ap_bus_type; in ap_scan_domains()
1853 dev->parent = &ac->ap_dev.device; in ap_scan_domains()
1854 dev_set_name(dev, "%02x.%04x", ac->id, dom); in ap_scan_domains()
1859 __func__, ac->id, dom); in ap_scan_domains()
1866 __func__, ac->id, dom); in ap_scan_domains()
1869 __func__, ac->id, dom); in ap_scan_domains()
1874 __func__, ac->id, dom); in ap_scan_domains()
1878 /* handle state changes on already existing queue device */ in ap_scan_domains()
1879 spin_lock_bh(&aq->lock); in ap_scan_domains()
1881 aq->se_bstate = hwinfo.bs; in ap_scan_domains()
1883 if (chkstop && !aq->chkstop) { in ap_scan_domains()
1884 /* checkstop on */ in ap_scan_domains()
1885 aq->chkstop = true; in ap_scan_domains()
1886 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) { in ap_scan_domains()
1887 aq->dev_state = AP_DEV_STATE_ERROR; in ap_scan_domains()
1888 aq->last_err_rc = AP_RESPONSE_CHECKSTOPPED; in ap_scan_domains()
1890 spin_unlock_bh(&aq->lock); in ap_scan_domains()
1891 AP_DBF_DBG("%s(%d,%d) queue dev checkstop on\n", in ap_scan_domains()
1892 __func__, ac->id, dom); in ap_scan_domains()
1893 /* 'receive' pending messages with -EAGAIN */ in ap_scan_domains()
1896 } else if (!chkstop && aq->chkstop) { in ap_scan_domains()
1898 aq->chkstop = false; in ap_scan_domains()
1899 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) in ap_scan_domains()
1901 spin_unlock_bh(&aq->lock); in ap_scan_domains()
1903 __func__, ac->id, dom); in ap_scan_domains()
1907 if (decfg && aq->config) { in ap_scan_domains()
1909 aq->config = false; in ap_scan_domains()
1910 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) { in ap_scan_domains()
1911 aq->dev_state = AP_DEV_STATE_ERROR; in ap_scan_domains()
1912 aq->last_err_rc = AP_RESPONSE_DECONFIGURED; in ap_scan_domains()
1914 spin_unlock_bh(&aq->lock); in ap_scan_domains()
1916 __func__, ac->id, dom); in ap_scan_domains()
1917 ap_send_config_uevent(&aq->ap_dev, aq->config); in ap_scan_domains()
1918 /* 'receive' pending messages with -EAGAIN */ in ap_scan_domains()
1921 } else if (!decfg && !aq->config) { in ap_scan_domains()
1922 /* config on this queue device */ in ap_scan_domains()
1923 aq->config = true; in ap_scan_domains()
1924 if (aq->dev_state > AP_DEV_STATE_UNINITIATED) in ap_scan_domains()
1926 spin_unlock_bh(&aq->lock); in ap_scan_domains()
1927 AP_DBF_DBG("%s(%d,%d) queue dev config on\n", in ap_scan_domains()
1928 __func__, ac->id, dom); in ap_scan_domains()
1929 ap_send_config_uevent(&aq->ap_dev, aq->config); in ap_scan_domains()
1933 if (!decfg && aq->dev_state == AP_DEV_STATE_ERROR) { in ap_scan_domains()
1934 spin_unlock_bh(&aq->lock); in ap_scan_domains()
1935 /* 'receive' pending messages with -EAGAIN */ in ap_scan_domains()
1937 /* re-init (with reset) the queue device */ in ap_scan_domains()
1940 __func__, ac->id, dom); in ap_scan_domains()
1943 spin_unlock_bh(&aq->lock); in ap_scan_domains()
1981 * If no card device exists, build one. If a card device exists, check in ap_scan_adapter()
1995 AP_DBF_INFO("%s(%d) no type info (no APQN found), rm card and queue devs\n", in ap_scan_adapter()
2000 AP_DBF_DBG("%s(%d) no type info (no APQN found), ignored\n", in ap_scan_adapter()
2006 /* No apdater type info available, an unusable adapter */ in ap_scan_adapter()
2008 AP_DBF_INFO("%s(%d) no valid type (0) info, rm card and queue devs\n", in ap_scan_adapter()
2013 AP_DBF_DBG("%s(%d) no valid type (0) info, ignored\n", in ap_scan_adapter()
2021 if (ac->hwinfo.at != hwinfo.at) { in ap_scan_adapter()
2027 } else if (ac->hwinfo.fac != hwinfo.fac) { in ap_scan_adapter()
2035 if (chkstop && !ac->chkstop) { in ap_scan_adapter()
2036 /* checkstop on */ in ap_scan_adapter()
2037 ac->chkstop = true; in ap_scan_adapter()
2038 AP_DBF_INFO("%s(%d) card dev checkstop on\n", in ap_scan_adapter()
2040 } else if (!chkstop && ac->chkstop) { in ap_scan_adapter()
2042 ac->chkstop = false; in ap_scan_adapter()
2047 if (decfg && ac->config) { in ap_scan_adapter()
2048 ac->config = false; in ap_scan_adapter()
2051 ap_send_config_uevent(&ac->ap_dev, ac->config); in ap_scan_adapter()
2052 } else if (!decfg && !ac->config) { in ap_scan_adapter()
2053 ac->config = true; in ap_scan_adapter()
2054 AP_DBF_INFO("%s(%d) card dev config on\n", in ap_scan_adapter()
2056 ap_send_config_uevent(&ac->ap_dev, ac->config); in ap_scan_adapter()
2075 ac->config = !decfg; in ap_scan_adapter()
2076 ac->chkstop = chkstop; in ap_scan_adapter()
2077 dev = &ac->ap_dev.device; in ap_scan_adapter()
2078 dev->bus = &ap_bus_type; in ap_scan_adapter()
2079 dev->parent = ap_root_device; in ap_scan_adapter()
2082 if (ac->maxmsgsize > atomic_read(&ap_max_msg_size)) { in ap_scan_adapter()
2083 atomic_set(&ap_max_msg_size, ac->maxmsgsize); in ap_scan_adapter()
2113 put_device(&ac->ap_dev.device); in ap_scan_adapter()
2117 * ap_get_configuration - get the host AP configuration
2172 AP_DBF_INFO("%s no queue device with default domain %d available\n", in ap_scan_bus()
2177 AP_DBF_DBG("%s init scan complete\n", __func__); in ap_scan_bus()
2202 /* all resources usable if no kernel parameter string given */ in ap_perms_init()
2237 return -ENODEV; in ap_module_init()
2240 /* init ap_queue hashtable */ in ap_module_init()
2250 if (ap_domain_index < -1 || ap_domain_index > ap_max_domain_id || in ap_module_init()
2255 ap_domain_index = -1; in ap_module_init()
2274 ap_root_device->bus = &ap_bus_type; in ap_module_init()
2280 * Setup the high resolution poll timer. in ap_module_init()
2288 /* Start the low priority AP bus poll thread. */ in ap_module_init()