From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 B5C6738F244 for ; Tue, 16 Jun 2026 20:38:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781642314; cv=none; b=aE6eISC0vMtRuUUkI2K8tu9YmHlU9ZdvoHnnwD9lGg2ybUbPcYsUCEWBjEYCUMPL6GUkO6eIAlcLl0/TTXO4m398EKvWZ5VDpoRrgx2dYNT+IP+R9hzwcv2DXfahxrttmQodEgSam/RrSmqrM5Do9Fn3zD2sJmO4edEe5mQqguk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781642314; c=relaxed/simple; bh=yRbsaIenMXgEK1Gk4AsMIjbJDs3Ig22fD+PcCY04YF4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FREmH7p4KWTwfdgnrXySutC13BeXcZIh5EqfFFu9Q2geKwmmiAKskPJm7CCZhJWq/eMXK5euBsfBujfv6baNkGcN56iyO2YVTwTm4jQ2DiopNare+RqnXI/kycb4cGxdYq5IogId2+3RCQd3lJvlROmGjcFvVZSLn6NycHpZ0q4= 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=ZEszDQ71; arc=none smtp.client-ip=209.85.214.169 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="ZEszDQ71" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2bf2d865383so5145ad.1 for ; Tue, 16 Jun 2026 13:38:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781642313; x=1782247113; 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=QQz3Sw9zxa6xC6R+gWy6vC8YGv1nZf7Z0czKC6/lgYU=; b=ZEszDQ71tOjT9CmXYfhw9qDyuJBLuzbQIp+1ceNVDnb8fNfErRtA351MTan/fOyTrz h8EQiuZN+Ym633T/Gl/Uc8ARurFGrmxu+z6OpJv5za0/YxFAFYfi9cCV4lTA8NHZ7TTf 67vsJS0PemddSW7jzZnakRy/lpWpiMwCulGZPFA56819/F4Q+fyeEE11+rJnjuwC5qDV /OMgPn3KB8W4jFY0wJ+qxPr0gjT4CCFn1eOshs/E3l0r1Llw2YTXddcRcR3Csrg08oM7 d0d23G3p0SqkP0Bfq3pvQNogNJOlxDOb9q8rLVKRkt+aVzpl8mSuCQpi7HM5ZmZd/4OC hOog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781642313; x=1782247113; 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=QQz3Sw9zxa6xC6R+gWy6vC8YGv1nZf7Z0czKC6/lgYU=; b=tYyaoqIEJqGj/tXq6jofB16yX+bMaBQVURKzGcBl1F0pLHoLhwmDHgtdjrIioTgR4I VJarn7ejcWFxd3lap/QHuaagg/KjReWW3u+7zaAH0FfvTP1ujpXMmoPpeEy/klxCs7+9 7k8mX/DSSdiACt7Hwb9H/xUhlMnpJcRkg+5btBj/JpLQ7AhTnglAZM3WLrosbH/n2UTA f0N4Bw4euUxjhfi0EQrgjwzE3Bh0nAJZErjG5xpvWOhMhTbdIFZfofEECdb71WbJXIXj 6e+2k4Xj3YzLPV/HIcEfkYdbDTCiNgtGkzO2ihwxwl5UYWJH9viWHIJtam+prpI2LHEe OAkQ== X-Gm-Message-State: AOJu0YzaG2SN7QVWhpgTZeIWxv/Xfc5QDBCSOz9BWcMqquFyy1mdrtQg Xs7+oGVA1bB0ktGEkp+95SaipPwU1Fd6tAfHBnNSAGo9UuEu3SsSTJQc98Gk03rWfQ== X-Gm-Gg: AfdE7cn6ZU7zBryLHfwPVRkoErOMuJUrqahztl0J4Ol65ew0ZrxWbKw7stJZp2XF9IU 8StJznNfSaX63upsstbkh+FBq1M8w2WMWJ6a5OuInFhPluc9P7vgRSTjfqBnoHu0v+KGsv0Zu6W 8V5zZz2UGVeOHgAX4cViGvnHD4SFJbT9O8AciL6jzYDWgo3Pi66OmiA/AR1s8FwM5l8cySMKs/T Mu9Bb6d6VCrQ0XoKqzH7kd/c8pCnQxJhobDeXm9eThUDVXSE+22w6aDOq0jraP5DiVpwBRPJqTN TZnmiyWNhLBf31WFCNkSfAFCLfbX0jmqdfyOpinFUXTWerLWWcwf0unMMM2Oy0Vo9oDIJw9gQJz rbzFE1QuRxS/Vr34p1wd9T8EMgPjOsPFPPmATylstHUMRZyrOS4UN5yw2WXjLEAch5Wd17iBist Xkdq+Wy9w8l6uRVX2wFPlHQv2Dy2LsNFGY3cYcjgbIDPPv81cEcllx5e5UagST X-Received: by 2002:a17:902:c94b:b0:2bf:1000:d3ac with SMTP id d9443c01a7336-2c6bd3ddaa6mr167145ad.11.1781642312500; Tue, 16 Jun 2026 13:38:32 -0700 (PDT) Received: from google.com (199.255.142.34.bc.googleusercontent.com. [34.142.255.199]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-37c521aa047sm4812201a91.3.2026.06.16.13.38.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jun 2026 13:38:31 -0700 (PDT) Date: Tue, 16 Jun 2026 20:38:24 +0000 From: Pranjal Shrivastava To: Jacob Pan Cc: linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" , Jason Gunthorpe , Alex Williamson , Joerg Roedel , Mostafa Saleh , David Matlack , Robin Murphy , Nicolin Chen , "Tian, Kevin" , Yi Liu , Baolu Lu , Saurabh Sengar , skhawaja@google.com, pasha.tatashin@soleen.com, Will Deacon Subject: Re: [PATCH v9 3/6] iommufd: Allow binding to a noiommu device Message-ID: References: <20260611172658.3421138-1-jacob.pan@linux.microsoft.com> <20260611172658.3421138-4-jacob.pan@linux.microsoft.com> 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: <20260611172658.3421138-4-jacob.pan@linux.microsoft.com> On Thu, Jun 11, 2026 at 10:26:55AM -0700, Jacob Pan wrote: > From: Jason Gunthorpe > > Allow iommufd to bind devices without an IOMMU (noiommu mode) by creating > a dummy igroup for such devices and skipping hwpt operations. > > This enables noiommu devices to operate through the same iommufd API as IOMMU- > capable devices. > > Reviewed-by: Kevin Tian > Reviewed-by: Yi Liu > Reviewed-by: Lu Baolu > Signed-off-by: Jason Gunthorpe > Signed-off-by: Jacob Pan [...] > +/* > + * Detect a noiommu device for the cdev path. We check dev->iommu rather than > + * using device_iommu_mapped() (which checks dev->iommu_group) because when > + * both group and cdev interfaces coexist, the group path assigns a fake > + * noiommu iommu_group to the device. That would cause device_iommu_mapped() > + * to return true and hide the noiommu case from the cdev path. dev->iommu is > + * reliably NULL when no IOMMU driver is managing the device. > + */ > +static bool iommufd_device_is_noiommu(struct iommufd_device *idev) > +{ > + return IS_ENABLED(CONFIG_IOMMUFD_NOIOMMU) && !idev->dev->iommu; > +} > + Helpful comment! Thanks :) > static void iommufd_group_release(struct kref *kref) > { > struct iommufd_group *igroup = > @@ -30,9 +43,11 @@ static void iommufd_group_release(struct kref *kref) > > WARN_ON(!xa_empty(&igroup->pasid_attach)); > > - xa_cmpxchg(&igroup->ictx->groups, iommu_group_id(igroup->group), igroup, > - NULL, GFP_KERNEL); > - iommu_group_put(igroup->group); > + if (igroup->group) { > + xa_cmpxchg(&igroup->ictx->groups, iommu_group_id(igroup->group), > + igroup, NULL, GFP_KERNEL); > + iommu_group_put(igroup->group); > + } > mutex_destroy(&igroup->lock); > kfree(igroup); > } Reviewed-by: Pranjal Shrivastava Thanks, Praan