From: tip-bot for FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@redhat.com,
fujita.tomonori@lab.ntt.co.jp, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:core/iommu] swiotlb: Add swiotlb_free() function
Date: Tue, 10 Nov 2009 13:24:08 GMT [thread overview]
Message-ID: <tip-5740afdb68abadc473fd5392df733558a58c1254@git.kernel.org> (raw)
In-Reply-To: <1257849980-22640-8-git-send-email-fujita.tomonori@lab.ntt.co.jp>
Commit-ID: 5740afdb68abadc473fd5392df733558a58c1254
Gitweb: http://git.kernel.org/tip/5740afdb68abadc473fd5392df733558a58c1254
Author: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
AuthorDate: Tue, 10 Nov 2009 19:46:18 +0900
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 10 Nov 2009 12:31:52 +0100
swiotlb: Add swiotlb_free() function
swiotlb_free() function frees all allocated memory for swiotlb.
We need to initialize swiotlb before IOMMU initialization (x86
and powerpc needs to allocate memory from bootmem allocator). If
IOMMU initialization is successful, we need to free swiotlb
resource (don't want to waste 64MB).
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: chrisw@sous-sol.org
Cc: dwmw2@infradead.org
Cc: joerg.roedel@amd.com
Cc: muli@il.ibm.com
LKML-Reference: <1257849980-22640-8-git-send-email-fujita.tomonori@lab.ntt.co.jp>
[ -v2: build fix for the !CONFIG_SWIOTLB case ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
include/linux/swiotlb.h | 6 ++++++
lib/swiotlb.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 73b1f1c..59bafa6 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -88,4 +88,10 @@ swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr);
extern int
swiotlb_dma_supported(struct device *hwdev, u64 mask);
+#ifdef CONFIG_SWIOTLB
+extern void __init swiotlb_free(void);
+#else
+static inline void swiotlb_free(void) { }
+#endif
+
#endif /* __LINUX_SWIOTLB_H */
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index ac25cd2..eee512b 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -97,6 +97,8 @@ static phys_addr_t *io_tlb_orig_addr;
*/
static DEFINE_SPINLOCK(io_tlb_lock);
+static int late_alloc;
+
static int __init
setup_io_tlb_npages(char *str)
{
@@ -262,6 +264,8 @@ swiotlb_late_init_with_default_size(size_t default_size)
swiotlb_print_info(bytes);
+ late_alloc = 1;
+
return 0;
cleanup4:
@@ -281,6 +285,32 @@ cleanup1:
return -ENOMEM;
}
+void __init swiotlb_free(void)
+{
+ if (!io_tlb_overflow_buffer)
+ return;
+
+ if (late_alloc) {
+ free_pages((unsigned long)io_tlb_overflow_buffer,
+ get_order(io_tlb_overflow));
+ free_pages((unsigned long)io_tlb_orig_addr,
+ get_order(io_tlb_nslabs * sizeof(phys_addr_t)));
+ free_pages((unsigned long)io_tlb_list, get_order(io_tlb_nslabs *
+ sizeof(int)));
+ free_pages((unsigned long)io_tlb_start,
+ get_order(io_tlb_nslabs << IO_TLB_SHIFT));
+ } else {
+ free_bootmem_late(__pa(io_tlb_overflow_buffer),
+ io_tlb_overflow);
+ free_bootmem_late(__pa(io_tlb_orig_addr),
+ io_tlb_nslabs * sizeof(phys_addr_t));
+ free_bootmem_late(__pa(io_tlb_list),
+ io_tlb_nslabs * sizeof(int));
+ free_bootmem_late(__pa(io_tlb_start),
+ io_tlb_nslabs << IO_TLB_SHIFT);
+ }
+}
+
static int is_swiotlb_buffer(phys_addr_t paddr)
{
return paddr >= virt_to_phys(io_tlb_start) &&
next prev parent reply other threads:[~2009-11-10 13:24 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-10 10:46 [PATCH v2 0/9] x86: handle HW IOMMU initialization failure gracefully FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 1/9] add iommu_init to x86_init_ops FUJITA Tomonori
2009-11-10 13:22 ` [tip:core/iommu] x86: Add " tip-bot for FUJITA Tomonori
2009-11-10 13:42 ` [tip:core/iommu] x86: Add iommu_init to x86_init_ops, fix build tip-bot for Ingo Molnar
2009-11-10 10:46 ` [PATCH -v2 2/9] Calgary: convert detect_calgary to use iommu_init hook FUJITA Tomonori
2009-11-10 13:22 ` [tip:core/iommu] x86: Calgary: Convert detect_calgary() " tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 3/9] GART: convert gart_iommu_hole_init " FUJITA Tomonori
2009-11-10 13:23 ` [tip:core/iommu] x86: GART: Convert gart_iommu_hole_init() " tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 4/9] amd_iommu: convert amd_iommu_detect " FUJITA Tomonori
2009-11-10 13:23 ` [tip:core/iommu] x86: amd_iommu: Convert amd_iommu_detect() " tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 5/9] intel-iommu: convert detect_intel_iommu " FUJITA Tomonori
2009-11-10 11:12 ` Ingo Molnar
2009-11-10 13:23 ` [tip:core/iommu] x86: intel-iommu: Convert " tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 6/9] bootmem: add free_bootmem_late FUJITA Tomonori
2009-11-10 12:00 ` Johannes Weiner
2009-11-14 12:50 ` FUJITA Tomonori
2009-11-10 13:23 ` [tip:core/iommu] bootmem: Add free_bootmem_late() tip-bot for FUJITA Tomonori
2009-11-11 23:56 ` [PATCH -v2 6/9] bootmem: add free_bootmem_late Andrew Morton
2009-11-12 7:47 ` Ingo Molnar
2009-11-10 10:46 ` [PATCH -v2 7/9] swiotlb: add swiotlb_free function FUJITA Tomonori
2009-11-10 11:27 ` Ingo Molnar
2009-11-10 13:24 ` tip-bot for FUJITA Tomonori [this message]
2009-11-10 10:46 ` [PATCH -v2 8/9] swiotlb: export swiotlb_print_info FUJITA Tomonori
2009-11-10 13:24 ` [tip:core/iommu] swiotlb: Defer swiotlb init printing, export swiotlb_print_info() tip-bot for FUJITA Tomonori
2009-11-10 10:46 ` [PATCH -v2 9/9] x86: handle HW IOMMU initialization failure gracely FUJITA Tomonori
2009-11-10 11:27 ` Ingo Molnar
2009-11-10 13:24 ` [tip:core/iommu] x86: Handle HW IOMMU initialization failure gracefully tip-bot for FUJITA Tomonori
2009-11-22 4:24 ` [PATCH] x86: fix gart iommu using for amd 64 bit system Yinghai Lu
2009-11-22 5:19 ` [PATCH] x86: fix gart iommu using for amd 64 bit system -v2 Yinghai Lu
2009-11-24 8:46 ` [PATCH] x86: fix gart iommu using for amd 64 bit system FUJITA Tomonori
2009-11-24 9:19 ` Yinghai Lu
2009-11-24 9:35 ` FUJITA Tomonori
2009-11-24 9:48 ` Yinghai Lu
2009-11-24 10:31 ` FUJITA Tomonori
2009-11-24 10:42 ` Yinghai Lu
2009-11-24 13:50 ` FUJITA Tomonori
2009-11-24 15:26 ` Ingo Molnar
2009-11-24 18:28 ` Yinghai Lu
2009-11-24 23:57 ` FUJITA Tomonori
2009-11-25 7:25 ` Ingo Molnar
2009-11-25 7:56 ` FUJITA Tomonori
2009-11-24 18:48 ` Yinghai Lu
2009-11-24 23:48 ` FUJITA Tomonori
2009-11-10 11:19 ` [PATCH v2 0/9] x86: handle HW IOMMU initialization failure gracefully Ingo Molnar
2009-11-10 11:55 ` Ingo Molnar
2009-11-10 12:35 ` FUJITA Tomonori
2009-11-22 3:17 ` Yinghai Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-5740afdb68abadc473fd5392df733558a58c1254@git.kernel.org \
--to=fujita.tomonori@lab.ntt.co.jp \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome