Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1383873pxx; Tue, 27 Oct 2020 15:52:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7p1Ib+ihAGprIHEPjzYPByMQVbONl+4P8/Rin5BqrdDstfOksz19zk3FtJ6A4V9D1tRWm X-Received: by 2002:aa7:ccd9:: with SMTP id y25mr4486125edt.375.1603839127940; Tue, 27 Oct 2020 15:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603839127; cv=none; d=google.com; s=arc-20160816; b=FM/iY5cWUc7fXeWs6/H1SMlEwFVH8n214xes77efwqikSXaYEKrijXZXzaLyNmczET BxH0Jgrsz0nIez3gwn37dttGqV+xTe0rj5FrYz8nP5hg4k8yH/cQQs/Nir//xG1IlWKm Fr2Mh+iyR1PUwKKu496qf70QmYtzJL9xVHLr8HDtMiNZEBnm9opx4hpk/2F2wzUAbg7A iDOJGSDwIxbm1b8Y8jWKMywM6yQFgjVuQdOpMvuqTIlf8VTFvq0k3yhmdp/sp3LQT1Vx RdmaC6Yo5vrqdRr7rRkSSToLbwIypH/X0286lMliRCJUaEXZL8KYdv+tAwzdIAvu4H99 x6cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=+EB3Ba+YB3WB7q0gxrMbSI/6yRWQyRgWwykAJcRMukA=; b=q24okaf6Vun8VAm6QvQgel26zP3zyO8bH5z8TrmpDxQlWhvRJVpd+5Y3xGFIoKfUMf WEKkjCJOAPpMTr1KYjZFAo0+liub9JKnqAG0dVsTWoJRcShjAZUXPY5n/rlAuYlpgLnF zFzAPfdxQKEzhhyxTg/v/EDfWbMfOpOCHoVkXiwhewT0CYRYBCTITySbpngbF0iCBE6k buNaY/cgZuic9YDpT/uoczcG0ViBLh0oIUsbhJtYMsKJTKge06U9jW6NY7p10A5SLMKs nQmszmxbdl2EOuRDkYESKhNwHWfqY7oQvK2PkvqoB2sDkDgyOgfw94bhUQ+ZPlDNHLA2 NFKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q10si2137303eji.291.2020.10.27.15.51.45; Tue, 27 Oct 2020 15:52:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2506896AbgJ0Gz0 (ORCPT + 99 others); Tue, 27 Oct 2020 02:55:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:42071 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504346AbgJ0GzZ (ORCPT ); Tue, 27 Oct 2020 02:55:25 -0400 IronPort-SDR: cKN6qzWOLs+5yjJ3Zz4PQilfal2iadaUDDi5Ne+uqM8EulQeh+2vPBoAtZTc7VNHm9uxC6NH7w YuaKwsieEhCg== X-IronPort-AV: E=McAfee;i="6000,8403,9786"; a="155004144" X-IronPort-AV: E=Sophos;i="5.77,422,1596524400"; d="scan'208";a="155004144" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2020 23:55:25 -0700 IronPort-SDR: Fi5OQQC70PvgoQk9EHdtsqxXjQGrV+YrGjgAPvr0UY36IuN7W562/k2T71cCtLqpUSJRFSyMrz ExGI3Lu3R3Kg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,422,1596524400"; d="scan'208";a="350175848" Received: from jsia-hp-z620-workstation.png.intel.com ([10.221.118.135]) by orsmga008.jf.intel.com with ESMTP; 26 Oct 2020 23:55:23 -0700 From: Sia Jee Heng To: vkoul@kernel.org, Eugeniy.Paltsev@synopsys.com Cc: andriy.shevchenko@linux.intel.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 03/15] dmaengine: dw-axi-dmac: move dma_pool_create() to alloc_chan_resources() Date: Tue, 27 Oct 2020 14:38:46 +0800 Message-Id: <20201027063858.4877-4-jee.heng.sia@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201027063858.4877-1-jee.heng.sia@intel.com> References: <20201027063858.4877-1-jee.heng.sia@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The DMA memory block is created at driver load time and exist for device lifetime. Move the dma_pool_create() to the ->chan_resource() callback function allowing the DMA memory blocks to be created as needed and destroyed when the channel is freed. Reviewed-by: Andy Shevchenko Signed-off-by: Sia Jee Heng --- .../dma/dw-axi-dmac/dw-axi-dmac-platform.c | 24 ++++++++++--------- drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c index 8cfd645479e1..46e2ba978e20 100644 --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c @@ -216,11 +216,10 @@ static struct axi_dma_desc *axi_desc_alloc(u32 num) static struct axi_dma_lli *axi_desc_get(struct axi_dma_chan *chan, dma_addr_t *addr) { - struct dw_axi_dma *dw = chan->chip->dw; struct axi_dma_lli *lli; dma_addr_t phys; - lli = dma_pool_zalloc(dw->desc_pool, GFP_NOWAIT, &phys); + lli = dma_pool_zalloc(chan->desc_pool, GFP_NOWAIT, &phys); if (unlikely(!lli)) { dev_err(chan2dev(chan), "%s: not enough descriptors available\n", axi_chan_name(chan)); @@ -236,14 +235,13 @@ static struct axi_dma_lli *axi_desc_get(struct axi_dma_chan *chan, static void axi_desc_put(struct axi_dma_desc *desc) { struct axi_dma_chan *chan = desc->chan; - struct dw_axi_dma *dw = chan->chip->dw; int count = atomic_read(&chan->descs_allocated); struct axi_dma_hw_desc *hw_desc; int descs_put; for (descs_put = 0; descs_put < count; descs_put++) { hw_desc = &desc->hw_desc[descs_put]; - dma_pool_free(dw->desc_pool, hw_desc->lli, hw_desc->llp); + dma_pool_free(chan->desc_pool, hw_desc->lli, hw_desc->llp); } kfree(desc->hw_desc); @@ -360,6 +358,15 @@ static int dma_chan_alloc_chan_resources(struct dma_chan *dchan) return -EBUSY; } + /* LLI address must be aligned to a 64-byte boundary */ + chan->desc_pool = dma_pool_create(dev_name(chan2dev(chan)), + chan->chip->dev, + sizeof(struct axi_dma_lli), + 64, 0); + if (!chan->desc_pool) { + dev_err(chan2dev(chan), "No memory for descriptors\n"); + return -ENOMEM; + } dev_vdbg(dchan2dev(dchan), "%s: allocating\n", axi_chan_name(chan)); pm_runtime_get(chan->chip->dev); @@ -381,6 +388,8 @@ static void dma_chan_free_chan_resources(struct dma_chan *dchan) vchan_free_chan_resources(&chan->vc); + dma_pool_destroy(chan->desc_pool); + chan->desc_pool = NULL; dev_vdbg(dchan2dev(dchan), "%s: free resources, descriptor still allocated: %u\n", axi_chan_name(chan), atomic_read(&chan->descs_allocated)); @@ -896,13 +905,6 @@ static int dw_probe(struct platform_device *pdev) if (ret) return ret; - /* Lli address must be aligned to a 64-byte boundary */ - dw->desc_pool = dmam_pool_create(KBUILD_MODNAME, chip->dev, - sizeof(struct axi_dma_lli), 64, 0); - if (!dw->desc_pool) { - dev_err(chip->dev, "No memory for descriptors dma pool\n"); - return -ENOMEM; - } INIT_LIST_HEAD(&dw->dma.channels); for (i = 0; i < hdata->nr_channels; i++) { diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h index 41e775e6e593..f886b2bb75de 100644 --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h @@ -39,6 +39,7 @@ struct axi_dma_chan { u8 id; atomic_t descs_allocated; + struct dma_pool *desc_pool; struct virt_dma_chan vc; struct axi_dma_desc *desc; @@ -49,7 +50,6 @@ struct axi_dma_chan { struct dw_axi_dma { struct dma_device dma; struct dw_axi_dma_hcfg *hdata; - struct dma_pool *desc_pool; /* channels */ struct axi_dma_chan *chan; -- 2.18.0