Linux IOMMU Development
 help / color / mirror / Atom feed
* [bug report] iommu/arm-smmu-v3: Refactor write_ctx_desc
@ 2024-02-01 12:18 Dan Carpenter
  2024-02-02 12:33 ` Michael Shavit
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2024-02-01 12:18 UTC (permalink / raw)
  To: mshavit; +Cc: iommu

Hello Michael Shavit,

The patch 24503148c545: "iommu/arm-smmu-v3: Refactor write_ctx_desc"
from Sep 15, 2023 (linux-next), leads to the following Smatch static
checker warning:

	drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:1036 arm_smmu_get_cd_ptr()
	warn: sleeping in atomic context

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
    1022 static __le64 *arm_smmu_get_cd_ptr(struct arm_smmu_master *master, u32 ssid)
    1023 {
    1024         __le64 *l1ptr;
    1025         unsigned int idx;
    1026         struct arm_smmu_l1_ctx_desc *l1_desc;
    1027         struct arm_smmu_device *smmu = master->smmu;
    1028         struct arm_smmu_ctx_desc_cfg *cd_table = &master->cd_table;
    1029 
    1030         if (cd_table->s1fmt == STRTAB_STE_0_S1FMT_LINEAR)
    1031                 return cd_table->cdtab + ssid * CTXDESC_CD_DWORDS;
    1032 
    1033         idx = ssid >> CTXDESC_SPLIT;
    1034         l1_desc = &cd_table->l1_desc[idx];
    1035         if (!l1_desc->l2ptr) {
                     ^^^^^^^^^^^^^^^
I don't know if l1_desc->l2ptr can be NULL for the call trees in
question so this might be a false positive.  You'd need to enable
CONFIG_DEBUG_ATOMIC_SLEEP=y to see these warnings at runtime.


--> 1036                 if (arm_smmu_alloc_cd_leaf_table(smmu, l1_desc))
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Sleeping allocation.

    1037                         return NULL;
    1038 
    1039                 l1ptr = cd_table->cdtab + idx * CTXDESC_L1_DESC_DWORDS;
    1040                 arm_smmu_write_cd_l1_desc(l1ptr, l1_desc);
    1041                 /* An invalid L1CD can be cached */
    1042                 arm_smmu_sync_cd(master, ssid, false);
    1043         }
    1044         idx = ssid & (CTXDESC_L2_ENTRIES - 1);
    1045         return l1_desc->l2ptr + idx * CTXDESC_CD_DWORDS;
    1046 }

The call trees which trigger this warning are:

arm_smmu_update_ctx_desc_devices() <- disables preempt
arm_smmu_mmu_notifier_get() <- disables preempt
-> arm_smmu_write_ctx_desc()
   -> arm_smmu_get_cd_ptr()

The patch adds new spinlocks to disable preemption.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-02-05 10:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-01 12:18 [bug report] iommu/arm-smmu-v3: Refactor write_ctx_desc Dan Carpenter
2024-02-02 12:33 ` Michael Shavit
2024-02-02 13:35   ` Jason Gunthorpe
2024-02-02 14:45     ` Dan Carpenter
2024-02-02 14:59       ` Jason Gunthorpe
2024-02-05 10:56         ` Dan Carpenter
2024-02-03  8:00     ` Michael Shavit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox