Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933204Ab1C3WMy (ORCPT ); Wed, 30 Mar 2011 18:12:54 -0400 Received: from mga09.intel.com ([134.134.136.24]:16640 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933113Ab1C3VF7 (ORCPT ); Wed, 30 Mar 2011 17:05:59 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.63,270,1299484800"; d="scan'208";a="727132736" From: Andi Kleen References: <20110330203.501921634@firstfloor.org> In-Reply-To: <20110330203.501921634@firstfloor.org> To: stern@rowland.harvard.edu, ak@linux.intel.com, Larry.Finger@lwfinger.net, david-b@pacbell.net, gregkh@suse.de, linux-kernel@vger.kernel.org, stable@kernel.org, tim.bird@am.sony.com Subject: [PATCH] [22/275] USB: EHCI: fix DMA deallocation bug Message-Id: <20110330210416.D30183E1A05@tassilo.jf.intel.com> Date: Wed, 30 Mar 2011 14:04:16 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2897 Lines: 77 2.6.35-longterm review patch. If anyone has any objections, please let me know. ------------------ From: Alan Stern commit f75593ceaa08e6d27aec1a5de31cded19e850dd1 upstream. 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 Signed-off-by: Andi Kleen Tested-by: Larry Finger CC: David Brownell Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ehci-hcd.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) Index: linux-2.6.35.y/drivers/usb/host/ehci-hcd.c =================================================================== --- linux-2.6.35.y.orig/drivers/usb/host/ehci-hcd.c 2011-03-29 23:02:58.277344248 -0700 +++ linux-2.6.35.y/drivers/usb/host/ehci-hcd.c 2011-03-29 23:02:58.672334141 -0700 @@ -544,6 +544,8 @@ ehci->iaa_watchdog.function = ehci_iaa_watchdog; ehci->iaa_watchdog.data = (unsigned long) ehci; + hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); + /* * hw default: 1K periodic list heads, one per frame. * periodic_size can shrink by USBCMD update if hcc_params allows. @@ -551,11 +553,20 @@ ehci->periodic_size = DEFAULT_I_TDPS; INIT_LIST_HEAD(&ehci->cached_itd_list); INIT_LIST_HEAD(&ehci->cached_sitd_list); + + if (HCC_PGM_FRAMELISTLEN(hcc_params)) { + /* periodic schedule size can be smaller than default */ + switch (EHCI_TUNE_FLS) { + case 0: ehci->periodic_size = 1024; break; + case 1: ehci->periodic_size = 512; break; + case 2: ehci->periodic_size = 256; break; + default: BUG(); + } + } if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0) return retval; /* controllers may cache some of the periodic schedule ... */ - hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); if (HCC_ISOC_CACHE(hcc_params)) // full frame cache ehci->i_thresh = 2 + 8; else // N microframes cached @@ -604,12 +615,6 @@ /* periodic schedule size can be smaller than default */ temp &= ~(3 << 2); temp |= (EHCI_TUNE_FLS << 2); - switch (EHCI_TUNE_FLS) { - case 0: ehci->periodic_size = 1024; break; - case 1: ehci->periodic_size = 512; break; - case 2: ehci->periodic_size = 256; break; - default: BUG(); - } } ehci->command = temp; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/