From patchwork Thu May 31 05:55:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 137320 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6180085lji; Wed, 30 May 2018 22:56:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI8LmyuhlDb1WwchBguBf08y5cC/TVL1mDBKEa3K0mfemq5sNRTfn046VNZiif5KJjf3I7Q X-Received: by 2002:a63:65c2:: with SMTP id z185-v6mr2889238pgb.163.1527746199672; Wed, 30 May 2018 22:56:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527746199; cv=none; d=google.com; s=arc-20160816; b=OwT9xAvdmqaxL2YMn6HbRd1YZP2q2PEsL9jFiRzIeaH5d9gICEUBIY1+TgVh0rONGc UFYCYY1yYvz1nxKNF0gHXPqQtxpnKW4ymx9atYchNZccrTzL7pfKK2nRUCfSBrHD4uoL mg5FVOuqPRX8lZ8G6R4s6J080E5E1hW1+yLeKif2MI1u8i2lrqBqB5OkJnrH9+2WzWmC 8SEGOVK3sJc4BGzpbf9H5D/+SJRYK8h/buO4We0wT+TSyeNm2pTDWC6UdkF6z6yqB0uR 8CQCileqzn8wIelDSopFOLdi88n3fZ+VoiL2ka1X+QMwZd2y70bYUEfoshnfiRG+Jk6p mK1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=LfqECe6/ajDViZPg7Vvp8PjmW1ok+SW0S6pF7ygIRDQ=; b=khwFCO4zdNtNWQ7DrA7bu7rhe50g3yzuJYPFZSWG48kIf13vA3SwewVGXDrQR6vZZ1 +/vlUa6UGyZ/Q8abuhibBHGWQTNGtgWoexiZjY/X9yN6AwgzZKCuK0rRYuibHW3lCywD MkVEQoHkMLDMKCAY0bVD9bWyTR8YeM0NP0IRAObSnDwul1frN4my7RBQU0gkEul1GaFq Mr4iatdWDmIA3Nq1ywjcFS7AeLLWdIBXx+9En4BbyVRkNQ7ODrBgO1RvtWY8taTjPZqP mnQw7lfHRYWzacN9MFkrL3utXxom2Gzmmt06RLfcKnmz3HtYRPYKgCg1qcOdr5mwlNax rMrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AlsOgn0s; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p186-v6si841862pga.2.2018.05.30.22.56.39; Wed, 30 May 2018 22:56:39 -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; dkim=pass header.i=@linaro.org header.s=google header.b=AlsOgn0s; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753961AbeEaF4h (ORCPT + 30 others); Thu, 31 May 2018 01:56:37 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:38666 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037AbeEaF4d (ORCPT ); Thu, 31 May 2018 01:56:33 -0400 Received: by mail-pf0-f196.google.com with SMTP id b74-v6so6764230pfl.5 for ; Wed, 30 May 2018 22:56:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=LfqECe6/ajDViZPg7Vvp8PjmW1ok+SW0S6pF7ygIRDQ=; b=AlsOgn0swjuFHym9QNoArYeBhCngvEATNhOUeL0cVk6ExOJjdj6P1gHmVvkH8o44oD 7kxY3qaQmPLkF6mzikGcr9f7mF+dylThkfLa+FH71AXpGF6QONPN9EAUr3BDoopQiMUh dUGhSNpiWzUxBNHEhK1hnhVXaq4yKXGWPNrgA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=LfqECe6/ajDViZPg7Vvp8PjmW1ok+SW0S6pF7ygIRDQ=; b=e/UYVWrQZqZ0uKy7DH7YlIs33r1YH//WENPmSVmm9hB49hsw97MXnZ6zXASWR20BTH fVz6DgGR/9e6664r66acAQFZM3Ne0gkoGvkpTRwlNuWEv9v9T8sWSAC3Ch1jGIZYoRaG N/9FNHhuS3/DopeDybidg+WCotqaSdacpD5MQvvtydJtY/UpnDPaHW1eDfDFhwPSu1Z0 9wAClEw6Kh73LswGHHOujmagqjVrc3Xd8GNukXhJmhugYHSwm5pORd7QIi3ItQ9k5hmY 3nn1NJVUNtIFWgL2/GXhCPAkPaiLANfDoXI1Jx/g17hrvHLSgzmn+HP4GSib5T2D0x9D /apg== X-Gm-Message-State: ALKqPwd57NWNB2UuSC8lK/EMf6dgv5xyppY4aOayirfAfJL/Hwwk1Tlf 0/WDcLhW6do++EppFlFvxY/mkA== X-Received: by 2002:a62:9056:: with SMTP id a83-v6mr5611228pfe.186.1527746193345; Wed, 30 May 2018 22:56:33 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id z15-v6sm54557494pgr.55.2018.05.30.22.56.29 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 May 2018 22:56:32 -0700 (PDT) From: Baolin Wang To: hch@lst.de, m.szyprowski@samsung.com Cc: robin.murphy@arm.com, gregkh@linuxfoundation.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, arnd@arndb.de, broonie@kernel.org, baolin.wang@linaro.org Subject: [PATCH 1/2] dma-coherent: Add one parameter to save available coherent memory Date: Thu, 31 May 2018 13:55:32 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is incorrect to use mem->size to valid if there are enough coherent memory to allocate in __dma_alloc_from_coherent(), since some devices may mark some occupied coherent memory by dma_mark_declared_memory_occupied(). So we can introduce one 'avail' parameter to save the available device coherent memory, to valid if we have enough coherent memory for the device to allocate. Signed-off-by: Baolin Wang --- drivers/base/dma-coherent.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 1.7.9.5 diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index 597d408..ce19832 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -18,6 +18,7 @@ struct dma_coherent_mem { unsigned long *bitmap; spinlock_t spinlock; bool use_dev_dma_pfn_offset; + int avail; }; static struct dma_coherent_mem *dma_coherent_default_memory __ro_after_init; @@ -73,6 +74,7 @@ static int dma_init_coherent_memory( dma_mem->device_base = device_addr; dma_mem->pfn_base = PFN_DOWN(phys_addr); dma_mem->size = pages; + dma_mem->avail = pages; dma_mem->flags = flags; spin_lock_init(&dma_mem->spinlock); @@ -141,6 +143,7 @@ void *dma_mark_declared_memory_occupied(struct device *dev, dma_addr_t device_addr, size_t size) { struct dma_coherent_mem *mem = dev->dma_mem; + int order = get_order(size); unsigned long flags; int pos, err; @@ -151,7 +154,9 @@ void *dma_mark_declared_memory_occupied(struct device *dev, spin_lock_irqsave(&mem->spinlock, flags); pos = PFN_DOWN(device_addr - dma_get_device_base(dev, mem)); - err = bitmap_allocate_region(mem->bitmap, pos, get_order(size)); + err = bitmap_allocate_region(mem->bitmap, pos, order); + if (!err) + mem->avail -= 1 << order; spin_unlock_irqrestore(&mem->spinlock, flags); if (err != 0) @@ -170,7 +175,7 @@ static void *__dma_alloc_from_coherent(struct dma_coherent_mem *mem, spin_lock_irqsave(&mem->spinlock, flags); - if (unlikely(size > (mem->size << PAGE_SHIFT))) + if (unlikely(size > (mem->avail << PAGE_SHIFT))) goto err; pageno = bitmap_find_free_region(mem->bitmap, mem->size, order); @@ -182,6 +187,7 @@ static void *__dma_alloc_from_coherent(struct dma_coherent_mem *mem, */ *dma_handle = mem->device_base + (pageno << PAGE_SHIFT); ret = mem->virt_base + (pageno << PAGE_SHIFT); + mem->avail -= 1 << order; spin_unlock_irqrestore(&mem->spinlock, flags); memset(ret, 0, size); return ret; @@ -244,6 +250,7 @@ static int __dma_release_from_coherent(struct dma_coherent_mem *mem, spin_lock_irqsave(&mem->spinlock, flags); bitmap_release_region(mem->bitmap, page, order); + mem->avail += 1 << order; spin_unlock_irqrestore(&mem->spinlock, flags); return 1; } From patchwork Thu May 31 05:55:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 137321 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp6180162lji; Wed, 30 May 2018 22:56:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI7SE+o86drLW+5Mg9W9NAlaxZ0VXcTxKHk/Aj0xtkLvdlcRn1RD3zcYRH1eIRN2jeGXnnx X-Received: by 2002:a65:4a42:: with SMTP id a2-v6mr4502386pgu.367.1527746206907; Wed, 30 May 2018 22:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527746206; cv=none; d=google.com; s=arc-20160816; b=l+yINkFy6h33Oo4MEkMAFKbgJCx2GNOzGE3CRn73btS45cf9osORevS541PQpR5pLR ZY7rdL10NvKWb+u1kWF4Wsl7QzBc4YelYT2Z/7QMfzTx3amVzcaWwUMM0jXWGxBLTNSk wgp9JwQsl5ahRC+KZnI5j1L1Ejr+u2I/9cJxE1ZcI+Y3z3pTTgTmpZjDwoLaljN50Rvj itO5MntvoDmHo4+l5iqi9Bglj094T0Iqi2vXVkdd4p9D9tuv0XPzUlrHuRn2gYjaTWpw U8ZhCDNbUiDMyr8XMg4q4AZrL8wL2TUajVrdLE8knao48b8hVVdx+gzIHul3Fpbvi24u IDBg== 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:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Kstyh1/+4Pb7krPgo/fSFaoZ109evKHQs8FCu23pw30=; b=ny0E5VPaDzR/bSVH2RfHZ0WV/KOhMgnyKuyw4nu8XpVfL8XApXVvy3GaMB0o0vvXpt OXXwjyzxAGrZcPrFPYybuRwUIPFjjQPfOAc1JpgY0mqpxsewRlwQxkEWlLPzX6Su4Txb 5BRTm2YXkxbw4/hROQ8jvrxNi+pAin1LKyLq1qZeCwigJCCLK2693Y/AfvqxBCqTDc+C JjFI6JzSrOzMFNdHw9Cuerut+j3ZkwIvci/2GreMtv5fg65u2rJ+G8ygHGhiAn7aEv1r RN2sW/lq40kHPDKljAVWGkrazOsm6w94yp0ZDXnCWK0J2U2oEB5Fz1C7buJc785s0j8f 1x5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=era0aiKP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p186-v6si841862pga.2.2018.05.30.22.56.46; Wed, 30 May 2018 22:56:46 -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; dkim=pass header.i=@linaro.org header.s=google header.b=era0aiKP; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753984AbeEaF4p (ORCPT + 30 others); Thu, 31 May 2018 01:56:45 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:45013 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037AbeEaF4m (ORCPT ); Thu, 31 May 2018 01:56:42 -0400 Received: by mail-pl0-f67.google.com with SMTP id z9-v6so9210280plk.11 for ; Wed, 30 May 2018 22:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Kstyh1/+4Pb7krPgo/fSFaoZ109evKHQs8FCu23pw30=; b=era0aiKPIGLh/n+V2tvvxaMz8nEKyG4B7Evy9XGJBD8dh8T4OEBbUKJ3pLF80+0PuE ckki57XIBmqGzaTkBaSpgQuOfjQcSwItVgFDCg6X++6d4ho8hov9jngkFSzMut2avU3K 55uv4NO6uLnPeSt3rOZ2dhGDRd7x7IfoCksjM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=Kstyh1/+4Pb7krPgo/fSFaoZ109evKHQs8FCu23pw30=; b=XlNPp/kJ8fiFYqjq5DJq/KdPh7sRcGaRZGCLK9iH7/eNyfougY0LdB2WFwbtNSdcCQ 0m5lyBP/KCZxYRieOwInpiyGjH+35e3MwTUo6wemeVHFM9aC1LSFeY5Y0MkpRj3XpYxu IBgqQ2rYjLanpxybv0OJA0A0Sma4ER6/vjr3aVTASXGl+FOa1R5MOFAyvDdyQI/Fhv6B L6Blezp+4X32Rh4/W6Wk7CEhTl3TZ0VoeCuMCPOxwGeeK2BF+eN5pMugF62yWI2Sg87p tinmmr6lTfYH8RDx72zwzSfxpbh6p8ETkYlLNP2bGtnMYnxotgu2qT5I1eEAn5wIDmTs Kvvg== X-Gm-Message-State: ALKqPwePLl355u+qtE+57x/viwJ2NbWrRcHmYC0MncVlOU4hVW/1WgJB Alv//7xoUNBv4bXMAhSUi4VSrQ== X-Received: by 2002:a17:902:7406:: with SMTP id g6-v6mr5580184pll.90.1527746201719; Wed, 30 May 2018 22:56:41 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id z15-v6sm54557494pgr.55.2018.05.30.22.56.33 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 May 2018 22:56:40 -0700 (PDT) From: Baolin Wang To: hch@lst.de, m.szyprowski@samsung.com Cc: robin.murphy@arm.com, gregkh@linuxfoundation.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, arnd@arndb.de, broonie@kernel.org, baolin.wang@linaro.org Subject: [PATCH 2/2] dma-coherent: Change the bitmap APIs Date: Thu, 31 May 2018 13:55:33 +0800 Message-Id: <892fabb55ebe7bb35aa3f0be03ee3f93132b7acc.1527745258.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The device coherent memory uses the bitmap helper functions, which take an order of PAGE_SIZE, that means the pages size is always a power of 2 as the allocation region. For Example, allocating 33 MB from a 33 MB dma_mem region requires 64MB free memory in that region. Thus we can change to use bitmap_find_next_zero_area()/bitmap_set()/ bitmap_clear() to present the allocation coherent memory, and reduce the allocation granularity to be one PAGE_SIZE. Moreover from Arnd's description: "I believe that bitmap_allocate_region() was chosen here because it is more efficient than bitmap_find_next_zero_area(), at least that is the explanation given in https://en.wikipedia.org/wiki/Buddy_memory_allocation. It's quite possible that we don't actually care about efficiency of dma_alloc_*() since a) it's supposed to be called very rarely, and b) the overhead of accessing uncached memory is likely higher than the search through a relatively small bitmap". Thus I think we can convert to change the allocation granularity to be one PAGE_SIZE replacing with new bitmap APIs, which will not cause efficiency issue. Signed-off-by: Baolin Wang --- drivers/base/dma-coherent.c | 54 +++++++++++++++++++++++-------------------- include/linux/dma-mapping.h | 6 ++--- 2 files changed, 32 insertions(+), 28 deletions(-) -- 1.7.9.5 diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c index ce19832..4131540 100644 --- a/drivers/base/dma-coherent.c +++ b/drivers/base/dma-coherent.c @@ -143,34 +143,31 @@ void *dma_mark_declared_memory_occupied(struct device *dev, dma_addr_t device_addr, size_t size) { struct dma_coherent_mem *mem = dev->dma_mem; - int order = get_order(size); unsigned long flags; - int pos, err; - - size += device_addr & ~PAGE_MASK; + int start_bit, nbits; if (!mem) return ERR_PTR(-EINVAL); + size += device_addr & ~PAGE_MASK; + nbits = (size + (1UL << PAGE_SHIFT) - 1) >> PAGE_SHIFT; + spin_lock_irqsave(&mem->spinlock, flags); - pos = PFN_DOWN(device_addr - dma_get_device_base(dev, mem)); - err = bitmap_allocate_region(mem->bitmap, pos, order); - if (!err) - mem->avail -= 1 << order; + start_bit = PFN_DOWN(device_addr - dma_get_device_base(dev, mem)); + bitmap_set(mem->bitmap, start_bit, nbits); + mem->avail -= nbits; spin_unlock_irqrestore(&mem->spinlock, flags); - if (err != 0) - return ERR_PTR(err); - return mem->virt_base + (pos << PAGE_SHIFT); + return mem->virt_base + (start_bit << PAGE_SHIFT); } EXPORT_SYMBOL(dma_mark_declared_memory_occupied); static void *__dma_alloc_from_coherent(struct dma_coherent_mem *mem, ssize_t size, dma_addr_t *dma_handle) { - int order = get_order(size); + int nbits = (size + (1UL << PAGE_SHIFT) - 1) >> PAGE_SHIFT; unsigned long flags; - int pageno; + int start_bit, end_bit; void *ret; spin_lock_irqsave(&mem->spinlock, flags); @@ -178,16 +175,22 @@ static void *__dma_alloc_from_coherent(struct dma_coherent_mem *mem, if (unlikely(size > (mem->avail << PAGE_SHIFT))) goto err; - pageno = bitmap_find_free_region(mem->bitmap, mem->size, order); - if (unlikely(pageno < 0)) + start_bit = 0; + end_bit = mem->size; + + start_bit = bitmap_find_next_zero_area(mem->bitmap, end_bit, start_bit, + nbits, 0); + if (start_bit >= end_bit) goto err; + bitmap_set(mem->bitmap, start_bit, nbits); + /* * Memory was found in the coherent area. */ - *dma_handle = mem->device_base + (pageno << PAGE_SHIFT); - ret = mem->virt_base + (pageno << PAGE_SHIFT); - mem->avail -= 1 << order; + *dma_handle = mem->device_base + (start_bit << PAGE_SHIFT); + ret = mem->virt_base + (start_bit << PAGE_SHIFT); + mem->avail -= nbits; spin_unlock_irqrestore(&mem->spinlock, flags); memset(ret, 0, size); return ret; @@ -241,16 +244,17 @@ void *dma_alloc_from_global_coherent(ssize_t size, dma_addr_t *dma_handle) } static int __dma_release_from_coherent(struct dma_coherent_mem *mem, - int order, void *vaddr) + int size, void *vaddr) { if (mem && vaddr >= mem->virt_base && vaddr < (mem->virt_base + (mem->size << PAGE_SHIFT))) { - int page = (vaddr - mem->virt_base) >> PAGE_SHIFT; + int nbits = (size + (1UL << PAGE_SHIFT) - 1) >> PAGE_SHIFT; + int start_bit = (vaddr - mem->virt_base) >> PAGE_SHIFT; unsigned long flags; spin_lock_irqsave(&mem->spinlock, flags); - bitmap_release_region(mem->bitmap, page, order); - mem->avail += 1 << order; + bitmap_clear(mem->bitmap, start_bit, nbits); + mem->avail += nbits; spin_unlock_irqrestore(&mem->spinlock, flags); return 1; } @@ -260,7 +264,7 @@ static int __dma_release_from_coherent(struct dma_coherent_mem *mem, /** * dma_release_from_dev_coherent() - free memory to device coherent memory pool * @dev: device from which the memory was allocated - * @order: the order of pages allocated + * @size: size of release memory area * @vaddr: virtual address of allocated pages * * This checks whether the memory was allocated from the per-device @@ -269,11 +273,11 @@ static int __dma_release_from_coherent(struct dma_coherent_mem *mem, * Returns 1 if we correctly released the memory, or 0 if the caller should * proceed with releasing memory from generic pools. */ -int dma_release_from_dev_coherent(struct device *dev, int order, void *vaddr) +int dma_release_from_dev_coherent(struct device *dev, int size, void *vaddr) { struct dma_coherent_mem *mem = dev_get_coherent_memory(dev); - return __dma_release_from_coherent(mem, order, vaddr); + return __dma_release_from_coherent(mem, size, vaddr); } EXPORT_SYMBOL(dma_release_from_dev_coherent); diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index f8ab1c0..29ae92e 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -162,7 +162,7 @@ static inline int is_device_dma_capable(struct device *dev) */ int dma_alloc_from_dev_coherent(struct device *dev, ssize_t size, dma_addr_t *dma_handle, void **ret); -int dma_release_from_dev_coherent(struct device *dev, int order, void *vaddr); +int dma_release_from_dev_coherent(struct device *dev, int size, void *vaddr); int dma_mmap_from_dev_coherent(struct device *dev, struct vm_area_struct *vma, void *cpu_addr, size_t size, int *ret); @@ -174,7 +174,7 @@ int dma_mmap_from_global_coherent(struct vm_area_struct *vma, void *cpu_addr, #else #define dma_alloc_from_dev_coherent(dev, size, handle, ret) (0) -#define dma_release_from_dev_coherent(dev, order, vaddr) (0) +#define dma_release_from_dev_coherent(dev, size, vaddr) (0) #define dma_mmap_from_dev_coherent(dev, vma, vaddr, order, ret) (0) static inline void *dma_alloc_from_global_coherent(ssize_t size, @@ -540,7 +540,7 @@ static inline void dma_free_attrs(struct device *dev, size_t size, BUG_ON(!ops); WARN_ON(irqs_disabled()); - if (dma_release_from_dev_coherent(dev, get_order(size), cpu_addr)) + if (dma_release_from_dev_coherent(dev, size, cpu_addr)) return; if (!ops->free || !cpu_addr)