Skip to content

Commit d3f557d

Browse files
committed
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>
1 parent f5ebe80 commit d3f557d

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

drivers/gpu/drm/xe/xe_device.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ int xe_device_probe(struct xe_device *xe)
873873

874874
err = xe_display_init(xe);
875875
if (err)
876-
goto err_fini_oa;
876+
return err;
877877

878878
err = xe_pxp_init(xe);
879879
if (err)
@@ -905,9 +905,6 @@ int xe_device_probe(struct xe_device *xe)
905905
err_fini_display:
906906
xe_display_driver_remove(xe);
907907

908-
err_fini_oa:
909-
xe_oa_fini(xe);
910-
911908
return err;
912909
}
913910

@@ -980,8 +977,6 @@ void xe_device_remove(struct xe_device *xe)
980977

981978
xe_device_remove_display(xe);
982979

983-
xe_oa_fini(xe);
984-
985980
xe_heci_gsc_fini(xe);
986981

987982
xe_device_call_remove_actions(xe);

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,6 +2641,27 @@ static void xe_oa_init_supported_formats(struct xe_oa *oa)
26412641
}
26422642
}
26432643

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+
26442665
/**
26452666
* xe_oa_init - OA initialization during device probe
26462667
* @xe: @xe_device
@@ -2672,31 +2693,10 @@ int xe_oa_init(struct xe_device *xe)
26722693
}
26732694

26742695
xe_oa_init_supported_formats(oa);
2675-
return 0;
2676-
exit:
2677-
oa->xe = NULL;
2678-
return ret;
2679-
}
26802696

2681-
static int destroy_config(int id, void *p, void *data)
2682-
{
2683-
xe_oa_config_put(p);
2684-
return 0;
2685-
}
2686-
2687-
/**
2688-
* xe_oa_fini - OA de-initialization during device remove
2689-
* @xe: @xe_device
2690-
*/
2691-
void xe_oa_fini(struct xe_device *xe)
2692-
{
2693-
struct xe_oa *oa = &xe->oa;
2694-
2695-
if (!oa->xe)
2696-
return;
2697-
2698-
idr_for_each(&oa->metrics_idr, destroy_config, oa);
2699-
idr_destroy(&oa->metrics_idr);
2697+
return devm_add_action_or_reset(xe->drm.dev, xe_oa_fini, xe);
27002698

2699+
exit:
27012700
oa->xe = NULL;
2701+
return ret;
27022702
}

drivers/gpu/drm/xe/xe_oa.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ struct xe_gt;
1515
struct xe_hw_engine;
1616

1717
int xe_oa_init(struct xe_device *xe);
18-
void xe_oa_fini(struct xe_device *xe);
1918
void xe_oa_register(struct xe_device *xe);
2019
void xe_oa_unregister(struct xe_device *xe);
2120
int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *file);

0 commit comments

Comments
 (0)