Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp517483yba; Thu, 16 May 2019 04:51:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8438TNA3h6DjZg+KzzBlxzT46N5wMC5n8EUlgrqJszvLGNdP1ao17dpfoPC+HEGszxUiz X-Received: by 2002:a63:c50c:: with SMTP id f12mr49471943pgd.71.1558007513056; Thu, 16 May 2019 04:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558007513; cv=none; d=google.com; s=arc-20160816; b=vjheNfQZ5HE3T+Tf/G5kiM+DKn+WrT9KjbAikIJxxoN5z1Tg5PQ/sL0/Gkp98C8yz/ jYcsI6q3bN+B4b3364o+NEX1xig/O/1FQ23IVF3dQjcaBBOaT19kHdGiASOA7QR/zf9H pA89cuCAe3kKktkCR/bwHwV/Hs85Faxc6fTbQs08tSwYgrB0tIqVJnhUBXQPDgH6lrny GkH1nQ3YP0gLB69s/QbNcL0wmwQn0Gdt46s5uBKtUW68wwHvLb5xl0QWiHz7ArQPkYDT hydjgOCIW6QH2UwjBDvnBUR7WvgwmbSXob33XfPAGJ6w6vbt1Fz75o1V59x2vzOtmg1a UANg== 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=pqJR0bJWiOUUW9arh7AzaYgd9F7ryo9hpvsWGDqQPks=; b=DKCjKrxztOlzV7ATKH5oKmcXrLACqUOzAcgZNL7mrzUPD45gNMJcxM3Z6xSwYShTNZ gQIE2XJjOHAzbm1qWQJiclTIYI5RNj2VLW/2ZkIxbvzzhytbVAltRfmNeqvfLaL6IPCd yO2VwHm5pwX6neCW01G03ncW66QC1ZOCggHeeJMD5nngAuPdhLhCL3gaZQsG+YIwg85g Uc5+PO2veT1LvmmFdpMpahgdX32Ji8rr35tzMZ5/8GBA7mUeycPX4s/zkmKl95rWoHyi oKIJmSRblIbOLMUgRGo01rbPpG24tpxfsLkQ8JMI3hy63N7bnz2haHtnIAN3eSb9IegT BO7g== 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 l62si4677658pga.434.2019.05.16.04.51.37; Thu, 16 May 2019 04:51:53 -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 S1728633AbfEPLuA (ORCPT + 99 others); Thu, 16 May 2019 07:50:00 -0400 Received: from inva021.nxp.com ([92.121.34.21]:44416 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727659AbfEPLt7 (ORCPT ); Thu, 16 May 2019 07:49:59 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id A77782001F2; Thu, 16 May 2019 13:49:56 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 998B7200061; Thu, 16 May 2019 13:49:56 +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 19A7F205CD; Thu, 16 May 2019 13:49:56 +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, noring@nocrew.org, JuergenUrban@gmx.de, Laurentiu Tudor Subject: [PATCH v4 3/3] usb: host: ohci-tmio: init genalloc for local memory Date: Thu, 16 May 2019 14:47:21 +0300 Message-Id: <20190516114721.27694-4-laurentiu.tudor@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190516114721.27694-1-laurentiu.tudor@nxp.com> References: <20190516114721.27694-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 | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c index f88a0370659f..1c39099b9870 100644 --- a/drivers/usb/host/ohci-tmio.c +++ b/drivers/usb/host/ohci-tmio.c @@ -30,6 +30,7 @@ #include #include #include +#include /*-------------------------------------------------------------------------*/ @@ -188,6 +189,7 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev) struct resource *config = platform_get_resource(dev, IORESOURCE_MEM, 1); struct resource *sram = platform_get_resource(dev, IORESOURCE_MEM, 2); int irq = platform_get_irq(dev, 0); + void __iomem *local_mem; struct tmio_hcd *tmio; struct ohci_hcd *ohci; struct usb_hcd *hcd; @@ -224,11 +226,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 +236,28 @@ 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; + } + + local_mem = devm_ioremap(&dev->dev, sram->start, resource_size(sram)); + if (!local_mem) { + ret = -ENOMEM; + goto err_enable; + } + + ret = gen_pool_add_virt(hcd->localmem_pool, (unsigned long)local_mem, + 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 +273,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 +293,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