From patchwork Mon May 6 03:01:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bo Shen X-Patchwork-Id: 241551 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E33632C00E9 for ; Mon, 6 May 2013 13:02:12 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3D0104A24B; Mon, 6 May 2013 05:02:10 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lbYkPm2LNYpG; Mon, 6 May 2013 05:02:10 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 02E424A243; Mon, 6 May 2013 05:02:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3448F4A243 for ; Mon, 6 May 2013 05:02:01 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JONkfZiwpL1N for ; Mon, 6 May 2013 05:01:55 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=SKIP(-1.5) (only DNSBL check requested) Received: from DVREDG01.corp.atmel.com (nasmtp01.atmel.com [192.199.1.245]) by theia.denx.de (Postfix) with ESMTPS id D6A694A242 for ; Mon, 6 May 2013 05:01:53 +0200 (CEST) Received: from apsmtp01.atmel.com (10.168.254.30) by DVREDG01.corp.atmel.com (10.42.103.30) with Microsoft SMTP Server (TLS) id 14.2.342.3; Sun, 5 May 2013 21:01:49 -0600 Received: from PENCHT02.corp.atmel.com (10.168.5.162) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server (TLS) id 14.2.342.3; Mon, 6 May 2013 11:01:39 +0800 Received: from [10.217.2.118] (10.168.5.13) by cas-ap.atmel.com (10.168.5.162) with Microsoft SMTP Server (TLS) id 14.2.342.3; Mon, 6 May 2013 11:01:45 +0800 Message-ID: <51871D17.8070201@atmel.com> Date: Mon, 6 May 2013 11:01:43 +0800 From: Bo Shen User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: Marek Vasut References: <51832F55.4030409@atmel.com> <201305031540.52128.marex@denx.de> In-Reply-To: <201305031540.52128.marex@denx.de> X-Originating-IP: [10.168.5.13] Cc: "u-boot@lists.denx.de" , wei.zhang@freescale.com Subject: Re: [U-Boot] Question: issues for usb keyboard work with OHCI HCD X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Hi Marek, On 5/3/2013 21:40, Marek Vasut wrote: > Dear Bo Shen, > >> Hi All, >> Now, I test usb host support with Atmel boards, for example, >> at91sam9x5ek board. >> >> When test OHCI USB host with usb keyboard. I meet the following issue. >> --->8--- >> U-Boot 2013.04-dirty (May 03 2013 - 11:00:34) >> >> CPU: AT91SAM9G35 >> Crystal frequency: 12 MHz >> CPU clock : 400 MHz >> Master clock : 133.333 MHz >> DRAM: 128 MiB >> WARNING: Caches not enabled >> NAND: 256 MiB >> MMC: mci: 0 >> In: serial >> Out: serial >> Err: serial >> Net: macb0 >> Hit any key to stop autoboot: 0 >> U-Boot> usb start >> (Re)start USB... >> USB0: scanning bus 0 for devices... 2 USB Device(s) found >> scanning usb for storage devices... 0 Storage Device(s) found >> U-Boot> setenv stdin usbkbd >> U-Boot> ERROR: sohci_submit_job: ENOMEM >> ERROR: sohci_submit_job failed >> ... ... >> (repeat to print these two error line) > > So the USB subsystem is leaking memory? Or do you only have too small MALLOC > area? I am not sure whether USB subsystem is leaking memory. I am digging it. This issue is not relative with MALLOC area. This issue come out when all ptd[i].usb_dev (the maximum value of i is 64) is not NULL. Each time to call td_alloc, it will check whether ptd[i].usb_dev is NULL (i from 0 to 63), if not find one of ptd[i].usb_dev is NULL, then report ENOMEM. >> ---<8--- >> >> After dig the usb ohci-hcd.c driver, I found every time it call >> submit_int_msg --> >> submit_common_msg --> sohci_submit_job, it will allocate memory for td >> (just call td_alloc), >> however nowhere free the td. So, after allocate 64 times (#define NUM_TD >> 64), >> all the ptd[i].usb_dev is not NULL. So, it will report: ENOMEM. >> >> I don't know why in sohci_return_job it call td_submit_job again? Any advice for this question? >> --->8--- >> static inline int sohci_return_job(struct ohci *hc, urb_priv_t *urb) >> { >> struct ohci_regs *regs = hc->regs; >> >> switch (usb_pipetype(urb->pipe)) { >> case PIPE_INTERRUPT: >> /* implicitly requeued */ >> if (urb->dev->irq_handle && >> (urb->dev->irq_act_len = urb->actual_length)) { >> ohci_writel(OHCI_INTR_WDH, ®s->intrenable); >> ohci_readl(®s->intrenable); /* PCI posting flush */ >> urb->dev->irq_handle(urb->dev); >> ohci_writel(OHCI_INTR_WDH, ®s->intrdisable); >> ohci_readl(®s->intrdisable); /* PCI posting flush */ >> } >> urb->actual_length = 0; >> td_submit_job( >> urb->dev, >> urb->pipe, >> urb->transfer_buffer, >> urb->transfer_buffer_length, >> NULL, >> urb, >> urb->interval); >> break >> ---<8--- >> Add where should we free the allocated td to fix the issue? If I comment the td_submit_job and add urb_free_priv(urb) here, then usb keyboard work properly. It looks like --->8--- urb->dev, urb->pipe, @@ -524,6 +525,8 @@ static inline int sohci_return_job(struct ohci *hc, urb_priv_t *urb) NULL, urb, urb->interval); +#endif + urb_free_priv(urb); ---<8--- >> Thanks. >> >> Best Regards, >> Bo Shen > > Best regards, > Marek Vasut > Best Regards, Bo Shen diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 9f47351..cc60bc5 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -516,6 +516,7 @@ static inline int sohci_return_job(struct ohci *hc, urb_priv_t *urb) ohci_readl(®s->intrdisable); /* PCI posting flush */ } urb->actual_length = 0; +#if 0 td_submit_job(