Re: [PATCH] usb: power off devices at shutdown

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

 



Hello,

sorry for late but I was waiting while launchpad compile new kernel
with this patch.
Now I tested it and works fine. Same result as with my patch (usb
mouse is not light after computer shutdown).

2010/9/3 Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>:
> On Thu, 2 Sep 2010, [UTF-8] Pali Rohár wrote:
>
>> Hello,
>>
>> I have motherboard Gigabyte GA-K8NF-9-RH with Nvidia nForce 4 chipset.
>> Here Is output from lspci:
>
> Thanks.  Okay, here is a patch for you to test instead of the patch you
> have been using.  Let me know how it works out.
>
> Alan Stern
>
>
>
> Index: usb-2.6/drivers/usb/core/hcd-pci.c
> ===================================================================
> --- usb-2.6.orig/drivers/usb/core/hcd-pci.c
> +++ usb-2.6/drivers/usb/core/hcd-pci.c
> @@ -329,8 +329,10 @@ void usb_hcd_pci_shutdown(struct pci_dev
>                return;
>
>        if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) &&
> -                       hcd->driver->shutdown)
> +                       hcd->driver->shutdown) {
>                hcd->driver->shutdown(hcd);
> +               pci_disable_device(dev);
> +       }
>  }
>  EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown);
>
> Index: usb-2.6/drivers/usb/host/ohci-hcd.c
> ===================================================================
> --- usb-2.6.orig/drivers/usb/host/ohci-hcd.c
> +++ usb-2.6/drivers/usb/host/ohci-hcd.c
> @@ -398,7 +398,14 @@ ohci_shutdown (struct usb_hcd *hcd)
>
>        ohci = hcd_to_ohci (hcd);
>        ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
> -       ohci_usb_reset (ohci);
> +       ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
> +
> +       /* If the SHUTDOWN quirk is set, don't put the controller in RESET */
> +       ohci->hc_control &= (ohci->flags & OHCI_QUIRK_SHUTDOWN) ?
> +                       OHCI_CTRL_RWC | OHCI_CTRL_HCFS :
> +                       OHCI_CTRL_RWC;
> +       ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
> +
>        /* flush the writes */
>        (void) ohci_readl (ohci, &ohci->regs->control);
>  }
> Index: usb-2.6/drivers/usb/host/ohci-pci.c
> ===================================================================
> --- usb-2.6.orig/drivers/usb/host/ohci-pci.c
> +++ usb-2.6/drivers/usb/host/ohci-pci.c
> @@ -201,6 +201,20 @@ static int ohci_quirk_amd700(struct usb_
>        return 0;
>  }
>
> +/* nVidia controllers continue to drive Reset signalling on the bus
> + * even after system shutdown, wasting power.  This flag tells the
> + * shutdown routine to leave the controller OPERATIONAL instead of RESET.
> + */
> +static int ohci_quirk_nvidia_shutdown(struct usb_hcd *hcd)
> +{
> +       struct ohci_hcd *ohci = hcd_to_ohci(hcd);
> +
> +       ohci->flags |= OHCI_QUIRK_SHUTDOWN;
> +       ohci_dbg(ohci, "enabled nVidia shutdown quirk\n");
> +
> +       return 0;
> +}
> +
>  /*
>  * The hardware normally enables the A-link power management feature, which
>  * lets the system lower the power consumption in idle states.
> @@ -332,6 +346,10 @@ static const struct pci_device_id ohci_p
>                PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4399),
>                .driver_data = (unsigned long)ohci_quirk_amd700,
>        },
> +       {
> +               PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
> +               .driver_data = (unsigned long) ohci_quirk_nvidia_shutdown,
> +       },
>
>        /* FIXME for some of the early AMD 760 southbridges, OHCI
>         * won't work at all.  blacklist them.
> Index: usb-2.6/drivers/usb/host/ohci.h
> ===================================================================
> --- usb-2.6.orig/drivers/usb/host/ohci.h
> +++ usb-2.6/drivers/usb/host/ohci.h
> @@ -403,6 +403,7 @@ struct ohci_hcd {
>  #define        OHCI_QUIRK_HUB_POWER    0x100                   /* distrust firmware power/oc setup */
>  #define        OHCI_QUIRK_AMD_ISO      0x200                   /* ISO transfers*/
>  #define        OHCI_QUIRK_AMD_PREFETCH 0x400                   /* pre-fetch for ISO transfer */
> +#define        OHCI_QUIRK_SHUTDOWN     0x800                   /* nVidia power bug */
>        // there are also chip quirks/bugs in init logic
>
>        struct work_struct      nec_work;       /* Worker for NEC quirk */
> Index: usb-2.6/drivers/usb/host/pci-quirks.c
> ===================================================================
> --- usb-2.6.orig/drivers/usb/host/pci-quirks.c
> +++ usb-2.6/drivers/usb/host/pci-quirks.c
> @@ -169,6 +169,7 @@ static int __devinit mmio_resource_enabl
>  static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
>  {
>        void __iomem *base;
> +       u32 control;
>
>        if (!mmio_resource_enabled(pdev, 0))
>                return;
> @@ -177,10 +178,14 @@ static void __devinit quirk_usb_handoff_
>        if (base == NULL)
>                return;
>
> +       control = readl(base + OHCI_CONTROL);
> +
>  /* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
> -#ifndef __hppa__
> -{
> -       u32 control = readl(base + OHCI_CONTROL);
> +#ifdef __hppa__
> +#define        OHCI_CTRL_MASK          (OHCI_CTRL_RWC | OHCI_CTRL_IR)
> +#else
> +#define        OHCI_CTRL_MASK          OHCI_CTRL_RWC
> +
>        if (control & OHCI_CTRL_IR) {
>                int wait_time = 500; /* arbitrary; 5 seconds */
>                writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
> @@ -194,13 +199,12 @@ static void __devinit quirk_usb_handoff_
>                        dev_warn(&pdev->dev, "OHCI: BIOS handoff failed"
>                                        " (BIOS bug?) %08x\n",
>                                        readl(base + OHCI_CONTROL));
> -
> -               /* reset controller, preserving RWC */
> -               writel(control & OHCI_CTRL_RWC, base + OHCI_CONTROL);
>        }
> -}
>  #endif
>
> +       /* reset controller, preserving RWC (and possibly IR) */
> +       writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL);
> +
>        /*
>         * disable interrupts
>         */
>
>



-- 
Pali Rohár
pali.rohar@xxxxxxxxx
��.n��������+%������w��{.n�����{���)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥



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

  Powered by Linux