From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.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 BCE86399CED for ; Sat, 23 May 2026 13:21:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779542516; cv=none; b=BI4jS/3R9yfLuDme6JZ3F5wF5wX1hpgPGUzzJzZfhKkwz0WqN1bqHM5BIwCIkWJyMjt9Qt/C0VzUfGSEdaA6ZiQo9CHR0Y6zxvR6Zwq02h3Uf76WWe2KzNBEPsxMGFFCiB/9Gw0QkSQt7+x8qUFagD8DkhSBwlYpuECjDByWjkU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779542516; c=relaxed/simple; bh=mVpavoyb7l6uQQyd2XffEa1v5GKCirvC2OQyuHu/WoM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S2QwCSaXyfDFo/6FeXSRA3Eyczl9cwtzPYxOUo4KOgchVizxOA0dBUEg3/cyoEX3gT0D2JaUST2ZZfyHdghoqpLJLUI1wGmagH39Pus3kdfrYSlfsQTMiEvqFbFeGUbGR74uR/GKYJsA9uTZ0npcYj6XjdMEEi2V56FCgNf9RV8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=Xxg3tiqh; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="Xxg3tiqh" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-516de78c4dcso11050341cf.2 for ; Sat, 23 May 2026 06:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1779542512; x=1780147312; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=RRo5ik7HMyePlqAnBOmFqKyPpDT1cZy71Z1vsu5Dc6A=; b=Xxg3tiqh/o10p9grWN8xlGLTCHbiYwdthKIAvtUw91N4QiOhp8Uk3rEIJaIO5Q1A+K F2TCrF3UD6rWquLJ0WrDEcuywqZDsO4cdlGpI74HWSVdfu2cKKScAkaH5WUujM6o2VTO ujZOYjmgyvP70L50HRgi8O6SyGJEAKyowIdh1wRV/+edUCXFLdG8JVanS2/dIBarcPbi JUn0ArbqRfl0TBsfk1EBYA1zZqKPXR3VGW3QUkUp4f3399sPWRudX5vK51lizA0KL6Yz 2WUE45uUISCAr3HJn2PsmypjLVWu05r7NVdrOuCXp29PulLUOFGh9/zpcZYz0tProgDd vINQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779542512; x=1780147312; h=in-reply-to:content-transfer-encoding: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=RRo5ik7HMyePlqAnBOmFqKyPpDT1cZy71Z1vsu5Dc6A=; b=dbq2Q9000J71PLD7GMEq8RfRd0SWSYR3DTU9XOI8myy0dR95r2EYV+LV0fZAHGuT15 JK3CCYthOKVgLT0ipXNqT7aH51uI816XmJEdCxzisDDN/sZR+ozPjAQIuPode0YTSXnc Y9MpASqYQWcrq/eNhkVgdBwymAQYeEwtgyEfdrVoeiquwKOzHczaR867nH8F8iQRLc4M TcJ/vEhOuzcMhAlYdR/n5myaFau7XPuRLqtF2VfhRInGVddWEcN+lCaJKqAl4/DJKrmL 32kfG273LhGNV4X9TT/w3xuRhT+1xg2F2z/SnxGhdCb64J4Kw1tlMzumdl3cKxc7t9SS DwiQ== X-Forwarded-Encrypted: i=1; AFNElJ+sOQo78waJVe7c/2NfQpaxgGsdvXkUMQ2/rYC6XzQtr5gZRpcMtj+PVjt4JzMhwvc3X/v1PMGQQsW4aQ0=@vger.kernel.org X-Gm-Message-State: AOJu0YyllROj+wguETKNWvMq+J+u+uXIYNJW/947mJDPWxhpmpXGxNWq 89GPIdMg9dEmUFqIC8Pw0l2NX6kcDxLqmtR/F2YA+fy4aVdWC44rfBmTUBWKVtfUCxg= X-Gm-Gg: Acq92OHmV3vN3j2PgFpIu+oFhcSl/QwINLo9D0ZNyoNCH28uY1MDPsudFPQzdaWum7G Jp4y8OP0axhCzmzJoi7nytLMV8nf3ld2Waow1BLns0T3AgerOLfNMSEcWozFbOtWJdhHePhYLGH 737dQNrQVyyr9+vzGQvQhfB9MmVCT/9KW0boEp/g5VudntPEVTCihJIaIkPka9sKr6xffkpLeAn 0YAiLgc5W3BN+UB5Sf6g6M41CwIZebaqEOAfxguRVfJzvFUpfFB3b8xNm9A+xxO9fnAapvwaAgp WzThGCqVIohtlqr5hNOByXG2ah8MDpYE2BHyyf+cKPS3g/kTg78BPmNO+RPnU76o3m6xhdOA8av 0CcT/IMYKBxuu+xfrEr9KVjNM2Vi14dAlwNo0nYpAzxLlxxGwoOqvDgrrdeb68L4JGhFne6oNng Dvb+yp1uwowGrSJvK4zWBVQrEPI4+zOSGIP7P5r76PaKYGiSsUwlRCgPvk9S6ChV4MGFxgWjqf3 nEkPYb34SmLWasu X-Received: by 2002:a05:622a:4cca:b0:50b:29a6:8696 with SMTP id d75a77b69052e-516d429b5e5mr107369911cf.7.1779542512416; Sat, 23 May 2026 06:21:52 -0700 (PDT) Received: from ziepe.ca (crbknf0213w-47-54-130-67.pppoe-dynamic.high-speed.nl.bellaliant.net. [47.54.130.67]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-516d8cb9650sm39132141cf.22.2026.05.23.06.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 May 2026 06:21:51 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wQmIY-00000006Gp4-3JkH; Sat, 23 May 2026 10:21:50 -0300 Date: Sat, 23 May 2026 10:21:50 -0300 From: Jason Gunthorpe To: "Aneesh Kumar K.V" , Paolo Bonzini Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Alexey Kardashevskiy , Bjorn Helgaas , Dan Williams , Joerg Roedel , Jonathan Cameron , Kevin Tian , Nicolin Chen , Samuel Ortiz , Steven Price , Suzuki K Poulose , Will Deacon , Xu Yilun , Shameer Kolothum , Sean Christopherson Subject: Re: [PATCH v4 1/4] iommufd/device: Associate a kvm pointer to iommufd_device Message-ID: <20260523132150.GF7702@ziepe.ca> References: <20260427061005.901854-1-aneesh.kumar@kernel.org> <20260427061005.901854-2-aneesh.kumar@kernel.org> <20260427135906.GB740385@ziepe.ca> <20260428125015.GB849557@ziepe.ca> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, Apr 29, 2026 at 07:22:46PM +0530, Aneesh Kumar K.V wrote: > > Jason Gunthorpe writes: > > > On Tue, Apr 28, 2026 at 05:31:04PM +0530, Aneesh Kumar K.V wrote: > >> > I thought we were trying to get away from struct kvm? > >> > > >> > https://lore.kernel.org/all/adf29Rn7q9Db0hxc@google.com/ > >> > > >> > Ie this should be a 'struct file *kvm_fd' > >> > > >> > ? > >> > > >> > Though I am wondering how practical it is to do this at this moment :\ > >> > > >> > >> Should we also switch > >> > >> modified drivers/vfio/vfio.h > >> @@ -22,8 +22,8 @@ struct vfio_device_file { > >> > >> u8 access_granted; > >> u32 devid; /* only valid when iommufd is valid */ > >> - spinlock_t kvm_ref_lock; /* protect kvm field */ > >> - struct kvm *kvm; > >> + spinlock_t kvm_ref_lock; /* protect kvm_file */ > >> + struct file *kvm_file; > >> struct iommufd_ctx *iommufd; /* protected by struct vfio_device_set::lock */ > >> }; > >> > >> @@ -88,7 +88,7 @@ struct vfio_group { > >> #endif > >> enum vfio_group_type type; > >> struct mutex group_lock; > >> - struct kvm *kvm; > >> + struct file *kvm_file; > >> struct file *opened_file; > >> struct blocking_notifier_head notifier; > >> struct iommufd_ctx *iommufd; > > > > Ideally, yes everything outside kvm should just use the struct file > > and there should be quite narrow places where you do some kvm > > operation on it. > > > >> ie, > >> KVM_CREATE_DEVICE with KVM_DEV_TYPE_VFIO still use kvm->users_count, > >> KVM_DEV_VFIO_FILE_ADD -> will switch to get_file(kvm->_file); > >> and VFIO_DEVICE_BIND_IOMMUFD -> will switch to get_file(df->kvm_file) > >> > >> > Maybe ask Paolo how his series is going? > > > > I thought the above is what Paolo's series was going after? > > > > Hi Paolo, > > Could you please take a look at this? I’ve tried to document the > reference count details and hope I’ve captured everything correctly, but > I’d appreciate your review to make sure I haven’t missed anything. Reminder? Jason