Lines Matching refs:doe_mb

92 	struct pci_doe_mb *doe_mb;  member
95 static int pci_doe_wait(struct pci_doe_mb *doe_mb, unsigned long timeout) in pci_doe_wait() argument
97 if (wait_event_timeout(doe_mb->wq, in pci_doe_wait()
98 test_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags), in pci_doe_wait()
104 static void pci_doe_write_ctrl(struct pci_doe_mb *doe_mb, u32 val) in pci_doe_write_ctrl() argument
106 struct pci_dev *pdev = doe_mb->pdev; in pci_doe_write_ctrl()
107 int offset = doe_mb->cap_offset; in pci_doe_write_ctrl()
112 static int pci_doe_abort(struct pci_doe_mb *doe_mb) in pci_doe_abort() argument
114 struct pci_dev *pdev = doe_mb->pdev; in pci_doe_abort()
115 int offset = doe_mb->cap_offset; in pci_doe_abort()
121 pci_doe_write_ctrl(doe_mb, PCI_DOE_CTRL_ABORT); in pci_doe_abort()
127 rc = pci_doe_wait(doe_mb, PCI_DOE_POLL_INTERVAL); in pci_doe_abort()
144 static int pci_doe_send_req(struct pci_doe_mb *doe_mb, in pci_doe_send_req() argument
147 struct pci_dev *pdev = doe_mb->pdev; in pci_doe_send_req()
148 int offset = doe_mb->cap_offset; in pci_doe_send_req()
195 pci_doe_write_ctrl(doe_mb, PCI_DOE_CTRL_GO); in pci_doe_send_req()
200 static bool pci_doe_data_obj_ready(struct pci_doe_mb *doe_mb) in pci_doe_data_obj_ready() argument
202 struct pci_dev *pdev = doe_mb->pdev; in pci_doe_data_obj_ready()
203 int offset = doe_mb->cap_offset; in pci_doe_data_obj_ready()
212 static int pci_doe_recv_resp(struct pci_doe_mb *doe_mb, struct pci_doe_task *task) in pci_doe_recv_resp() argument
215 struct pci_dev *pdev = doe_mb->pdev; in pci_doe_recv_resp()
216 int offset = doe_mb->cap_offset; in pci_doe_recv_resp()
225 doe_mb->cap_offset, task->prot.vid, task->prot.type, in pci_doe_recv_resp()
273 if (!pci_doe_data_obj_ready(doe_mb)) in pci_doe_recv_resp()
302 struct pci_doe_mb *doe_mb = task->doe_mb; in signal_task_abort() local
303 struct pci_dev *pdev = doe_mb->pdev; in signal_task_abort()
305 if (pci_doe_abort(doe_mb)) { in signal_task_abort()
311 doe_mb->cap_offset); in signal_task_abort()
312 set_bit(PCI_DOE_FLAG_DEAD, &doe_mb->flags); in signal_task_abort()
321 struct pci_doe_mb *doe_mb = task->doe_mb; in doe_statemachine_work() local
322 struct pci_dev *pdev = doe_mb->pdev; in doe_statemachine_work()
323 int offset = doe_mb->cap_offset; in doe_statemachine_work()
328 if (test_bit(PCI_DOE_FLAG_DEAD, &doe_mb->flags)) { in doe_statemachine_work()
334 rc = pci_doe_send_req(doe_mb, task); in doe_statemachine_work()
364 rc = pci_doe_wait(doe_mb, PCI_DOE_POLL_INTERVAL); in doe_statemachine_work()
372 rc = pci_doe_recv_resp(doe_mb, task); in doe_statemachine_work()
386 static int pci_doe_discovery(struct pci_doe_mb *doe_mb, u8 *index, u16 *vid, in pci_doe_discovery() argument
396 rc = pci_doe(doe_mb, PCI_VENDOR_ID_PCI_SIG, PCI_DOE_PROTOCOL_DISCOVERY, in pci_doe_discovery()
420 static int pci_doe_cache_protocols(struct pci_doe_mb *doe_mb) in pci_doe_cache_protocols() argument
430 rc = pci_doe_discovery(doe_mb, &index, &vid, &prot); in pci_doe_cache_protocols()
434 pci_dbg(doe_mb->pdev, in pci_doe_cache_protocols()
436 doe_mb->cap_offset, xa_idx, vid, prot); in pci_doe_cache_protocols()
438 rc = xa_insert(&doe_mb->prots, xa_idx++, in pci_doe_cache_protocols()
447 static void pci_doe_cancel_tasks(struct pci_doe_mb *doe_mb) in pci_doe_cancel_tasks() argument
450 set_bit(PCI_DOE_FLAG_DEAD, &doe_mb->flags); in pci_doe_cancel_tasks()
453 set_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags); in pci_doe_cancel_tasks()
454 wake_up(&doe_mb->wq); in pci_doe_cancel_tasks()
472 struct pci_doe_mb *doe_mb; in pci_doe_create_mb() local
475 doe_mb = kzalloc(sizeof(*doe_mb), GFP_KERNEL); in pci_doe_create_mb()
476 if (!doe_mb) in pci_doe_create_mb()
479 doe_mb->pdev = pdev; in pci_doe_create_mb()
480 doe_mb->cap_offset = cap_offset; in pci_doe_create_mb()
481 init_waitqueue_head(&doe_mb->wq); in pci_doe_create_mb()
482 xa_init(&doe_mb->prots); in pci_doe_create_mb()
484 doe_mb->work_queue = alloc_ordered_workqueue("%s %s DOE [%x]", 0, in pci_doe_create_mb()
487 doe_mb->cap_offset); in pci_doe_create_mb()
488 if (!doe_mb->work_queue) { in pci_doe_create_mb()
490 doe_mb->cap_offset); in pci_doe_create_mb()
496 rc = pci_doe_abort(doe_mb); in pci_doe_create_mb()
499 doe_mb->cap_offset, rc); in pci_doe_create_mb()
507 rc = pci_doe_cache_protocols(doe_mb); in pci_doe_create_mb()
510 doe_mb->cap_offset, rc); in pci_doe_create_mb()
514 return doe_mb; in pci_doe_create_mb()
517 pci_doe_cancel_tasks(doe_mb); in pci_doe_create_mb()
518 xa_destroy(&doe_mb->prots); in pci_doe_create_mb()
520 destroy_workqueue(doe_mb->work_queue); in pci_doe_create_mb()
522 kfree(doe_mb); in pci_doe_create_mb()
533 static void pci_doe_destroy_mb(struct pci_doe_mb *doe_mb) in pci_doe_destroy_mb() argument
535 pci_doe_cancel_tasks(doe_mb); in pci_doe_destroy_mb()
536 xa_destroy(&doe_mb->prots); in pci_doe_destroy_mb()
537 destroy_workqueue(doe_mb->work_queue); in pci_doe_destroy_mb()
538 kfree(doe_mb); in pci_doe_destroy_mb()
550 static bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type) in pci_doe_supports_prot() argument
559 xa_for_each(&doe_mb->prots, index, entry) in pci_doe_supports_prot()
585 static int pci_doe_submit_task(struct pci_doe_mb *doe_mb, in pci_doe_submit_task() argument
588 if (!pci_doe_supports_prot(doe_mb, task->prot.vid, task->prot.type)) in pci_doe_submit_task()
591 if (test_bit(PCI_DOE_FLAG_DEAD, &doe_mb->flags)) in pci_doe_submit_task()
594 task->doe_mb = doe_mb; in pci_doe_submit_task()
596 queue_work(doe_mb->work_queue, &task->work); in pci_doe_submit_task()
628 int pci_doe(struct pci_doe_mb *doe_mb, u16 vendor, u8 type, in pci_doe() argument
645 rc = pci_doe_submit_task(doe_mb, &task); in pci_doe()
669 struct pci_doe_mb *doe_mb; in pci_find_doe_mailbox() local
672 xa_for_each(&pdev->doe_mbs, index, doe_mb) in pci_find_doe_mailbox()
673 if (pci_doe_supports_prot(doe_mb, vendor, type)) in pci_find_doe_mailbox()
674 return doe_mb; in pci_find_doe_mailbox()
682 struct pci_doe_mb *doe_mb; in pci_doe_init() local
690 doe_mb = pci_doe_create_mb(pdev, offset); in pci_doe_init()
691 if (IS_ERR(doe_mb)) { in pci_doe_init()
693 offset, PTR_ERR(doe_mb)); in pci_doe_init()
697 rc = xa_insert(&pdev->doe_mbs, offset, doe_mb, GFP_KERNEL); in pci_doe_init()
701 pci_doe_destroy_mb(doe_mb); in pci_doe_init()
708 struct pci_doe_mb *doe_mb; in pci_doe_destroy() local
711 xa_for_each(&pdev->doe_mbs, index, doe_mb) in pci_doe_destroy()
712 pci_doe_destroy_mb(doe_mb); in pci_doe_destroy()
719 struct pci_doe_mb *doe_mb; in pci_doe_disconnected() local
722 xa_for_each(&pdev->doe_mbs, index, doe_mb) in pci_doe_disconnected()
723 pci_doe_cancel_tasks(doe_mb); in pci_doe_disconnected()