You can NOT protect a function like that with a semaphore (or a mutex), unless it can do something if it is called while protected. Imagine that it is in the protected section with the semaphore taken, then the interrupt occurs, The function will see the semaphore taken but can’t wait for it to be given, as you can’t leave the ISR and then come back.
Code sections that need protection from reentry by ISRs need to use critical sections which disable interrupts (and thus need to be kept small).
If you really need to decide, then some ports provide a function to determine if you are currently inside an ISR, so you could check and do the right action.
I would first think carefully if this is actually being setup right, as generally ISRs should be short and not calling a lot of functions, especial those that do a lot of calculations or need to access protected stuff for long. You might want to see if that part would be better done in a task signaled by the ISR.