Commit Graph

21 Commits

Author SHA1 Message Date
Jyri Sarha ab8849581c tools/probe: Add routing FW logs to stdout and dma data from stdin
To get dma data from std in, just leav out the -p flag, and to get
logs from stdout, use -l flag.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-10-03 15:00:39 +01:00
Jyri Sarha 7438070eec tools/probe: Split the demuxer and offline command to separate files
Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-10-03 15:00:39 +01:00
Jyri Sarha ceced0e641 tools/probe: Drop undeeded include files
Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-10-03 15:00:39 +01:00
Jyri Sarha 43bc85f570 tools/probe: Another restructure of dma stream demux code
This time the target is to make the demuxer more modular so that it is
not coupled with file reading operations and it is easy to use
alsa-lib directly.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-10-03 15:00:39 +01:00
Jyri Sarha 29af2df766 tools/probe: Fix realloc condition
The allocated packet should accommodate the header, the data, and the
checksum. The header size was missing from the condition from the
beginning, even if its there in realloc parameter. The bug should be
harmless waste of cycles thou.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-09-28 14:04:39 +01:00
Jyri Sarha 548de64551 tools/probe: Move data_to_copy variable down in scope
Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-09-28 14:04:39 +01:00
Jyri Sarha e21be99ce6 tools/probe: Drop sync_word_at(), a simple == condition will do
The sync_word_at() only checks for two things, if the len parameter is
greater than sizeof(uint32_t) and if the memory pointed p parameter
holds PROBE_EXTRACT_SYNC_WORD value. Now that the available bytes is
checked just before sync_word_at() call, the whole function starts to
look a bit pointless.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-09-28 14:04:39 +01:00
Jyri Sarha 1a1a558ac0 tools/probe: Remove unused write_data() function
Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-09-28 14:04:39 +01:00
Jyri Sarha a940766d27 tools/probe: Fix realloc() usage
Realloc may change the location of memory and the code should
anticipate it.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-09-28 14:04:39 +01:00
Jyri Sarha 50caa7dc1a tools/probe: Several fixes and restructuring for demuxcode
Several fixes and restructuring for demuxcode to make it work with sub
32-bit word granularity.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-09-28 14:04:39 +01:00
Jyri Sarha 34d750d40b probe: Drop old IPC3 style probe DMA framing
Drop IPC3 probe DMA framing and use IPC4 framing for IPC3 mode
too. This change simplifies the code quite a bit. After this change
both the SOF firmware and sof-probe demux tool should be updated at
the same time.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-09-28 14:04:39 +01:00
Kai Vehmanen 87425baf22 probe-app: add support for non-audio probe buffers
Identify non-audio probe streams and write them out with ".bin"
extension and without the RIFF WAVE header.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-08-16 15:35:03 +01:00
Kai Vehmanen bd9168f676 probe-app: support non-word aligned probe data streams
Modify code to correctly handle probe streams where sync word
can occur at any byte boundary, and where probe packet size may
not be aligned to 32bit word size.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-08-16 15:35:03 +01:00
Kai Vehmanen e2a5d925ba probe-app: bail out if opening file fails
Do not blindly call fwrite without checking whether file open
succeeded or not.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-08-16 15:35:03 +01:00
Kai Vehmanen 89039c6bff probe-app: fix handling of buffer-id of zero
Don't assume buffer-id of zero is an invalid value.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-08-16 15:35:03 +01:00
Curtis Malainey 89e7983498 probe: fix realloc mishandling
you need to use a temp var always with realloc, otherwise you through
away your pointer to your memory (which is still valid) in the event of
realloc failing.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-06-03 13:32:59 +01:00
Curtis Malainey ead5afa6c2 probe: refactor function to decrease indent
following commit fixes a bug but to do the fix we need to allow
ourselves more room to add ifs, so lets pull out this function

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2021-06-03 13:32:59 +01:00
Marc Herbert 0b80998bb1 Revert __builtin_assume_aligned(4) probe packet, replace with aligned(4)
This reverts and replaces commit 2765b22049 ("probe-app: assume probe
packet aligned"). That commit applied a __builtin_assume_aligned(4) to
every pointer assignment of the following type:

  uint32_t *ptr = struct probe_data_packet *packet;

Instead of using __builtin_assume_aligned(4) every time a
probe_data_packet is used like this, the probe_data_packet type
definition is now 32 bits aligned in only one place thanks to (packed,
aligned(4)).

struct probe_data_packet is made entirely of uint32_t members. It
is (packed) to avoid a 64 bits compiler hypothetically padding and
aligning these 32 bits members to 64 bits. However, (packed) alone is
roughly equivalent to aligned(1) (neither is part of the C standard)
which causes some gcc versions to warn about this:

  sof/tools/probes/probes_main.c:228:5: error: converting a packed
  ‘struct probe_data_packet’ pointer (alignment 1) to a ‘uint32_t’
  {aka ‘unsigned int’} pointer (alignment 4) may result in an
  unaligned pointer value [-Werror=address-of-packed-member]

  228 |     w_ptr = (uint32_t *)packet;
      |     ^~~~~

Unlike "assuming" with __builtin_assume_aligned, (packed, aligned(4))
makes sure probe_data_packet are _actually_ 4 bytes aligned. As a
demontration, it stops the following _Static_assert() from failing:

modified   src/probe/probe.c
@ -64,9 +64,12 @ struct probe_pdata {
 	struct probe_dma_ext ext_dma;
 	struct probe_dma_ext inject_dma[CONFIG_PROBE_DMA_MAX];
 	struct probe_point probe_points[CONFIG_PROBE_POINTS_MAX];
+	uint8_t dummy;
 	struct probe_data_packet header; // aligned(4)?
 	struct task dmap_work;
 };
+_Static_assert(offsetof(struct probe_pdata, header) % 4 == 0 ,
+               "probe_data_packet is not 4 aligned");

In addition to gcc version 8 and 9, I tested and confirmed with
_Static_assert and pahole that the same attributes behave the same with
clang 9.0.1-2.fc31.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-04-07 14:45:48 +01:00
Adrian Bonislawski f1fa3be980 probes-app: add allocation check
This will check if the allocation succeeded

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
2020-03-18 21:58:03 +00:00
Adrian Bonislawski 2765b22049 probe-app: assume probe packet aligned
Thats because probe packet struct is packed and aligned to 1
which will generate a warning (error) with pointer assigning

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
2020-03-18 21:58:03 +00:00
Adrian Bonislawski 1b2a6ef02e probe-app: initial code
Probes will extract data for several probe points in one stream
 with extra headers. This app will read the resulting file,
 strip the headers and create wave files for each extracted buffer.

 Usage to parse data and create wave files: ./sof-probes -p data.bin

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@linux.intel.com>
2020-02-19 12:28:59 +00:00