RDMA/usnic: use iommu_map_atomic() under spin_lock()
authorYang Yingliang <yangyingliang@huawei.com>
Sun, 29 Jan 2023 09:37:57 +0000 (17:37 +0800)
committerLeon Romanovsky <leon@kernel.org>
Mon, 30 Jan 2023 09:38:41 +0000 (11:38 +0200)
usnic_uiom_map_sorted_intervals() is called under spin_lock(), iommu_map()
might sleep, use iommu_map_atomic() to avoid potential sleep in atomic
context.

Fixes: e3cf00d0a87f ("IB/usnic: Add Cisco VIC low-level hardware driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20230129093757.637354-1-yangyingliang@huawei.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/usnic/usnic_uiom.c

index c301b3b..a2857ac 100644 (file)
@@ -276,8 +276,8 @@ iter_chunk:
                                size = pa_end - pa_start + PAGE_SIZE;
                                usnic_dbg("va 0x%lx pa %pa size 0x%zx flags 0x%x",
                                        va_start, &pa_start, size, flags);
                                size = pa_end - pa_start + PAGE_SIZE;
                                usnic_dbg("va 0x%lx pa %pa size 0x%zx flags 0x%x",
                                        va_start, &pa_start, size, flags);
-                               err = iommu_map(pd->domain, va_start, pa_start,
-                                                       size, flags);
+                               err = iommu_map_atomic(pd->domain, va_start,
+                                                      pa_start, size, flags);
                                if (err) {
                                        usnic_err("Failed to map va 0x%lx pa %pa size 0x%zx with err %d\n",
                                                va_start, &pa_start, size, err);
                                if (err) {
                                        usnic_err("Failed to map va 0x%lx pa %pa size 0x%zx with err %d\n",
                                                va_start, &pa_start, size, err);
@@ -293,8 +293,8 @@ iter_chunk:
                                size = pa - pa_start + PAGE_SIZE;
                                usnic_dbg("va 0x%lx pa %pa size 0x%zx flags 0x%x\n",
                                        va_start, &pa_start, size, flags);
                                size = pa - pa_start + PAGE_SIZE;
                                usnic_dbg("va 0x%lx pa %pa size 0x%zx flags 0x%x\n",
                                        va_start, &pa_start, size, flags);
-                               err = iommu_map(pd->domain, va_start, pa_start,
-                                               size, flags);
+                               err = iommu_map_atomic(pd->domain, va_start,
+                                                      pa_start, size, flags);
                                if (err) {
                                        usnic_err("Failed to map va 0x%lx pa %pa size 0x%zx with err %d\n",
                                                va_start, &pa_start, size, err);
                                if (err) {
                                        usnic_err("Failed to map va 0x%lx pa %pa size 0x%zx with err %d\n",
                                                va_start, &pa_start, size, err);