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 B3044396D28 for ; Tue, 14 Jul 2026 12:29:19 +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=1784032166; cv=none; b=OSFEaO3w6gGB3ziKBecK5ad7KwJk59lsKASgsOAB3cOKKhXy7Y7emnlAsaMMniBtPAHRS+Zz8Uzml4fo53wEv7R1YdyVulCj+3OiLeSfArtalufxNzi9mXEiWSmZ0m+/iFRoDrWJtsZG5fGmRR85cnPSyFshXwBMUX2gplygDpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784032166; c=relaxed/simple; bh=gmsT/6hGiTgG3nhnsb9gPpjrDpYzwYt2AkwBPDl85/U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IMtz4EnYOnzKtUBKeHBsBHcxinGnwz4pY+WonPjUod8n8Iw3RN73PdGXoaKJBf8XPGKlJReQyB4NlsUqn5lADgR8IpId5FW3tO3SdGPyF6wSOh8bk2bscxIOsf6VVNsincHAvYDWcB7nf4JwrVA88u5ulByNHdONq7R64TtmQSQ= 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=nBeZA2zH; 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="nBeZA2zH" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2cede6375caso118605ad.0 for ; Tue, 14 Jul 2026 05:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784032157; x=1784636957; 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=6cCQA9k6bE3JnyYuduP9TfMmZZN2aOdMtIN4G4eRzms=; b=nBeZA2zH4YjBRpTi0yN/K5yty1o5WSFvm/6oGwhc6Kdtf1z78voNa0AH8wFoJhJ4s0 F7F3+0EYTSd6o+LEr1rJBEXG/jAvqANe7w/bXHEhseYhVbP/oaV9r2qng7H2b8n4mbyh fo8OdJEZ/SA3a2D/QkSro88kxwXCausCxXPPJYNgjdCQCPyYZfwd9tqrtW1Dryf9sn6g rMJwh4jmCM+6AdTt6zWq6vJhBZJywhwLWKRv/9oC6hgSfx3fLuGqEq2MigJuO1Z/J0XP 5/ihazDCkup8vgioGcC+sRFSk4VNMj81iEr/14RK5QVUmcqwbOf14ZO3Y6MYaLRQYNkz I3JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784032157; x=1784636957; 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=6cCQA9k6bE3JnyYuduP9TfMmZZN2aOdMtIN4G4eRzms=; b=V9stDZohWHfDqDNchiSy9DcKjGIyaBWsGWAgoC/MebY+053YCG8LYY23QzzgVK4v+L Mh+6OUqA/L6k1aGVRGf7Wsbe9ms7bPcjubeB/8rB/kJUcJ7qeiikf/tsKVsIDBj1dFXZ RoTuPdf5chEMdQKoEicrbdrABO6HhJQUtCQl3Tk+ElvCqc0lS943HXd+dOAfxkYVKfbW tyKjiiZ8U6ho5eTRNLmoB1supLgetNDnKWN0Uym+8HLfgU4Ddkfdpc9RqVoumsnn9Vpk MGkvYIwiS3yEQKT60W52Vg84uwWHnXG4zfZf/MvxE3IQOFoLZ5Sf7pOHrRzdnGDaCl4i aPTw== X-Forwarded-Encrypted: i=1; AHgh+Rp57CBZLtvwHqaMcdq5hcpiLXvqub1FwhgMfHoroGjVLJQoPFF2/yUf7lehHLSu17uVplHMGgHGcQdLwFE=@vger.kernel.org X-Gm-Message-State: AOJu0YyzB4vbIuKzVKX6DeArIt6qLJqpz27Y1ldDII4DyJ0T60Xg4ErG WBZmbgE4Gzqk5VHee72Urpqz8umZBB6ygP4Tq3+9fD3oc7z9gM6NJjgqj0rg6Df3nA== X-Gm-Gg: AfdE7cmhEDKSin3htm96uk/vynUItQ8tjLU3sJ/DtFKAuUy6RhDobjhUKbG6CtYGGr2 PA/hPYQ2vWih0iD+E7kh0tz9fp5PC8jAC9Z4zXJk0kIzJU62i0r2HjXGGPTmW5ObA5kPxa1PPfa Ry+9IT4U2EntMPJ7sUlf0GekU4VifMbycB0W3CC+KAfkVI0SP7Kqby0FloPiheBymsdBHqlSECE 80TQp1rFLiriHBrEJVG7rSA0aAWYu5+4wYLjH9C8IikuMZ4mP5n4CHPjw6UOzQpayH9HUgkl/US ZbOxUYNQC7sXQwJ9XKCBuwzwKLFQ3/9xV5NfqfsuzxS/loEF+NhwHhqBsa7hMiAEqQXqj7OXNFG yMH/DeaqbgFWFwnirEEXo4iIyxIZUfPwFG6VpmlI4w+/Nsy+yPSmm1kBYm/2cYploKc5SDXFzHP 1wcvLcG2hLYl211rWVGj4DQ94WrVocsr//pUqGbaXj1nvcnFc= X-Received: by 2002:a17:902:c94a:b0:2cc:a859:d404 with SMTP id d9443c01a7336-2cee1cab7bamr5500905ad.23.1784032156142; Tue, 14 Jul 2026 05:29:16 -0700 (PDT) Received: from google.com (10.129.124.34.bc.googleusercontent.com. [34.124.129.10]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ccc9d1ea7fsm115135605ad.38.2026.07.14.05.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jul 2026 05:29:15 -0700 (PDT) Date: Tue, 14 Jul 2026 12:29:08 +0000 From: Pranjal Shrivastava To: Nicolin Chen Cc: Will Deacon , Jason Gunthorpe , Kevin Tian , Lu Baolu , Robin Murphy , joro@8bytes.org, David Woodhouse , linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/5] iommufd: Iterate the cache invalidation array in the core 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 08, 2026 at 12:44:17PM -0700, Nicolin Chen wrote: > The cache invalidation ops, cache_invalidate_user() for a nested HWPT and > the cache_invalidate() for a vIOMMU, are each handed the full user request > array and report how many of the array entries they handled by setting the > array->entry_num. Every driver therefore implements its own loop over the > array, and a driver wanting to process that array in fixed-size chunks > (e.g. to issue commands out of a fixed-size on-stack buffer) has to carry > the loop and its sub-array bookkeeping all on its own. > > Move the iteration into the iommufd core instead. Invoke the op with a > sub-array that starts at the first not-yet-handled entry, let it handle a > prefix of that sub-array and report the count via array->entry_num, then > advance the base pointer and re-invoke the op until the entire array has > been consumed or until the op returns an error along the way. > > A driver that handles the entire window in one single call, as all of the > current drivers happen to do, finishes the loop in just one pass, so this > does not change any of the existing behavior. It instead lets each of the > drivers convert to bounded chunk processing on its own, done by each of the > subsequent changes. > > Suggested-by: Jason Gunthorpe > Reviewed-by: Kevin Tian > Assisted-by: Claude:claude-opus-4-8 > Signed-off-by: Nicolin Chen Reviewed-by: Pranjal Shrivastava Thanks, Praan