Commit a74440b27b3f12d2cce54d7910953af19f1ac051

Authored by Ramon Fried
Committed by Tom Rini
1 parent b559c4af80

iotrace: add IO region limit

When dealing with a lot of IO regions, sometimes
it makes sense only to trace a specific one.
This patch adds support for region limits.
If region is not set, the iotrace works the same as it was.
If region is set, the iotrace only logs io operation that falls
in the defined region.

Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 51 additions and 0 deletions Side-by-side Diff

... ... @@ -42,6 +42,8 @@
42 42 * @start: Start address of iotrace buffer
43 43 * @size: Size of iotrace buffer in bytes
44 44 * @offset: Current write offset into iotrace buffer
  45 + * @region_start: Address of IO region to trace
  46 + * @region_size: Size of region to trace. if 0 will trace all address space
45 47 * @crc32: Current value of CRC chceksum of trace records
46 48 * @enabled: true if enabled, false if disabled
47 49 */
... ... @@ -49,6 +51,8 @@
49 51 ulong start;
50 52 ulong size;
51 53 ulong offset;
  54 + ulong region_start;
  55 + ulong region_size;
52 56 u32 crc32;
53 57 bool enabled;
54 58 } iotrace;
... ... @@ -66,6 +70,11 @@
66 70 if (!(gd->flags & GD_FLG_RELOC) || !iotrace.enabled)
67 71 return;
68 72  
  73 + if (iotrace.region_size)
  74 + if ((ulong)ptr < iotrace.region_start ||
  75 + (ulong)ptr > iotrace.region_start + iotrace.region_size)
  76 + return;
  77 +
69 78 /* Store it if there is room */
70 79 if (iotrace.offset + sizeof(*rec) < iotrace.size) {
71 80 rec = (struct iotrace_record *)map_sysmem(
... ... @@ -140,6 +149,24 @@
140 149 u32 iotrace_get_checksum(void)
141 150 {
142 151 return iotrace.crc32;
  152 +}
  153 +
  154 +void iotrace_set_region(ulong start, ulong size)
  155 +{
  156 + iotrace.region_start = start;
  157 + iotrace.region_size = size;
  158 +}
  159 +
  160 +void iotrace_reset_region(void)
  161 +{
  162 + iotrace.region_start = 0;
  163 + iotrace.region_size = 0;
  164 +}
  165 +
  166 +void iotrace_get_region(ulong *start, ulong *size)
  167 +{
  168 + *start = iotrace.region_start;
  169 + *size = iotrace.region_size;
143 170 }
144 171  
145 172 void iotrace_set_enabled(int enable)
... ... @@ -59,6 +59,30 @@
59 59 u32 iotrace_get_checksum(void);
60 60  
61 61 /**
  62 + * iotrace_set_region() - Set whether iotrace is limited to a specific
  63 + * io region.
  64 + *
  65 + * Defines the address and size of the limited region.
  66 + *
  67 + * @start: address of the beginning of the region
  68 + * @size: size of the region in bytes.
  69 + */
  70 +void iotrace_set_region(ulong start, ulong size);
  71 +
  72 +/**
  73 + * iotrace_reset_region() - Reset the region limit
  74 + */
  75 +void iotrace_reset_region(void);
  76 +
  77 +/**
  78 + * iotrace_get_region() - Get region information
  79 + *
  80 + * @start: Returns start address of region
  81 + * @size: Returns size of region in bytes
  82 + */
  83 +void iotrace_get_region(ulong *start, ulong *size);
  84 +
  85 +/**
62 86 * iotrace_set_enabled() - Set whether iotracing is enabled or not
63 87 *
64 88 * This controls whether the checksum is updated and a trace record added