Re: [PATCH 06/17] coresight: tmc: Make ETR SG table circular

From: Suzuki K Poulose
Date: Wed Nov 01 2017 - 06:12:49 EST


On 20/10/17 18:11, Julien Thierry wrote:

+static int __maybe_unused
+tmc_etr_sg_table_rotate(struct etr_sg_table *etr_table, u64 base_offset)
+{
+ÂÂÂ u32 last_entry, first_entry;
+ÂÂÂ u64 last_offset;
+ÂÂÂ struct tmc_sg_table *sg_table = etr_table->sg_table;
+ÂÂÂ sgte_t *table_ptr = sg_table->table_vaddr;
+ÂÂÂ ssize_t buf_size = tmc_sg_table_buf_size(sg_table);
+
+ÂÂÂ /* Offset should always be SG PAGE_SIZE aligned */
+ÂÂÂ if (base_offset & (ETR_SG_PAGE_SIZE - 1)) {
+ÂÂÂÂÂÂÂ pr_debug("unaligned base offset %llx\n", base_offset);
+ÂÂÂÂÂÂÂ return -EINVAL;
+ÂÂÂ }
+ÂÂÂ /* Make sure the offset is within the range */
+ÂÂÂ if (base_offset < 0 || base_offset > buf_size) {

base_offset is unsigned, so the left operand of the '||' is useless (would've expected the compiler to emit a warning for this).

+ÂÂÂÂÂÂÂ base_offset = (base_offset + buf_size) % buf_size;
+ÂÂÂÂÂÂÂ pr_debug("Resetting offset to %llx\n", base_offset);
+ÂÂÂ }
+ÂÂÂ first_entry = tmc_etr_sg_offset_to_table_index(base_offset);
+ÂÂÂ if (first_entry == etr_table->first_entry) {
+ÂÂÂÂÂÂÂ pr_debug("Head is already at %llx, skipping\n", base_offset);
+ÂÂÂÂÂÂÂ return 0;
+ÂÂÂ }
+
+ÂÂÂ /* Last entry should be the previous one to the new "base" */
+ÂÂÂ last_offset = ((base_offset - ETR_SG_PAGE_SIZE) + buf_size) % buf_size;
+ÂÂÂ last_entry = tmc_etr_sg_offset_to_table_index(last_offset);
+
+ÂÂÂ /* Reset the current Last page to Normal and new Last page to NORMAL */

Current Last page to NORMAL and new Last page to LAST?

Thanks again, will fix them

Cheers
Suzuki