From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 B095D3DCDA3 for ; Wed, 11 Mar 2026 11:25:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773228329; cv=none; b=owTunYATvQaApt/HPFHGzq9HnYlej46froR/teJnVvp6vN/gDl1M+6YBCh7jDgYf4ixdrdIyvQwVW8nCMIsPH05X2kokzNd5pEnjLNWoDsuKXoxDbUcxpbXlew6ikDveov+N6qUYtYzLRbUmpNPO02ibvcM/RgcSGTSRyGPKtaA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773228329; c=relaxed/simple; bh=Bz8L6lJ5ljmm0f1bzOA7lmmgPpBjGpva/qWmEvAb8MY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Fh7QfNBgflj3wqbEj02QCucNoTqG1w9+Oy40dSjxeabMyhwezYo30p96G9df0gG34wE5A954EuCMSNCCijX21g4ERAMLYCs1TD7c13bhOG3G6r9AYcT5zTP2bHK3eyYY7hRRof6BkaSGZZezZ00hVMHsheLIoeixudSP4C5RNJM= 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=gjEi7UaP; arc=none smtp.client-ip=209.85.221.47 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="gjEi7UaP" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-439c4bde55cso5615885f8f.1 for ; Wed, 11 Mar 2026 04:25:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773228324; x=1773833124; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=CJze5/pXmPew2sfHMpjfcTTl4xqaN7GKbsQ4t36q17Q=; b=gjEi7UaPHAFk6q2s51w18yNUF03XkuvFUOBRtX4PJxLEfSWhntd03DcwQd5ef/DK6w mgYzuEuj48AU/x0wUIEjswwwUyV+B7krb5hOMHQiJ8UwyyUPQHEDoTjt0SkHOW6R69L4 6L9THeytyGz8TFUzCmze6v2IRLNvaQK6qmx72iVPWCOSNhFL2EKpf9clVU+q4M7omaiJ nZw52V/+sPJ1Xmws4PP4tBHosuOj65m8Be07hrsUkAKiw+WEOTcOnONlSuSzeTfRl9vJ k9/OvMzkMYZQxOt3qvOZFEd6Kac7PJaY77UDEFkGn40X4PZZBV+EaC1uX2DUq2LM5YUt 4+fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773228324; x=1773833124; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CJze5/pXmPew2sfHMpjfcTTl4xqaN7GKbsQ4t36q17Q=; b=WD8Wz5lFkq6x/FUbeGRGc7nYNCRNtC2oH5cLsV9ldAE8N7j2m9NWk15sPoZHyuzTDA irZr1zB76uzSH05n1WxwWDy4YtR9mN9opBHJGdh0j6EW6FvftS+mBtsIvsUyjg1q11Qr s0POHgnwBkXPJGSpQj6NtfhacEHcwOo4FYUkySyxGz3BCH8Sn6tJu5XTWYjxlLOS0mX8 Z3DxdpsxKlmvvFUVWE75kGLJO4gzDO6rzVqFvSC7kvKLC/whmY0bBSQbOlS9hg17AUxp IjPSaVKCSWxvWmaowBF353DnLeq1KvmRDLf8cZAWfLqIvsKdv8zelLj3GqRV/1u2dwMO qpdA== X-Forwarded-Encrypted: i=1; AJvYcCWziodRl8D6GZMUz3i1mKM+PfHPTmrBoZIfRaNM8O98jGIIo+8Pliz8di2Hrz81zBzAgprzthy9x9W3ipA=@vger.kernel.org X-Gm-Message-State: AOJu0Yx5nUGpdfXjRCpx7d4tZN4kdshi4VmXWeJY64QmRUvWRBaOqxSQ iLAfTidlLQID0fTCITYMczhcB7lYGJVFFdurZZPBoAT1pSDrnrpYF8eKBjn6AcD20Mw= X-Gm-Gg: ATEYQzwhTrDl0P0rsCgMQqYQlxp3Zj+Unc6MbMLuo+JU1k2VPNoMhc1VG91b/je9lmT 4VCfys1OJj4ktaFyEb0wgd+CFI2XoraoEaGMzfCBk+jMr+VvVsNeZp+MxDcw1+0BcLt6WCWZj2M VfkemO7CSUfdrrUn4wnWEz003Kxyb+izcYF2hybXXiOJm+PE6r1KaK5t/807HBfN75KbgKzItQK CkEheJDpeUDbiRpAA8Rmbr9Z2rf1yZz1QeTgOee0UPF/Fg4yaaOKz6owei0AONmPpScK/55hGKi JbSYIw2AVmQ5KeekZj67sFxQx1GaOZZf61CmL5u4T9iLORcpxp9E7oeTN7YkZMVxces68D6M/BG NgkWiGLoQyrYRAjuNBeaWI0Eqtbqc+y3NOeDYRaAbehdJXefCwdXx+FpsGr87bpPAqAmxPJZvCl 3lvFc+UKYbmoX+v6f0TUdqr1SNAGJOPcO6cGq2WPC7EJPisw== X-Received: by 2002:a5d:5d0b:0:b0:439:b79d:b9a5 with SMTP id ffacd0b85a97d-439f8431382mr4099695f8f.37.1773228323834; Wed, 11 Mar 2026 04:25:23 -0700 (PDT) Received: from linaro.org ([2a02:2454:ff23:4441:1c2c:7aff:fe45:362e]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439f81f1318sm6682078f8f.21.2026.03.11.04.25.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2026 04:25:23 -0700 (PDT) Date: Wed, 11 Mar 2026 12:25:07 +0100 From: Stephan Gerhold To: Bartosz Golaszewski Cc: Vinod Koul , Jonathan Corbet , Thara Gopinath , Herbert Xu , "David S. Miller" , Udit Tiwari , Daniel Perez-Zoghbi , Md Sadre Alam , Dmitry Baryshkov , Peter Ujfalusi , Michal Simek , Frank Li , dmaengine@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski , Bartosz Golaszewski Subject: Re: [PATCH v12 05/12] dmaengine: qcom: bam_dma: add support for BAM locking Message-ID: References: <20260310-qcom-qce-cmd-descr-v12-0-398f37f26ef0@oss.qualcomm.com> <20260310-qcom-qce-cmd-descr-v12-5-398f37f26ef0@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Mar 11, 2026 at 03:32:38AM -0700, Bartosz Golaszewski wrote: > On Wed, Mar 11, 2026 at 11:00 AM Stephan Gerhold > wrote: > > > > I'm not entirely sure if this actually guarantees waiting with the > > unlock until the transaction is "done", for two reasons: > > > > 1. &bchan->vc.desc_issued looks like a "TODO" list for descriptors we > > haven't fully managed to squeeze into the BAM FIFO yet. It doesn't > > tell you which descriptors have been consumed and finished > > processing inside the FIFO. > > > > Consider e.g. the following case: The client has issued a number of > > descriptors, they all fit into the FIFO. The first descriptor has a > > callback assigned, so we ask the BAM to send us an interrupt when it > > has been consumed. We get the interrupt for the first descriptor and > > process_channel_irqs() marks it as completed, the rest of the > > descriptors are still pending. &bchan->vc.desc_issued is empty, so > > you queue the unlock command before the rest of the descriptors have > > finished. > > > > Thanks for looking into it. Good catch, I think you're right. > > > 2. From reading the BAM chapter in the APQ8016E TRM I get the > > impression that by default an interrupt for a descriptor just tells > > you that the descriptor was consumed by the BAM (and forwarded to > > the peripheral). If you want to guarantee that the transaction is > > actually done on the peripheral side before allowing writes into > > config registers, you would need to set the NWD (Notify When Done) > > bit (aka DMA_PREP_FENCE) on the last descriptor before the unlock > > command. > > > > NWD seems to stall descriptor processing until the peripheral > > signals completion, so this might allow you to immediately queue the > > unlock command like in v11. The downside is that you would need to > > make assumptions about the set of commands submitted by the client > > again... The downstream driver seems to set NWD on the data > > descriptor immediately before the UNLOCK command [1]. > > > > If what we have in the queue is: > > [DATA] [DATA] [DATA] [CMD] > > And we want to extend it with LOCK/UNLOCK like so: > > [LOCK] [DATA] [DATA] [DATA] [CMD] [UNLOCK] > > Should the NWD go with the last DATA descriptor or the last descriptor period > whether data or command? > > It's, again, not very clear from reading tha part. > I'm not sure, my impression is that the exact behavior of NWD is quite specific to the actual peripheral (i.e. QCE, QPIC NAND, etc). In the downstream drivers: - QCE seems to add NWD to the last data descriptor before the UNLOCK (as I wrote, it seems to queue command descriptors before data). - QPIC NAND has a dedicated "cmd" pipe that doesn't get any data descriptors, it specifies NWD always for the EXEC_CMD register write, which isn't even the last descriptor. This is also done in mainline already (see NAND_BAM_NWD in qcom_write_reg_dma() [1]). It is possible that NWD works only when attached to certain descriptors (when there is an actual operation running that gets completed by a certain descriptor), so we might not be able to simply add NWD to the last descriptor. :/ I suppose you could argue that "make sure engine does not get re-configured while busy" is a requirement of QCE and not BAM, so perhaps it would be easiest and safest if you just add DMA_PREP_FENCE to the right descriptor inside the QCE driver. qcom_nandc has that already. Thanks, Stephan [1]: https://elixir.bootlin.com/linux/v7.0-rc3/source/drivers/mtd/nand/qpic_common.c#L484