[PATCH v3 05/11] iommu: Change group->devices to RCU-protected list
Baolu Lu
baolu.lu at linux.intel.com
Thu Apr 23 19:53:49 PDT 2026
On 4/17/26 07:28, Nicolin Chen wrote:
> To allow lockless iterations of the group->devices list in an ISR context
> that cannot hold the group->mutex, change the list to be RCU protected.
>
> Signed-off-by: Nicolin Chen<nicolinc at nvidia.com>
> ---
> drivers/iommu/iommu.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 768ac728b4cc3..d1be62a07904a 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -84,18 +84,20 @@ struct group_device {
> */
> bool blocked;
> unsigned int reset_depth;
> + struct rcu_head rcu;
> };
>
> /* Iterate over each struct group_device in a struct iommu_group */
> #define for_each_group_device(group, pos) \
> - list_for_each_entry(pos, &(group)->devices, list)
> + list_for_each_entry_rcu(pos, &(group)->devices, list, \
> + lockdep_is_held(&(group)->mutex))
for_each_group_device() is used in bus_iommu_probe() without holding
either the mutex or the rcu lock:
static int bus_iommu_probe(const struct bus_type *bus)
{
struct iommu_group *group, *next;
LIST_HEAD(group_list);
int ret;
[-- cut for short --]
mutex_unlock(&group->mutex);
/*
* FIXME: Mis-locked because the ops->probe_finalize()
call-back
* of some IOMMU drivers calls arm_iommu_attach_device() which
* in-turn might call back into IOMMU core code, where it tries
* to take group->mutex, resulting in a deadlock.
*/
for_each_group_device(group, gdev)
iommu_group_do_probe_finalize(gdev->dev);
}
return 0;
}
Will the change above trigger a lockdep splat due to this "mis-locked"
case?"
Thanks,
baolu
More information about the linux-arm-kernel
mailing list