- kfree(payload);
I think it would be easier to understand this kfree if payload was also allocated in this function in stead of inside the get_large_config().
That's a good thinking. There was an internal conversation regarding this back in time when we have been implementing getters for the first time. There are no clear victors, there are drawbacks - as you do not know the size upfront, caller has to guess and then reallocate the buffer accordingly to retrieved payload size from the firmware. So, even if you allocate buffer here, chances are, it's not the same buffer when the avs_ipc_get_large_config() returns to the caller.
We have decided to reduce the code size by letting the single, common handler do the allocation and leave the other responsibilities to the caller.
What could make it simpler is if you allocate MAX IPC size for payload in this function and then copy the right size in the avs_ipc_get_large_config(). payload_size tells you that information anyway right?
Thanks, Ranjani