diff options
Diffstat (limited to 'drivers/usb/early/ehci-dbgp.c')
| -rw-r--r-- | drivers/usb/early/ehci-dbgp.c | 39 | 
1 files changed, 25 insertions, 14 deletions
diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c index 94ecdbc758c..8cfc3191be5 100644 --- a/drivers/usb/early/ehci-dbgp.c +++ b/drivers/usb/early/ehci-dbgp.c @@ -20,6 +20,7 @@  #include <linux/usb/ehci_def.h>  #include <linux/delay.h>  #include <linux/serial_core.h> +#include <linux/kconfig.h>  #include <linux/kgdb.h>  #include <linux/kthread.h>  #include <asm/io.h> @@ -102,6 +103,9 @@ static struct kgdb_io kgdbdbgp_io_ops;  #define dbgp_kgdb_mode (0)  #endif +/* Local version of HC_LENGTH macro as ehci struct is not available here */ +#define EARLY_HC_LENGTH(p)	(0x00ff & (p)) /* bits 7 : 0 */ +  /*   * USB Packet IDs (PIDs)   */ @@ -331,7 +335,7 @@ static int dbgp_control_msg(unsigned devnum, int requesttype,  	int ret;  	read = (requesttype & USB_DIR_IN) != 0; -	if (size > (read ? DBGP_MAX_PACKET:0)) +	if (size > (read ? DBGP_MAX_PACKET : 0))  		return -1;  	/* Compute the control message */ @@ -447,7 +451,7 @@ static int dbgp_ehci_startup(void)  	writel(FLAG_CF, &ehci_regs->configured_flag);  	/* Wait until the controller is no longer halted */ -	loop = 10; +	loop = 1000;  	do {  		status = readl(&ehci_regs->status);  		if (!(status & STS_HALT)) @@ -488,7 +492,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; @@ -564,10 +568,6 @@ try_again:  		dbgp_printk("Could not find attached debug device\n");  		goto err;  	} -	if (ret < 0) { -		dbgp_printk("Attached device is not a debug device\n"); -		goto err; -	}  	dbgp_endpoint_out = dbgp_desc.bDebugOutEndpoint;  	dbgp_endpoint_in = dbgp_desc.bDebugInEndpoint; @@ -601,7 +601,7 @@ try_again:  		dbgp_printk("dbgp_bulk_write failed: %d\n", ret);  		goto err;  	} -	dbgp_printk("small write doned\n"); +	dbgp_printk("small write done\n");  	dbgp_not_safe = 0;  	return 0; @@ -610,7 +610,6 @@ err:  		goto try_again;  	return -ENODEV;  } -EXPORT_SYMBOL_GPL(dbgp_external_startup);  static int ehci_reset_port(int port)  { @@ -648,7 +647,7 @@ static int ehci_reset_port(int port)  		if (!(portsc & PORT_CONNECT))  			return -ENOTCONN; -		/* bomb out completely if something weird happend */ +		/* bomb out completely if something weird happened */  		if ((portsc & PORT_CSC))  			return -EINVAL; @@ -801,7 +800,7 @@ try_next_port:  		dbgp_ehci_status("ehci skip - already configured");  	} -	ret = dbgp_external_startup(); +	ret = _dbgp_external_startup();  	if (ret == -EIO)  		goto next_debug_port; @@ -892,7 +891,7 @@ int __init early_dbgp_init(char *s)  	dbgp_printk("ehci_bar: %p\n", ehci_bar);  	ehci_caps  = ehci_bar; -	ehci_regs  = ehci_bar + HC_LENGTH(readl(&ehci_caps->hc_capbase)); +	ehci_regs  = ehci_bar + EARLY_HC_LENGTH(readl(&ehci_caps->hc_capbase));  	ehci_debug = ehci_bar + offset;  	ehci_dev.bus = bus;  	ehci_dev.slot = slot; @@ -931,7 +930,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); @@ -971,10 +970,15 @@ struct console early_dbgp_console = {  	.index =	-1,  }; -int dbgp_reset_prep(void) +#if IS_ENABLED(CONFIG_USB) +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; @@ -995,6 +999,13 @@ int dbgp_reset_prep(void)  }  EXPORT_SYMBOL_GPL(dbgp_reset_prep); +int dbgp_external_startup(struct usb_hcd *hcd) +{ +	return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup(); +} +EXPORT_SYMBOL_GPL(dbgp_external_startup); +#endif /* USB */ +  #ifdef CONFIG_KGDB  static char kgdbdbgp_buf[DBGP_MAX_PACKET];  | 
