Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
@keyonjie I wonder why you use "ptr" here. I guess this is harmless, but it seems this may be called also on noncached pointers.
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.
The dcache_writeback_invalidate_region() internal will do nothing for noncached "ptr", and do flush and invalidate for cached "ptr".
The "ptr" is what the user/caller used, while it could be different with the one used for memory blocks management. Imagine that we are using uncached address for BUFFER zone management, while user can use its corresponding cached alias to read/write from the cache lines. That's why we might need to free blocks with uncached_ptr, and do wb/inv with cached one.
On the other hand, if the user/caller uses uncached ptr directly, we don't want/need to do extra/superfluous wb/inv with its alias cached ptr (cached_ptr), so use "ptr" -- the one the user used and pass it into dcache_writeback_invalidate_region() to decide if wb/inv is actually needed.
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.
@keyonjie what about the size of the memory you're invalidatign and writing back here? Shouldnt we be using the original size that was allocated?
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.
We don't have the original size from the rfree() invoking, and since the whole block is occupied by the caller exclusively, so wb/invalidate the whole block size is safe, although the caller may actually not touching some portion of it at all.
OTOH, if parts of the specified address is not in the cache (as the caller not touching it at all), the wb/inv instruction will actually has no effect on those address, no actual writeback or invalidate happens with those address.
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.
@keyonjie thats good but then shouldnt we be using free_ptr instead of ptr?
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.
No, please see my comment above: #4861 (comment)
The free_ptr could be different with the user used ptr.
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.
@keyonjie Isn't it possible that you then wbinv part of the next block? To be fair you're not losing data so this is reasonable but was this accounted for when you wrote the patch?
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.
@paulstelian97 Yes, that was considered: one fact is that all the return allocated pointers are PLATFORM_DCACHE_ALIGN aligned today, so there is no 2 allocated buffers share a same dcache line, wbinv of one allocated cached buffer will not take the cache line from another allocated buffer.