18c2ecf20Sopenharmony_ci=====================================================
28c2ecf20Sopenharmony_ciFreescale i.MX8 DDR Performance Monitoring Unit (PMU)
38c2ecf20Sopenharmony_ci=====================================================
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ciThere are no performance counters inside the DRAM controller, so performance
68c2ecf20Sopenharmony_cisignals are brought out to the edge of the controller where a set of 4 x 32 bit
78c2ecf20Sopenharmony_cicounters is implemented. This is controlled by the CSV modes programed in counter
88c2ecf20Sopenharmony_cicontrol register which causes a large number of PERF signals to be generated.
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciSelection of the value for each counter is done via the config registers. There
118c2ecf20Sopenharmony_ciis one register for each counter. Counter 0 is special in that it always counts
128c2ecf20Sopenharmony_ci“time” and when expired causes a lock on itself and the other counters and an
138c2ecf20Sopenharmony_ciinterrupt is raised. If any other counter overflows, it continues counting, and
148c2ecf20Sopenharmony_cino interrupt is raised.
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ciThe "format" directory describes format of the config (event ID) and config1
178c2ecf20Sopenharmony_ci(AXI filtering) fields of the perf_event_attr structure, see /sys/bus/event_source/
188c2ecf20Sopenharmony_cidevices/imx8_ddr0/format/. The "events" directory describes the events types
198c2ecf20Sopenharmony_cihardware supported that can be used with perf tool, see /sys/bus/event_source/
208c2ecf20Sopenharmony_cidevices/imx8_ddr0/events/. The "caps" directory describes filter features implemented
218c2ecf20Sopenharmony_ciin DDR PMU, see /sys/bus/events_source/devices/imx8_ddr0/caps/.
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci    .. code-block:: bash
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci        perf stat -a -e imx8_ddr0/cycles/ cmd
268c2ecf20Sopenharmony_ci        perf stat -a -e imx8_ddr0/read/,imx8_ddr0/write/ cmd
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciAXI filtering is only used by CSV modes 0x41 (axid-read) and 0x42 (axid-write)
298c2ecf20Sopenharmony_cito count reading or writing matches filter setting. Filter setting is various
308c2ecf20Sopenharmony_cifrom different DRAM controller implementations, which is distinguished by quirks
318c2ecf20Sopenharmony_ciin the driver. You also can dump info from userspace, filter in "caps" directory
328c2ecf20Sopenharmony_ciindicates whether PMU supports AXI ID filter or not; enhanced_filter indicates
338c2ecf20Sopenharmony_ciwhether PMU supports enhanced AXI ID filter or not. Value 0 for un-supported, and
348c2ecf20Sopenharmony_civalue 1 for supported.
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci* With DDR_CAP_AXI_ID_FILTER quirk(filter: 1, enhanced_filter: 0).
378c2ecf20Sopenharmony_ci  Filter is defined with two configuration parts:
388c2ecf20Sopenharmony_ci  --AXI_ID defines AxID matching value.
398c2ecf20Sopenharmony_ci  --AXI_MASKING defines which bits of AxID are meaningful for the matching.
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci      - 0: corresponding bit is masked.
428c2ecf20Sopenharmony_ci      - 1: corresponding bit is not masked, i.e. used to do the matching.
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_ci  AXI_ID and AXI_MASKING are mapped on DPCR1 register in performance counter.
458c2ecf20Sopenharmony_ci  When non-masked bits are matching corresponding AXI_ID bits then counter is
468c2ecf20Sopenharmony_ci  incremented. Perf counter is incremented if::
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci        AxID && AXI_MASKING == AXI_ID && AXI_MASKING
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci  This filter doesn't support filter different AXI ID for axid-read and axid-write
518c2ecf20Sopenharmony_ci  event at the same time as this filter is shared between counters.
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci  .. code-block:: bash
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci      perf stat -a -e imx8_ddr0/axid-read,axi_mask=0xMMMM,axi_id=0xDDDD/ cmd
568c2ecf20Sopenharmony_ci      perf stat -a -e imx8_ddr0/axid-write,axi_mask=0xMMMM,axi_id=0xDDDD/ cmd
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci  .. note::
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci      axi_mask is inverted in userspace(i.e. set bits are bits to mask), and
618c2ecf20Sopenharmony_ci      it will be reverted in driver automatically. so that the user can just specify
628c2ecf20Sopenharmony_ci      axi_id to monitor a specific id, rather than having to specify axi_mask.
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci  .. code-block:: bash
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci        perf stat -a -e imx8_ddr0/axid-read,axi_id=0x12/ cmd, which will monitor ARID=0x12
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci* With DDR_CAP_AXI_ID_FILTER_ENHANCED quirk(filter: 1, enhanced_filter: 1).
698c2ecf20Sopenharmony_ci  This is an extension to the DDR_CAP_AXI_ID_FILTER quirk which permits
708c2ecf20Sopenharmony_ci  counting the number of bytes (as opposed to the number of bursts) from DDR
718c2ecf20Sopenharmony_ci  read and write transactions concurrently with another set of data counters.
72