Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3547728pxb; Mon, 16 Nov 2020 18:43:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4Gkk9y8FdxJz8ui6yV/9OQUxyV3tl0nAY0xp44hnqabORD7w5wA7UL7w7aS3aPnVXPu6d X-Received: by 2002:aa7:d5d7:: with SMTP id d23mr18945764eds.203.1605581013099; Mon, 16 Nov 2020 18:43:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605581013; cv=none; d=google.com; s=arc-20160816; b=OcsZxHg1TWClPaSbpVSXFqmtzsHzVG8Qs5AYB48QYIwFJQhQoQzyTg2R5nTFOP5NXA dh2ojhXjCxTr6XMHwVcyuuf3CyR1i/DWm226VB+Fu2XwBQ9td2z8cEatsL76Ecij3d9u 3lqBxen8K2MS/+i+51k6gXZOITtJRpZKLj4Yu5Ry9ueBTGahRMRthDwVVCn5lpw9VQKa qbk0Cx/QgLxanCVAOfswOQF7Cqhev3J7/MRSqXed15OZddIs3WHUV9gjdd5rOnbBaPcK g0TaZ3QChx25jgLAMIUpHtqACR/ZUtn8bztQBRQAX4q69KuehUACw0u26UzD9ofcwIqz Hv+g== 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=OcqhWwgnEhc98P4Ef24ZELh1DQ9hnxNT8nPbJnkiufWNFSKFEGsN5o0diJjkuCD93R FpNpFgWTEaHokUjJET0yiGJnhTR/ef3sAkqLHa7vqj0+5TdAy27bC6KkDc2cIsGlASs0 6N2oV2XjtGx+jBX4J1ex4ZegveNOY017ZLCj9ED3JvbSkOuMGrjWwtQtRe1YUU1dcJwE K6pIASv39v5PLzdwFrFZYFIgDYcQhSKPT/uSsoDD02DY7fC+hsKwjn92sFASzo3j7iYb v0BOx74HSzmQRsu14LbPHX7EwFS+UrxgG4vSxLY5d2kr6l1x54IMBI5aDcqcsc+jTXYP TnqA== 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 c19si12222059ejz.274.2020.11.16.18.43.10; Mon, 16 Nov 2020 18:43:33 -0800 (PST) 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 S1727132AbgKQCiu (ORCPT + 99 others); Mon, 16 Nov 2020 21:38:50 -0500 Received: from mga04.intel.com ([192.55.52.120]:52551 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgKQCit (ORCPT ); Mon, 16 Nov 2020 21:38:49 -0500 IronPort-SDR: jlvb8hmDI4+YsURTzD+84pVAGiv8akxqms/8itHC1+uCTu5q94BkLAvs7rrm9ORIHGRam40es/ C8y5bpZKXcdw== X-IronPort-AV: E=McAfee;i="6000,8403,9807"; a="168274051" X-IronPort-AV: E=Sophos;i="5.77,484,1596524400"; d="scan'208";a="168274051" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Nov 2020 18:38:48 -0800 IronPort-SDR: /kMa6frJSHrSq6HbJDRUjU0LOBlZIG1U/uAbKBm0XUBMFxakOu3+58jjo2pu0J+8JvzNnLCcU0 Y1QmPKEL07oQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,484,1596524400"; d="scan'208";a="358706038" Received: from jsia-hp-z620-workstation.png.intel.com ([10.221.118.135]) by fmsmga004.fm.intel.com with ESMTP; 16 Nov 2020 18:38:46 -0800 From: Sia Jee Heng To: vkoul@kernel.org, Eugeniy.Paltsev@synopsys.com, robh+dt@kernel.org Cc: andriy.shevchenko@linux.intel.com, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v4 03/15] dmaengine: dw-axi-dmac: move dma_pool_create() to alloc_chan_resources() Date: Tue, 17 Nov 2020 10:22:03 +0800 Message-Id: <20201117022215.2461-4-jee.heng.sia@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201117022215.2461-1-jee.heng.sia@intel.com> References: <20201117022215.2461-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