From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 0087737BE9B for ; Fri, 23 Jan 2026 09:54:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769162097; cv=none; b=ejsT5IxkYgFPkjLk69PYp6H5XvYyDu4v/51BaVGgS31NpiB/HH1ggrRwiS35uI3UYtyb+hsHMYRr77BNtjrmaEspTZfBD+i6+cgj+nLr9AUb0KLZgdgi/WXLGJU53DrBKQVFTouKi19HsZwvfQXNmqG7WsFX8dbOj8KEEXwjgXs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769162097; c=relaxed/simple; bh=7jP8H/Jfn0/rI3MbEn++2nxKkgZ6bWFHg2NXMRv1Mms=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gM2PfJxk4G8RS0BFtXEOL5tNr9MD8LzpAns8ADZZvtm0+kMl98uXqQ3LEF1KBZiZPkZvDg3VNe7VPqFxZKfDctz0y28VezrR6Na6ZM4B4VeIDEm8nMnnajhgzaMCt4xNyCaNB46JKXxkObz4DzEBNdAgoUhZk77NUkpiJGpfFc0= 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=I6Gih51q; arc=none smtp.client-ip=209.85.214.176 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="I6Gih51q" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2a76b39587aso95935ad.0 for ; Fri, 23 Jan 2026 01:54:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769162083; x=1769766883; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=gTYFAMmhtE4NKQmdzfuC730nwqhs3VcPytU8c4s1NEc=; b=I6Gih51qHHpKWmzZ95tyNIfr4ro2ZQ7fBoAAd+g+UcFEoQYFMMdnyjEcscP3qfNCP5 crv/l99/C7TV6z7843DIg2DXT/eKkVZZmVlFoXs8FTA4NmS0iSiV1QrykU0lSGJV3ibq fOo4UtrVsjdv/S7OIKEqyEusnL6F2e1MTlkeEx+3a14qU7YaDG7vjTex7n5wIKuOYZgm 3a/k9alfiHnEodJ/YxV647xiVqxK0cEj0Z8eZsmCvGwa2dh2YnuYZ1KceON++2cMuj8q UpwkxTGhLt9NVatvcDdaEUmhcq35iqiT9XedPbkTjGmIIjMhS+Yg2eiVMKXK7pdRam0j +Z0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769162083; x=1769766883; h=in-reply-to: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=gTYFAMmhtE4NKQmdzfuC730nwqhs3VcPytU8c4s1NEc=; b=vtVuosXJUttbWuX4JxJU03sNfONP6OPc+jYCWW1dChZCrNw7bNRL0yA0NiEorpIVkI zcnCbJOdcwqiSaKIs68XDhgMhoYIIpIdtnZuKX+2PVfGrU2h0cMJ/Yws9eACZ9x7s7/z obnzsurrbzdhNkXZ6dHVgrc3Hmh2mSU0KZ40cy+xZbUhxDtpWfdKtiGUZJNxLM+a5Bra IsOjfDxcxWmhrnqvMUKK8pV9Ub4TmBRfR66ZbrEJsaBGMeE5ok+GBHdzCMMqttD4wpqF wqizxys+voLCctQd9lesQr2mSXjB2O3VAhGcVNbYKGqvJbbWdJxaLzzf+rgOy91363/7 SvPA== X-Forwarded-Encrypted: i=1; AJvYcCUhV5iVlRVrGSvayWx8Cx/mKvT34nFpE+tTca5moJxeDMHexf0yKNmsF3sMAuA/o1VHxUmIlqgfIaP3tKE=@vger.kernel.org X-Gm-Message-State: AOJu0YwTTFbQSlrkBBq82Dz3Pyqp+JK0IFiK/9wGlE0vPu4dFcZaxpZr OuVJB/D9RgDbp3AK07MbnFwPoGIa9zcg5sANYng89FOCtsQQFfvfMQPduULe073ytw== X-Gm-Gg: AZuq6aIWsUbp/FMDsg6qa36q/mtHWRfm/HsuH/CiiMD4vrYS+ScTRbj1EjWpEOXvhPB e2MZ+xO1TCgqrn72RxZFzJ+d3ggmV5QOiApq3BcmdQSivuEqbdC0CvFT1I3sj5HjCCBoe1wnLw5 366AvCXBBwnOzveMwPKY363YAu2ZRLJKsQRUnq+qbUzP1LLYnWPVhd28kgOiRaLySr3I+IDh4b9 jZkQAyaMfSEeC+XfmGUrkPUlQg3a6M3zcrjrqiX9xtJYDmuh8rSTY50uttNuLtWR8XTa9arak0j f5m98abHj1mCe7mm9YbZC56Q7F96oTyvYQllwQQkzfADw9l6gfJhbo7P37pit9FprtlG2ohY7Hg PJGLGi/iilkLaKw7bsTyPRg54agZUU+UgRTa0J9WPJo6FgVV6rTAvVF1OHgLGd+fdjqKPR0VvqJ LQyST+yf5PfMvQEfokqTVRN0lUChCbwiXddCrkNKQi7VHJeTWO X-Received: by 2002:a17:902:e548:b0:294:ecba:c8e with SMTP id d9443c01a7336-2a805c9abbfmr2227345ad.3.1769162082816; Fri, 23 Jan 2026 01:54:42 -0800 (PST) Received: from google.com (222.245.187.35.bc.googleusercontent.com. [35.187.245.222]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8231871d57csm1719570b3a.41.2026.01.23.01.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jan 2026 01:54:42 -0800 (PST) Date: Fri, 23 Jan 2026 09:54:36 +0000 From: Pranjal Shrivastava To: Nicolin Chen Cc: will@kernel.org, jean-philippe@linaro.org, robin.murphy@arm.com, joro@8bytes.org, jgg@nvidia.com, balbirs@nvidia.com, miko.lenczewski@arm.com, peterz@infradead.org, kevin.tian@intel.com, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 4/7] iommu/arm-smmu-v3: Pre-allocate a per-master invalidation array 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 Fri, Dec 19, 2025 at 12:11:26PM -0800, Nicolin Chen wrote: > When a master is attached from an old domain to a new domain, it needs to > build an invalidation array to delete and add the array entries from/onto > the invalidation arrays of those two domains, passed via the to_merge and > to_unref arguments into arm_smmu_invs_merge/unref() respectively. > > Since the master->num_streams might differ across masters, a memory would > have to be allocated when building an to_merge/to_unref array which might > fail with -ENOMEM. > > On the other hand, an attachment to arm_smmu_blocked_domain must not fail > so it's the best to avoid any memory allocation in that path. > > Pre-allocate a fixed size invalidation array for every master. This array > will be used as a scratch to fill dynamically when building a to_merge or > to_unref invs array. Sort fwspec->ids in an ascending order to fit to the > arm_smmu_invs_merge() function. > > Co-developed-by: Jason Gunthorpe > Signed-off-by: Jason Gunthorpe > Reviewed-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 8 ++++ > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 41 +++++++++++++++++++-- > 2 files changed, 45 insertions(+), 4 deletions(-) > Reviewed-by: Pranjal Shrivastava Thanks Praan