Commit 9fa5780beea1274d498a224822397100022da7d4

Authored by Jan Beulich
Committed by Greg Kroah-Hartman
1 parent ee42f6c9fc

USB EHCI/Xen: propagate controller reset information to hypervisor

Just like for the in-tree early console debug port driver, the
hypervisor - when using a debug port based console - also needs to be
told about controller resets, so it can suppress using and then
re-initialize the debug port accordingly.

Other than the in-tree driver, the hypervisor driver actually cares
about doing this only for the device where the debug is port actually
in use, i.e. it needs to be told the coordinates of the device being
reset (quite obviously, leveraging the addition done for that would
likely benefit the in-tree driver too).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 7 changed files with 105 additions and 15 deletions Side-by-side Diff

drivers/usb/early/ehci-dbgp.c
... ... @@ -491,7 +491,7 @@
491 491 * Return -ENODEV for any general failure
492 492 * Return -EIO if wait for port fails
493 493 */
494   -int dbgp_external_startup(void)
  494 +static int _dbgp_external_startup(void)
495 495 {
496 496 int devnum;
497 497 struct usb_debug_descriptor dbgp_desc;
... ... @@ -613,6 +613,11 @@
613 613 goto try_again;
614 614 return -ENODEV;
615 615 }
  616 +
  617 +int dbgp_external_startup(struct usb_hcd *hcd)
  618 +{
  619 + return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup();
  620 +}
616 621 EXPORT_SYMBOL_GPL(dbgp_external_startup);
617 622  
618 623 static int ehci_reset_port(int port)
... ... @@ -804,7 +809,7 @@
804 809 dbgp_ehci_status("ehci skip - already configured");
805 810 }
806 811  
807   - ret = dbgp_external_startup();
  812 + ret = _dbgp_external_startup();
808 813 if (ret == -EIO)
809 814 goto next_debug_port;
810 815  
... ... @@ -934,7 +939,7 @@
934 939 ctrl = readl(&ehci_debug->control);
935 940 if (!(ctrl & DBGP_ENABLED)) {
936 941 dbgp_not_safe = 1;
937   - dbgp_external_startup();
  942 + _dbgp_external_startup();
938 943 } else {
939 944 cmd |= CMD_RUN;
940 945 writel(cmd, &ehci_regs->command);
941 946  
942 947  
... ... @@ -974,9 +979,13 @@
974 979 .index = -1,
975 980 };
976 981  
977   -int dbgp_reset_prep(void)
  982 +int dbgp_reset_prep(struct usb_hcd *hcd)
