Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

google_aec: Sparse fixups #9265

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/audio/google/google_rtc_audio_processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ struct google_rtc_audio_processing_comp_data {
void (*out_copy)(struct sof_sink *dst, int frames, float **src_bufs);
};

/* The underlying API is not sparse-aware, so rather than try to
* finesse the conversions everywhere the buffers touch, turn checking
* off when we computed the cached address
*/
static void *cached_ptr(void *p)
{
return (__sparse_force void *) sys_cache_cached_ptr_get(p);
}

void *GoogleRtcMalloc(size_t size)
{
return rballoc(0, SOF_MEM_CAPS_RAM, size);
Expand Down Expand Up @@ -526,7 +535,7 @@ static int google_rtc_audio_processing_init(struct processing_module *mod)
cd->num_frames = NUM_FRAMES;

/* Giant blob of scratch memory. */
GoogleRtcAudioProcessingAttachMemoryBuffer(sys_cache_cached_ptr_get(&aec_mem_blob[0]),
GoogleRtcAudioProcessingAttachMemoryBuffer(cached_ptr(&aec_mem_blob[0]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we not just put a linter disable here for sparse?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we not just put a linter disable here for sparse?

I thought a "linter disable" was what this PR is already doing :-D

More seriously, what do you mean by "here"? This file, this directory, other?

How about something like this below? Now you could really rid all this code of all sparse annotations.

At this point it would better to create a new app/overlays/sparse.conf, similar to #9264 which I just submitted.

--- a/.github/workflows/sparse-zephyr.yml
+++ b/.github/workflows/sparse-zephyr.yml
@@ -70,6 +70,7 @@ jobs:
              ./sof/zephyr/docker-build.sh ${{ matrix.platform }}          \
              --cmake-args=-DZEPHYR_SCA_VARIANT=sparse --cmake-args=-DCONFIG_LOG_USE_VLA=n  \
              --cmake-args=-DCONFIG_MINIMAL_LIBC=y  \
+             --cmake-args=-DCONFIG_GOOGLE_RTC_STUFF=n  \
              --pristine 2>&1 | tee _.log
 
              printf '\n\n\t\t\t  ---- Messages below are treated as sparse errors --- \n\n\n'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No no, we want the sparse checking in general in this file. It was this one situation where we're dealing with buffers (in cached addresses) that need to be passed to a third party library without sparse annotation that something needs to be fudged. I think there's room for argument about where the fudging should be (I lean hard to the "brevity" side over "pedantic correctness" in this patch). But all the other SOF API use wants to know that it will be cache-correct going forward.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah got it, wasn't sure if we could do something like a style linter and drop a comment to silence this one line

sizeof(aec_mem_blob));

cd->state = GoogleRtcAudioProcessingCreateWithConfig(CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING_SAMPLE_RATE_HZ,
Expand Down Expand Up @@ -554,8 +563,8 @@ static int google_rtc_audio_processing_init(struct processing_module *mod)
}

for (i = 0; i < CHAN_MAX; i++) {
cd->raw_mic_buffers[i] = sys_cache_cached_ptr_get(&micbuf[i][0]);
cd->refout_buffers[i] = sys_cache_cached_ptr_get(&refoutbuf[i][0]);
cd->raw_mic_buffers[i] = cached_ptr(&micbuf[i][0]);
cd->refout_buffers[i] = cached_ptr(&refoutbuf[i][0]);
}

cd->buffered_frames = 0;
Expand Down Expand Up @@ -804,7 +813,7 @@ static int mod_process(struct processing_module *mod, struct sof_source **source

/* Clear the buffer if the reference pipeline shuts off */
if (!ref_ok && cd->last_ref_ok)
bzero(sys_cache_cached_ptr_get(refoutbuf), sizeof(refoutbuf));
bzero(cached_ptr(refoutbuf), sizeof(refoutbuf));

int fmic = source_get_data_frames_available(mic);
int fref = source_get_data_frames_available(ref);
Expand Down
Loading