From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 8F42E39183A for ; Wed, 29 Jul 2026 05:46:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785303993; cv=none; b=F35Z2iZowtqcvacsxeBN/UsimRdKP9PQ2y3adhb5s9/kl91PnbJLLAkUAoNDLMHVnhbC1+/xzBnkcM9nvGD1Jw13LxNWUW/aVpUrSj8U+uXHXF/VA/AZ/P4NspWFi7EJ63FdSyZB9MLUY6S1v+x7K37BEjCl+cBdTodFhwBpceM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785303993; c=relaxed/simple; bh=ydP+87D/K348FSpdC9NbnctdfuYDb3MlvkZ+qPWf4JA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lB/kWlcWdPLl1aISI2tJ/Upaz6y3kyzYqijnpvOq/iSpgSNvZPfqK8UR3oEekV/JMYAgwxasWXsr/sc67r5hm5uGik0IKoFJFh4XA3pbWwPxN7qz9tkbJzTYs0l/9at326FnJyzl5kZEafmg/5JfJJEdv4dRvgKQH07MtyFZF54= 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=YDlzlwJz; arc=none smtp.client-ip=209.85.214.173 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="YDlzlwJz" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2ccdf36f63dso73145ad.0 for ; Tue, 28 Jul 2026 22:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1785303992; x=1785908792; 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=KUrSKghuESWPVo/dW96oFPOfRQeq5DnIatYi5FWLDOg=; b=YDlzlwJzSwUaxfX2pp0QjT3ySEOEwq0XhS+axxtAfoDZdN7ZgvMJ+4y7KHme1MD2OG 6FHvLkkCLXcb3LwKzgb9ReptEuHBD9Fgrzzc9cPPCeZsyB4L4Eca0h+StNOBCseGtW0n hF3vP3/mM4Py9gK0MsGM5WjRrqZGpEP+G9XpuMzLaNsK6ckNgvqTraHl6ZDZQpu0f3MG C7N2W9X0Yfz6Ov796JdGw7FgIj9rdS6mNr8fv8PZvz41aLe+XhGEq+FZOmWcZnlUrcai Y6LuUNPokGWpA/LzzvJ5DhzjzJqG8F23Hv0EmcrhQVPlZe7kwNHvOtS/6zm7KJzQ/KJu 3JPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785303992; x=1785908792; 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=KUrSKghuESWPVo/dW96oFPOfRQeq5DnIatYi5FWLDOg=; b=NL+Z+n0snd/b0ZQ9R9K4BkwpRNGcqagIQ6oXVKyHy4eG9J7NIRy2KlkF3/ta4LCJGO eltHxdM1pct2BGbxvQn436kTC6KTM5mn3geU6vaQicKzIvzPdbSAx/NvhDtPbxVvPp0J tPuxQuBj5RACVf6LC9Z21cergEVtt15oovtZcuhb0OeePikoynrCOu/eFUo95BTZJraZ iavNXM2mx4fG6q/zGJhanfzSNT6dzeWzTWqZ2IGy6/H9plid1ku6bi/7TavKR33pFgp6 VRw2ferZs1qBvjL4KBb7YKH+5dYBW9l3usGKxg/SCjyZ+OXB9M9/27k+TzmchUSNKCx8 RKxA== X-Forwarded-Encrypted: i=1; AHgh+Rqd4Q6DigKWc1z5RyTD+Crgf7mDeUvIotQYXQbvRqJIKfDB5uuomErKBuAvI0oQIhTxXD+qHMFz/7ZAVRM=@vger.kernel.org X-Gm-Message-State: AOJu0YwXgL2BQ838e2U52x0MYkNE9lpFExOZakHLBEa7A36A87AlE8f7 YSdSfDWBytbgWjY8R2g15n3oz+qBzSH/xcxm+vvkrBrgh9f/oli/D6GSGRCfFn0GUg== X-Gm-Gg: AR+sD12Wno37zTMMRoouv2Ef5m2LAQsR75BhIR2ZxbhlD5xEwuDl3i6zu8obV+fA4Bl CDaiS1LWFa0g98PULW4gyimeiis5Mkkus4EbxKPZPtX0TsdQTO5cU2S1q7LDqndb3LUcbJ16bDk gwjp1J9Asr/DLBWBZEO5i8voIjwbnVXr12W2RMbBwzTLCMo+flnI2yTV9dKbJUkKCB2iOWJutBy Dq6x7pGQhxaM8k702/1YXzhO3dqauJyvQlLJ2y3Au/WQzqr4S+e/Ss07Nwm538M1Dp0CPxNAN0+ u+mKNUH1ZctfOdLZYXx/78kOlMe7r1D/ytss6g7+pze3kMJK+e0ZSeiro8T+Ys09NUHO11JsUSn UyxkgevuaUHIswDCiyk7tGrVJQYxZsygHTFYxePzFZN3DbhDsvCqMPt6wKhV5LTcDdc+1W3fEW6 1uhIgwv1SiQHFwxFmT7d4bXSsCqTA21SV4NvyGzG3TlTQv78p/8UzP0aN+PLprvhz1jHP5PVuW3 9+VNM5/SbUfQF9pvBROE6A= X-Received: by 2002:a17:903:4091:b0:2ca:be81:b469 with SMTP id d9443c01a7336-2d026c4dcc4mr1313315ad.0.1785303991374; Tue, 28 Jul 2026 22:46:31 -0700 (PDT) Received: from google.com (21.168.124.34.bc.googleusercontent.com. [34.124.168.21]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38f642fbf74sm2219437a91.17.2026.07.28.22.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2026 22:46:30 -0700 (PDT) Date: Wed, 29 Jul 2026 05:46:23 +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 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). Let me know if I m missing anything? Praan