Skip to content

Commit

Permalink
net: make caching calls work on RISC-V, even though they are no-ops
Browse files Browse the repository at this point in the history
Rather than having #ifdefs for ARM, we instead have the implementations
handle the architecture specific operations. In RISC-V's case, this is
just a no-op.

I removed `ROUND_UP(buffer.len, 1 << CONFIG_L1_CACHE_LINE_SIZE_BITS)`
because we do the rounding up in `cache_clean_and_invalidate`
anyways. We can't have this line on RISC-V because
`CONFIG_L1_CACHE_LINE_SIZE_BITS` does not exist on non-ARM architectures.

Signed-off-by: Ivan Velickovic <i.velickovic@unsw.edu.au>
  • Loading branch information
Ivan-Velickovic committed Sep 24, 2024
1 parent 62d5cfc commit a32fdae
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
10 changes: 1 addition & 9 deletions network/components/virt_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,7 @@ void rx_return(void)
// Cache invalidate after DMA write, so we don't read stale data.
// This must be performed after the DMA write to avoid reading
// data that was speculatively fetched before the DMA write.
//
// We would invalidate if it worked in usermode. Alas, it
// does not -- see [1]. The fastest operation that works is a
// usermode CleanInvalidate (faster than a Invalidate via syscall).
//
// [1]: https://developer.arm.com/documentation/ddi0595/2021-06/AArch64-Instructions/DC-IVAC--Data-or-unified-Cache-line-Invalidate-by-VA-to-PoC
#ifdef CONFIG_ARCH_ARM
cache_clean_and_invalidate(buffer_vaddr, buffer_vaddr + ROUND_UP(buffer.len, 1 << CONFIG_L1_CACHE_LINE_SIZE_BITS));
#endif
cache_clean_and_invalidate(buffer_vaddr, buffer_vaddr + buffer.len);
int client = get_mac_addr_match((struct ethernet_header *) buffer_vaddr);
if (client == BROADCAST_ID) {
int ref_index = buffer.io_or_offset / NET_BUFFER_SIZE;
Expand Down
2 changes: 0 additions & 2 deletions network/components/virt_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ void tx_provide(void)
assert(!err);
continue;
}
#ifdef CONFIG_ARCH_ARM
cache_clean(buffer.io_or_offset + state.buffer_region_vaddrs[client],
buffer.io_or_offset + state.buffer_region_vaddrs[client] + buffer.len);
#endif

buffer.io_or_offset = buffer.io_or_offset + state.buffer_region_paddrs[client];
err = net_enqueue_active(&state.tx_queue_drv, buffer);
Expand Down

0 comments on commit a32fdae

Please sign in to comment.