From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 87A6B3AAF54 for ; Wed, 29 Jul 2026 17:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785344466; cv=none; b=ERL7vG/Z/VckW3zLMNhu0MXO/uFqmPdJ06tNj1J6IX6c+NRAxKy4Z0Y9uVt8/CIKyuqXeJrm+S69I7Pz1OhzowploBND2NmgyMGTQ4YWg1WJL1fBpobfgQcYMGDdqNN5/GuZKpgMhLDjMeCUCc0FqTIOAupQDn0+VkQN/D2zOzE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785344466; c=relaxed/simple; bh=fSOZJ17rVEbG+FfK1DiMh3qgkRdHa+C33+C3HyGA1Hc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KoQGT4AmHGxd9lALeIj6zsLzsWnujwk2Crw5ou7x1nomExaNd2K/kg5nJ/HL/Zuj6TEOXvxS/agvz+RIXtvdoDRfKWOOqLn6llASbnnzzC86XnGI3CICnn5HleI33+xBOuVIc6sh3PzR/2pPzXtxCxmbqqiRAO2znHVp5NLJ7Gg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=BEGvEfIV; arc=none smtp.client-ip=209.85.214.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="BEGvEfIV" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2cab97c86bdso495ad.1 for ; Wed, 29 Jul 2026 10:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785344463; x=1785949263; darn=vger.kernel.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=NtT0ExTXo5bL6h0YkCoaVWGGXnkWOHvTo5L6MU1yaIQ=; b=BEGvEfIVPia25HWYQyOmpAwClDSOZjE8ZLqbdTfn6xnC6I12VdCONnLWG5f2SuIHpz 6EgM88RI+Jgja+3JGcA16o1ysVqQpvnZlMu7bpnZFvEEX4Jl3tIyZbYGP0jkj1QR1V8V 7Snuriz8ID5ys2yV9mAHhQRFs2SWp1xtT6mKA+2nNMlX8LNqbOoIXw9FnOpUitaoejW0 w+jYwyXFv2isGx+ArpXKaCDV+OS3Z9x8f6mWSb8snE7/i02idR8TsAE/TGfMCFqwJCFI ZW4Ux+wVCs17XguFUZ/cwMIE61nxB//G9hiNUi/tGVdxyyGp7Wo+6/e/fguMVtyGnWDS kDQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785344463; x=1785949263; 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=NtT0ExTXo5bL6h0YkCoaVWGGXnkWOHvTo5L6MU1yaIQ=; b=GBTvxT+M6L045Esw1UUE9K2aVCE0UjQh4I/5pifmVAtEPs0BmCkfOwwIYcC0X3hb+0 BS7joIryNncEsBwXR7UU15gGZFtpeENkwHuG7L13OCkBTD4181i+vw15LR3kSn8pOrsc ySjNPcGxnbW+zuVuFjSXObQ8LFWsQe0W+0AQJ5LejBpB/8VBEg6sIGJ/Q7xcB0+CSFbO pGCEd8P16GyWFuxcVfAU1ehKT714rAlUwaMr1Qj/PNETJi1MJUp5AmUwasipKFRS5pll qeOEOOjNy0bmdhsg4Mn32j7fRY94WS71S77g6o4WVN9y0cpA1QuJBqNPQQhThi0ssKBL JEGQ== X-Forwarded-Encrypted: i=1; AHgh+RrjZMtn/LnMOhOimJ2OSEag/GNkTVGI0wDWJKTxwrPksmrJ79fnoPXPv5qh9nLamVX6n+9x52UHRnst+Yk=@vger.kernel.org X-Gm-Message-State: AOJu0YxF+wlagtFik+aOJv4JLOFAUzSJKw6KvlpIVDPvs48n82DsI0lT Vc5BxGuIxV5wgCF+YBXZiUsbT3N/5igyWjgsbkbCNSi5HuUzyDKRFmtiw1yOL1+gZw== X-Gm-Gg: AR+sD132FYsbTpSxDYhahC0coc4/Cx9H5a6Tl+IAIIfwcqxSnBKfORmP+hrZMgaOVnk eNsc5KoAIw5wBeRNsQBtxTZ8D31Qu4N48E8shJhgTOM4nzmqxXzma32+LAqrb3XKfNIwPIt98NY NN4SIHo29ygcLfxcYaghtky0dyDrQjzfjDFRNpfwPbr47aK7IE1UnXyvLZU+jyil+PZr3o8BP4e YQT/rKCSsF7Z2ik2FeUFiRVfcdg/jU1nvHyJc/ZPXs9W5WiT0yH73EcptgNaWYTNAC3cjD5B6Jj aPqoNf7Rk/hpwDgwAu7o5nhIiDf0FVmuMojEFBNGe3wCBbuzrPjFiZ1LMgefgVEKk8DUJ4vtBM7 PVzEVrZDFTISK5DITD7MSTbctz6REs6lLfRFOem20oxd54jdMqVy1V1UotBN74Bv/A2FzzjQedL IVFo9fF4bR8B6K0SUwiTYas4CUo49u0glWs/K4cPRrDUnEDdEI8qUG5YF5c2EHQmyfDxIpvL1Nk 9BfMCMgYr7y09CJO6IwfmY= X-Received: by 2002:a17:902:f608:b0:2c0:defb:557e with SMTP id d9443c01a7336-2d03210f8c4mr355465ad.1.1785344461607; Wed, 29 Jul 2026 10:01:01 -0700 (PDT) Received: from google.com (21.168.124.34.bc.googleusercontent.com. [34.124.168.21]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84ea0051591sm1750258b3a.19.2026.07.29.10.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jul 2026 10:01:01 -0700 (PDT) Date: Wed, 29 Jul 2026 17:00:48 +0000 From: Pranjal Shrivastava To: Nicolin Chen Cc: will@kernel.org, robin.murphy@arm.com, jgg@nvidia.com, joro@8bytes.org, bhelgaas@google.com, kevin.tian@intel.com, kees@kernel.org, smostafa@google.com, baolu.lu@linux.intel.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, skaestle@nvidia.com, mmarrid@nvidia.com, skolothumtho@nvidia.com, bbiber@nvidia.com Subject: Re: [PATCH v2 03/11] iommu/arm-smmu-v3: Add arm_smmu_drain_queue_for_iopf() helper Message-ID: References: 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 In-Reply-To: On Wed, Jul 29, 2026 at 09:47:45AM -0700, Nicolin Chen wrote: > On Wed, Jul 29, 2026 at 05:46:23AM +0000, Pranjal Shrivastava wrote: > > On Tue, Jul 28, 2026 at 10:26:19PM -0700, Nicolin Chen wrote: > > > On Wed, Jul 29, 2026 at 05:15:43AM +0000, Pranjal Shrivastava wrote: > > > > For PRIQ/EVTQ, my only worry was the HW producing more events, > > > > say Device A is detached (we call drain from attach_release) but Device B > > > > (still attached) starts an agressive DMA with multiple PRI requests/evts. > > > > > > > > Maybe we should go back to snapshot based polling for that? > > > > > > If you look closely, "pending" is the snapshot, regardless of the > > > growing prod. > > > > > > * With @until_empty == false (for EVTQ/PRIQ), exit once "drained" reaches its > > > * target: "pending" (i.e. prod0 - cons0, frozen at the entry time): > > > * > > > * cons0 cons prod0 (prod) > > > * |<---- drained ---->| | | > > > * ---+###################+=====================+=============+---> > > > * |<--------------- pending --------------->| > > > > > > > Right, but we write back cons to cons_reg only after we see queue_empty() > > We have a do { .. } while (!queue_empty(llq)); and then we call > > queue_sync_cons_ovf(q). Same for PRIQ handler. > > > > IIUC the helper relies on cons_reg being updated: > > > > cons = readl_relaxed(q->cons_reg); > > drained += Q_POS(&q->llq, cons - prev); > > > > Thus, if we get a storm of pri reqs / evts, we may never leave that loop > > and queue_sync_cons_ovf(q). > > cons_reg is updated by queue_remove_raw() every iteration inside > that loop. > > queue_sync_cons_ovf() doesn't update cons_reg unless an overflow. > Ahh right, I was too focused on the storm *facepalm*. In that case the new helper LGTM. Thanks, Praan