diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2008-06-26 15:27:45 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-27 04:12:10 -0400 |
commit | b36ca91e1d2d7e846844820784d57d20ad73dbd8 (patch) | |
tree | 9452099ea66cf8b54d604f07e5037c43f6b188e5 /arch/x86/kernel/amd_iommu_init.c | |
parent | b2026aa2dce4454950ccd9c410790f310d65696a (diff) |
x86, AMD IOMMU: add command buffer (de-)allocation
This patch adds the functions to allocate and deallocate the command buffer for
one IOMMU in the system.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Cc: iommu@lists.linux-foundation.org
Cc: bhavna.sarathy@amd.com
Cc: Sebastian.Biemueller@amd.com
Cc: robert.richter@amd.com
Cc: joro@8bytes.org
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/amd_iommu_init.c')
-rw-r--r-- | arch/x86/kernel/amd_iommu_init.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c index ffb8ac82e32f..c2be3adee877 100644 --- a/arch/x86/kernel/amd_iommu_init.c +++ b/arch/x86/kernel/amd_iommu_init.c | |||
@@ -278,3 +278,33 @@ static int __init find_last_devid_acpi(struct acpi_table_header *table) | |||
278 | return 0; | 278 | return 0; |
279 | } | 279 | } |
280 | 280 | ||
281 | static u8 * __init alloc_command_buffer(struct amd_iommu *iommu) | ||
282 | { | ||
283 | u8 *cmd_buf = (u8 *)__get_free_pages(GFP_KERNEL, | ||
284 | get_order(CMD_BUFFER_SIZE)); | ||
285 | u64 entry = 0; | ||
286 | |||
287 | if (cmd_buf == NULL) | ||
288 | return NULL; | ||
289 | |||
290 | iommu->cmd_buf_size = CMD_BUFFER_SIZE; | ||
291 | |||
292 | memset(cmd_buf, 0, CMD_BUFFER_SIZE); | ||
293 | |||
294 | entry = (u64)virt_to_phys(cmd_buf); | ||
295 | entry |= MMIO_CMD_SIZE_512; | ||
296 | memcpy_toio(iommu->mmio_base + MMIO_CMD_BUF_OFFSET, | ||
297 | &entry, sizeof(entry)); | ||
298 | |||
299 | iommu_feature_enable(iommu, CONTROL_CMDBUF_EN); | ||
300 | |||
301 | return cmd_buf; | ||
302 | } | ||
303 | |||
304 | static void __init free_command_buffer(struct amd_iommu *iommu) | ||
305 | { | ||
306 | if (iommu->cmd_buf) | ||
307 | free_pages((unsigned long)iommu->cmd_buf, | ||
308 | get_order(CMD_BUFFER_SIZE)); | ||
309 | } | ||
310 | |||