Commit 78d313c6 authored by Baoquan He's avatar Baoquan He Committed by Joerg Roedel

iommu/amd: Add several helper functions

Move single iommu enabling codes into a wrapper function early_enable_iommu().
This can make later kdump change easier.

And also add iommu_disable_command_buffer and iommu_disable_event_buffer
for later usage.
Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent 4c232a70
...@@ -634,6 +634,14 @@ static void iommu_enable_command_buffer(struct amd_iommu *iommu) ...@@ -634,6 +634,14 @@ static void iommu_enable_command_buffer(struct amd_iommu *iommu)
amd_iommu_reset_cmd_buffer(iommu); amd_iommu_reset_cmd_buffer(iommu);
} }
/*
* This function disables the command buffer
*/
static void iommu_disable_command_buffer(struct amd_iommu *iommu)
{
iommu_feature_disable(iommu, CONTROL_CMDBUF_EN);
}
static void __init free_command_buffer(struct amd_iommu *iommu) static void __init free_command_buffer(struct amd_iommu *iommu)
{ {
free_pages((unsigned long)iommu->cmd_buf, get_order(CMD_BUFFER_SIZE)); free_pages((unsigned long)iommu->cmd_buf, get_order(CMD_BUFFER_SIZE));
...@@ -666,6 +674,14 @@ static void iommu_enable_event_buffer(struct amd_iommu *iommu) ...@@ -666,6 +674,14 @@ static void iommu_enable_event_buffer(struct amd_iommu *iommu)
iommu_feature_enable(iommu, CONTROL_EVT_LOG_EN); iommu_feature_enable(iommu, CONTROL_EVT_LOG_EN);
} }
/*
* This function disables the event log buffer
*/
static void iommu_disable_event_buffer(struct amd_iommu *iommu)
{
iommu_feature_disable(iommu, CONTROL_EVT_LOG_EN);
}
static void __init free_event_buffer(struct amd_iommu *iommu) static void __init free_event_buffer(struct amd_iommu *iommu)
{ {
free_pages((unsigned long)iommu->evt_buf, get_order(EVT_BUFFER_SIZE)); free_pages((unsigned long)iommu->evt_buf, get_order(EVT_BUFFER_SIZE));
...@@ -2046,15 +2062,8 @@ static void iommu_enable_ga(struct amd_iommu *iommu) ...@@ -2046,15 +2062,8 @@ static void iommu_enable_ga(struct amd_iommu *iommu)
#endif #endif
} }
/* static void early_enable_iommu(struct amd_iommu *iommu)
* This function finally enables all IOMMUs found in the system after
* they have been initialized
*/
static void early_enable_iommus(void)
{ {
struct amd_iommu *iommu;
for_each_iommu(iommu) {
iommu_disable(iommu); iommu_disable(iommu);
iommu_init_flags(iommu); iommu_init_flags(iommu);
iommu_set_device_table(iommu); iommu_set_device_table(iommu);
...@@ -2064,7 +2073,18 @@ static void early_enable_iommus(void) ...@@ -2064,7 +2073,18 @@ static void early_enable_iommus(void)
iommu_enable_ga(iommu); iommu_enable_ga(iommu);
iommu_enable(iommu); iommu_enable(iommu);
iommu_flush_all_caches(iommu); iommu_flush_all_caches(iommu);
} }
/*
* This function finally enables all IOMMUs found in the system after
* they have been initialized
*/
static void early_enable_iommus(void)
{
struct amd_iommu *iommu;
for_each_iommu(iommu)
early_enable_iommu(iommu);
#ifdef CONFIG_IRQ_REMAP #ifdef CONFIG_IRQ_REMAP
if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment