[PATCH v5 04/18] iommu: Convert gdev->blocked from bool to enum gdev_blocked
From: Nicolin Chen <hidden>
Date: 2026-07-03 04:07:59
Also in:
linux-acpi, linux-iommu, linux-pci, lkml
Subsystem:
iommu subsystem, the rest · Maintainers:
Joerg Roedel, Will Deacon, Linus Torvalds
The gdev->blocked flag tracks whether a device is individually being held in the group->blocking_domain while group->domain is retained. Up to now, a PCI reset in flight is the only producer, so a bool suffices. Subsequent changes will add more reasons to keep a device blocked, e.g. a failed-reset case that must not auto-unblock, or a driver-side quarantine for a hardware fault. These reasons are cleared by different events, which a single bool cannot encode. Convert "bool blocked" into "enum gdev_blocked blocked", provisioned with two initial values: BLOCKED_NO and BLOCKED_RESETTING, for the existing use cases. All readers keep the "if (gdev->blocked)" form, as BLOCKED_NO == 0. This is a pure type change with no behavior change. Follow-on changes will add new enum values along with their producers. Assisted-by: Claude:claude-opus-4-7 Signed-off-by: Nicolin Chen <redacted> --- drivers/iommu/iommu.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index e8f13dcebbde5..342e8a5ad628c 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c@@ -73,16 +73,20 @@ struct iommu_group { void *owner; }; +enum gdev_blocked { + BLOCKED_NO = 0, /* Not blocked */ + BLOCKED_RESETTING, /* PCI reset in flight */ +}; + struct group_device { struct list_head list; struct device *dev; char *name; /* * Device is blocked for a pending recovery while its group->domain is - * retained. This can happen when: - * - Device is undergoing a reset + * retained. */ - bool blocked; + enum gdev_blocked blocked; unsigned int reset_depth; };
@@ -4072,7 +4076,7 @@ int pci_dev_reset_iommu_prepare(struct pci_dev *pdev) * the correct domain in iommu_driver_get_domain_for_dev() that might be * called in a set_dev_pasid callback function. */ - gdev->blocked = true; + gdev->blocked = BLOCKED_RESETTING; /* * Stage PASID domains at blocking_domain while retaining pasid_array.
@@ -4198,7 +4202,7 @@ void pci_dev_reset_iommu_done(struct pci_dev *pdev) * the correct domain in iommu_driver_get_domain_for_dev() that might be * called in a set_dev_pasid callback function. */ - gdev->blocked = false; + gdev->blocked = BLOCKED_NO; /* * Re-attach PASID domains back to the domains retained in pasid_array.
--
2.43.0