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

drm/xe/oa: Move fini to xe_oa

Like done with other functions, cleanup the error handling in
xe_device_probe() by moving the OA fini to be handled by xe_oa
itself, which relies on devm to call the cleanup function.

Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250213192909.996148-9-lucas.demarchi@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>

+25 -31
+1 -6
drivers/gpu/drm/xe/xe_device.c
··· 873 873 874 874 err = xe_display_init(xe); 875 875 if (err) 876 - goto err_fini_oa; 876 + return err; 877 877 878 878 err = xe_pxp_init(xe); 879 879 if (err) ··· 904 904 905 905 err_fini_display: 906 906 xe_display_driver_remove(xe); 907 - 908 - err_fini_oa: 909 - xe_oa_fini(xe); 910 907 911 908 return err; 912 909 } ··· 976 979 xe_oa_unregister(xe); 977 980 978 981 xe_device_remove_display(xe); 979 - 980 - xe_oa_fini(xe); 981 982 982 983 xe_heci_gsc_fini(xe); 983 984
+24 -24
drivers/gpu/drm/xe/xe_oa.c
··· 2641 2641 } 2642 2642 } 2643 2643 2644 + static int destroy_config(int id, void *p, void *data) 2645 + { 2646 + xe_oa_config_put(p); 2647 + 2648 + return 0; 2649 + } 2650 + 2651 + static void xe_oa_fini(void *arg) 2652 + { 2653 + struct xe_device *xe = arg; 2654 + struct xe_oa *oa = &xe->oa; 2655 + 2656 + if (!oa->xe) 2657 + return; 2658 + 2659 + idr_for_each(&oa->metrics_idr, destroy_config, oa); 2660 + idr_destroy(&oa->metrics_idr); 2661 + 2662 + oa->xe = NULL; 2663 + } 2664 + 2644 2665 /** 2645 2666 * xe_oa_init - OA initialization during device probe 2646 2667 * @xe: @xe_device ··· 2693 2672 } 2694 2673 2695 2674 xe_oa_init_supported_formats(oa); 2696 - return 0; 2675 + 2676 + return devm_add_action_or_reset(xe->drm.dev, xe_oa_fini, xe); 2677 + 2697 2678 exit: 2698 2679 oa->xe = NULL; 2699 2680 return ret; 2700 - } 2701 - 2702 - static int destroy_config(int id, void *p, void *data) 2703 - { 2704 - xe_oa_config_put(p); 2705 - return 0; 2706 - } 2707 - 2708 - /** 2709 - * xe_oa_fini - OA de-initialization during device remove 2710 - * @xe: @xe_device 2711 - */ 2712 - void xe_oa_fini(struct xe_device *xe) 2713 - { 2714 - struct xe_oa *oa = &xe->oa; 2715 - 2716 - if (!oa->xe) 2717 - return; 2718 - 2719 - idr_for_each(&oa->metrics_idr, destroy_config, oa); 2720 - idr_destroy(&oa->metrics_idr); 2721 - 2722 - oa->xe = NULL; 2723 2681 }
-1
drivers/gpu/drm/xe/xe_oa.h
··· 15 15 struct xe_hw_engine; 16 16 17 17 int xe_oa_init(struct xe_device *xe); 18 - void xe_oa_fini(struct xe_device *xe); 19 18 void xe_oa_register(struct xe_device *xe); 20 19 void xe_oa_unregister(struct xe_device *xe); 21 20 int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *file);