]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iommu/amd: Add lockdep asserts for domain->dev_list
authorJason Gunthorpe <jgg@nvidia.com>
Fri, 6 Dec 2024 00:13:42 +0000 (20:13 -0400)
committerJoerg Roedel <jroedel@suse.de>
Tue, 10 Dec 2024 09:12:06 +0000 (10:12 +0100)
Add an assertion to all the iteration points that don't obviously
have the lock held already. These all take the locker higher in their
call chains.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Link: https://lore.kernel.org/r/2-v1-3b9edcf8067d+3975-amd_dev_list_locking_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/iommu.c

index 23a168e229b171b973b1a6836c5f5baa9958dd1c..16f40b8000d7981a8a9ed066386084593576f267 100644 (file)
@@ -1415,6 +1415,7 @@ static int domain_flush_pages_v2(struct protection_domain *pdom,
        struct iommu_cmd cmd;
        int ret = 0;
 
+       lockdep_assert_held(&pdom->lock);
        list_for_each_entry(dev_data, &pdom->dev_list, list) {
                struct amd_iommu *iommu = get_amd_iommu_from_dev(dev_data->dev);
                u16 domid = dev_data->gcr3_info.domid;
@@ -1464,6 +1465,8 @@ static void __domain_flush_pages(struct protection_domain *domain,
        ioasid_t pasid = IOMMU_NO_PASID;
        bool gn = false;
 
+       lockdep_assert_held(&domain->lock);
+
        if (pdom_is_v2_pgtbl_mode(domain)) {
                gn = true;
                ret = domain_flush_pages_v2(domain, address, size);
@@ -1585,6 +1588,8 @@ void amd_iommu_update_and_flush_device_table(struct protection_domain *domain)
 {
        struct iommu_dev_data *dev_data;
 
+       lockdep_assert_held(&domain->lock);
+
        list_for_each_entry(dev_data, &domain->dev_list, list) {
                struct amd_iommu *iommu = rlookup_amd_iommu(dev_data->dev);