From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796025231; b=IFVzkyLGGpfuLozByDZXZFz9adrtyG6jBOiXUkt7tk7e6azKolXdnaj8HRUQE1b7/mC9 LaV5SLR2SNnnVYj4bd96fqvKoM+Cj/5T3kRt3sQaSrs5kcZFxfiVbhNznt1WGiIPwTGKm CTNKCtifMB7QCnvYnhy5bX0UiDwc8JTbzcsSVjQJlicSbVljKb4DrOZ0YHk2fpfy1n+2P Qm0HpFAWU4TDT6ljjnFsUSzT+8ucuPUaDSrOg4/BkYtCvhREp7tdS81eHn9PA6fPo89ok XtVluCQgOplNEE5KiYR6fbg2+CQplBIhfTjK/4tqyJYJk0knQ+20I7dGQM5HcQ/CRow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796025231; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-ORIG-GUID: X-Authority-Analysis:X-Proofpoint-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=07srFXNiwuqa3od0r4PhGGeGV/JNplyEKyJ7iLXoLJw=; b=Cb5pjzpNY9HvmLasQvRzwF+q85bWG+SwX9XqwkvYeNOabuRRTJW0aiHPlRQNqcV32T6J 4EARjs777W/EGhFFnW3r3UbO077iGILyeJPfD/CDXXptrlh/rsYFGHicJceikCPOz4WaR OOwgtrogcdKV8EQfpMe6IOtDRxBYPzgBpdQBbMEXXx/xilkiIiVb5EQfKCHj+ZskYOHc7 EiAvb0rp5W5wEt7rwqWdKLZlFHkIlZekYhIitFs1NzIw6pxIyNw2ebP1KFMtKgRz0EoXD S5p5WWKdxUjh2Rg5Mj+qQujI9Q+TmSel1opomHvnMyeSuFeCjbedt515EWQphewIQ0w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b="f1cs/xaj"; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=YHfbt9JZ; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EDAC606A32F for ; Mon, 30 Nov 2026 07:53:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3EDAC606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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.a=rsa-sha256 header.s=qcppdkim1 header.b=f1cs/xaj; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=YHfbt9JZ Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AU5GKC91713771 for ; Mon, 30 Nov 2026 07:53:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=07srFXNiwuq a3od0r4PhGGeGV/JNplyEKyJ7iLXoLJw=; b=f1cs/xajWMxnM0Q4IDWEntfXyiw 17haQSaLVl/bgteyP0LOX6FHpd/sHPrm0nkdcWr0sifX/t6RMUUFs8OFUogmAt26 bUgQRvQGJHUDef3X9WZSgbmfPEpvdyeO4KqxXo+SCICEyfZXOOAvHhx8MhCNq0yt fSRJudt3EEOX2ok8h92I0FMngkhtqzkjZosOXN/tc+FDKT/888KMeUNppd94PuFr AIrAhDWm5mmb51qb6oFvwS7ZXGfC2FF+fX9WqMm4wz6RdQnKmjoJpxtmzJHPqRkZ sUUSlVvNVu/c0eHGw3u6vos50EPfPvJ2Sc3nq0EAFiGc7h5N081wIZvudiw== Received: from mail-dy1-f199.google.com (mail-dy1-f199.google.com [74.125.82.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j7q6358rw-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 30 Nov 2026 07:53:50 +0000 (GMT) Received: by mail-dy1-f199.google.com with SMTP id 5a478bee46e88-382af5cfc58so699783eec.0 for ; Sun, 29 Nov 2026 23:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796025230; x=1796630030; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=07srFXNiwuqa3od0r4PhGGeGV/JNplyEKyJ7iLXoLJw=; b=YHfbt9JZrZU8l8ELsx7jGd4BKccQkaMgDBS8ExAKMRU5y9fFXUizG0Kf6hk8Brx71U nSF9MW3ILE6g+R3FY7qOf0M68fHiGeL0NQ5tqN2kezTnEYUQvGjNVzSWFU8G5L/lzRcA lzwjVuc489RvraQH5vJJ/VPOW/vtPvhflXmQqfergmbp5AojlHEXKLlgtJBrgDi8gsDI +hmCQXhZngvph8p0r4qEPsecMbhAqi0AXc9BGoayZ6haFJBPdC4+zrv4KObgJDsjl9Xm aPb+Ii0sln5roYJRhZuND+V+Emmk/nhxRo3ob1+5swL9lu8iuZat5PuEHG4RJ6BBqT6G 2rZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796025230; x=1796630030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=07srFXNiwuqa3od0r4PhGGeGV/JNplyEKyJ7iLXoLJw=; b=mnCaBQwAUE9gvw91u+ArR1vnx+zNllu60mRX6p9ued8OxxNbQnihf5A05Rz3GyRilT MFHqfkWv221Q3yRYIGXqNzG56Ed2x0XXr7LhUjle1/A9R7Hh/fb8cxvSzceYQcBoem31 3d/8eAnY95+pWm2o1qvZ5+rs01ihbM4TPFW+VJLR/guWSROKSOBkED5A9BTERHMpYgBy C5iJROeeAAgZTs4lm0MN5zpJsLKwpriVgINEzia5vC/7LvhXL27Pa0cePaRXZuN2aHvP GOMtqbwNtIn/u0U4DkS1LYbfXi17rBp+HJWE5oOXUaYErUZy7miToqX6Of0lDijbn9UW lkVg== X-Forwarded-Encrypted: i=1; AL+hErFhzrzFMqt7kW5h3Ps3+Faisuv19d8+hvTH0/LTj17gNsSM+vbJZhQu4RoFagoNzqsNb8pu7St60jgVPpE=@vger.kernel.org X-Gm-Message-State: APuU4Z9GitZdG4BoEj9s/N6mtsvwl1LzTmQ86xkgTtaYuKgPQBfB6EA9 Z9t1Awt7GBA3aSe0ltVFhIDSITDQ0KU+M4ZKCK7O9y5wBrZfu5u5T1+Z8Xo3lKx5StMt/ppFEyO NuMJo0ioo4fno2fs53SK/Rma1tHDSSmG1CQwvJv1fC3rxqtp5wbtQ8P51X7y9aoyasjE= X-Gm-Gg: AZFdTZcnOg58yYpCY0ar03oldnjsEBXtJW5gWnejj9Z/vztu62fUmYapiOya49dnqJ7 F8gqxw3NMsl8nqq1TuF5XYQ+nG3/ju+MjMQL6k9uGkKwOpO856EpDYpnkzwUMGxFPDyQ7vyMDVE 4KCPhtNby2E5cvXkFTaeOewRWn1SXXUbtmjE9YeA2nz34+EvJ3bQ/j4GQgrLv201AjlR25Bh9cX qyp36Fg5/e+AkuX3+CgvvdBPDFZBM95OGBSFL/tIRjx062uVy1/5ss38AOtYqiq6RB6PuKMXra3 LImthtR7cgUyClJMRAuoXrhcpy3IybUaH9pKLTBDRhVDHVTcFdJ0L/Rfemk0Z/Vc8zeWnv/ZvI9 tVaJfeWS3HthRdPOCl6OGOTPU84XWw/1vVzpgYDLbytpW0pgcOciW5Jw7MvHxL5a150fuZsq7bJ ZcEj9y1YJX9xzrxVoDltOpZ+2judKmxisB X-Received: by 2002:a05:7300:2728:b0:383:c2f0:e753 with SMTP id 5a478bee46e88-3856c0d0a68mr36732792eec.3.1796025229720; Sun, 29 Nov 2026 23:53:49 -0800 (PST) X-Received: by 2002:a05:7300:2728:b0:383:c2f0:e753 with SMTP id 5a478bee46e88-3856c0d0a68mr36732772eec.3.1796025229236; Sun, 29 Nov 2026 23:53:49 -0800 (PST) Received: from QCOM-aGQu4IUr3Y.qualcomm.com (i-global052.qualcomm.com. [199.106.103.52]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-38707b612cbsm19865156eec.4.2026.11.29.23.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 23:53:48 -0800 (PST) From: Shawn Guo To: Srinivas Kandagatla , Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Mohit Sharma , Ajay Kumar Nandam , Prasad Kumpatla , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Shawn Guo Subject: [PATCH v2 1/3] ASoC: qcom: q6apm: Wait for SPF to be ready before registering Date: Mon, 30 Nov 2026 15:53:31 +0800 Message-ID: <20261130075333.43354-2-shengchao.guo@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261130075333.43354-1-shengchao.guo@oss.qualcomm.com> References: <20261130075333.43354-1-shengchao.guo@oss.qualcomm.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Info: AW1haW4tMjYxMTMwMDAzMSBTYWx0ZWRfX4sjF8s0P943T dk9G78469u0FK2I5m6L9yWONrnX/isXjNGUSW8/ZNWYLz0otXwb1b53zF9JfRh27ICWYqxZrwV+ ahkNltKqN48wnmaMC5d3DDyWLRVZENQ= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDAzMSBTYWx0ZWRfX61VBSr9BoFnq UOQu4VmD/LtPN2I/7azqCZhUfk67PC96SkPQYzHhNi9dfxodtyz5kKAHA7kmNUfYz39Ech6BsNc cyEz+5TYlU7BNjJ+HEyuuEuZ7zQjSV2NDjSY2rAKNGDzHdv+cyw6YaQF6OeR6sfMiyH7kM/0wro kj5KxNMNl6ZGcJIRzngT3SNs1LuTWQoGGIzNKJy+2+0QaD0eGv5IkULRurKln/uOkZHT52EhswV 6oUdgiWt08f16yTLApXokoUhyju8e/fVVoKFUDd5LGKMth2SJf6WegNfVPDzuteq9hO9lgIfmsq I8Cs+Nl38MsfqXfzlKwXeUxyEZo4xFk93S72WLWWYq/jrTClvM/J7aKVxEZFefG6q/hHp/rV+Zt Ls762eNUJ6SmcUHKXbbJ+Dmsj0xH3pDZIN7VT7/pHytbV8v7RunYMRcn9JeXmrrYzMyrHvqS7GK s0L6lEEp79Z5JMkQWfw== X-Proofpoint-ORIG-GUID: kDpWfQxb1TXKUxTGg4b3UJ-DNkyLEYcr X-Authority-Analysis: v=2.4 cv=WtO+otfv c=1 sm=1 tr=0 ts=6b0d2b8e cx=c_pps a=cFYjgdjTJScbgFmBucgdfQ==:117 a=b9+bayejhc3NMeqCNyeLQQ==:17 a=zJRp6_cAMcgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=jCUHPVBPsCGQFQZixyAA:9 a=scEy_gLbYbu1JhEsrz4S:22 X-Proofpoint-GUID: kDpWfQxb1TXKUxTGg4b3UJ-DNkyLEYcr X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-30_02,2026-11-27_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 adultscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 impostorscore=0 phishscore=0 spamscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611300031 apm_probe() sends APM_CMD_GET_SPF_STATE once and ignores the result. At cold boot this is harmless: module loading and PDR lookup delay the probe by tens of milliseconds after the DSP is up, so SPF is listening by the time the command is sent. After an ADSP restart, everything is already loaded and PDR reports the audio PD up at once. The GPR service is added about 0.5 ms after the remoteproc reports the DSP up, and SPF drops a command sent that early without replying: remoteproc remoteproc0: remote processor adsp is now up qcom,apr ...: Adding APR/GPR dev: gprsvc:service:2:1 qcom-apm gprsvc:service:2:1: CMD timeout for [1001021] opcode Once the q6apm component is registered, a sound card whose other components are still bound can bind right away, inside apm_probe(), and issue APM_CMD_SHARED_MEM_MAP_REGIONS before SPF can handle it. The map times out and the card fails to come up: qcom-apm gprsvc:service:2:1: CMD timeout for [100100c] opcode Poll GET_SPF_STATE before registering the component. Simply retrying q6apm_get_apm_state() is not enough: it goes through audioreach_send_cmd_sync(), whose 5 second timeout makes every dropped command stall the probe, and the card with it, for 5 seconds. Instead, send the command directly and wait only 100 ms for the reply, for up to 5 seconds in total, which is the worst case of the single command sent before. A timed out try is retried at once, while a "not ready" reply or a send failure backs off for 100 ms first. On Nord, SPF answers within 100-200 ms of the restart. If it still does not answer, warn and carry on as before rather than failing the probe. Signed-off-by: Shawn Guo --- sound/soc/qcom/qdsp6/q6apm.c | 50 +++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/sound/soc/qcom/qdsp6/q6apm.c b/sound/soc/qcom/qdsp6/q6apm.c index 4cb597d737b1..e7ba6bc93142 100644 --- a/sound/soc/qcom/qdsp6/q6apm.c +++ b/sound/soc/qcom/qdsp6/q6apm.c @@ -26,6 +26,8 @@ struct apm_graph_mgmt_cmd { } __packed; #define APM_GRAPH_MGMT_PSIZE(p, n) ALIGN(struct_size(p, sub_graph_id_list, n), 8) +#define Q6APM_SPF_POLL_MS 100 +#define Q6APM_SPF_READY_MS 5000 static struct q6apm *g_apm; @@ -154,6 +156,47 @@ static int q6apm_get_apm_state(struct q6apm *apm) return apm->state; } +/* + * Right after the DSP boots, the SPF drops commands without replying. Poll + * GET_SPF_STATE with a short timeout per try instead of the 5 s one of + * q6apm_send_cmd_sync(), so a dropped command does not stall the probe. + */ +static bool q6apm_wait_spf_ready(struct q6apm *apm) +{ + unsigned long timeout = jiffies + msecs_to_jiffies(Q6APM_SPF_READY_MS); + gpr_device_t *gdev = apm->gdev; + + do { + struct gpr_pkt *pkt __free(kfree) = + audioreach_alloc_apm_cmd_pkt(0, APM_CMD_GET_SPF_STATE, 0); + long rc; + + if (IS_ERR(pkt)) + return false; + + pkt->hdr.dest_domain = audioreach_gpr_dest_domain(gdev); + + mutex_lock(&apm->lock); + apm->result.opcode = 0; + apm->state = 0; + rc = gpr_send_pkt(gdev, pkt); + if (rc >= 0) + rc = wait_event_timeout(apm->wait, + apm->result.opcode == APM_CMD_RSP_GET_SPF_STATE, + msecs_to_jiffies(Q6APM_SPF_POLL_MS)); + mutex_unlock(&apm->lock); + + if (apm->state) + return true; + + /* A timeout has already waited, anything else backs off */ + if (rc) + msleep(Q6APM_SPF_POLL_MS); + } while (time_before(jiffies, timeout)); + + return false; +} + bool q6apm_is_adsp_ready(void) { if (g_apm) @@ -906,7 +949,12 @@ static int apm_probe(gpr_device_t *gdev) dev_set_drvdata(dev, apm); g_apm = apm; - q6apm_get_apm_state(apm); + /* + * Once the component is registered a card can bind and send commands + * at once, so wait for the SPF first. + */ + if (!q6apm_wait_spf_ready(apm)) + dev_warn(dev, "SPF not ready\n"); ret = snd_soc_register_component(dev, &q6apm_audio_component, NULL, 0); if (ret < 0) { -- 2.43.0