From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7CFFBCA5FC1 for ; Wed, 30 Sep 2026 20:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PHcKhVSnEwqoc+1KLjRnxGF2Mva/GHzPrgk/jJQDp10=; b=JwHuq8PlggXtlgbymyM/ltOd09 TAdmSZjtAmRDMINf28jD2JQNv1AMywaoTskYRoe7m9mr0G/BKMlqIhCV17qCiJ4fc8SLSH3DjfjpA RAyRNymgx7tJiYSQkGIGweCWsXSZclrYB65LkKffLfMTSrqYItXITgjbuDFdZuGWMEnuhwI4iW5Gi KsTJnU+xKDP28Vp2p3PkEs3sj82IOsDdabDi5hDyEgD7kW9xq8l0uX/yKZHY2vfsSHAFeoYJtjnvn bWv7paloEjBgeWNn58zGcc1k0uJ3fRQvu3aQ/jX1l4kesV+UUCIKxt9UgTBpLLyDGywKge/ikxrtG uO9/LmPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xC0kb-000000079aE-362B; Wed, 30 Sep 2026 20:18:01 +0000 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xC0kZ-000000079Zs-0xl8 for linux-arm-kernel@lists.infradead.org; Wed, 30 Sep 2026 20:18:00 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-2d8fd7a3f38so7755ad.1 for ; Wed, 30 Sep 2026 13:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1790799478; x=1791404278; darn=lists.infradead.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=PHcKhVSnEwqoc+1KLjRnxGF2Mva/GHzPrgk/jJQDp10=; b=GqLOEITfFHWRIvTfT2hPEd1CqBw6cyQkaKtfyJCDt11tF9aY4/Y+tu69jKjmu+HoLi TFfr7re5+NRBKr5sFbuFjAExCTkmP+fLRtlclpJHcuTKqv+klPhjX9oWdMnwQ5hyte4O JaKaYBoJpzBtZGU3m0qtNAZdaQrVa2knJxru7HtWRMFI/RhmmYUaDr04EPD7ogrYNIRi PjJ3lViJh/r20F32iuzu8Xgz+lMM4wwE29w3aht9xv2BmzKV0/dzzv4rtq+rBYcbOL/I gc+OJBztO2BtZIDwNbWlCpN13BUNyTuaRwCFhwpEPHD6NW52mX3ZUdexj9jT8XdJPB2Z 1mAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790799478; x=1791404278; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=PHcKhVSnEwqoc+1KLjRnxGF2Mva/GHzPrgk/jJQDp10=; b=j+54CreVReHC1voNymhppKBAi+bpJ3OlKa5Jo/26oGitYnssT7R1192rD2Zc9A9ZgB Rl2O3RZ/7SqsiwSJNzn0ldrXZ9wjCCuEeV5dLOpVEJ079/ZghtiW7D2HxfmwHboVDY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d89f:fd98 with SMTP id d9443c01a7336-2e301ae27ecmr1354315ad.1.1790799477609; Wed, 30 Sep 2026 13:17:57 -0700 (PDT) Received: from google.com (105.211.142.34.bc.googleusercontent.com. [34.142.211.105]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2e300af8560sm2018515ad.46.2026.09.30.13.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 13:17:57 -0700 (PDT) Date: Wed, 30 Sep 2026 20:17:50 +0000 From: Pranjal Shrivastava To: Nicolin Chen Cc: iommu@lists.linux.dev, Will Deacon , Joerg Roedel , Robin Murphy , Jason Gunthorpe , Mostafa Saleh , Daniel Mentz , Ashish Mhetre , linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Radu Rendec , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , rafael@kernel.org, Danilo Krummrich , driver-core@lists.linux.dev Subject: Re: [PATCH v11 03/16] iommu/arm-smmu-v3: Add arm_smmu_drain_queue() helper Message-ID: References: <20260929034510.2023173-1-praan@google.com> <20260929034510.2023173-4-praan@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260930_131759_275815_4E58D28B X-CRM114-Status: GOOD ( 20.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Sep 30, 2026 at 11:24:21AM -0700, Nicolin Chen wrote: > On Tue, Sep 29, 2026 at 03:44:57AM +0000, Pranjal Shrivastava wrote: > > +/** > > + * arm_smmu_drain_queue - Drain an SMMU queue > > + * @smmu: the SMMU device > > + * @q: the queue to drain > > + * @until_empty: target selection > > + * > > + * With @until_empty == true (for CMDQ), exit once the queue is observed empty: > > + * > > + * cons0 cons prod > > + * | | | > > + * ---+###################+=====================+=============+---> > > + * |<--------- undrained==0? --------->| > > Jason gave some remarks against this API: > https://lore.kernel.org/linux-iommu/179018862538.3334538.17643821143626392419.b4-review@b4/ > I see! > So, my PRI series would drop this patch. I suspect that it still > has some value for the RPM/CMDQ case, compared to a busy-waiting > alternative. Yet, it probably should be simplified for CMDQ case > only. > > In RPM case, the "prod" would be fixed/stable right? IOW, there > should be no new commands added to the cmdq, so it only needs to > wait for cons == prod? > Yes, that's correct. By the time we drain, the STOP_FLAG is set and we've waited for owner_prod to reach the target & cmdq->lock to drop.. so PROD is stable and only the HW moves CONS (same for the lvcmdqs). I'll simplify this to just serve the CMDQ in v12, maybe just a sleeping readl_relaxed_poll_timeout() on CONS until it matches PROD..? I'll think try to see if I could repurpose this too. Thanks, Praan