Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6443206yba; Tue, 14 May 2019 07:39:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMIXvycSydcujuPHQtrPutklQD6eoIdUQyunyW/FFw0KvrXgFy9zUd3/Xw5sLiScUe/tfy X-Received: by 2002:a62:2706:: with SMTP id n6mr4151597pfn.150.1557844792007; Tue, 14 May 2019 07:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557844791; cv=none; d=google.com; s=arc-20160816; b=LL/Rb33jlkwrQt9eCa0gi/qekTwuFPR6aLSMmnrm1l3ZN7GHPNV8rOj0OVxbJUXFuY NmYPKUJv7TkSBpwj29vCzjfTwCLIz+M/4NU7aVxygCgwajd7cSrbUzgEYur9CgeV4fsr OyKthN1yt17WnrsxHlYJYqvNKBM2Q2El5L115nGLiR/gAmPvXRyLO4jfjUDzW5TMFE/F bTXsNrGRGTSME2CDybX7QKIi5E9koywrZYJstmgkN6hwWTsaY0hNLtuXoMVPixRuwms1 pNtfKZCQG3ZJUzjA10YSL9bmi3xWyo20qQ7qYln7R+7lYhanUupuLrxiYGF7Ox+jln87 hzvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=92hQdxNeKWuRTIddlvAP6Y7aZH3efXefOJPe60tMTwc=; b=i6EVHoCNPOAQe8fThMsuR5qniO1XhJ1hEtYtHyJ2NEQb4FX0fxHB1I6K6OFn4RiuXP 0Dko21NUo6QnoeMNDRHHlCNUZaWMwneV2xH6UX5LMuxfRqa0vTEMKjear6R+kh5i7zC2 O+JxSxHQB5B8MCC2UuQP3D+5mPK1t7k9uKWjbP2SmSdyAvNrIlBz7dvUsHveOJr5xrjM 6NBvAUWGLvA4+CCyh0txoJwpi+dusc3bEwssLjzS8PJYR0Ga70ThRwJFkK4Mt8SQRHsz GDS71TZ6ic9qpFXHOq1LJamkncmca1009KJAZJR4JdR28ByWFBfT6DKdhJgfTeKgf3Ue LP/g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c193si20884130pga.6.2019.05.14.07.39.34; Tue, 14 May 2019 07:39:51 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726429AbfENOiS (ORCPT + 99 others); Tue, 14 May 2019 10:38:18 -0400 Received: from inva020.nxp.com ([92.121.34.13]:49652 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbfENOiO (ORCPT ); Tue, 14 May 2019 10:38:14 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id BDB961A0125; Tue, 14 May 2019 16:38:12 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id B1A931A00C2; Tue, 14 May 2019 16:38:12 +0200 (CEST) Received: from fsr-ub1864-101.ea.freescale.net (fsr-ub1864-101.ea.freescale.net [10.171.82.13]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 2190E2061C; Tue, 14 May 2019 16:38:12 +0200 (CEST) From: laurentiu.tudor@nxp.com To: hch@lst.de, stern@rowland.harvard.edu, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, marex@denx.de Cc: leoyang.li@nxp.com, linux-kernel@vger.kernel.org, robin.murphy@arm.com, Laurentiu Tudor Subject: [RFC PATCH v2 3/3] usb: host: ohci-tmio: init genalloc for local memory Date: Tue, 14 May 2019 17:38:07 +0300 Message-Id: <20190514143807.7745-4-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190514143807.7745-1-laurentiu.tudor@nxp.com> References: <20190514143807.7745-1-laurentiu.tudor@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Laurentiu Tudor In preparation for dropping the existing "coherent" dma mem declaration APIs, replace the current dma_declare_coherent_memory() based mechanism with the creation of a genalloc pool that will be used in the OHCI subsystem as replacement for the DMA APIs. For context, see thread here: https://lkml.org/lkml/2019/4/22/357 Signed-off-by: Laurentiu Tudor --- drivers/usb/host/ohci-tmio.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c index f88a0370659f..34869382618f 100644 --- a/drivers/usb/host/ohci-tmio.c +++ b/drivers/usb/host/ohci-tmio.c @@ -30,6 +30,7 @@ #include #include #include +#include /*-------------------------------------------------------------------------*/ @@ -224,11 +225,6 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev) goto err_ioremap_regs; } - ret = dma_declare_coherent_memory(&dev->dev, sram->start, sram->start, - resource_size(sram)); - if (ret) - goto err_dma_declare; - if (cell->enable) { ret = cell->enable(dev); if (ret) @@ -239,6 +235,20 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev) ohci = hcd_to_ohci(hcd); ohci_hcd_init(ohci); + hcd->localmem_pool = devm_gen_pool_create(&dev->dev, PAGE_SHIFT, + dev_to_node(&dev->dev), + "ohci-sm501"); + if (IS_ERR(hcd->localmem_pool)) { + ret = PTR_ERR(hcd->localmem_pool); + goto err_enable; + } + ret = gen_pool_add_virt(hcd->localmem_pool, sram->start, sram->start, + resource_size(sram), dev_to_node(&dev->dev)); + if (ret < 0) { + dev_err(&dev->dev, "failed to add to pool: %d\n", ret); + goto err_enable; + } + ret = usb_add_hcd(hcd, irq, 0); if (ret) goto err_add_hcd; @@ -254,8 +264,6 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev) if (cell->disable) cell->disable(dev); err_enable: - dma_release_declared_memory(&dev->dev); -err_dma_declare: iounmap(hcd->regs); err_ioremap_regs: iounmap(tmio->ccr); @@ -276,7 +284,6 @@ static int ohci_hcd_tmio_drv_remove(struct platform_device *dev) tmio_stop_hc(dev); if (cell->disable) cell->disable(dev); - dma_release_declared_memory(&dev->dev); iounmap(hcd->regs); iounmap(tmio->ccr); usb_put_hcd(hcd); -- 2.17.1