Re: [PATCH v3 1/2] USB: Try MSI first before line IRQ for Intel PCIe USB3 HCD

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/11/2012 04:17 PM, Alex,Shi wrote:
>> Since this device ID is not used by anyone, you'd better put it in xhci
>> driver.
> 
> how about to move to xhci_pci.c file as following new patch

This looks better.

>>
>> And I don't think PCI_DEVICE_ID_INTEL_USB_XHCI is a good enough name -
>> are you sure all the Intel xHCI host controllers will share the same PCI
>> device ID?
> 
> I don't have better name for it. :( 

Perhaps you can use the chipset name. For example, panther point? :)

Thanks,
Andiry

> Maybe Sarah can bring a better one. Anyway we can change it when new
> device appears. 
> 
> =============
>>From 7b77bc2f18784c98f0cfa18b535d53e858e4a671 Mon Sep 17 00:00:00 2001
> From: Alex Shi <alex.shi@xxxxxxxxx>
> Date: Wed, 11 Jan 2012 11:13:44 +0800
> Subject: [PATCH v3 1/2] USB: Try MSI first before line IRQ for Intel PCIe USB3 HCD
> 
> We have a PCI USB xhci host controller on a new platform. It have no
> line IRQ definition in BIOS. So the Linux driver refuses to initial this
> controller. But Windows works well for it depending on MSI.
> 
> Actually, Linux also can work for MSI. This patch skips the first line
> IRQ checking for our HCD in usb-core pci probe, then try to enable MSI
> firstly. That make this HCD works well under Linux.
> 
> Thanks for Sarah's suggestion and review for this patch.
> 
> Signed-off-by: Alex Shi <alex.shi@xxxxxxxxx>
> ---
>  drivers/usb/core/hcd-pci.c  |    3 ++-
>  drivers/usb/core/hcd.c      |    8 ++++++--
>  drivers/usb/host/xhci-pci.c |    9 +++++++++
>  drivers/usb/host/xhci.c     |    5 +++++
>  include/linux/usb/hcd.h     |    1 +
>  5 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
> index a004db3..266ea2f 100644
> --- a/drivers/usb/core/hcd-pci.c
> +++ b/drivers/usb/core/hcd-pci.c
> @@ -187,7 +187,8 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  		return -ENODEV;
>  	dev->current_state = PCI_D0;
>  
> -	if (!dev->irq) {
> +	/* skip irq check if hcd wants MSI firstly. */
> +	if (!(driver->flags & HCD_MSI_FIRST) && !dev->irq) {
>  		dev_err(&dev->dev,
>  			"Found HC with no IRQ.  Check BIOS/PCI %s setup!\n",
>  			pci_name(dev));
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 13222d3..9dd8098 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -2466,8 +2466,12 @@ int usb_add_hcd(struct usb_hcd *hcd,
>  			&& device_can_wakeup(&hcd->self.root_hub->dev))
>  		dev_dbg(hcd->self.controller, "supports USB remote wakeup\n");
>  
> -	/* enable irqs just before we start the controller */
> -	if (usb_hcd_is_primary_hcd(hcd)) {
> +	/* enable irqs just before we start the controller. But Intel USB3
> +	 * hcd can't do this here on some platform, they will do it in
> +	 * following driver->start();
> +	 */
> +	if (usb_hcd_is_primary_hcd(hcd) &&
> +			!(hcd->driver->flags & HCD_MSI_FIRST)) {
>  		retval = usb_hcd_request_irqs(hcd, irqnum, irqflags);
>  		if (retval)
>  			goto err_request_irq;
> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> index ef98b38..b5b12de 100644
> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -33,6 +33,9 @@
>  #define PCI_VENDOR_ID_ETRON		0x1b6f
>  #define PCI_DEVICE_ID_ASROCK_P67	0x7023
>  
> +/* Device need skip line irq check */
> +#define PCI_DEVICE_ID_INTEL_USB_XHCI	0x1e31
> +
>  static const char hcd_name[] = "xhci_hcd";
>  
>  /* called after powerup, by probe or system-pm "wakeup" */
> @@ -136,6 +139,12 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
>  	struct usb_hcd *hcd;
>  
>  	driver = (struct hc_driver *)id->driver_data;
> +
> +	/* stop line IRQ checking in xhci_hcd_pci_probe. */
> +	if (dev->vendor == PCI_VENDOR_ID_INTEL &&
> +			dev->device == PCI_DEVICE_ID_INTEL_USB_XHCI)
> +		driver->flags |= HCD_MSI_FIRST;
> +
>  	/* Register the USB 2.0 roothub.
>  	 * FIXME: USB core must know to register the USB 2.0 roothub first.
>  	 * This is sort of silly, because we could just set the HCD driver flags
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index a1afb7c..05cf62d 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -352,6 +352,11 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd)
>  		/* hcd->irq is -1, we have MSI */
>  		return 0;
>  
> +	if (!pdev->irq) {
> +		xhci_err(xhci, "No msi-x/msi found and no IRQ in BIOS\n");
> +		return -EINVAL;
> +	}
> +
>  	/* fall back to legacy interrupt*/
>  	ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED,
>  			hcd->irq_descr, hcd);
> diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
> index 03354d5..ea1637b 100644
> --- a/include/linux/usb/hcd.h
> +++ b/include/linux/usb/hcd.h
> @@ -212,6 +212,7 @@ struct hc_driver {
>  #define	HCD_MEMORY	0x0001		/* HC regs use memory (else I/O) */
>  #define	HCD_LOCAL_MEM	0x0002		/* HC needs local memory */
>  #define	HCD_SHARED	0x0004		/* Two (or more) usb_hcds share HW */
> +#define	HCD_MSI_FIRST	0x0008		/* Try to get MSI first, PCI only */
>  #define	HCD_USB11	0x0010		/* USB 1.1 */
>  #define	HCD_USB2	0x0020		/* USB 2.0 */
>  #define	HCD_USB3	0x0040		/* USB 3.0 */


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux