iommu/vt-d: Use dmar_can_force_on() for platform opt-in

So the policy of requesting ACS in detect_intel_iommu() is consistent
with that in platform_optin_force_iommu().

While at it, remove no_platform_optin which is unnecessary now.

Signed-off-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
This commit is contained in:
Kevin Tian 2026-08-05 07:43:03 +08:00 committed by Joerg Roedel
parent 7e6bd2211e
commit 98c8a9809b

View File

@ -58,7 +58,6 @@ static int rwbf_quirk;
*/
static int force_on = 0;
int intel_iommu_tboot_noforce;
static int no_platform_optin;
#define ROOT_ENTRY_NR (VTD_PAGE_SIZE/sizeof(struct root_entry))
@ -251,7 +250,6 @@ static int __init intel_iommu_setup(char *str)
} else if (!strncmp(str, "off", 3)) {
dmar_policy = DMAR_USER_OFF;
dmar_disabled = 1;
no_platform_optin = 1;
pr_info("IOMMU disabled\n");
} else if (!strncmp(str, "igfx_off", 8)) {
disable_igfx_iommu = 1;
@ -2491,20 +2489,23 @@ static bool has_external_pci(void)
static int __init platform_optin_force_iommu(void)
{
if (no_iommu || !dmar_platform_optin() || no_platform_optin ||
!has_external_pci())
if (!dmar_platform_optin() || !dmar_can_force_on(DMAR_FORCEON_PLATFORM))
return 0;
if (dmar_disabled)
pr_info("Intel-IOMMU force enabled due to platform opt in\n");
if (!has_external_pci())
return 0;
/*
* If Intel-IOMMU is disabled by default, we will apply identity
* map for all devices except those marked as being untrusted.
*/
if (dmar_disabled)
if (dmar_policy_off()) {
pr_info("Intel-IOMMU force enabled due to platform opt in\n");
iommu_set_default_passthrough(false);
}
/* No concurrent access to dmar_policy at this point. */
dmar_policy = DMAR_FORCE_ON;
dmar_disabled = 0;
return 1;