Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

intel_th: msu: Make contiguous buffers uncached

We already keep the multiblock mode buffers uncached, but forget the
single mode. Address this.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Link: https://lore.kernel.org/r/20210621151246.31891-4-alexander.shishkin@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alexander Shishkin and committed by
Greg Kroah-Hartman
02ca71ef ae128916

+32 -16
+32 -16
drivers/hwtracing/intel_th/msu.c
··· 1024 1024 } 1025 1025 1026 1026 #ifdef CONFIG_X86 1027 - static void msc_buffer_set_uc(struct msc_window *win, unsigned int nr_segs) 1027 + static void msc_buffer_set_uc(struct msc *msc) 1028 1028 { 1029 1029 struct scatterlist *sg_ptr; 1030 + struct msc_window *win; 1030 1031 int i; 1031 1032 1032 - for_each_sg(win->sgt->sgl, sg_ptr, nr_segs, i) { 1033 - /* Set the page as uncached */ 1034 - set_memory_uc((unsigned long)sg_virt(sg_ptr), 1035 - PFN_DOWN(sg_ptr->length)); 1033 + if (msc->mode == MSC_MODE_SINGLE) { 1034 + set_memory_uc((unsigned long)msc->base, msc->nr_pages); 1035 + return; 1036 + } 1037 + 1038 + list_for_each_entry(win, &msc->win_list, entry) { 1039 + for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { 1040 + /* Set the page as uncached */ 1041 + set_memory_uc((unsigned long)sg_virt(sg_ptr), 1042 + PFN_DOWN(sg_ptr->length)); 1043 + } 1036 1044 } 1037 1045 } 1038 1046 1039 - static void msc_buffer_set_wb(struct msc_window *win) 1047 + static void msc_buffer_set_wb(struct msc *msc) 1040 1048 { 1041 1049 struct scatterlist *sg_ptr; 1050 + struct msc_window *win; 1042 1051 int i; 1043 1052 1044 - for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { 1045 - /* Reset the page to write-back */ 1046 - set_memory_wb((unsigned long)sg_virt(sg_ptr), 1047 - PFN_DOWN(sg_ptr->length)); 1053 + if (msc->mode == MSC_MODE_SINGLE) { 1054 + set_memory_wb((unsigned long)msc->base, msc->nr_pages); 1055 + return; 1056 + } 1057 + 1058 + list_for_each_entry(win, &msc->win_list, entry) { 1059 + for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { 1060 + /* Reset the page to write-back */ 1061 + set_memory_wb((unsigned long)sg_virt(sg_ptr), 1062 + PFN_DOWN(sg_ptr->length)); 1063 + } 1048 1064 } 1049 1065 } 1050 1066 #else /* !X86 */ 1051 1067 static inline void 1052 - msc_buffer_set_uc(struct msc_window *win, unsigned int nr_segs) {} 1053 - static inline void msc_buffer_set_wb(struct msc_window *win) {} 1068 + msc_buffer_set_uc(struct msc *msc) {} 1069 + static inline void msc_buffer_set_wb(struct msc *msc) {} 1054 1070 #endif /* CONFIG_X86 */ 1055 1071 1056 1072 /** ··· 1112 1096 1113 1097 if (ret <= 0) 1114 1098 goto err_nomem; 1115 - 1116 - msc_buffer_set_uc(win, ret); 1117 1099 1118 1100 win->nr_segs = ret; 1119 1101 win->nr_blocks = nr_blocks; ··· 1165 1151 msc->base = NULL; 1166 1152 msc->base_addr = 0; 1167 1153 } 1168 - 1169 - msc_buffer_set_wb(win); 1170 1154 1171 1155 if (msc->mbuf && msc->mbuf->free_window) 1172 1156 msc->mbuf->free_window(msc->mbuf_priv, win->sgt); ··· 1272 1260 */ 1273 1261 static void msc_buffer_free(struct msc *msc) 1274 1262 { 1263 + msc_buffer_set_wb(msc); 1264 + 1275 1265 if (msc->mode == MSC_MODE_SINGLE) 1276 1266 msc_buffer_contig_free(msc); 1277 1267 else if (msc->mode == MSC_MODE_MULTI) ··· 1317 1303 } 1318 1304 1319 1305 if (!ret) { 1306 + msc_buffer_set_uc(msc); 1307 + 1320 1308 /* allocation should be visible before the counter goes to 0 */ 1321 1309 smp_mb__before_atomic(); 1322 1310