eth: fix cache maintenance

This commit is contained in:
Astro 2020-06-22 02:43:22 +02:00
parent 7f3e75e20c
commit 7ae8be58cf
3 changed files with 8 additions and 16 deletions

View File

@ -217,7 +217,7 @@ if false {
while let Ok(stream) = TcpStream::accept(TCP_PORT, 0x10_0000, 0x10_0000).await {
let stats_tx = stats_tx.clone();
task::spawn(async move {
let tx_data = (0..=255).take(4096).collect::<alloc::vec::Vec<u8>>();
let tx_data = (0..=255).take(65536).collect::<alloc::vec::Vec<u8>>();
loop {
// const CHUNK_SIZE: usize = 65536;
// match stream.send((0..=255).cycle().take(CHUNK_SIZE)).await {

View File

@ -83,10 +83,6 @@ impl DescList {
entry.word1.write(
DescWord1::zeroed()
);
// Flush buffer from cache, to be filled by the peripheral
// before next read
l2cache().clean_invalidate_slice(&buffer[..]);
dcci_slice(&buffer[..]);
}
DescList {
@ -112,8 +108,9 @@ impl DescList {
let word1 = entry.word1.read();
let len = word1.frame_length_lsbs().into();
let buffer = &mut self.buffers[self.next][0..len];
// l2cache().invalidate_slice(&mut buffer[..]);
// dcci_slice(&buffer[..]);
// Invalidate caches for packet buffer
l2cache().invalidate_slice(&mut buffer[..]);
dcci_slice(&buffer[..]);
self.next += 1;
if self.next >= list_len {
@ -142,10 +139,6 @@ pub struct PktRef<'a> {
impl<'a> Drop for PktRef<'a> {
fn drop(&mut self) {
// Flush buffer from cache, to be filled by the peripheral
// before next read
l2cache().invalidate_slice(self.buffer);
dcci_slice(self.buffer);
self.entry.word0.modify(|_, w| w.used(false));
dmb();

View File

@ -1,6 +1,6 @@
use core::ops::{Deref, DerefMut};
use alloc::{vec, vec::Vec};
use libcortex_a9::{cache::dcc_slice, UncachedSlice};
use libcortex_a9::{asm::dmb, cache::dcc_slice, UncachedSlice};
use libregister::*;
use log::{debug, warn};
use crate::l2cache;
@ -99,7 +99,7 @@ impl DescList {
// debug!("send {}", length);
let list_len = self.list.len();
let entry = &mut self.list[self.next];
// dmb();
dmb();
if entry.word1.read().used() {
let buffer = &mut self.buffers[self.next][0..length];
entry.word1.write(DescWord1::zeroed()
@ -133,13 +133,12 @@ pub struct PktRef<'a> {
impl<'a> Drop for PktRef<'a> {
fn drop(&mut self) {
// Write back all dirty cachelines of this buffer
// Write back all dirty cachelines of packet buffer
dcc_slice(self.buffer);
l2cache().clean_slice(self.buffer);
self.entry.word1.modify(|_, w| w.used(false));
// dcci(self.entry);
// l2cache().clean_invalidate(self.entry);
dmb();
// dsb();
if ! self.regs.tx_status.read().tx_go() {
// Start TX if not already running