978 983 {
  984 + int ret = xen_dbgp_reset_prep(hcd);
979 985 u32 ctrl;
  986 +
  987 + if (ret)
  988 + return ret;
980 989  
981 990 dbgp_not_safe = 1;
982 991 if (!ehci_debug)
drivers/usb/host/ehci-hcd.c
... ... @@ -228,7 +228,7 @@
228 228  
229 229 /* If the EHCI debug controller is active, special care must be
230 230 * taken before and after a host controller reset */
231   - if (ehci->debug && !dbgp_reset_prep())
  231 + if (ehci->debug && !dbgp_reset_prep(ehci_to_hcd(ehci)))
232 232 ehci->debug = NULL;
233 233  
234 234 command |= CMD_RESET;
... ... @@ -251,7 +251,7 @@
251 251 tdi_reset (ehci);
252 252  
253 253 if (ehci->debug)
254   - dbgp_external_startup();
  254 + dbgp_external_startup(ehci_to_hcd(ehci));
255 255  
256 256 ehci->port_c_suspend = ehci->suspended_ports =
257 257 ehci->resuming_ports = 0;
drivers/usb/host/ehci-hub.c
... ... @@ -353,10 +353,10 @@
353 353 goto shutdown;
354 354  
355 355 if (unlikely(ehci->debug)) {
356   - if (!dbgp_reset_prep())
  356 + if (!dbgp_reset_prep(hcd))
357 357 ehci->debug = NULL;
358 358 else
359   - dbgp_external_startup();
  359 + dbgp_external_startup(hcd);
360 360 }
361 361  
362 362 /* Ideally and we've got a real resume here, and no port's power
drivers/xen/Makefile
... ... @@ -18,7 +18,7 @@
18 18 obj-$(CONFIG_XEN_TMEM) += tmem.o
19 19 obj-$(CONFIG_SWIOTLB_XEN) += swiotlb-xen.o
20 20 obj-$(CONFIG_XEN_DOM0) += pcpu.o
21   -obj-$(CONFIG_XEN_DOM0) += pci.o acpi.o
  21 +obj-$(CONFIG_XEN_DOM0) += pci.o dbgp.o acpi.o
22 22 obj-$(CONFIG_XEN_MCE_LOG) += mcelog.o
23 23 obj-$(CONFIG_XEN_PCIDEV_BACKEND) += xen-pciback/
24 24 obj-$(CONFIG_XEN_PRIVCMD) += xen-privcmd.o
  1 +#include <linux/pci.h>
  2 +#include <linux/usb.h>
  3 +#include <linux/usb/ehci_def.h>
  4 +#include <linux/usb/hcd.h>
  5 +#include <asm/xen/hypercall.h>
  6 +#include <xen/interface/physdev.h>
  7 +#include <xen/xen.h>
  8 +
  9 +static int xen_dbgp_op(struct usb_hcd *hcd, int op)
  10 +{
  11 + const struct device *ctrlr = hcd_to_bus(hcd)->controller;
  12 + struct physdev_dbgp_op dbgp;
  13 +
  14 + if (!xen_initial_domain())
  15 + return 0;
  16 +
  17 + dbgp.op = op;
  18 +
  19 +#ifdef CONFIG_PCI
  20 + if (ctrlr->bus == &pci_bus_type) {
  21 + const struct pci_dev *pdev = to_pci_dev(ctrlr);
  22 +
  23 + dbgp.u.pci.seg = pci_domain_nr(pdev->bus);
  24 + dbgp.u.pci.bus = pdev->bus->number;
  25 + dbgp.u.pci.devfn = pdev->devfn;
  26 + dbgp.bus = PHYSDEVOP_DBGP_BUS_PCI;
  27 + } else
  28 +#endif
  29 + dbgp.bus = PHYSDEVOP_DBGP_BUS_UNKNOWN;
  30 +
  31 + return HYPERVISOR_physdev_op(PHYSDEVOP_dbgp_op, &dbgp);
  32 +}
  33 +
  34 +int xen_dbgp_reset_prep(struct usb_hcd *hcd)
  35 +{
  36 + return xen_dbgp_op(hcd, PHYSDEVOP_DBGP_RESET_PREPARE);
  37 +}
  38 +
  39 +int xen_dbgp_external_startup(struct usb_hcd *hcd)
  40 +{
  41 + return xen_dbgp_op(hcd, PHYSDEVOP_DBGP_RESET_DONE);
  42 +}
  43 +
  44 +#ifndef CONFIG_EARLY_PRINTK_DBGP
  45 +#include <linux/export.h>
  46 +EXPORT_SYMBOL_GPL(xen_dbgp_reset_prep);
  47 +EXPORT_SYMBOL_GPL(xen_dbgp_external_startup);
  48 +#endif
include/linux/usb/ehci_def.h
... ... @@ -221,18 +221,35 @@
221 221 extern struct console early_dbgp_console;
222 222 #endif /* CONFIG_EARLY_PRINTK_DBGP */
223 223  
  224 +struct usb_hcd;
  225 +
  226 +#ifdef CONFIG_XEN_DOM0
  227 +extern int xen_dbgp_reset_prep(struct usb_hcd *);
  228 +extern int xen_dbgp_external_startup(struct usb_hcd *);
  229 +#else
  230 +static inline int xen_dbgp_reset_prep(struct usb_hcd *hcd)
  231 +{
  232 + return 1; /* Shouldn't this be 0? */
  233 +}
  234 +
  235 +static inline int xen_dbgp_external_startup(struct usb_hcd *hcd)
  236 +{
  237 + return -1;
  238 +}
  239 +#endif
  240 +
224 241 #ifdef CONFIG_EARLY_PRINTK_DBGP
225 242 /* Call backs from ehci host driver to ehci debug driver */
226   -extern int dbgp_external_startup(void);
227   -extern int dbgp_reset_prep(void);
  243 +extern int dbgp_external_startup(struct usb_hcd *);
  244 +extern int dbgp_reset_prep(struct usb_hcd *hcd);
228 245 #else
229   -static inline int dbgp_reset_prep(void)
  246 +static inline int dbgp_reset_prep(struct usb_hcd *hcd)
230 247 {
231   - return 1;
  248 + return xen_dbgp_reset_prep(hcd);
232 249 }
233   -static inline int dbgp_external_startup(void)
  250 +static inline int dbgp_external_startup(struct usb_hcd *hcd)
234 251 {
235   - return -1;
  252 + return xen_dbgp_external_startup(hcd);
236 253 }
237 254 #endif
238 255  
include/xen/interface/physdev.h
... ... @@ -258,6 +258,22 @@
258 258 uint8_t devfn;
259 259 };
260 260  
  261 +#define PHYSDEVOP_DBGP_RESET_PREPARE 1
  262 +#define PHYSDEVOP_DBGP_RESET_DONE 2
  263 +
  264 +#define PHYSDEVOP_DBGP_BUS_UNKNOWN 0
  265 +#define PHYSDEVOP_DBGP_BUS_PCI 1
  266 +
  267 +#define PHYSDEVOP_dbgp_op 29
  268 +struct physdev_dbgp_op {
  269 + /* IN */
  270 + uint8_t op;
  271 + uint8_t bus;
  272 + union {
  273 + struct physdev_pci_device pci;
  274 + } u;
  275 +};
  276 +
261 277 /*
262 278 * Notify that some PIRQ-bound event channels have been unmasked.
263 279 * ** This command is obsolete since interface version 0x00030202 and is **