From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (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 60D313C3451 for ; Fri, 1 May 2026 14:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777646461; cv=none; b=OBCAF87SmLMn+GJg+GWfZQzw7DXDjAtEPD/mBPStKfIouf3MPuCTsCyfJXTBS7jUFP984dgVCKedd3t5oB5APraR/HusuuA8Kqx/SnZVPG7fVFvYufDu4cKm+/vZ681S9C8CfwR9Q0J9NkoKnsIfURrGfwzdMdo72xRNE0w/vlQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777646461; c=relaxed/simple; bh=axhZE7iq4V4NfKtkFtOnf9unIcr5Q6pw8mBt6qvrky4=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=hiQiucXSX49vN6UaMtRfXwxuRT4hrskh5IPC2si9apA/pWK93xTgv5MJAgnfm3o9B1oIVL8qN3kLy9NyxtlMcLAp4CLYAv7cnu+U+X1oDIoUTWoMDmgKO+vIx1f9S3MCtfyrfBFM9Jjtc0DWX2wwllkowW157Nzx96rPV21cdL4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RQrgPpYN; arc=none smtp.client-ip=209.85.219.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RQrgPpYN" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-8a151012558so22041876d6.3 for ; Fri, 01 May 2026 07:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777646457; x=1778251257; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=axhZE7iq4V4NfKtkFtOnf9unIcr5Q6pw8mBt6qvrky4=; b=RQrgPpYNGtyAbT/hwsUN3smG0TtRk0ER4qeekKs0D+bIj7LZeSm0DlKbbwBr8eRLX3 +UO1uCxCSRwlW3+dylrKI9R85XtCJuQb8I5y6/nu8AJyQuAQ40txrLggKxFARwqYwhVS GJRgalO40GCtI1NYOm2xRoLH6/bU3D5d5fPPWpohoAFloWGHQZRehhw8m2dQGK6pju+e 3WI5N+2CB/CnXhXDo8xwtkcvELyNCoJgv8bR2SM/fg7A7wxMHjs4Z5LtoQYaBSwA64Kg UiwCpcpUQP3T5haqHUQjRkNNB4GoO0yIRfPyJUGSI5ZnlB7vx38Agy7rz8Tx46WVlwTD rd9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777646457; x=1778251257; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=axhZE7iq4V4NfKtkFtOnf9unIcr5Q6pw8mBt6qvrky4=; b=OH3B0bRntGU/XHRQlDwx4wrqh6LkPe8/ATGtSc0AZ4HSZiBX2cEAJbkybOE4Oupwoc HGZ4YbCBoDr1GoBRufL7A35IPrcFcfq2xz+2LN/D7lyDJ9ugHvgpQ36nlbhbBH4EYOvG WJR7rG30RBVfRx/JRyqgicxYmwBz2fEG/seGpCIFUBymhDRPeoZll9dd/8KpszxYr8Je y4q12Vog35z4dEzozVQ0OQz59/lEM1Y0DLMcqfBgmhh/hdgiib1gwxZX4ayhc3yoWUy9 2x4WsYpG+ETDU3ag2ufJ8XcSpTjU22vmfOsSEsjyRRigJbhHXevWBSHdYiZjxpu59fHW Y18Q== X-Forwarded-Encrypted: i=1; AFNElJ8TE80DR9VFpMTFR3cwgQ/ZOn8Ow5SW1coIPMIiLnJBGx8XikkW0neOMCaiotTAKr7stQ+UcQQl1vzI3iI=@vger.kernel.org X-Gm-Message-State: AOJu0YwARf77BintuUIKWTO/wRIn6oo/ie1g9EnwQQVStzAMAxWj80A/ UX7u7reH8hNWMosNdm/Y1I9zaOP28AN7qNZTFvZcSsaDOVsDz0WjF9cO X-Gm-Gg: AeBDievYnCQ2dW7ngnjYJSlufjlBKIjcyFtpzb5Nl8CsQ7bdBeFEhwx41/zEJAxaxIM upFkXOG2NlgLwaR7DHXfQth/1pgCdp2eXveLmtmiHgSgDowX5n+Z8RJOjlz+USCv5Y+NBtVnEXK YUa2B002kdHV0Yx0gEaILkVFDk2LH03ckj/Psr5ajGxcXd8v+i3RC9ZvOnRVEy5MU+cltbcZetE DeaTlLUcDPWU4EW1k0mjfRSZX0HkBoC4R1hNxPfL4FwjxfSgL2OUSUoxLaQDGmzHMIrj5rHkSrF NTIsXr751U5sAQrhSDm6Q8hZJuWzf204yvijU1YyEzXEtnkV+ZI7i3j0bHYLuif9u3Tjscq4VWi TKPGX/nAHdgc7u+kuCHy3sBYmTpbuKnKm9/T4+MyeNtWvLJLmzbWAYmrZmI1m5jtYGbzKJFSBi3 +oR6d8ShD/fDVBLEHaLH6JAT9fiLxa6jB18L9HSl+awRcvlhiBDjyipQw+YUXNAmVLCLzbtCTuy Tn+PyqTPyBC7FCnYjd/P+LGTobJqvEteDJW X-Received: by 2002:a05:6214:3012:b0:8a1:3ba4:9832 with SMTP id 6a1803df08f44-8b3fe766b5cmr104223706d6.16.1777646457024; Fri, 01 May 2026 07:40:57 -0700 (PDT) Received: from localhost (bras-base-toroon21-grc-75-184-144-58-243.dsl.bell.ca. [184.144.58.243]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8b5395c5b4csm26439146d6.16.2026.05.01.07.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2026 07:40:56 -0700 (PDT) Date: Fri, 1 May 2026 10:41:49 -0400 From: Richard Acayan To: Srinivas Kandagatla , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Greg Kroah-Hartman , Richard Acayan , Kees Cook , Joris Verhaegen , Kuninori Morimoto , linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: ASoC q6asm race condition when stopping and preparing the stream Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, There seems to be a race condition in q6asm when stopping the stream (with uncompressed PCM). When receiving SNDRV_PCM_TRIGGER_STOP, the driver sets the state to Q6ASM_STREAM_STOPPED and sends CMD_EOS to the ADSP. If userspace decides to prepare the stream again in q6asm_dai_prepare before receiving ASM_CLIENT_EVENT_CMD_EOS_DONE, the memory-mapped region appears to still be in use and fails to map again. I believe this race was observed since commit 81c53b52de21 ("ASoC: qcom: qdsp6: q6asm-dai: set 10 ms period and buffer alignment."), but would need to verify. On sdm670, we are coping downstream by keeping the state as Q6ASM_STREAM_RUNNING until receiving CMD_EOS_DONE. Can the ADSP emit DATA_WRITE_DONE or DATA_READ_DONE before CMD_EOS_DONE? We might need an extra stopping state between CMD_EOS and CMD_EOS_DONE so the driver doesn't request more data transfers.