From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6A401DDC33 for ; Wed, 20 May 2026 22:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779315074; cv=none; b=OcyLoV9CR6/BJaHxOJuHgGtSElY9tqjo4w0RB6HljH9ObsgphQflK4iV5WViX1HfRmWgJ5ijBTcOd+Yhrjglg5vtrDS4dzIT/vTMIGNAOc67aMUpIS1YHp/Jf0fXbJQr4d1jhylWF91pKZqf7bj/0jNXgtJAkapdilYNsI7fBfU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779315074; c=relaxed/simple; bh=37M9PUOfQy2p5QSRWIOQGsVGmX9OOYtVM7BVMxAeCXI=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=JmK4dFzGyixi73m4C5ZoYgK9sWvdsZiVSHDwy3v2UI10e46kmC2oKxfPoURbRED7QJL1+ax298zCn6LyjSHmTndtF7/LRrzzgBh1TdLJG3OC8CJwBsgS4abaGeIX0u5BKxgz7cwumDSV0mjyNdvcOXC5gi6M0Yv+pw5QjtnDLJ8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=WomUS9xZ; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="WomUS9xZ" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-488ad135063so43858875e9.0 for ; Wed, 20 May 2026 15:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1779315071; x=1779919871; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XztvXw0EM5mypFKKLP+bYDI+RT7mLsUytHlSi+Ua1b0=; b=WomUS9xZcBabBoucqci2fo+RdWAZF7GBLCOzGByDrdGtnYgNI3Z2QEO4AyVX316eku 1MYsmIGNyKe7rfbax36szSYq260l0FNRzD88vXhqapUEaaaZV0EVJTVo5+dc9uv5vEBu jo2/Q7tYJMRTHbNPgUh+DVbVTo8FFJxdXIryMnONLeiZnlUUmOJXAUMLcekblogx3wJQ 92F/O0QC9Wvp35EXyFThjSzc9p/6fvoRwjcuZ80kNrtWjT1Xtn+Lu2JXKhogpTVQ8feG EmncWb238VB5RDVJyWjKxup4l3d7gqoslY+NPJ9vRGUiWMSQYaPfiR632zXA48MTmUzg ij0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779315071; x=1779919871; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=XztvXw0EM5mypFKKLP+bYDI+RT7mLsUytHlSi+Ua1b0=; b=GaW4+P9CPFdkVgE2JW9NGRX87Y/2cYdGdN0zTNVu7tY9YmgqMZiZ4acRZ/cPcgJABQ kFOlsVyUob3sdNNrvIFPZAxSv1DcIJo81aDPEIl/XWa4oquekF2+/kzOyG717rc9DiMW /2s21nQIuzzNzz29v8bbfg5brB9x8bg0jdXl7qkW7muMmJbKlSu/FEYWYPQVmDGIiLsy nbByXHEdpYlja2qBJOnnHaZXcIDiGuAMz/bJUZc3jS5lGwAeKn/BaNr2ACYm1Q1p437v 8prC1lE+4Rz6FXWox2wpYPprou+ypBx4hWZyj0Ng9E9BevWgGuNCh/sr51TXm+QfE48b b2Cg== X-Forwarded-Encrypted: i=1; AFNElJ9bNNV+3t8Y9OZQiejzoPtJLRWPAVc0YMVdNcSE0mSdqhwh6VqIbuVgvxBBsUJutZd8lvwS8ECNvP0XCbY=@vger.kernel.org X-Gm-Message-State: AOJu0YylNzTVJV8Cxeie9H4hyq1O1+AjxxeSD3B585dYLHO4wm0yGChg PQjtgB8S7+MdguHwQrKip0Cx2nke1NB4NE2amyNopaXo7fMkr+f6XulXtDGcRBrVwLM= X-Gm-Gg: Acq92OEMUNA/oLIdAkKoGgVvdOVaLY0D0/364oG93b9yyttst1NAGy9aHkMjTE+qb63 Jvv7iAqGEdu7JoJfAxxXR/3aG4uip7kHI5pfHOohd5deg+zgCzU6XER5r+oDaVuAjhEwB6YwbP8 MRBx7FhGlaaG5BY3hVLQrN/ABly9kv0gmY8OhqqV5NvA6DbgatwaTVVxZKxCRIzKBBQTm6a5U5D 7ZzYPlZXX/luCJ/a1alQAN23iWgHPS9DqhU8CIA1/rgSiH7zGhSmj4xOyHW/y4GTXd4EMMjOnJJ 8Z4+OhBCWlK1GtIV4Uk/Al+Fny5X/SkJMPTml7iOB3QNzFKJ0jiJIW+cJW0583FL6pioVbdZJuJ z0VF0/piZR4cSlBYy4eZg7ltl3sW05drxdmDC2cgXlnI/FkkfrKTrPioA5uZsZY+UpF+PNMPs2x +0FOfaplpziMN51aaQUrqsRGlPtQiKV7yxv+WYzrMbpTi4vI3iXr4ef1002NbwMeJg4VQbODhB8 0715y+wgG45lw== X-Received: by 2002:a05:600c:42d1:b0:489:1ba8:5bf0 with SMTP id 5b1f17b1804b1-49036089466mr1297995e9.21.1779315071295; Wed, 20 May 2026 15:11:11 -0700 (PDT) Received: from localhost ([94.4.195.193]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49033cdcc01sm23507635e9.0.2026.05.20.15.11.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 May 2026 15:11:10 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 20 May 2026 23:11:09 +0100 Message-Id: Cc: , , , , , , , , , , , , , Subject: Re: [PATCH 5/6] ASoC: qcom: q6apm: add watermark event support From: "Alexey Klimov" To: "Srinivas Kandagatla" , X-Mailer: aerc 0.21.0 References: <20260519131527.4002526-1-srinivas.kandagatla@oss.qualcomm.com> <20260519131527.4002526-6-srinivas.kandagatla@oss.qualcomm.com> In-Reply-To: <20260519131527.4002526-6-srinivas.kandagatla@oss.qualcomm.com> On Tue May 19, 2026 at 2:15 PM BST, Srinivas Kandagatla wrote: > Push-pull shared memory modules can report watermark events when the DSP > read/write index reaches configured circular buffer levels. > > Add support for registering watermark levels with the shared memory modul= e > and route the resulting module event to q6apm clients using a new > APM_CLIENT_EVENT_WATERMARK_EVENT event. > > Signed-off-by: Srinivas Kandagatla > --- > sound/soc/qcom/qdsp6/audioreach.c | 36 ++++++++++++++++++++++ > sound/soc/qcom/qdsp6/audioreach.h | 50 +++++++++++++++++++++++++++++++ > sound/soc/qcom/qdsp6/q6apm.c | 19 ++++++++++++ > sound/soc/qcom/qdsp6/q6apm.h | 2 ++ > 4 files changed, 107 insertions(+) > > diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/aud= ioreach.c > index c984b12409dd..e6e9eb2e85aa 100644 > --- a/sound/soc/qcom/qdsp6/audioreach.c > +++ b/sound/soc/qcom/qdsp6/audioreach.c > @@ -1118,6 +1118,42 @@ static int audioreach_pcm_set_media_format(struct = q6apm_graph *graph, > return q6apm_send_cmd_sync(graph->apm, pkt, 0); > } > =20 > +int audioreach_shmem_register_event(struct q6apm_graph *graph, int bytes= , int num_levels) > +{ > + struct apm_module_register_events *event; > + struct event_cfg_sh_mem_pull_push_mode_watermark_t *level; > + int i, payload_size; > + struct gpr_pkt *pkt __free(kfree) =3D NULL; > + void *p; > + > + if (num_levels <=3D 0 || bytes <=3D 0) > + return -EINVAL; > + > + payload_size =3D sizeof(*event) + sizeof(*level) + num_levels * sizeof(= uint32_t); > + > + pkt =3D audioreach_alloc_cmd_pkt(payload_size, APM_CMD_REGISTER_MODULE_= EVENTS, 0, > + graph->port->id, graph->shm_iid); > + if (IS_ERR(pkt)) > + return PTR_ERR(pkt); > + > + p =3D (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; > + > + event =3D p; > + event->module_instance_id =3D graph->shm_iid; > + event->event_id =3D EVENT_ID_SH_MEM_PULL_PUSH_MODE_WATERMARK; > + event->is_register =3D 1; > + event->event_config_payload_size =3D sizeof(*level) + num_levels * size= of(uint32_t); > + p +=3D sizeof(*event); > + level =3D p; > + level->num_water_mark_levels =3D num_levels; > + > + for (i =3D 0; i < num_levels; i++) > + level->level[i] =3D (i + 1) * bytes; Let's hope that compilers optimize this to avoid multiplication, anyway it shouln't be a hot path, although I don't really know. - don't you need a check like num_levels<=3DARRAY_SIZE(level->level) before this loop? Looking at the code it seems that it relies on pkt which is allocated using audioreach_alloc_cmd_pkt() taking payload_size into account. Looks okay but I wanted to double check. - level->level[] is of u32 types. Can level->level[i] =3D (i + 1) * bytes overflow? [..] > +struct event_cfg_sh_mem_pull_push_mode_watermark_t { > + uint32_t num_water_mark_levels; > + uint32_t level[]; > +} __packed; [..] Best regards, Alexey