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