Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fa5780b authored by Jan Beulich's avatar Jan Beulich Committed by Greg Kroah-Hartman
Browse files

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: default avatarJan Beulich <jbeulich@suse.com>
Acked-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ee42f6c9
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -491,7 +491,7 @@ static int ehci_wait_for_port(int port);
 * Return -ENODEV for any general failure
 * Return -EIO if wait for port fails
 */
int dbgp_external_startup(void)
static int _dbgp_external_startup(void)
{
	int devnum;
	struct usb_debug_descriptor dbgp_desc;
@@ -613,6 +613,11 @@ int dbgp_external_startup(void)
		goto try_again;
	return -ENODEV;
}

int dbgp_external_startup(struct usb_hcd *hcd)
{
	return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup();
}
EXPORT_SYMBOL_GPL(dbgp_external_startup);

static int ehci_reset_port(int port)
@@ -804,7 +809,7 @@ static int __init ehci_setup(void)
		dbgp_ehci_status("ehci skip - already configured");
	}

	ret = dbgp_external_startup();
	ret = _dbgp_external_startup();
	if (ret == -EIO)
		goto next_debug_port;

@@ -934,7 +939,7 @@ static void early_dbgp_write(struct console *con, const char *str, u32 n)
		ctrl = readl(&ehci_debug->control);
		if (!(ctrl & DBGP_ENABLED)) {
			dbgp_not_safe = 1;
			dbgp_external_startup();
			_dbgp_external_startup();
		} else {
			cmd |= CMD_RUN;
			writel(cmd, &ehci_regs->command);
@@ -974,10 +979,14 @@ struct console early_dbgp_console = {
	.index =	-1,
};

int dbgp_reset_prep(void)
int dbgp_reset_prep(struct usb_hcd *hcd)
{
	int ret = xen_dbgp_reset_prep(hcd);
	u32 ctrl;

	if (ret)
		return ret;

	dbgp_not_safe = 1;
	if (!ehci_debug)
		return 0;
+2 −2
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ static int ehci_reset (struct ehci_hcd *ehci)

	/* If the EHCI debug controller is active, special care must be
	 * taken before and after a host controller reset */
	if (ehci->debug && !dbgp_reset_prep())
	if (ehci->debug && !dbgp_reset_prep(ehci_to_hcd(ehci)))
		ehci->debug = NULL;

	command |= CMD_RESET;
@@ -251,7 +251,7 @@ static int ehci_reset (struct ehci_hcd *ehci)
		tdi_reset (ehci);

	if (ehci->debug)
		dbgp_external_startup();
		dbgp_external_startup(ehci_to_hcd(ehci));

	ehci->port_c_suspend = ehci->suspended_ports =
			ehci->resuming_ports = 0;
+2 −2
Original line number Diff line number Diff line
@@ -353,10 +353,10 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
		goto shutdown;

	if (unlikely(ehci->debug)) {
		if (!dbgp_reset_prep())
		if (!dbgp_reset_prep(hcd))
			ehci->debug = NULL;
		else
			dbgp_external_startup();
			dbgp_external_startup(hcd);
	}

	/* Ideally and we've got a real resume here, and no port's power
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ obj-$(CONFIG_XEN_PVHVM) += platform-pci.o
obj-$(CONFIG_XEN_TMEM)			+= tmem.o
obj-$(CONFIG_SWIOTLB_XEN)		+= swiotlb-xen.o
obj-$(CONFIG_XEN_DOM0)			+= pcpu.o
obj-$(CONFIG_XEN_DOM0)			+= pci.o acpi.o
obj-$(CONFIG_XEN_DOM0)			+= pci.o dbgp.o acpi.o
obj-$(CONFIG_XEN_MCE_LOG)		+= mcelog.o
obj-$(CONFIG_XEN_PCIDEV_BACKEND)	+= xen-pciback/
obj-$(CONFIG_XEN_PRIVCMD)		+= xen-privcmd.o

drivers/xen/dbgp.c

0 → 100644
+48 −0
Original line number Diff line number Diff line
#include <linux/pci.h>
#include <linux/usb.h>
#include <linux/usb/ehci_def.h>
#include <linux/usb/hcd.h>
#include <asm/xen/hypercall.h>
#include <xen/interface/physdev.h>
#include <xen/xen.h>

static int xen_dbgp_op(struct usb_hcd *hcd, int op)
{
	const struct device *ctrlr = hcd_to_bus(hcd)->controller;
	struct physdev_dbgp_op dbgp;

	if (!xen_initial_domain())
		return 0;

	dbgp.op = op;

#ifdef CONFIG_PCI
	if (ctrlr->bus == &pci_bus_type) {
		const struct pci_dev *pdev = to_pci_dev(ctrlr);

		dbgp.u.pci.seg = pci_domain_nr(pdev->bus);
		dbgp.u.pci.bus = pdev->bus->number;
		dbgp.u.pci.devfn = pdev->devfn;
		dbgp.bus = PHYSDEVOP_DBGP_BUS_PCI;
	} else
#endif
		dbgp.bus = PHYSDEVOP_DBGP_BUS_UNKNOWN;

	return HYPERVISOR_physdev_op(PHYSDEVOP_dbgp_op, &dbgp);
}

int xen_dbgp_reset_prep(struct usb_hcd *hcd)
{
	return xen_dbgp_op(hcd, PHYSDEVOP_DBGP_RESET_PREPARE);
}

int xen_dbgp_external_startup(struct usb_hcd *hcd)
{
	return xen_dbgp_op(hcd, PHYSDEVOP_DBGP_RESET_DONE);
}

#ifndef CONFIG_EARLY_PRINTK_DBGP
#include <linux/export.h>
EXPORT_SYMBOL_GPL(xen_dbgp_reset_prep);
EXPORT_SYMBOL_GPL(xen_dbgp_external_startup);
#endif
Loading