From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 B2FA93890F7 for ; Mon, 13 Jul 2026 11:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783940878; cv=none; b=orFQOq5PlVl9OshmofkLwlVHgZgPTTma8DU6JNywb40CnRJuuLYmF72gFozzR4qnibuhSELpjx7J+38LJGIBGIUa2Gni/uYT0hQ0OOLWI9cSzMCoCyP9J5wpnyHnJ412SGBxwYTnyR1KDOe5uASnIF2kFLcIybO//4wfBVJkZp4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783940878; c=relaxed/simple; bh=Eds3EgvFkpLMHtynlmWxSgjSfgcwXmnfbdoaPHhBueo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WZsBSvm3/2OBokjFx0MBkD2Ryb2Yk7H1QFod9xSW1UVFboCQO5tZwB8pSObC9xKYSbypto8Tw77IK1nvBwZdi6yQTRXbag/C5m885r9sZRfZH8X68EfwCpstIpCKODYRc/VfLxC5ZJiRDuovV3SvRhwN9CtljOM+OtFDDFA9hIg= 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=kjQN3VFo; arc=none smtp.client-ip=209.85.128.49 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="kjQN3VFo" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-493b8d92a4eso86585e9.1 for ; Mon, 13 Jul 2026 04:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783940874; x=1784545674; darn=lists.linux.dev; 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=YZ0k43QjY4fFBTZv9XwnB5eVI6fl2iA5pqXp0CRkiRA=; b=kjQN3VFouwZEARB9hUIajlTsgmWEiHve6Yuwo+NxHmbWURYOusdy/YfnvJ0X2iy2U/ 0fHW+Ike6w0BbWsAFwEKX7rFs0EzVRJb0AQXtJdsOfIf+jKev9X7BASb3rK+ZH+QnECv C4do24yUKpnNhLNjbpKiDmbwCGR2U2PXTXumWVahvbc6Qe4CDyZrgtJRxbdIz8xqWioA hpdk7Ux/Oro22XwJZDZKlRG6HEw/ZkEu/uyYKn3XM2Hby/zc4GwGM6O35WUWuugE7AW7 0IMkbubCDeuc0j702sLq6VNrPAuhVJffnQTlElOqFb7k/lRT3APpZ6DVJWVE0mLHif8L 1KLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783940874; x=1784545674; 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=YZ0k43QjY4fFBTZv9XwnB5eVI6fl2iA5pqXp0CRkiRA=; b=geYm8sapjD/PuZj+x1W4LoBmGJ2a1GNygRpB/GRhkF6Q+Iapds+27uuaAKUF0a/Zlw KcoElxEuaVosJdxDk+tXXWymUhH8TCZjbay+A/b0EZzRmb243yRdPCGOPXofBz8QZWBX zOXoTzU+08EW1fOMzFjvi0BGh4fT75Dfxygy6sRqMKGRP2yFfUIviSDPT1h7fqeDVcU9 oq+yfVRUe4BvjpR1CS6+i46DVNADwdkOwIYIGHYwRfUtV8jDkcrLhjMifPD1dOFV/GFW fZ8/VM39r/foFWvM3n1edT8f2pZJWZvkbBoWVjxdaQLyIs2W1RmYEMYtNiE7/YYtGWi2 syEg== X-Forwarded-Encrypted: i=1; AHgh+RphdX4nqRlTCRD4uUFsUrU6BgeICqwVIaBBBSGRhe5eLWu/2v4ToiwUhaFkB3u/lgL/Djj90A==@lists.linux.dev X-Gm-Message-State: AOJu0YxXpmXGRtGc8w66YDcYdD0jwCIsyKuk0RrVzVSD5CvbGSZQ06Fk YLaw8029Ha19AKEMRD6qNCnXFqq7qNywjfLQ0XjFOvc7OoNoqAkrSjLltzrJnq9Liw== X-Gm-Gg: AfdE7cko6P/HwjhIFNg128LEQKh/9LhDmnqAEIPkdPvKFg4M4sN0QjD08jkH8mo6C7b yEBy0dQ5I16mTGcgjvWgo4VjayODy4uQfin0sxAALRcl7Uubackd+s/ZQZLNDSNxau/6B/73e1t UuAp1dS3IVOSsIHvnuRvXbP3lL4BMbn6ahJurEMgN5mqRlST3+xbS92YBv8k4UwW1K3mlLK/PCy S6sQYGgIKcffyKB4i4RPZCR58hCJG821NdQHptIG/Ej+oKjPLWRvW3RoPjX+pHAyVvpKdywROhP xXQMrwQxTDJrpjq3DDzeXJNORsCIEl5+CD58TjXXGAwrJsUkpzdvalxJGBi4yfVqe2a2ZuQcnsq i4m16lZcSJB2t1mTvoONNlsiSPNRdS+h3uVjij1yFQ0X1dIyOkkhdcH8lsvDCmQmr0g7aWCp/Cp 8/XA4amSyd4Bd7gbudWXc+a+xBzvkyxiygETIiMhkSXMxJXNep X-Received: by 2002:a05:600c:a088:b0:45f:2940:d194 with SMTP id 5b1f17b1804b1-4945e32136bmr235535e9.2.1783940873591; Mon, 13 Jul 2026 04:07:53 -0700 (PDT) Received: from google.com (220.60.76.34.bc.googleusercontent.com. [34.76.60.220]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47aa0f214d2sm82275582f8f.33.2026.07.13.04.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jul 2026 04:07:52 -0700 (PDT) Date: Mon, 13 Jul 2026 11:07:48 +0000 From: Mostafa Saleh To: Vincent Donnefort Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, iommu@lists.linux.dev, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, joro@8bytes.org, jean-philippe@linaro.org, jgg@ziepe.ca, mark.rutland@arm.com, qperret@google.com, tabba@google.com, sebastianene@google.com, keirf@google.com Subject: Re: [PATCH v6 16/25] iommu/arm-smmu-v3-kvm: Add CMDQ functions Message-ID: References: <20260501111928.259252-1-smostafa@google.com> <20260501111928.259252-17-smostafa@google.com> Precedence: bulk X-Mailing-List: iommu@lists.linux.dev 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, Jul 10, 2026 at 05:01:07PM +0100, Vincent Donnefort wrote: > On Fri, May 01, 2026 at 11:19:18AM +0000, Mostafa Saleh wrote: > > Add functions to access the command queue, there are 2 main usage: > > - Hypervisor's own commands, as TLB invalidation, would use functions > > as smmu_send_cmd(), which creates and sends a command. > > - Add host commands to the shadow command queue, after being filtered, > > these will be added with smmu_add_cmd_raw. > > > > Signed-off-by: Mostafa Saleh > > --- > > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 14 ++- > > .../iommu/arm/arm-smmu-v3/pkvm/arm-smmu-v3.c | 107 ++++++++++++++++++ > > 2 files changed, 115 insertions(+), 6 deletions(-) > > [...] > > I only looked at that smmu_wait() as this is the hyp_clock_ns() caller. > > > > > +/* > > + * Wait until @cond is true. > > + * Return 0 on success, or -ETIMEDOUT > > nit: Would be nice to explain use_wfe. I will add it. > > > + */ > > +#define smmu_wait(use_wfe, _cond) \ > > nit:, (__use_wfe, __cond), or (use_fw, cond) Will do. > > > +({ \ > > + int __ret = 0; \ > > + u64 delay = hyp_clock_ns() + ARM_SMMU_POLL_TIMEOUT_US * 1000; \ > > Does it help to lower the risk for the 128-bits fallback if we keep the > resolution to _us? I will remove the tracing clock support as mentioned and I will handle the overflow in smmu_wait() > > Also, ARM_SMMU_POLL_TIMEOUT_US seems to be 1s. Blocking that long at EL2 is > really terrible. Any chance to lower that? > That should never really happen, I am re-using the kernel max, but I can change this for the hypervisor. > > + \ > > + while (!(_cond)) { \ > > + if (use_wfe) { \ > > + wfe(); \ > > + if ((_cond)) \ > > nit: I believe there's no need for the double () here is there? > Will do. Thanks, Mostafa