Re: [RFT 2/5] xhci: Don't write zeroed pointers to xHC registers.

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

 



2012/3/17 Sarah Sharp <sarah.a.sharp@xxxxxxxxxxxxxxx>:
> When xhci_mem_cleanup() is called, we can't be sure if the xHC is
> actually halted.  We can ask the xHC to halt by writing to the RUN bit
> in the command register, but that might timeout due to a HW hang.
>
> If the host controller is still running, we should not write zeroed
> values to the event ring dequeue pointers or base tables, the DCBAA
> pointers, or the command ring pointers.  Eric Fu reports his VIA VL800
> host accesses the event ring pointers after a failed register restore on
> resume from suspend.  The hypothesis is that the host never actually
> halted before the register write to change the event ring pointer to
> zero.
>
> Remove all writes of zeroed values to pointer registers in
> xhci_mem_cleanup().  Instead, make all callers of the function reset the
> host controller first, which will reset those registers to zero.
> xhci_mem_init() is the only caller that doesn't first halt and reset the
> host controller before calling xhci_mem_cleanup().
>

This patch is ok. After adding it the hibernate operation is ok. And the
suspend operation is still failed. The integrated 2.0 hub can't be
re-enumerated.

The hibernate operation log:

[   62.984568] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro,commit=0
[   64.269097] PM: Marking nosave pages: 000000000009f000 - 0000000000100000
[   64.269143] PM: Basic memory bitmaps created
[   64.269167] PM: Syncing filesystems ... done.
[   64.417483] Freezing user space processes ... (elapsed 0.01 seconds) done.
[   64.433904] PM: Preallocating image memory... done (allocated 152582 pages)
[   64.487882] PM: Allocated 610328 kbytes in 0.05 seconds (12206.56 MB/s)
[   64.487916] Freezing remaining freezable tasks ... (elapsed 0.01
seconds) done.
[   64.501920] Suspending console(s) (use no_console_suspend to debug)
[   64.502076] sd 0:0:1:0: [sda] Synchronizing SCSI cache
[   64.502150] xhci_hcd 0000:01:00.0: WARN Event TRB for slot 2 ep 3
with no TDs queued?
[   64.502259] xhci_hcd 0000:01:00.0: WARN Event TRB for slot 2 ep 2
with no TDs queued?
[   64.502368] xhci_hcd 0000:01:00.0: WARN Event TRB for slot 2 ep 0
with no TDs queued?
[   64.621617] PM: freeze of devices complete after 119.751 msecs
[   64.622023] PM: late freeze of devices complete after 0.400 msecs
[   64.622411] ACPI: Preparing to enter system sleep state S4
[   64.622768] PM: Saving platform NVS memory
[   64.622794] Disabling non-boot CPUs ...
[   64.725627] CPU 1 is now offline
[   64.829476] CPU 2 is now offline
[   64.830558] Broke affinity for irq 12
[   64.830575] Broke affinity for irq 19
[   64.933409] CPU 3 is now offline
[   64.933834] PM: Creating hibernation image:
[   64.956014] PM: Need to copy 151426 pages
[   64.956016] PM: Normal pages needed: 52668 + 1024, available pages: 174512
[   64.933857] PM: Restoring platform NVS memory
[   64.934249] Enabling non-boot CPUs ...
[   64.934321] Booting Node 0 Processor 1 APIC 0x4
[   64.934322] smpboot cpu 1: start_ip = 9b000
[   64.944477] Initializing CPU#1
[   64.945367] Calibrating delay loop (skipped) already calibrated this CPU
[   64.965964] CPU1 is up
[   64.966169] Booting Node 0 Processor 2 APIC 0x1
[   64.966170] smpboot cpu 2: start_ip = 9b000
[   64.976328] Initializing CPU#2
[   64.977215] Calibrating delay loop (skipped) already calibrated this CPU
[   64.997920] CPU2 is up
[   64.998010] Booting Node 0 Processor 3 APIC 0x5
[   64.998012] smpboot cpu 3: start_ip = 9b000
[   65.008170] Initializing CPU#3
[   65.009057] Calibrating delay loop (skipped) already calibrated this CPU
[   65.029686] CPU3 is up
[   65.032037] ACPI: Waking up from system sleep state S4
[   65.033125] PM: early restore of devices complete after 0.672 msecs
[   65.058144] i915 0000:00:02.0: setting latency timer to 64
[   65.058148] uhci_hcd 0000:00:1a.0: setting latency timer to 64
[   65.058167] usb usb1: root hub lost power or was reset
[   65.058170] uhci_hcd 0000:00:1a.1: setting latency timer to 64
[   65.058178] uhci_hcd 0000:00:1a.2: setting latency timer to 64
[   65.058183] ehci_hcd 0000:00:1a.7: setting latency timer to 64
[   65.058190] usb usb2: root hub lost power or was reset
[   65.058200] usb usb3: root hub lost power or was reset
[   65.058207] uhci_hcd 0000:00:1d.0: setting latency timer to 64
[   65.058212] uhci_hcd 0000:00:1d.1: setting latency timer to 64
[   65.058233] usb usb4: root hub lost power or was reset
[   65.058237] usb usb5: root hub lost power or was reset
[   65.058245] uhci_hcd 0000:00:1d.2: setting latency timer to 64
[   65.058252] ehci_hcd 0000:00:1d.7: setting latency timer to 64
[   65.058266] snd_hda_intel 0000:00:1b.0: irq 44 for MSI/MSI-X
[   65.058268] usb usb6: root hub lost power or was reset
[   65.058273] pci 0000:00:1e.0: setting latency timer to 64
[   65.058289] usb usb9: root hub lost power or was reset
[   65.058290] usb usb10: root hub lost power or was reset
[   65.058323] usb usb7: root hub lost power or was reset
[   65.062219] ehci_hcd 0000:00:1a.7: cache line size of 64 is not supported
[   65.062340] xhci_hcd 0000:01:00.0: irq 42 for MSI/MSI-X
[   65.062393] usb usb8: root hub lost power or was reset
[   65.066279] ehci_hcd 0000:00:1d.7: cache line size of 64 is not supported
[   65.066305] ata_piix 0000:00:1f.2: setting latency timer to 64
[   65.066327] ata_piix 0000:00:1f.5: setting latency timer to 64
[   65.396102] ata4: SATA link down (SStatus 0 SControl 300)
[   65.401492] usb 9-1: reset high-speed USB device number 2 using xhci_hcd
[   65.406750] ata3: SATA link down (SStatus 0 SControl 300)
[   65.417768] xhci_hcd 0000:01:00.0: xHCI xhci_drop_endpoint called
with disabled ep eddf8e00
[   65.529704] usb 10-1: reset SuperSpeed USB device number 2 using xhci_hcd
[   65.545997] xhci_hcd 0000:01:00.0: xHCI xhci_drop_endpoint called
with disabled ep f150d060
[   65.546002] xhci_hcd 0000:01:00.0: xHCI xhci_drop_endpoint called
with disabled ep f150d08c
[   65.715948] ata2.00: SATA link down (SStatus 0 SControl 300)
[   65.715959] ata2.01: SATA link down (SStatus 0 SControl 300)
[   65.861247] ata1.00: SATA link down (SStatus 0 SControl 300)
[   65.861260] ata1.01: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[   65.877275] ata1.01: ACPI cmd ef/03:45:00:00:00:b0 (SET FEATURES)
filtered out
[   65.877282] ata1.01: ACPI cmd ef/03:45:00:00:00:b0 (SET FEATURES)
filtered out
[   65.877288] ata1.01: ACPI cmd ef/03:0c:00:00:00:b0 (SET FEATURES)
filtered out
[   65.893518] ata1.01: configured for UDMA/133
[   65.893856] sd 0:0:1:0: [sda] Starting disk
[   65.903872] PM: restore of devices complete after 846.471 msecs
[   65.939293] PM: Image restored successfully.
[   65.940713] Restarting tasks ... done.
[   65.944491] PM: Basic memory bitmaps freed
[   66.000522] r8169 0000:03:00.0: eth0: link down
[   66.000528] r8169 0000:03:00.0: eth0: link down
[   66.000671] ADDRCONF(NETDEV_UP): eth0: link is not ready
[   66.334675] psmouse serio1: hgpk: ID: 10 00 50
[   66.839409] EXT4-fs (sda2): re-mounted. Opts: errors=remount-ro,commit=0
[   67.554972] r8169 0000:03:00.0: eth0: link up
[   67.555151] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   67.952070] xhci_hcd 0000:01:00.0: WARN Event TRB for slot 1 ep 0
with no TDs queued?
[   78.505906] eth0: no IPv6 routers present
[   80.706403] r8169 0000:03:00.0: eth0: link down


