diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2011-01-06 10:17:09 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-01-22 21:36:43 -0500 |
commit | f75593ceaa08e6d27aec1a5de31cded19e850dd1 (patch) | |
tree | 884e842e5ad6dbfd8035f8615106936d68c48a30 /drivers/usb/host/ehci-hcd.c | |
parent | 06f1b9715c324589b42be69ad33422b83bd42f02 (diff) |
USB: EHCI: fix DMA deallocation bug
This patch (as1440) fixes a bug in ehci-hcd. ehci->periodic_size is
used to compute the size in a dma_alloc_coherent() call, but then it
gets changed later on. As a result, the corresponding call to
dma_free_coherent() passes a different size from the original
allocation. Fix the problem by adjusting ehci->periodic_size before
carrying out any of the memory allocations.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Larry Finger <Larry.Finger@lwfinger.net>
CC: David Brownell <david-b@pacbell.net>
CC: <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/ehci-hcd.c')
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 6fee3cd58efe..74dcf49bd015 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -572,6 +572,8 @@ static int ehci_init(struct usb_hcd *hcd) | |||
572 | ehci->iaa_watchdog.function = ehci_iaa_watchdog; | 572 | ehci->iaa_watchdog.function = ehci_iaa_watchdog; |
573 | ehci->iaa_watchdog.data = (unsigned long) ehci; | 573 | ehci->iaa_watchdog.data = (unsigned long) ehci; |
574 | 574 | ||
575 | hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); | ||
576 | |||
575 | /* | 577 | /* |
576 | * hw default: 1K periodic list heads, one per frame. | 578 | * hw default: 1K periodic list heads, one per frame. |
577 | * periodic_size can shrink by USBCMD update if hcc_params allows. | 579 | * periodic_size can shrink by USBCMD update if hcc_params allows. |
@@ -579,11 +581,20 @@ static int ehci_init(struct usb_hcd *hcd) | |||
579 | ehci->periodic_size = DEFAULT_I_TDPS; | 581 | ehci->periodic_size = DEFAULT_I_TDPS; |
580 | INIT_LIST_HEAD(&ehci->cached_itd_list); | 582 | INIT_LIST_HEAD(&ehci->cached_itd_list); |
581 | INIT_LIST_HEAD(&ehci->cached_sitd_list); | 583 | INIT_LIST_HEAD(&ehci->cached_sitd_list); |
584 | |||
585 | if (HCC_PGM_FRAMELISTLEN(hcc_params)) { | ||
586 | /* periodic schedule size can be smaller than default */ | ||
587 | switch (EHCI_TUNE_FLS) { | ||
588 | case 0: ehci->periodic_size = 1024; break; | ||
589 | case 1: ehci->periodic_size = 512; break; | ||
590 | case 2: ehci->periodic_size = 256; break; | ||
591 | default: BUG(); | ||
592 | } | ||
593 | } | ||
582 | if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0) | 594 | if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0) |
583 | return retval; | 595 | return retval; |
584 | 596 | ||
585 | /* controllers may cache some of the periodic schedule ... */ | 597 | /* controllers may cache some of the periodic schedule ... */ |
586 | hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); | ||
587 | if (HCC_ISOC_CACHE(hcc_params)) // full frame cache | 598 | if (HCC_ISOC_CACHE(hcc_params)) // full frame cache |
588 | ehci->i_thresh = 2 + 8; | 599 | ehci->i_thresh = 2 + 8; |
589 | else // N microframes cached | 600 | else // N microframes cached |
@@ -637,12 +648,6 @@ static int ehci_init(struct usb_hcd *hcd) | |||
637 | /* periodic schedule size can be smaller than default */ | 648 | /* periodic schedule size can be smaller than default */ |
638 | temp &= ~(3 << 2); | 649 | temp &= ~(3 << 2); |
639 | temp |= (EHCI_TUNE_FLS << 2); | 650 | temp |= (EHCI_TUNE_FLS << 2); |
640 | switch (EHCI_TUNE_FLS) { | ||
641 | case 0: ehci->periodic_size = 1024; break; | ||
642 | case 1: ehci->periodic_size = 512; break; | ||
643 | case 2: ehci->periodic_size = 256; break; | ||
644 | default: BUG(); | ||
645 | } | ||
646 | } | 651 | } |
647 | if (HCC_LPM(hcc_params)) { | 652 | if (HCC_LPM(hcc_params)) { |
648 | /* support link power management EHCI 1.1 addendum */ | 653 | /* support link power management EHCI 1.1 addendum */ |