-
Notifications
You must be signed in to change notification settings - Fork 348
Code to decode pipeline create messages payload #10265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| uint32_t domain_id; /* userspace domain ID */ | ||
| uint32_t stack_bytes; /* required stack size in bytes, 0 means default size */ | ||
| uint32_t heap_bytes; /* required heap size in bytes, 0 means default size */ | ||
| } __packed __aligned(4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on the one hand bytes are simple to understand and work with. OTOH if we use a larger unit (words, or cache lines, or pages), then we (1) can potentially use a smaller integer, (2) avoid the need to check and enforce alignment. No strong preference, just a thought
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes fine here since these are uint32_t - we should have enough space.
lgirdwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, we can followup with the allocations per pipeline or domain later.
| uint32_t domain_id; /* userspace domain ID */ | ||
| uint32_t stack_bytes; /* required stack size in bytes, 0 means default size */ | ||
| uint32_t heap_bytes; /* required heap size in bytes, 0 means default size */ | ||
| } __packed __aligned(4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bytes fine here since these are uint32_t - we should have enough space.
ac3bf18 to
5c3c095
Compare
src/ipc/ipc4/helper.c
Outdated
| char *data; | ||
|
|
||
| dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE, | ||
| MAILBOX_HOSTBOX_SIZE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is currently 8KiB on PTL... if there's a reasonable maximum size of data here, would be good to use it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of pipeline create, that would mean two calls, first just the payload header and then the rest, as there was no space for payload size in the msg itself. But the piece of code is from module init message handling, and there the size of the payload is encoded in the msg extension bits and could be used in the cache invalidation call.
I can do the both and unify the code a bit... actually there would be be quite a bit of cleaning work to be done in the IPC cocde...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, after picking this up again, it makes me wonder what is the harm in invalidating the whole mailbox? The operation time is hardly proportional to the range of memory the cache is being invalidated? And if there are some saved cache lines still present form some earlier IPC message, wouldn't it actually be good to mark those invalid. They should be of no use to anyone anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, you'll have a loop over 8KiB taking 64 bytes at a time, which makes 128 iterations. We should expect, that most addresses won't have cache lines associated with them, so their invalidation hopefully should be a NOP. Cache operations are relatively expensive, especially writing back, but if most addresses have no cache lines to them, their inivalidation shouldn't take too long. So, as I wrote - if some reasonable maximum size is easily available, it would be good to use it, if not - we can use this to begin with,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the whole mailbox is always invalidated, there should not be too many active lines there, only the amount left from previus IPC message. One could even think that it would be beneficial to free up these lines as they are certainly not of any use any more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they will be freed automatically, the hardware shouldn't need our help for that :-)
src/ipc/ipc4/helper.c
Outdated
| size_t size; | ||
|
|
||
| dcache_invalidate_region((__sparse_force void __sparse_cache *)MAILBOX_HOSTBOX_BASE, | ||
| hdr_cache_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're trying now to use sys_cache_data_invd_range() directly
src/ipc/ipc4/helper.c
Outdated
| dcache_invalidate_region((__sparse_force void __sparse_cache *) | ||
| ((char *)MAILBOX_HOSTBOX_BASE + hdr_cache_size), | ||
| ALIGN_UP(size, CONFIG_DCACHE_LINE_SIZE) - | ||
| hdr_cache_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be safe to just use whatever pointers and sizes you have, cache management functions adjust for cache lines internally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but to avoid invalidating the first cache line twice, and to avoid the second call all together if its not needed, I need the complex calculations.
e43cb7b to
9f5d981
Compare
2dc8ac4 to
7e4bb9a
Compare
| *((uint32_t *)hdr)); | ||
|
|
||
| obj = (const struct ipc4_pipeline_ext_object *)(hdr + 1); | ||
| while (!last_object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (obj = (const struct ipc4_pipeline_ext_object *)(hdr + 1); !last_object; obj = next_obj)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like while() better, especially as its now a better match to module_ext_init_decode() implementation
|
|
||
| /* Check if there is space for the object header */ | ||
| if ((char *)(obj + 1) - data > size) { | ||
| tr_err(&ipc_tr, "obj header overflow, %u > %u", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the format be %zu for size here and below?
| break; | ||
| } | ||
| default: | ||
| tr_info(&ipc_tr, "Unknown ext init object id %u of %u words", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tr_warn() or tr_dbg()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you have agains info 😄? If I must change this I'd go with warn, as if somebody is indeed reading the logs, it could be useful to know that the firmware is not able to use all info from the pipeline create payload.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supposedly we have all the different logging levels for a reason, so we might as well use them ;-) It's just that a message, beginning with "Unknown" but with a neutral status is a bit unclear to me. Is it bad or not? If it isn't bad - do I need to know about it? If not - maybe make it dbg(). If it does indeed indicate a potential problem, then a warn()
Add lifetime_bytes_requirement and shared_bytes_requirement widget attributes. This token's value indicates the amount of heap memory needed at component initialization phase. Signed-off-by: Jyri Sarha <[email protected]>
Adds structs and definitions for adding a payload to struct ipc4_pipeline_create message. The structure of the payload is very similar to struct ipc4_module_init_ext_init payload for struct ipc4_module_init_instance. Signed-off-by: Jyri Sarha <[email protected]>
Add ipc4_create_pipeline_payload_decode() and call it if struct ipc4_pipeline_create's extension.r.payload bit is set. The function decodes the message payload, logs the contents, but does not store the information anywhere. Signed-off-by: Jyri Sarha <[email protected]>
Invalidate cache for only the create pipeline payload size not whole mailbox. Signed-off-by: Jyri Sarha <[email protected]>
Invalidate cache for only the module init payload size not the whole mailbox. Signed-off-by: Jyri Sarha <[email protected]>
Add default values for stack, lifetime, and heap memory size for all widgets, e.g. module instances. These values were tested with vpages branch and all cases that I tried worked with them. Eventually each module should be added with more accurate values, based on measurements. Signed-off-by: Jyri Sarha <[email protected]>
Pass create pipeline payload parameters down to pipeline_new() by using struct pipeline_params. That is the place where the data will be used. Signed-off-by: Jyri Sarha <[email protected]>
7e4bb9a to
d9de565
Compare
|
@lgirdwood this is now updated so that it should be almost exact match to #10281 , vpages code only needs to use the params passed to pipeline_new(). But to use this the topology should be built from this PR and you need my linux driver PR #10281 too to pass down the topology info. |
Code to decode pipline create messages payload. E.g. this code is written to test this PR: thesofproject/linux#5537