> Signed-off-by: Sarah Sharp <sarah.a.sharp@xxxxxxxxxxxxxxx>
> Reported-by: Elric Fu <elricfu1@xxxxxxxxx>
> ---
>  drivers/usb/host/xhci-mem.c |    9 ++-------
>  1 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 383fc85..4c1e721 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -1690,11 +1690,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
>        int i;
>
>        /* Free the Event Ring Segment Table and the actual Event Ring */
> -       if (xhci->ir_set) {
> -               xhci_writel(xhci, 0, &xhci->ir_set->erst_size);
> -               xhci_write_64(xhci, 0, &xhci->ir_set->erst_base);
> -               xhci_write_64(xhci, 0, &xhci->ir_set->erst_dequeue);
> -       }
>        size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries);
>        if (xhci->erst.entries)
>                dma_free_coherent(&pdev->dev, size,
> @@ -1706,7 +1701,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
>        xhci->event_ring = NULL;
>        xhci_dbg(xhci, "Freed event ring\n");
>
> -       xhci_write_64(xhci, 0, &xhci->op_regs->cmd_ring);
>        if (xhci->cmd_ring)
>                xhci_ring_free(xhci, xhci->cmd_ring);
>        xhci->cmd_ring = NULL;
> @@ -1735,7 +1729,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
>        xhci->medium_streams_pool = NULL;
>        xhci_dbg(xhci, "Freed medium stream array pool\n");
>
> -       xhci_write_64(xhci, 0, &xhci->op_regs->dcbaa_ptr);
>        if (xhci->dcbaa)
>                dma_free_coherent(&pdev->dev, sizeof(*xhci->dcbaa),
>                                xhci->dcbaa, xhci->dcbaa->dma);
> @@ -2344,6 +2337,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
>
>  fail:
>        xhci_warn(xhci, "Couldn't initialize memory\n");
> +       xhci_halt(xhci);
> +       xhci_reset(xhci);
>        xhci_mem_cleanup(xhci);
>        return -ENOMEM;
>  }
> --
> 1.7.9
>
--
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