* NVME's IO queue should be Per-CPU, fixup the affinity after the secondary CPU * startup, this stage can make sure the affinity setting success as possible. */
| 1269 | * startup, this stage can make sure the affinity setting success as possible. |
| 1270 | */ |
| 1271 | static int nvme_queue_affinify_fixup(void) |
| 1272 | { |
| 1273 | int cpuid = rt_hw_cpu_id(); |
| 1274 | struct rt_nvme_controller *nvme; |
| 1275 | RT_IRQ_AFFINITY_DECLARE(affinity) = { 0 }; |
| 1276 | RT_IRQ_AFFINITY_DECLARE(current_affinity) = { 0 }; |
| 1277 | |
| 1278 | RT_IRQ_AFFINITY_SET(affinity, cpuid); |
| 1279 | |
| 1280 | rt_hw_spin_lock(&nvme_lock.lock); |
| 1281 | rt_list_for_each_entry(nvme, &nvme_nodes, list) |
| 1282 | { |
| 1283 | for (int i = cpuid % RT_CPUS_NR; i < nvme->io_queue_max; i += RT_CPUS_NR) |
| 1284 | { |
| 1285 | int irq = nvme->irqs[i]; |
| 1286 | |
| 1287 | if (!rt_pic_irq_get_affinity(irq, current_affinity) && |
| 1288 | !rt_bitmap_test_bit(current_affinity, cpuid)) |
| 1289 | { |
| 1290 | rt_ubase_t level = rt_hw_interrupt_disable(); |
| 1291 | |
| 1292 | rt_pic_irq_set_affinity(irq, affinity); |
| 1293 | |
| 1294 | rt_hw_interrupt_enable(level); |
| 1295 | } |
| 1296 | } |
| 1297 | } |
| 1298 | rt_hw_spin_unlock(&nvme_lock.lock); |
| 1299 | |
| 1300 | return 0; |
| 1301 | } |
| 1302 | INIT_SECONDARY_CPU_EXPORT(nvme_queue_affinify_fixup); |
nothing calls this directly
no test coverage detected