Lines Matching refs:ap_dev
59 static int __ap_poll_device(struct ap_device *ap_dev, unsigned long *flags);
63 static void ap_reset(struct ap_device *ap_dev);
623 static void ap_increase_queue_count(struct ap_device *ap_dev) in ap_increase_queue_count() argument
625 int timeout = ap_dev->drv->request_timeout; in ap_increase_queue_count()
627 ap_dev->queue_count++; in ap_increase_queue_count()
628 if (ap_dev->queue_count == 1) { in ap_increase_queue_count()
629 mod_timer(&ap_dev->timeout, jiffies + timeout); in ap_increase_queue_count()
630 ap_dev->reset = AP_RESET_ARMED; in ap_increase_queue_count()
641 static void ap_decrease_queue_count(struct ap_device *ap_dev) in ap_decrease_queue_count() argument
643 int timeout = ap_dev->drv->request_timeout; in ap_decrease_queue_count()
645 ap_dev->queue_count--; in ap_decrease_queue_count()
646 if (ap_dev->queue_count > 0) in ap_decrease_queue_count()
647 mod_timer(&ap_dev->timeout, jiffies + timeout); in ap_decrease_queue_count()
654 ap_dev->reset = AP_RESET_IGNORE; in ap_decrease_queue_count()
663 struct ap_device *ap_dev = to_ap_dev(dev); in ap_hwtype_show() local
664 return snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->device_type); in ap_hwtype_show()
672 struct ap_device *ap_dev = to_ap_dev(dev); in ap_raw_hwtype_show() local
674 return snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->raw_hwtype); in ap_raw_hwtype_show()
682 struct ap_device *ap_dev = to_ap_dev(dev); in ap_depth_show() local
683 return snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->queue_depth); in ap_depth_show()
691 struct ap_device *ap_dev = to_ap_dev(dev); in ap_request_count_show() local
694 spin_lock_bh(&ap_dev->lock); in ap_request_count_show()
695 rc = snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->total_request_count); in ap_request_count_show()
696 spin_unlock_bh(&ap_dev->lock); in ap_request_count_show()
705 struct ap_device *ap_dev = to_ap_dev(dev); in ap_requestq_count_show() local
708 spin_lock_bh(&ap_dev->lock); in ap_requestq_count_show()
709 rc = snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->requestq_count); in ap_requestq_count_show()
710 spin_unlock_bh(&ap_dev->lock); in ap_requestq_count_show()
719 struct ap_device *ap_dev = to_ap_dev(dev); in ap_pendingq_count_show() local
722 spin_lock_bh(&ap_dev->lock); in ap_pendingq_count_show()
723 rc = snprintf(buf, PAGE_SIZE, "%d\n", ap_dev->pendingq_count); in ap_pendingq_count_show()
724 spin_unlock_bh(&ap_dev->lock); in ap_pendingq_count_show()
741 struct ap_device *ap_dev = to_ap_dev(dev); in ap_functions_show() local
742 return snprintf(buf, PAGE_SIZE, "0x%08X\n", ap_dev->functions); in ap_functions_show()
771 struct ap_device *ap_dev = to_ap_dev(dev); in ap_bus_match() local
781 (id->dev_type != ap_dev->device_type)) in ap_bus_match()
798 struct ap_device *ap_dev = to_ap_dev(dev); in ap_uevent() local
801 if (!ap_dev) in ap_uevent()
805 retval = add_uevent_var(env, "DEV_TYPE=%04X", ap_dev->device_type); in ap_uevent()
810 retval = add_uevent_var(env, "MODALIAS=ap:t%02X", ap_dev->device_type); in ap_uevent()
817 struct ap_device *ap_dev = to_ap_dev(dev); in ap_bus_suspend() local
837 spin_lock_bh(&ap_dev->lock); in ap_bus_suspend()
838 __ap_poll_device(ap_dev, &flags); in ap_bus_suspend()
839 spin_unlock_bh(&ap_dev->lock); in ap_bus_suspend()
842 spin_lock_bh(&ap_dev->lock); in ap_bus_suspend()
843 ap_dev->unregistered = 1; in ap_bus_suspend()
844 spin_unlock_bh(&ap_dev->lock); in ap_bus_suspend()
851 struct ap_device *ap_dev = to_ap_dev(dev); in ap_bus_resume() local
891 if (AP_QID_QUEUE(ap_dev->qid) != ap_domain_index) { in ap_bus_resume()
892 spin_lock_bh(&ap_dev->lock); in ap_bus_resume()
893 ap_dev->qid = AP_MKQID(AP_QID_DEVICE(ap_dev->qid), in ap_bus_resume()
895 spin_unlock_bh(&ap_dev->lock); in ap_bus_resume()
912 struct ap_device *ap_dev = to_ap_dev(dev); in ap_device_probe() local
916 ap_dev->drv = ap_drv; in ap_device_probe()
919 list_add(&ap_dev->list, &ap_device_list); in ap_device_probe()
922 rc = ap_drv->probe ? ap_drv->probe(ap_dev) : -ENODEV; in ap_device_probe()
925 list_del_init(&ap_dev->list); in ap_device_probe()
937 static void __ap_flush_queue(struct ap_device *ap_dev) in __ap_flush_queue() argument
941 list_for_each_entry_safe(ap_msg, next, &ap_dev->pendingq, list) { in __ap_flush_queue()
943 ap_dev->pendingq_count--; in __ap_flush_queue()
944 ap_msg->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); in __ap_flush_queue()
946 list_for_each_entry_safe(ap_msg, next, &ap_dev->requestq, list) { in __ap_flush_queue()
948 ap_dev->requestq_count--; in __ap_flush_queue()
949 ap_msg->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); in __ap_flush_queue()
953 void ap_flush_queue(struct ap_device *ap_dev) in ap_flush_queue() argument
955 spin_lock_bh(&ap_dev->lock); in ap_flush_queue()
956 __ap_flush_queue(ap_dev); in ap_flush_queue()
957 spin_unlock_bh(&ap_dev->lock); in ap_flush_queue()
963 struct ap_device *ap_dev = to_ap_dev(dev); in ap_device_remove() local
964 struct ap_driver *ap_drv = ap_dev->drv; in ap_device_remove()
966 ap_flush_queue(ap_dev); in ap_device_remove()
967 del_timer_sync(&ap_dev->timeout); in ap_device_remove()
969 list_del_init(&ap_dev->list); in ap_device_remove()
972 ap_drv->remove(ap_dev); in ap_device_remove()
973 spin_lock_bh(&ap_dev->lock); in ap_device_remove()
974 atomic_sub(ap_dev->queue_count, &ap_poll_requests); in ap_device_remove()
975 spin_unlock_bh(&ap_dev->lock); in ap_device_remove()
1249 static int ap_probe_device_type(struct ap_device *ap_dev) in ap_probe_device_type() argument
1309 status = __ap_send(ap_dev->qid, 0x0102030405060708ULL, in ap_probe_device_type()
1319 status = __ap_recv(ap_dev->qid, &psmid, reply, 4096); in ap_probe_device_type()
1327 ap_dev->device_type = AP_DEVICE_TYPE_PCICC; in ap_probe_device_type()
1329 ap_dev->device_type = AP_DEVICE_TYPE_PCICA; in ap_probe_device_type()
1360 struct ap_device *ap_dev = to_ap_dev(dev); in ap_device_release() local
1362 kfree(ap_dev); in ap_device_release()
1367 struct ap_device *ap_dev; in ap_scan_bus() local
1394 ap_dev = to_ap_dev(dev); in ap_scan_bus()
1395 spin_lock_bh(&ap_dev->lock); in ap_scan_bus()
1396 if (rc || ap_dev->unregistered) { in ap_scan_bus()
1397 spin_unlock_bh(&ap_dev->lock); in ap_scan_bus()
1398 if (ap_dev->unregistered) in ap_scan_bus()
1404 spin_unlock_bh(&ap_dev->lock); in ap_scan_bus()
1413 ap_dev = kzalloc(sizeof(*ap_dev), GFP_KERNEL); in ap_scan_bus()
1414 if (!ap_dev) in ap_scan_bus()
1416 ap_dev->qid = qid; in ap_scan_bus()
1417 ap_dev->queue_depth = queue_depth; in ap_scan_bus()
1418 ap_dev->unregistered = 1; in ap_scan_bus()
1419 spin_lock_init(&ap_dev->lock); in ap_scan_bus()
1420 INIT_LIST_HEAD(&ap_dev->pendingq); in ap_scan_bus()
1421 INIT_LIST_HEAD(&ap_dev->requestq); in ap_scan_bus()
1422 INIT_LIST_HEAD(&ap_dev->list); in ap_scan_bus()
1423 setup_timer(&ap_dev->timeout, ap_request_timeout, in ap_scan_bus()
1424 (unsigned long) ap_dev); in ap_scan_bus()
1428 if (ap_probe_device_type(ap_dev)) { in ap_scan_bus()
1429 kfree(ap_dev); in ap_scan_bus()
1434 ap_dev->device_type = 10; in ap_scan_bus()
1437 ap_dev->device_type = device_type; in ap_scan_bus()
1439 ap_dev->raw_hwtype = device_type; in ap_scan_bus()
1443 ap_dev->functions = device_functions; in ap_scan_bus()
1445 ap_dev->functions = 0u; in ap_scan_bus()
1447 ap_dev->device.bus = &ap_bus_type; in ap_scan_bus()
1448 ap_dev->device.parent = ap_root_device; in ap_scan_bus()
1449 if (dev_set_name(&ap_dev->device, "card%02x", in ap_scan_bus()
1450 AP_QID_DEVICE(ap_dev->qid))) { in ap_scan_bus()
1451 kfree(ap_dev); in ap_scan_bus()
1454 ap_dev->device.release = ap_device_release; in ap_scan_bus()
1455 rc = device_register(&ap_dev->device); in ap_scan_bus()
1457 put_device(&ap_dev->device); in ap_scan_bus()
1461 rc = sysfs_create_group(&ap_dev->device.kobj, in ap_scan_bus()
1464 spin_lock_bh(&ap_dev->lock); in ap_scan_bus()
1465 ap_dev->unregistered = 0; in ap_scan_bus()
1466 spin_unlock_bh(&ap_dev->lock); in ap_scan_bus()
1469 device_unregister(&ap_dev->device); in ap_scan_bus()
1522 static int ap_poll_read(struct ap_device *ap_dev, unsigned long *flags) in ap_poll_read() argument
1527 if (ap_dev->queue_count <= 0) in ap_poll_read()
1529 status = __ap_recv(ap_dev->qid, &ap_dev->reply->psmid, in ap_poll_read()
1530 ap_dev->reply->message, ap_dev->reply->length); in ap_poll_read()
1534 ap_decrease_queue_count(ap_dev); in ap_poll_read()
1535 list_for_each_entry(ap_msg, &ap_dev->pendingq, list) { in ap_poll_read()
1536 if (ap_msg->psmid != ap_dev->reply->psmid) in ap_poll_read()
1539 ap_dev->pendingq_count--; in ap_poll_read()
1540 ap_msg->receive(ap_dev, ap_msg, ap_dev->reply); in ap_poll_read()
1543 if (ap_dev->queue_count > 0) in ap_poll_read()
1549 atomic_sub(ap_dev->queue_count, &ap_poll_requests); in ap_poll_read()
1550 ap_dev->queue_count = 0; in ap_poll_read()
1551 list_splice_init(&ap_dev->pendingq, &ap_dev->requestq); in ap_poll_read()
1552 ap_dev->requestq_count += ap_dev->pendingq_count; in ap_poll_read()
1553 ap_dev->pendingq_count = 0; in ap_poll_read()
1571 static int ap_poll_write(struct ap_device *ap_dev, unsigned long *flags) in ap_poll_write() argument
1576 if (ap_dev->requestq_count <= 0 || in ap_poll_write()
1577 ap_dev->queue_count >= ap_dev->queue_depth) in ap_poll_write()
1580 ap_msg = list_entry(ap_dev->requestq.next, struct ap_message, list); in ap_poll_write()
1581 status = __ap_send(ap_dev->qid, ap_msg->psmid, in ap_poll_write()
1586 ap_increase_queue_count(ap_dev); in ap_poll_write()
1587 list_move_tail(&ap_msg->list, &ap_dev->pendingq); in ap_poll_write()
1588 ap_dev->requestq_count--; in ap_poll_write()
1589 ap_dev->pendingq_count++; in ap_poll_write()
1590 if (ap_dev->queue_count < ap_dev->queue_depth && in ap_poll_write()
1591 ap_dev->requestq_count > 0) in ap_poll_write()
1619 static inline int ap_poll_queue(struct ap_device *ap_dev, unsigned long *flags) in ap_poll_queue() argument
1623 rc = ap_poll_read(ap_dev, flags); in ap_poll_queue()
1626 return ap_poll_write(ap_dev, flags); in ap_poll_queue()
1636 static int __ap_queue_message(struct ap_device *ap_dev, struct ap_message *ap_msg) in __ap_queue_message() argument
1640 if (list_empty(&ap_dev->requestq) && in __ap_queue_message()
1641 ap_dev->queue_count < ap_dev->queue_depth) { in __ap_queue_message()
1642 status = __ap_send(ap_dev->qid, ap_msg->psmid, in __ap_queue_message()
1647 list_add_tail(&ap_msg->list, &ap_dev->pendingq); in __ap_queue_message()
1649 ap_dev->pendingq_count++; in __ap_queue_message()
1650 ap_increase_queue_count(ap_dev); in __ap_queue_message()
1651 ap_dev->total_request_count++; in __ap_queue_message()
1655 list_add_tail(&ap_msg->list, &ap_dev->requestq); in __ap_queue_message()
1656 ap_dev->requestq_count++; in __ap_queue_message()
1657 ap_dev->total_request_count++; in __ap_queue_message()
1661 ap_msg->receive(ap_dev, ap_msg, ERR_PTR(-EINVAL)); in __ap_queue_message()
1664 ap_msg->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); in __ap_queue_message()
1668 list_add_tail(&ap_msg->list, &ap_dev->requestq); in __ap_queue_message()
1669 ap_dev->requestq_count++; in __ap_queue_message()
1670 ap_dev->total_request_count++; in __ap_queue_message()
1677 void ap_queue_message(struct ap_device *ap_dev, struct ap_message *ap_msg) in ap_queue_message() argument
1686 spin_lock_bh(&ap_dev->lock); in ap_queue_message()
1687 if (!ap_dev->unregistered) { in ap_queue_message()
1689 rc = ap_poll_queue(ap_dev, &flags); in ap_queue_message()
1691 rc = __ap_queue_message(ap_dev, ap_msg); in ap_queue_message()
1695 ap_dev->unregistered = 1; in ap_queue_message()
1697 ap_msg->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); in ap_queue_message()
1700 spin_unlock_bh(&ap_dev->lock); in ap_queue_message()
1702 device_unregister(&ap_dev->device); in ap_queue_message()
1716 void ap_cancel_message(struct ap_device *ap_dev, struct ap_message *ap_msg) in ap_cancel_message() argument
1720 spin_lock_bh(&ap_dev->lock); in ap_cancel_message()
1722 list_for_each_entry(tmp, &ap_dev->pendingq, list) in ap_cancel_message()
1724 ap_dev->pendingq_count--; in ap_cancel_message()
1727 ap_dev->requestq_count--; in ap_cancel_message()
1731 spin_unlock_bh(&ap_dev->lock); in ap_cancel_message()
1754 static void ap_reset(struct ap_device *ap_dev) in ap_reset() argument
1758 ap_dev->reset = AP_RESET_IGNORE; in ap_reset()
1759 atomic_sub(ap_dev->queue_count, &ap_poll_requests); in ap_reset()
1760 ap_dev->queue_count = 0; in ap_reset()
1761 list_splice_init(&ap_dev->pendingq, &ap_dev->requestq); in ap_reset()
1762 ap_dev->requestq_count += ap_dev->pendingq_count; in ap_reset()
1763 ap_dev->pendingq_count = 0; in ap_reset()
1764 rc = ap_init_queue(ap_dev->qid); in ap_reset()
1766 ap_dev->unregistered = 1; in ap_reset()
1771 static int __ap_poll_device(struct ap_device *ap_dev, unsigned long *flags) in __ap_poll_device() argument
1773 if (!ap_dev->unregistered) { in __ap_poll_device()
1774 if (ap_poll_queue(ap_dev, flags)) in __ap_poll_device()
1775 ap_dev->unregistered = 1; in __ap_poll_device()
1776 if (ap_dev->reset == AP_RESET_DO) in __ap_poll_device()
1777 ap_reset(ap_dev); in __ap_poll_device()
1793 struct ap_device *ap_dev; in ap_poll_all() local
1804 list_for_each_entry(ap_dev, &ap_device_list, list) { in ap_poll_all()
1805 spin_lock(&ap_dev->lock); in ap_poll_all()
1806 __ap_poll_device(ap_dev, &flags); in ap_poll_all()
1807 spin_unlock(&ap_dev->lock); in ap_poll_all()
1830 struct ap_device *ap_dev; in ap_poll_thread() local
1852 list_for_each_entry(ap_dev, &ap_device_list, list) { in ap_poll_thread()
1853 spin_lock(&ap_dev->lock); in ap_poll_thread()
1854 __ap_poll_device(ap_dev, &flags); in ap_poll_thread()
1855 spin_unlock(&ap_dev->lock); in ap_poll_thread()
1901 struct ap_device *ap_dev = (struct ap_device *) data; in ap_request_timeout() local
1903 if (ap_dev->reset == AP_RESET_ARMED) { in ap_request_timeout()
1904 ap_dev->reset = AP_RESET_DO; in ap_request_timeout()