Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3716847pxu; Sun, 11 Oct 2020 21:47:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7P91EhD+TDtZwmiildiU4gUWM9/ymfYh7q4X2DR/rtShW4wa5nasIsE0fyOC2hnxvfeNu X-Received: by 2002:a05:6402:1c10:: with SMTP id ck16mr12425357edb.7.1602478023051; Sun, 11 Oct 2020 21:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602478023; cv=none; d=google.com; s=arc-20160816; b=muktxgvCxb/meNrSZd3Cf7uQ21cVZ9k5uJlVbH3S4gnPmBWYNYfgRKQ/QJ79L9VJic FBU+emk6btIxdVMKNi4uiyikKZhSwWPjmfV61Whjby9tDhT6stQ4W4bQOzo8bTop7QTx 8B52Dp/EiobqQLz4uSeMxC/ZcSkHUwesGCsVE2rUw3PhjRZkmTzRAzz3TfO8LSY35OlY zEgb0hUf126+WL0vPwQNk3i9v2U0cOhkATOUwAjGYYyAAV4kTpEekk1A4rliSaaWbKnX vlti1/4TJr4UcVhrzEiAWsgKLtXOE8IlOcbuEyHKTHkH6dECkFw2FoWZy5gkdWLwK1Ck 9nAQ== 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=rVlzw0xV6zqey3LDvj5hp1S2KjxFNPrcrdWD0WERQ6c4acjcH6rHGzEPB+/kp23Gem CO0dtyvLjbNQPyJvaWmvPN2kUNDYeMqSLviuuQIvrMLJ4yn9Hf+IoLiZXFp3YzxyUhiY Z/Y01zhg6FP6KAeppznWCKwPzLGDvSMbX2rIT0h4Oxu9rapkuadQ4MrEAXNCOKjL3K2O H80ln7N9nLml1WZor7OZYYjkRbhNz00MhM05jSKtZ5rcV4ThZhKgTNIkDKiEE6wiDTiR LePk4BiEZggwRjycR+cCW0vP/n+jAGvde6JIBFB3TLiBC41HciJCwDnbAZ17KOTZ9DIk +R8Q== 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 i11si12630361edl.230.2020.10.11.21.46.40; Sun, 11 Oct 2020 21:47:03 -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 S1728627AbgJLEjD (ORCPT + 99 others); Mon, 12 Oct 2020 00:39:03 -0400 Received: from mga14.intel.com ([192.55.52.115]:21586 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbgJLEjB (ORCPT ); Mon, 12 Oct 2020 00:39:01 -0400 IronPort-SDR: J+/e1WApMFmwmET8zE6zrm94CMbO3V1IBz6en65+JqXfRj4i/z1IEFlGfo+rtUogbfY/jNVkYx iTQD2DV9jTSg== X-IronPort-AV: E=McAfee;i="6000,8403,9771"; a="164903161" X-IronPort-AV: E=Sophos;i="5.77,365,1596524400"; d="scan'208";a="164903161" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2020 21:39:00 -0700 IronPort-SDR: JMAeJETwynV2MMoKSA82+2DXavPx+w7D0/6KiPwWV+zPyatPooW6W5vxaG+ex9vffwHtr1qcNP dKYepDZU4Cug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,365,1596524400"; d="scan'208";a="313321265" Received: from unknown (HELO jsia-HP-Z620-Workstation.png.intel.com) ([10.221.118.135]) by orsmga003.jf.intel.com with ESMTP; 11 Oct 2020 21:38:59 -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 03/15] dmaengine: dw-axi-dmac: move dma_pool_create() to alloc_chan_resources() Date: Mon, 12 Oct 2020 12:21:48 +0800 Message-Id: <20201012042200.29787-4-jee.heng.sia@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20201012042200.29787-1-jee.heng.sia@intel.com> References: <20201012042200.29787-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