Go to file
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
.github/ISSUE_TEMPLATE github: fix link to bug tracking docs 2020-01-09 11:24:06 +00:00
doc audio-stream: dox: add full api documentation 2020-03-28 13:04:55 +01:00
rimage rimage: Remove ldc generation ability 2020-04-03 16:27:04 +01:00
scripts cmake: add *_overridedefconfig targets 2020-04-03 20:20:43 +01:00
smex smex: Add elf modules content validation 2020-04-03 16:27:04 +01:00
src Revert __builtin_assume_aligned(4) probe packet, replace with aligned(4) 2020-04-07 14:45:48 +01:00
test sof: Avoid comparison with NULL 2020-04-07 12:07:59 +03:00
tools Revert __builtin_assume_aligned(4) probe packet, replace with aligned(4) 2020-04-07 14:45:48 +01:00
.gitignore gitignore: Ignore cscope cache files 2019-12-04 15:41:33 +02:00
.travis.yml CI: travis: Add host-testbecnh 2020-04-03 09:13:03 +01:00
CMakeLists.txt cmake: build option for clang static analyzer 2020-03-04 11:02:56 +01:00
CODEOWNERS CODEOWNERS: scripts/ += marc-hb 2020-04-04 20:06:49 +01:00
Kconfig memory: change LP_SRAM to helper config 2020-02-04 11:30:02 +00:00
LICENCE licence: update for kconfig and elf.h 2019-02-01 11:12:36 +00:00
README.md Updated Readme for cht configuration 2019-04-26 10:42:41 +01:00

README.md

Sound Open Firmware

Status

Build Status

Documentation

See docs

Prerequisites

  • Docker
  • CMake (version >= 3.10)

Build Instructions

  1. Create directory in checked out repo for build files:
mkdir build && cd build
  1. Run configuration for your toolchain:

Baytrail / Cherrytrail:

cmake -DTOOLCHAIN=xtensa-byt-elf -DROOT_DIR=`pwd`/../../xtensa-root/xtensa-byt-elf ..

Haswell / Broadwell:

cmake -DTOOLCHAIN=xtensa-hsw-elf -DROOT_DIR=`pwd`/../../xtensa-root/xtensa-hsw-elf ..

Apollolake:

cmake -DTOOLCHAIN=xtensa-apl-elf -DROOT_DIR=`pwd`/../../xtensa-root/xtensa-apl-elf ..

Cannonlake:

cmake -DTOOLCHAIN=xtensa-cnl-elf -DROOT_DIR=`pwd`/../../xtensa-root/xtensa-cnl-elf ..
  1. Apply default config for your platform.

Baytrail:

make baytrail_defconfig

Cherrytrail:

make cherrytrail_defconfig

Haswell:

make haswell_defconfig

Broadwell:

make broadwell_defconfig

Apollolake:

make apollolake_defconfig

Cannonlake:

make cannonlake_defconfig
  1. (Optional) Customize your configuration
make menuconfig
  1. Build firmware
make bin
# or `make bin -j<jobs>` for parallel build

Running the tests

See unit testing documentation

Deployment

TODO: Add additional notes about how to deploy this on a live system

Contributing

See Contributing to the Project

License

This project is licensed under the BSD Clause 3 - see the LICENCE file for details