Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6447512yba; Tue, 14 May 2019 07:44:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1qM3bckQAz6h2je68vgUhDRxpPEnetitX/UDOGVu6tVzl/BUck9d+C8VX1b+V6opqrI/F X-Received: by 2002:a63:fb02:: with SMTP id o2mr37449287pgh.357.1557845066081; Tue, 14 May 2019 07:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557845066; cv=none; d=google.com; s=arc-20160816; b=KK0xGszzDrpuzKyRp+UedgT7bGLWyh1nHm/HBnh96Bx2nDwq6kr21M/iYIc4Z8DDvK MYlvDlk7tAOHQogI3SaRH6qmuywZSm6QH2BbmEHQ4j6zuHbxuCXKXun8kjc6/HvKEELf IGYU7Y3p4BP4q6quU2D5rlzWDMBN5Nqr2X0tSl65n8xNls9+A3B4GsITZ0lvoxkMEBYO xMSWvQaDN9s6iStkLOhA9Jc7NVLJJ49/uDjoLnjEPnWqAvNNdwmDRNq1iISmaIiAMY8O HtFqgbjl6pyj1nbsgw1B2AFCXWHZ1HtDwIx3M9xIWOO5DZTSm0qWkZf3ZRsGka/Nes06 5bog== 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=4UjiEqC+YHjgaJqYjPLbRUvNJ2vGKlwZKfMwScBEdoE=; b=kJut7Bfjnr4+vV1V5ALosibvpvZpdocVwBCuM/fp3pFy3rk7WhIjTdweIsjky1nU3w LnpbVml28exNQAjR/KiSDbRjooFhn0n1rNHojP+ew3vrnqjQV0KYLCsqU5TPk0mG8FP5 S8YtmoZrGS+e3ctkGwBnviOHx7VQaYBO+TYfsr2Ik7MxVZBbXT6fzmk/jYZ04ARgTTYM rbBogAb/wxt/6tbBDXIau8EBh5bIzUIBSG6LHAC6ggyu6b0gVE4JX0s7x/k5zUdSgvmF suNhctt2gVboKul70GgJsD33Z+B9UbG3ZUejgNNdYbLhPg+bMZOOfd4tQX4XGLt8FQL3 DvDg== 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 r185si20322812pgr.10.2019.05.14.07.44.10; Tue, 14 May 2019 07:44:26 -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 S1726515AbfENOmb (ORCPT + 99 others); Tue, 14 May 2019 10:42:31 -0400 Received: from verein.lst.de ([213.95.11.211]:46209 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbfENOmb (ORCPT ); Tue, 14 May 2019 10:42:31 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id 7826268B05; Tue, 14 May 2019 16:42:10 +0200 (CEST) Date: Tue, 14 May 2019 16:42:10 +0200 From: Christoph Hellwig To: laurentiu.tudor@nxp.com Cc: 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 Subject: Re: [RFC PATCH v2 1/3] USB: use genalloc for USB HCs with local memory Message-ID: <20190514144210.GA14625@lst.de> References: <20190514143807.7745-1-laurentiu.tudor@nxp.com> <20190514143807.7745-2-laurentiu.tudor@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190514143807.7745-2-laurentiu.tudor@nxp.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > @@ -136,6 +137,10 @@ void *hcd_buffer_alloc( > if (size <= pool_max[i]) > return dma_pool_alloc(hcd->pool[i], mem_flags, dma); > } > + > + if (hcd->driver->flags & HCD_LOCAL_MEM) > + return gen_pool_dma_alloc(hcd->localmem_pool, size, dma); I think this check needs to be before the above code to use the dma pools, as we should always use the HCD local memory. Probably all the way up just below the size == 0 check, that way we can also remove the other HCD_LOCAL_MEM check. > @@ -165,5 +170,10 @@ void hcd_buffer_free( > return; > } > } > - dma_free_coherent(hcd->self.sysdev, size, addr, dma); > + > + if (hcd->driver->flags & HCD_LOCAL_MEM) > + gen_pool_free(hcd->localmem_pool, (unsigned long)addr, > + size); > + else > + dma_free_coherent(hcd->self.sysdev, size, addr, dma); Same here. > @@ -505,8 +506,15 @@ static int ohci_init (struct ohci_hcd *ohci) > timer_setup(&ohci->io_watchdog, io_watchdog_func, 0); > ohci->prev_frame_no = IO_WATCHDOG_OFF; > > - ohci->hcca = dma_alloc_coherent (hcd->self.controller, > - sizeof(*ohci->hcca), &ohci->hcca_dma, GFP_KERNEL); > + if (hcd->driver->flags & HCD_LOCAL_MEM) > + ohci->hcca = gen_pool_dma_alloc(hcd->localmem_pool, > + sizeof(*ohci->hcca), > + &ohci->hcca_dma); > + else > + ohci->hcca = dma_alloc_coherent(hcd->self.controller, > + sizeof(*ohci->hcca), > + &ohci->hcca_dma, > + GFP_KERNEL); I wonder if we could just use hcd_buffer_alloc/free here, althought that would require them to be exported. I'll leave that decision to the relevant maintainers, though. Except for this the series looks exactly what I had envisioned to get rid of the device local dma_declare_coherent use case, thanks!