Pass parameters to function through an action

add_action() and add_filter() take 4 params: string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1.

So, the function you are hooking to takes more than 1 param, then just pass the number of params it accepts as the 4th param to add_action(). In your case,

add_action ('my_action', 'my_function', 10, 2) ;