dbgp.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. #include <linux/pci.h>
  3. #include <linux/usb.h>
  4. #include <linux/usb/ehci_def.h>
  5. #include <linux/usb/hcd.h>
  6. #include <asm/xen/hypercall.h>
  7. #include <xen/interface/physdev.h>
  8. #include <xen/xen.h>
  9. static int xen_dbgp_op(struct usb_hcd *hcd, int op)
  10. {
  11. #ifdef CONFIG_PCI
  12. const struct device *ctrlr = hcd_to_bus(hcd)->controller;
  13. #endif
  14. struct physdev_dbgp_op dbgp;
  15. if (!xen_initial_domain())
  16. return 0;
  17. dbgp.op = op;
  18. #ifdef CONFIG_PCI
  19. if (dev_is_pci(ctrlr)) {
  20. const struct pci_dev *pdev = to_pci_dev(ctrlr);
  21. dbgp.u.pci.seg = pci_domain_nr(pdev->bus);
  22. dbgp.u.pci.bus = pdev->bus->number;
  23. dbgp.u.pci.devfn = pdev->devfn;
  24. dbgp.bus = PHYSDEVOP_DBGP_BUS_PCI;
  25. } else
  26. #endif
  27. dbgp.bus = PHYSDEVOP_DBGP_BUS_UNKNOWN;
  28. return HYPERVISOR_physdev_op(PHYSDEVOP_dbgp_op, &dbgp);
  29. }
  30. int xen_dbgp_reset_prep(struct usb_hcd *hcd)
  31. {
  32. return xen_dbgp_op(hcd, PHYSDEVOP_DBGP_RESET_PREPARE);
  33. }
  34. int xen_dbgp_external_startup(struct usb_hcd *hcd)
  35. {
  36. return xen_dbgp_op(hcd, PHYSDEVOP_DBGP_RESET_DONE);
  37. }
  38. #ifndef CONFIG_EARLY_PRINTK_DBGP
  39. #include <linux/export.h>
  40. EXPORT_SYMBOL_GPL(xen_dbgp_reset_prep);
  41. EXPORT_SYMBOL_GPL(xen_dbgp_external_startup);
  42. #endif