Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/mlx5: Cleanup DEVX initialization flow

Move DEVX initialization and cleanup flows to the devx.c instead of having
almost empty functions in main.c

Link: https://lore.kernel.org/r/20200702081809.423482-6-leon@kernel.org
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Leon Romanovsky and committed by
Jason Gunthorpe
d8b7515e f7c4ffda

+51 -54
+27 -16
drivers/infiniband/hw/mlx5/devx.c
··· 2362 2362 return NOTIFY_OK; 2363 2363 } 2364 2364 2365 - void mlx5_ib_devx_init_event_table(struct mlx5_ib_dev *dev) 2365 + int mlx5_ib_devx_init(struct mlx5_ib_dev *dev) 2366 2366 { 2367 2367 struct mlx5_devx_event_table *table = &dev->devx_event_table; 2368 + int uid; 2368 2369 2369 - xa_init(&table->event_xa); 2370 - mutex_init(&table->event_xa_lock); 2371 - MLX5_NB_INIT(&table->devx_nb, devx_event_notifier, NOTIFY_ANY); 2372 - mlx5_eq_notifier_register(dev->mdev, &table->devx_nb); 2370 + uid = mlx5_ib_devx_create(dev, false); 2371 + if (uid > 0) { 2372 + dev->devx_whitelist_uid = uid; 2373 + xa_init(&table->event_xa); 2374 + mutex_init(&table->event_xa_lock); 2375 + MLX5_NB_INIT(&table->devx_nb, devx_event_notifier, NOTIFY_ANY); 2376 + mlx5_eq_notifier_register(dev->mdev, &table->devx_nb); 2377 + } 2378 + 2379 + return 0; 2373 2380 } 2374 2381 2375 - void mlx5_ib_devx_cleanup_event_table(struct mlx5_ib_dev *dev) 2382 + void mlx5_ib_devx_cleanup(struct mlx5_ib_dev *dev) 2376 2383 { 2377 2384 struct mlx5_devx_event_table *table = &dev->devx_event_table; 2378 2385 struct devx_event_subscription *sub, *tmp; ··· 2387 2380 void *entry; 2388 2381 unsigned long id; 2389 2382 2390 - mlx5_eq_notifier_unregister(dev->mdev, &table->devx_nb); 2391 - mutex_lock(&dev->devx_event_table.event_xa_lock); 2392 - xa_for_each(&table->event_xa, id, entry) { 2393 - event = entry; 2394 - list_for_each_entry_safe(sub, tmp, &event->unaffiliated_list, 2395 - xa_list) 2396 - devx_cleanup_subscription(dev, sub); 2397 - kfree(entry); 2383 + if (dev->devx_whitelist_uid) { 2384 + mlx5_eq_notifier_unregister(dev->mdev, &table->devx_nb); 2385 + mutex_lock(&dev->devx_event_table.event_xa_lock); 2386 + xa_for_each(&table->event_xa, id, entry) { 2387 + event = entry; 2388 + list_for_each_entry_safe( 2389 + sub, tmp, &event->unaffiliated_list, xa_list) 2390 + devx_cleanup_subscription(dev, sub); 2391 + kfree(entry); 2392 + } 2393 + mutex_unlock(&dev->devx_event_table.event_xa_lock); 2394 + xa_destroy(&table->event_xa); 2395 + 2396 + mlx5_ib_devx_destroy(dev, dev->devx_whitelist_uid); 2398 2397 } 2399 - mutex_unlock(&dev->devx_event_table.event_xa_lock); 2400 - xa_destroy(&table->event_xa); 2401 2398 } 2402 2399 2403 2400 static ssize_t devx_async_cmd_event_read(struct file *filp, char __user *buf,
+19
drivers/infiniband/hw/mlx5/devx.h
··· 23 23 }; 24 24 struct list_head event_sub; /* holds devx_event_subscription entries */ 25 25 }; 26 + #if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS) 27 + int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user); 28 + void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid); 29 + int mlx5_ib_devx_init(struct mlx5_ib_dev *dev); 30 + void mlx5_ib_devx_cleanup(struct mlx5_ib_dev *dev); 31 + #else 32 + static inline int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user) 33 + { 34 + return -EOPNOTSUPP; 35 + } 36 + static inline void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid) {} 37 + static inline int mlx5_ib_devx_init(struct mlx5_ib_dev *dev) 38 + { 39 + return 0; 40 + } 41 + static inline void mlx5_ib_devx_cleanup(struct mlx5_ib_dev *dev) 42 + { 43 + } 44 + #endif 26 45 #endif /* _MLX5_IB_DEVX_H */
+5 -24
drivers/infiniband/hw/mlx5/main.c
··· 32 32 #include "mlx5_ib.h" 33 33 #include "ib_rep.h" 34 34 #include "cmd.h" 35 + #include "devx.h" 35 36 #include "fs.h" 36 37 #include "srq.h" 37 38 #include "qp.h" ··· 4662 4661 mlx5_notifier_unregister(dev->mdev, &dev->mdev_events); 4663 4662 } 4664 4663 4665 - static int mlx5_ib_stage_devx_init(struct mlx5_ib_dev *dev) 4666 - { 4667 - int uid; 4668 - 4669 - uid = mlx5_ib_devx_create(dev, false); 4670 - if (uid > 0) { 4671 - dev->devx_whitelist_uid = uid; 4672 - mlx5_ib_devx_init_event_table(dev); 4673 - } 4674 - 4675 - return 0; 4676 - } 4677 - static void mlx5_ib_stage_devx_cleanup(struct mlx5_ib_dev *dev) 4678 - { 4679 - if (dev->devx_whitelist_uid) { 4680 - mlx5_ib_devx_cleanup_event_table(dev); 4681 - mlx5_ib_devx_destroy(dev, dev->devx_whitelist_uid); 4682 - } 4683 - } 4684 - 4685 4664 void __mlx5_ib_remove(struct mlx5_ib_dev *dev, 4686 4665 const struct mlx5_ib_profile *profile, 4687 4666 int stage) ··· 4752 4771 NULL, 4753 4772 mlx5_ib_stage_pre_ib_reg_umr_cleanup), 4754 4773 STAGE_CREATE(MLX5_IB_STAGE_WHITELIST_UID, 4755 - mlx5_ib_stage_devx_init, 4756 - mlx5_ib_stage_devx_cleanup), 4774 + mlx5_ib_devx_init, 4775 + mlx5_ib_devx_cleanup), 4757 4776 STAGE_CREATE(MLX5_IB_STAGE_IB_REG, 4758 4777 mlx5_ib_stage_ib_reg_init, 4759 4778 mlx5_ib_stage_ib_reg_cleanup), ··· 4812 4831 NULL, 4813 4832 mlx5_ib_stage_pre_ib_reg_umr_cleanup), 4814 4833 STAGE_CREATE(MLX5_IB_STAGE_WHITELIST_UID, 4815 - mlx5_ib_stage_devx_init, 4816 - mlx5_ib_stage_devx_cleanup), 4834 + mlx5_ib_devx_init, 4835 + mlx5_ib_devx_cleanup), 4817 4836 STAGE_CREATE(MLX5_IB_STAGE_IB_REG, 4818 4837 mlx5_ib_stage_ib_reg_init, 4819 4838 mlx5_ib_stage_ib_reg_cleanup),
-14
drivers/infiniband/hw/mlx5/mlx5_ib.h
··· 1353 1353 extern const struct uapi_definition mlx5_ib_qos_defs[]; 1354 1354 extern const struct uapi_definition mlx5_ib_std_types_defs[]; 1355 1355 1356 - 1357 - #if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS) 1358 - int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user); 1359 - void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid); 1360 - void mlx5_ib_devx_init_event_table(struct mlx5_ib_dev *dev); 1361 - void mlx5_ib_devx_cleanup_event_table(struct mlx5_ib_dev *dev); 1362 - #else 1363 - static inline int 1364 - mlx5_ib_devx_create(struct mlx5_ib_dev *dev, 1365 - bool is_user) { return -EOPNOTSUPP; } 1366 - static inline void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid) {} 1367 - static inline void mlx5_ib_devx_init_event_table(struct mlx5_ib_dev *dev) {} 1368 - static inline void mlx5_ib_devx_cleanup_event_table(struct mlx5_ib_dev *dev) {} 1369 - #endif 1370 1356 static inline void init_query_mad(struct ib_smp *mad) 1371 1357 { 1372 1358 mad->base_version = 1;