All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ohci-pci: add qemu quirk
@ 2017-03-14  9:52 Gerd Hoffmann
  2017-03-14 15:15 ` Alan Stern
  0 siblings, 1 reply; 2+ messages in thread
From: Gerd Hoffmann @ 2017-03-14  9:52 UTC (permalink / raw)
  To: linux-usb; +Cc: Gerd Hoffmann, Alan Stern, Greg Kroah-Hartman, open list

On a loaded virtualization host (dozen guests booting at the same time)
it may happen that the ohci controller emulation doesn't manage to do
timely frame processing, with the result that the io watchdog fires and
considers the controller being dead, even though it's only the emulation
being unusual slow due to the load peak.

So, add a quirk for qemu and don't use the watchdog in case we figure we
are running on emulated ohci.  The virtual ohci controller masquerades
as apple ohci controller, but we can identify it by subsystem id.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/usb/host/ohci-hcd.c |  3 ++-
 drivers/usb/host/ohci-pci.c | 16 ++++++++++++++++
 drivers/usb/host/ohci.h     |  1 +
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index b6daf2e..b75ae28 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -231,7 +231,8 @@ static int ohci_urb_enqueue (
 
 		/* Start up the I/O watchdog timer, if it's not running */
 		if (!timer_pending(&ohci->io_watchdog) &&
-				list_empty(&ohci->eds_in_use)) {
+		    list_empty(&ohci->eds_in_use) &&
+		    !(ohci->flags & OHCI_QUIRK_QEMU)) {
 			ohci->prev_frame_no = ohci_frame_no(ohci);
 			mod_timer(&ohci->io_watchdog,
 					jiffies + IO_WATCHDOG_DELAY);
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index bb15096..a84aebe 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -164,6 +164,15 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd)
 	return 0;
 }
 
+static int ohci_quirk_qemu(struct usb_hcd *hcd)
+{
+	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
+
+	ohci->flags |= OHCI_QUIRK_QEMU;
+	ohci_dbg(ohci, "enabled qemu quirk\n");
+	return 0;
+}
+
 /* List of quirks for OHCI */
 static const struct pci_device_id ohci_pci_quirks[] = {
 	{
@@ -214,6 +223,13 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd)
 		PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4399),
 		.driver_data = (unsigned long)ohci_quirk_amd700,
 	},
+	{
+		.vendor		= PCI_VENDOR_ID_APPLE,
+		.device		= 0x003f,
+		.subvendor	= PCI_SUBVENDOR_ID_REDHAT_QUMRANET,
+		.subdevice	= PCI_SUBDEVICE_ID_QEMU,
+		.driver_data	= (unsigned long)ohci_quirk_qemu,
+	},
 
 	/* FIXME for some of the early AMD 760 southbridges, OHCI
 	 * won't work at all.  blacklist them.
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index 37f1725..a51b189 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -418,6 +418,7 @@ struct ohci_hcd {
 #define	OHCI_QUIRK_AMD_PLL	0x200			/* AMD PLL quirk*/
 #define	OHCI_QUIRK_AMD_PREFETCH	0x400			/* pre-fetch for ISO transfer */
 #define	OHCI_QUIRK_GLOBAL_SUSPEND	0x800		/* must suspend ports */
+#define	OHCI_QUIRK_QEMU		0x1000			/* relax timing expectations */
 
 	// there are also chip quirks/bugs in init logic
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ohci-pci: add qemu quirk
  2017-03-14  9:52 [PATCH] ohci-pci: add qemu quirk Gerd Hoffmann
@ 2017-03-14 15:15 ` Alan Stern
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Stern @ 2017-03-14 15:15 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: linux-usb, Greg Kroah-Hartman, open list

On Tue, 14 Mar 2017, Gerd Hoffmann wrote:

> On a loaded virtualization host (dozen guests booting at the same time)
> it may happen that the ohci controller emulation doesn't manage to do
> timely frame processing, with the result that the io watchdog fires and
> considers the controller being dead, even though it's only the emulation
> being unusual slow due to the load peak.
> 
> So, add a quirk for qemu and don't use the watchdog in case we figure we
> are running on emulated ohci.  The virtual ohci controller masquerades
> as apple ohci controller, but we can identify it by subsystem id.
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  drivers/usb/host/ohci-hcd.c |  3 ++-
>  drivers/usb/host/ohci-pci.c | 16 ++++++++++++++++
>  drivers/usb/host/ohci.h     |  1 +
>  3 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
> index b6daf2e..b75ae28 100644
> --- a/drivers/usb/host/ohci-hcd.c
> +++ b/drivers/usb/host/ohci-hcd.c
> @@ -231,7 +231,8 @@ static int ohci_urb_enqueue (
>  
>  		/* Start up the I/O watchdog timer, if it's not running */
>  		if (!timer_pending(&ohci->io_watchdog) &&
> -				list_empty(&ohci->eds_in_use)) {
> +		    list_empty(&ohci->eds_in_use) &&
> +		    !(ohci->flags & OHCI_QUIRK_QEMU)) {

I would appreciate it if you do not change the indentation used by this 
driver.

>  			ohci->prev_frame_no = ohci_frame_no(ohci);
>  			mod_timer(&ohci->io_watchdog,
>  					jiffies + IO_WATCHDOG_DELAY);
> diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
> index bb15096..a84aebe 100644
> --- a/drivers/usb/host/ohci-pci.c
> +++ b/drivers/usb/host/ohci-pci.c
> @@ -164,6 +164,15 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd)
>  	return 0;
>  }
>  
> +static int ohci_quirk_qemu(struct usb_hcd *hcd)
> +{
> +	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
> +
> +	ohci->flags |= OHCI_QUIRK_QEMU;
> +	ohci_dbg(ohci, "enabled qemu quirk\n");
> +	return 0;
> +}
> +
>  /* List of quirks for OHCI */
>  static const struct pci_device_id ohci_pci_quirks[] = {
>  	{
> @@ -214,6 +223,13 @@ static int ohci_quirk_amd700(struct usb_hcd *hcd)
>  		PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4399),
>  		.driver_data = (unsigned long)ohci_quirk_amd700,
>  	},
> +	{
> +		.vendor		= PCI_VENDOR_ID_APPLE,
> +		.device		= 0x003f,
> +		.subvendor	= PCI_SUBVENDOR_ID_REDHAT_QUMRANET,
> +		.subdevice	= PCI_SUBDEVICE_ID_QEMU,
> +		.driver_data	= (unsigned long)ohci_quirk_qemu,
> +	},
>  
>  	/* FIXME for some of the early AMD 760 southbridges, OHCI
>  	 * won't work at all.  blacklist them.
> diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
> index 37f1725..a51b189 100644
> --- a/drivers/usb/host/ohci.h
> +++ b/drivers/usb/host/ohci.h
> @@ -418,6 +418,7 @@ struct ohci_hcd {
>  #define	OHCI_QUIRK_AMD_PLL	0x200			/* AMD PLL quirk*/
>  #define	OHCI_QUIRK_AMD_PREFETCH	0x400			/* pre-fetch for ISO transfer */
>  #define	OHCI_QUIRK_GLOBAL_SUSPEND	0x800		/* must suspend ports */
> +#define	OHCI_QUIRK_QEMU		0x1000			/* relax timing expectations */
>  
>  	// there are also chip quirks/bugs in init logic

Aside from that minor point,

Acked-by: Alan Stern <stern@rowland.harvard.edu>

Alan Stern

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-14 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14  9:52 [PATCH] ohci-pci: add qemu quirk Gerd Hoffmann
2017-03-14 15:15 ` Alan Stern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.