From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C62B23EA8A for ; Thu, 21 May 2026 07:52:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779349976; cv=none; b=DjxEjBaZHiV86IUwsE+68nwhAFMwTjElPQqvdGi+uMi5e0qmMjVBUWkcui70UYP9OSlWFkwOnh1nXDhViDXIu4JMYCd9cDUsS4G01HV3ycTkLTpnc4r9VnPlAFuFPnnwyOaBkjxx7w0zG5BtBA0X+XVMaN23CWmg1Db0vf6zuhE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779349976; c=relaxed/simple; bh=stVPPS6O8UFoAUjYnTraqqaK8al/lIlE9rgsYzMSiIE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bbBUfAi8XtIhS15GWtr6MgM0Pb/1AkL7aJdEdZnOOVSU1RzKPeUO6UM3/bmps+7W3AHhAOG7Qms4dNAiVda52bbVBaNjhUN/mA8pa41qvaWYvYv358qtiB+HyUnGmhQEtH5PxpX12uQq1h5FUZbz1r4mkLsB0rxZHkFLbaXvlu8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=KZ1G0JTH; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=f4gqyLRB; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="KZ1G0JTH"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="f4gqyLRB" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 64L2wX7R2180418 for ; Thu, 21 May 2026 07:52:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= +gnhFm+Z05zsb0VJc1wdbQL302KSFbm3E9qMnG4C42A=; b=KZ1G0JTHIHa/1L94 4xcRazHzg87YkBNF/xyPb9sCZzF2NJconO6K4fygn/DBfFUM7wn4IbykM5JcO/lA EwH/wLjqz79s5u+94adtjkBIeN7oO2SIBtH2wmEnyNcrrklhTgTMD9AjCSfKf3ab WYxBX03fzrBikgIR4NuZ9dj4WJXVEqLoOIKkId7Kte3NeXtkg5OnK9rxdnDBNVOf eYwOIPdyMSXBdFX0S4XFQLJad9anlvUCEzIbfLJzMao8lWXIbyznoGzer+XddECe aIBCGBcDOV6fNQRnd+nxutP1QEEJL+pwKlLJQ5LykOLj7dr3f8q3LqT7Q7Lh5rIz dQIEUw== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e9sr3112n-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 21 May 2026 07:52:53 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-514551d5f2aso230330221cf.2 for ; Thu, 21 May 2026 00:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779349973; x=1779954773; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+gnhFm+Z05zsb0VJc1wdbQL302KSFbm3E9qMnG4C42A=; b=f4gqyLRBrYZ9FdyHFNeXvTHlSHJJegBQiEBZemk8sFZnbXx8d8S0nEtVzpvUxTRFVQ M+MhO/HGEnYsA4y7sd1bI/y2Absn6br8Se4JHRNLfjpWZ0HNz54Ur66CJAefWJgXLUqe OYNtKy8xzT1PVJWuPWTfIS2JZ46cebUDf0p72K95KwBVPtUchydZ4kj5ncqs/1Z+P2Zz +BMJ/Is3nPH9lVDQFqusK8HrCR14CPwqHLmDpIY3uO5NeYtsNGAmV9oWf0mlmMoYWR3q vMoFvBo7rxt1vgUQ9sOlhzvOcalU+A+4rHNxaYRTIoa/0YMBU3NTKg/poF1PMsFApqkc ZqGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779349973; x=1779954773; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+gnhFm+Z05zsb0VJc1wdbQL302KSFbm3E9qMnG4C42A=; b=NVDhkywzJtyrghwG66v2Z0ddEf6G6kXh7Z61NyWe9wINjA5L+Kk6EHiD37cdblL9V0 3VkLe3oqfu45bkO58CZSPOeX/Hp0RFNFG/DAk55Dx+bXim+8qC+ZWJH3WEUVC9aGJodk TodcACsAQASI64PK4L3426r0e0XGFOQsJijP7HrRcig6VmS5tR+drxhkGi4LxerNJTkL X8kPwo4rzanUpJhgJ0mhLa53IVgIY+74Zt7AFpFP3CMLQzTciHzd0DwO3H8ONGKWKeml +8BgyEMYDyWQ5FGoTlu1RU3MMTml+mKY1cOdIZYGnVgquCnEXz8bz3VEEF8oLuFEDemK 6OsA== X-Forwarded-Encrypted: i=1; AFNElJ9ZLVMEZxPGvetbCwx67zZ2j1qtg/D4MxWmZc97ww1k26ZKLLVLk+zKc/46J5vnTlz/XE3cOjrTBYP+m5w=@vger.kernel.org X-Gm-Message-State: AOJu0YzAwWsy1tioXMHtVd8EToxtbhtg0hrBGG2jKYkRaGvF+n4gojHW rCE3sNZt0V3pX1k07cn0M5BGqBwWSvU8CStf86kBPAFf1PEWPYpUrs99bhRJof9YGHlI+AhbJJY GH5zBS4xR6msRCkTZml//Sy56k/2Gsfvc3o4F8jArHsncq2EPKWjR17m+RD14lAoMDVE= X-Gm-Gg: Acq92OEbl6uUQKdk+/dJhLPliSxU9OT1CkJA7OV9Td3Y2UHFcJSPqmr9fnahFehwwOg vqY4NlAdIddqSdBLou35Llf50daTYcpw8RIgkWLfgvz+sSZP+giFaZG+tAGiwJxYQOaS5OUdMHz vaYPrn1eVbkPLRi7TBlYjl/oFzvodh++r3jEG2AfMPIlf8pm+lcwXxlXDQpq8IRc4gb+UpHB/yy FenRpd0LUWeQEjubR5MFblc6aJDmM+GX9DTxvEOUGlgaCUbzCnrGikIvZtzD71RADqhUp1wYtzR cuki2IQeOyHKKG/Ldc/Jjamd3RRGnNW+Luo44A2aai0JYru878odFvuSoB9wNmLSd/HChoqmNTU jf/EWyKaODjnU6YEGzS1GIPzbyiYdTz4zp5TY1dM0ZCdc87Ecsce3pHmBcCM= X-Received: by 2002:a05:622a:5e14:b0:50d:81c4:4c79 with SMTP id d75a77b69052e-516c557611bmr21837521cf.35.1779349972803; Thu, 21 May 2026 00:52:52 -0700 (PDT) X-Received: by 2002:a05:622a:5e14:b0:50d:81c4:4c79 with SMTP id d75a77b69052e-516c557611bmr21837291cf.35.1779349972343; Thu, 21 May 2026 00:52:52 -0700 (PDT) Received: from [192.168.68.112] ([5.133.47.210]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4903ad2ee77sm9386845e9.0.2026.05.21.00.52.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 May 2026 00:52:51 -0700 (PDT) Message-ID: <9793ea97-70bb-49a4-9b93-a6fe38e07965@oss.qualcomm.com> Date: Thu, 21 May 2026 07:52:50 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/6] ASoC: qcom: q6apm: add watermark event support To: Alexey Klimov , Srinivas Kandagatla , broonie@kernel.org Cc: srini@kernel.org, lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, krzysztof.kozlowski@oss.qualcomm.com, mohammad.rafi.shaik@oss.qualcomm.com, ravi.hothi@oss.qualcomm.com, mathieu.poirier@linaro.org, verhaegen@google.com, andersson@kernel.org, linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260519131527.4002526-1-srinivas.kandagatla@oss.qualcomm.com> <20260519131527.4002526-6-srinivas.kandagatla@oss.qualcomm.com> Content-Language: en-US From: Srinivas Kandagatla In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-GUID: Ys-oUWotfewfliQ_DV0UykAn-e1r3KYq X-Proofpoint-ORIG-GUID: Ys-oUWotfewfliQ_DV0UykAn-e1r3KYq X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIxMDA3NSBTYWx0ZWRfX4SylVSP5Jjab J2VB5sCFbCMfy8L0Z5KsY5Ctj08VShB1yLeK1z05zzRqAsv2UOvA4NsyJppTFiw8XxwldE3Mtww RxucLlgH/ON8xzqLIge2zNneF63K9wm3KcvxPRHVpRRTMGjcf+lp89KWYYG7xDKFwfYkBJ8/+t+ b3D5ygcDQeZJEaFE5NvzHNmWYmCslMZlkx44v+eLheM3MtFn1rxNXey7S343u4NnY8bjNjTzyZd QMtvzYcCDdEWTUj21bpKpRi8gmsoVYfoyVOVFHgLJy3bXbySWA/c/P1ajj8DJH4uPODXeT0uBKb Su+aYUFv1KVduNLRs/USkh00M3fHdgh8ndOKtEhqb23ZW82y+ZPqwsCh5AF+i81zIGK6A7aQfG2 X3K0QYs+igRzAYENIH0REbkOi9V5wKPqA2+LmGrMyJ8KQg+O7zpG/mikAHVCY1J8QD7VJEzxxTw s5VZOCz8ppZZ6CSAj/A== X-Authority-Analysis: v=2.4 cv=L+YtheT8 c=1 sm=1 tr=0 ts=6a0eb9d5 cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=ZsC4DHZuhs/kKio7QBcDoQ==:17 a=IkcTkHD0fZMA:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=LvOwEAKMvOOzFXVW9JgA:9 a=QEXdDO2ut3YA:10 a=uxP6HrT_eTzRwkO_Te1X:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-20_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 adultscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605210075 On 5/20/26 10:11 PM, Alexey Klimov wrote: > 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 module >> 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/audioreach.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); >> } >> >> +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) = NULL; >> + void *p; >> + >> + if (num_levels <= 0 || bytes <= 0) >> + return -EINVAL; >> + >> + payload_size = sizeof(*event) + sizeof(*level) + num_levels * sizeof(uint32_t); >> + >> + pkt = 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 = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; >> + >> + event = p; >> + event->module_instance_id = graph->shm_iid; >> + event->event_id = EVENT_ID_SH_MEM_PULL_PUSH_MODE_WATERMARK; >> + event->is_register = 1; >> + event->event_config_payload_size = sizeof(*level) + num_levels * sizeof(uint32_t); >> + p += sizeof(*event); >> + level = p; >> + level->num_water_mark_levels = num_levels; >> + >> + for (i = 0; i < num_levels; i++) >> + level->level[i] = (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<=ARRAY_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. > thanks for the review Alexey, Yes, its okay, its flexible array in that struct , as long we allocate enough space at the end equal to number of levels its fine. This is exactly what we do in payload_size = sizeof(*event) + sizeof(*level) + num_levels * sizeof(uint32_t); > - level->level[] is of u32 types. Can level->level[i] = (i + 1) * bytes > overflow?you mean overflow u32 bit value? Technically yes, but the level is period bytes are limited to max of period size and num of periods which is BUFFER_MAX SIZE that is 64k*8, --srini > > [..] >> +struct event_cfg_sh_mem_pull_push_mode_watermark_t { >> + uint32_t num_water_mark_levels; >> + uint32_t level[]; >> +} __packed; > [..] > > Best regards, > Alexey