Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp33326ybi; Thu, 13 Jun 2019 11:06:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7wHwMoLJlTTT3eIl8BFfMpdyIt3JgziixNOBBhuCniYlUU6dp+FRQndfTwHDDZNmgueD4 X-Received: by 2002:a63:4e07:: with SMTP id c7mr32200982pgb.350.1560449207030; Thu, 13 Jun 2019 11:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560449207; cv=none; d=google.com; s=arc-20160816; b=02tFw3UJ2h9rglYtdDwq5MQPcv/75WVnPBdJMGctqcigpflrG/qhwlC6vqOEjXV0Tb C46ZBI7ffeec1WpubmvcjMrhyTTL7reroKmGwfiuTxxUEr4opCXbeGPlsfxU8CQb/kNu HqsrZ+348s574ZOH9MqZJRp5/GQckD+ZmqvkX3kPzk9KAI6u0IrKLmzJGCOzi7W0CwSI USHxhDL7AJ0kpMiXMlli+rEdX8ficRqVMuQXs+myFvuinXT8xsNEINQYMj7YhVK1lP6L VdLiNgksfXpumJF4I2sLu+dwGXQib0ysc/0msZWrdgwBQcqGANWVKOb32gqVrA8e51GR 3CtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=6EdW1zQmAAxK0Wa2ppkGhsrx4V+WLwXRsMm+jl3+ewo=; b=j0b+IFfOZiXSa1MfiZr72fXpDSxmaqs2zJLMDLd+AyA8oxaLzBqiZLentPuCyGgeVj vTmcVmlbCt5WLcrcTN0N9mRZkn1k3e7xUdUU+Eaw+gEnoWBLeSgEPHmpQEyEljwvprEw p8KrqWyhCJxy53WfnGCKyVxaGpKIQ8YRQ3c5P/Hd7o01F47CGtNYB7wpT1if27kadUvW A539HPqxp4lewLNVeeRvycZQ8aljtGUCEJ4f92TaFtVrfZiwL4y2Ot3St7SaZF2afd1/ KHAMOC14NGCHXDsp/wm1FDapcbwKZCClF6Y2E65zAM9doDGMycjdiijnHLZ/AUBmJfFE fgfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CY4EEIKX; 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 j9si346807pgf.439.2019.06.13.11.06.30; Thu, 13 Jun 2019 11:06:47 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CY4EEIKX; 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 S1727179AbfFMSFq (ORCPT + 99 others); Thu, 13 Jun 2019 14:05:46 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38361 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbfFMSFp (ORCPT ); Thu, 13 Jun 2019 14:05:45 -0400 Received: by mail-pg1-f193.google.com with SMTP id v11so11387411pgl.5; Thu, 13 Jun 2019 11:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=6EdW1zQmAAxK0Wa2ppkGhsrx4V+WLwXRsMm+jl3+ewo=; b=CY4EEIKXVyaEX9Q2YU2gGkUHWd0Pp+IvLWSb6NtU47cM2RbPyozw/YKui7GvEIcwXu HKkMgmbcBo1EaMxgNpnwOvJZ6rOOjaKXtTQDMI18ftK6UlsiXnX69m3EuC4g+DFjMEP8 /Y5jh4IvbkOXkTlRmwSGNP92wjUu191GVcrBMWSmso443/L3e96pZUErlVAOEZLit1tu 71LtfO2NSARBP+p6M9M6EryIuIBu3VhwHn7lqcexvjPCcNB7rzothPlLhXbadTR04wqT z7t9JiGqQKfncKIS0AxAEC+07IoUXybdLqMag/zqJROoNbpYwOTXOWl6Hy8i2X1DyHWS VWcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6EdW1zQmAAxK0Wa2ppkGhsrx4V+WLwXRsMm+jl3+ewo=; b=B329nxDxhP8B7FCzNqdtX7Jedvy47klGNjcJI+FLEqUs2xT9T5+M3qD8mebSUR0OJP xaT/CD4tqj7SMl3ChawQp0RGOh+LSBpkqZpedlrbgSl5xwQn2zVhs4w7YFWALDRZDkrb nSHaIgOEVtES1i9GLWS5yR8vbIgV6/TfhQEwi8Af4Gf3Sz5uN7fjg0f9DxGGsQU90G6v 02iGAC9PxHFGg9s6i9BQUZ9VaKTrYf5zFC6sh7smxrnoiQKz+K/BJiiRjbAi5K/At5eS mT1uP63aKFNVUEqULfLGgLT4CKwqXbsBWIIXs0sUDXXpvCwcOuRSawkJwmBulhS7PIam ssQw== X-Gm-Message-State: APjAAAX3bPM22rkAsv20az3oxmpOUW75etHs8vh5jQzWnJPD6cHFHEBG zE0fE33+qSgFpB2rdU8aZ3w= X-Received: by 2002:a17:90a:2648:: with SMTP id l66mr6718507pje.65.1560449144861; Thu, 13 Jun 2019 11:05:44 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id 16sm343780pfo.65.2019.06.13.11.05.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 11:05:43 -0700 (PDT) Subject: Re: [PATCH v7 3/5] usb: host: ohci-sm501: init genalloc for local memory To: Fredrik Noring 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 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> <20190613153414.GA909@sx9> From: Guenter Roeck Message-ID: <3f2164cd-7655-b7cc-ec57-d8751886728c@roeck-us.net> Date: Thu, 13 Jun 2019 11:05:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190613153414.GA909@sx9> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/13/19 8:34 AM, Fredrik Noring wrote: > 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. > You are right, the patch below fixes the problem. I did not get the warning with order==5. Nevertheless, I also tested with order==8; that works as well. Thanks a lot for tracking this down! Guenter > 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); >