Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7042927ybi; Thu, 13 Jun 2019 08:36:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiCMg4JuZYkCRNzV0SEhvRx1rzMgM95DJr3/wsJEJPEih3iIIPCva4BKViXxcdKody38pn X-Received: by 2002:a17:90a:2ec2:: with SMTP id h2mr6252119pjs.119.1560440206376; Thu, 13 Jun 2019 08:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560440206; cv=none; d=google.com; s=arc-20160816; b=hl9pyvm8moOO9MtWQlRK0d31sbptZry5rp/mSoSbZrEATdtLa62I0af5ACq9JvAvDV 22IiO0kYGEo6oTzg4ru1YDyhMiaRCJFwFk4AAXREtw+WqyCoWitJ/fga0JMTHAA0+Y4g OO5i0akEJig9cblLpiXBksevUKwyZr6krGlML1Apo1IdWHzKuKfZnMCWs3JytJQwLaAs hwRQwY+iUuTXf/7LLhgopRRWDUfC7sjmfwBVlic2FvNe5g4Xm6YVscj4PzZPRWekQvY0 F03PdPcs6ORjuPfUhebtAgPTl05BlvZ9HoWrsI82oyhwX1UwLyspNb5/V5RzvRVWNYo8 stKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Vuv52ikaQl9FNxe7Grc1QmJNkLezlunK4+d/SAHXwuo=; b=uIDH/5Z6rF6mKl65xwGX7t7JqL4FgVoE023jcd0ww+5Jd7+PVFHxAM91KHcBWjvTsI MgY2Zm36BEXW7BFDlcl1LIqI6QA4MsWZyR7baL7ytEv2d+wiZp8i98/sJ0JmAAOvt0Ix BNsZEutnGzW8ydci29Tvp/Q5bpvPskYFw9UmGcwGtqjeRDbvVX66Dh+gGcPrkCnZv48U Bs4nfd/Mcl+uIhLFrTfcT/pYKlYUc3QgE3UCm8E0kyyIwnyWEJPWWsLZ1gOhgAMhgqwb 8/Wn4WvvRJGXQ6LB2FeM2AayyWJC0xdsW/wpc1ZlwsSwLclX1OwvId9BLGCuGYylhvpC A7LQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s12si85400pgv.158.2019.06.13.08.36.30; Thu, 13 Jun 2019 08:36:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727150AbfFMPeZ (ORCPT + 99 others); Thu, 13 Jun 2019 11:34:25 -0400 Received: from pio-pvt-msa1.bahnhof.se ([79.136.2.40]:43990 "EHLO pio-pvt-msa1.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727200AbfFMPeX (ORCPT ); Thu, 13 Jun 2019 11:34:23 -0400 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 279A73F7C1; Thu, 13 Jun 2019 17:34:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 tagged_above=-999 required=6.31 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=ham autolearn_force=no Received: from pio-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xRpvJaXI_Z3q; Thu, 13 Jun 2019 17:34:15 +0200 (CEST) Received: from localhost (h-41-252.A163.priv.bahnhof.se [46.59.41.252]) (Authenticated sender: mb547485) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 07A5E3F70B; Thu, 13 Jun 2019 17:34:14 +0200 (CEST) Date: Thu, 13 Jun 2019 17:34:14 +0200 From: Fredrik Noring To: Guenter Roeck Cc: laurentiu.tudor@nxp.com, hch@lst.de, stern@rowland.harvard.edu, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, marex@denx.de, leoyang.li@nxp.com, linux-kernel@vger.kernel.org, robin.murphy@arm.com, JuergenUrban@gmx.de Subject: Re: [PATCH v7 3/5] usb: host: ohci-sm501: init genalloc for local memory Message-ID: <20190613153414.GA909@sx9> References: <20190529102843.13174-1-laurentiu.tudor@nxp.com> <20190529102843.13174-4-laurentiu.tudor@nxp.com> <20190605214622.GA22254@roeck-us.net> <20190611133223.GA30054@roeck-us.net> <20190611172654.GA2602@sx9> <20190611190343.GA18459@roeck-us.net> <20190613134033.GA2489@sx9> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Guenter, > Thanks for the confirmation. Do you see the problem only with the > ohci-sm501 driver or also with others ? All are likely affected, but it depends, because I believe the problem is that the USB subsystem runs out of memory. Please try the attached patch! The pool assumed 4096 byte page alignment for every allocation, which is excessive given that many requests are for 16 and 32 bytes. In the patch below, I have turned down the order to 5, which is good enough for the ED and TD structures of the OHCI, but not enough for the HCCA that needs 256 byte alignment. With some luck, the WARN_ON_ONCE will not trigger in your test, though. If it does, you may try to increase the order from 5 to 8. I have observed strange things happen when the USB subsystem runs out of memory. The mass storage drivers often seem to busy-wait on -ENOMEM, consuming a lot of processor resources. It would be much more efficient to sleep waiting for memory to become available. In your case I suspect that allocation failures are not correctly attributed. Certain kinds of temporary freezes may also occur, as the various devices are reset due to host memory allocation errors. Fredrik diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -3011,7 +3011,7 @@ int usb_hcd_setup_local_mem(struct usb_hcd *hcd, phys_addr_t phys_addr, int err; void __iomem *local_mem; - hcd->localmem_pool = devm_gen_pool_create(hcd->self.sysdev, PAGE_SHIFT, + hcd->localmem_pool = devm_gen_pool_create(hcd->self.sysdev, 5, dev_to_node(hcd->self.sysdev), dev_name(hcd->self.sysdev)); if (IS_ERR(hcd->localmem_pool)) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -517,6 +517,7 @@ static int ohci_init (struct ohci_hcd *ohci) GFP_KERNEL); if (!ohci->hcca) return -ENOMEM; + WARN_ON_ONCE(ohci->hcca_dma & 0xff); if ((ret = ohci_mem_init (ohci)) < 0) ohci_stop (hcd);