From 83fcbedc65f4b9ae7e491ecf6f07c0af4b245f74 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sat, 27 Mar 2021 17:17:19 -0400 Subject: rk27xx: Take advantage of STORAGE_NEEDS_BOUNCE_BUFFER (And get rid of its custom realignment code) Change-Id: Iff27d717b870d3db239310421776744ea6863373 --- firmware/target/arm/rk27xx/sd-rk27xx.c | 9 +++++++++ firmware/target/arm/rk27xx/system-target.h | 1 + 2 files changed, 10 insertions(+) diff --git a/firmware/target/arm/rk27xx/sd-rk27xx.c b/firmware/target/arm/rk27xx/sd-rk27xx.c index e5467058de..2ddf91a67e 100644 --- a/firmware/target/arm/rk27xx/sd-rk27xx.c +++ b/firmware/target/arm/rk27xx/sd-rk27xx.c @@ -41,6 +41,7 @@ #include "sysfont.h" #define RES_NO (-1) +// #define ALIGN_BUF /* debug stuff */ unsigned long sd_debug_time_rd = 0; @@ -51,7 +52,9 @@ static tCardInfo card_info; /* for compatibility */ static long last_disk_activity = -1; +#ifdef ALIGN_BUF static unsigned char aligned_buf[512] STORAGE_ALIGN_ATTR; +#endif static struct mutex sd_mtx SHAREDBSS_ATTR; #ifndef BOOTLOADER @@ -397,8 +400,10 @@ static inline void read_sd_data(unsigned char **dst) { void *buf = *dst; +#ifdef ALIGN_BUF if (!IS_ALIGNED(((unsigned long)*dst), CACHEALIGN_SIZE)) buf = aligned_buf; +#endif commit_discard_dcache_range((const void *)buf, 512); @@ -413,8 +418,10 @@ static inline void read_sd_data(unsigned char **dst) /* wait for DMA engine to finish transfer */ while (A2A_DMA_STS & 1); +#ifdef ALIGN_BUF if (buf == aligned_buf) memcpy(*dst, aligned_buf, 512); +#endif *dst += 512; } @@ -423,11 +430,13 @@ static inline void write_sd_data(unsigned char **src) { void *buf = *src; +#ifdef ALIGN_BUF if (!IS_ALIGNED(((unsigned long)*src), CACHEALIGN_SIZE)) { buf = aligned_buf; memcpy(aligned_buf, *src, 512); } +#endif commit_discard_dcache_range((const void *)buf, 512); diff --git a/firmware/target/arm/rk27xx/system-target.h b/firmware/target/arm/rk27xx/system-target.h index a5b27cc6b2..eca675a2af 100644 --- a/firmware/target/arm/rk27xx/system-target.h +++ b/firmware/target/arm/rk27xx/system-target.h @@ -53,5 +53,6 @@ void commit_discard_idcache(void); #define CPUFREQ_MAX 200000000 #define STORAGE_WANTS_ALIGN +#define STORAGE_NEEDS_BOUNCE_BUFFER #endif /* SYSTEM_TARGET_H */ -- cgit v1.2.3