From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3CFD606A322 for ; Sat, 5 Dec 2026 00:17:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iukBDaN3 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4ADE61131E9; Sat, 5 Dec 2026 00:17:32 +0000 (UTC) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by gabe.freedesktop.org (Postfix) with ESMTPS id 051AB1131E9 for ; Sat, 5 Dec 2026 00:17:26 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 2EBAC6057A; Sat, 5 Dec 2026 00:17:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43D311F00936; Sat, 5 Dec 2026 00:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796429844; bh=PxTQDoYJSAvyXMsWqnZYQ52zQodnBSMj0vlW1KRHezA=; h=Date:To:From:Subject:Cc:References:In-Reply-To; b=iukBDaN3fKvCSZiNC+9vex3hzhdIwfSaL0ixRar7EV1VlGo8zU+DJsuMpZWcZyWBo Glzv7FY22yH+ARoo9qgscxZnorgUQHviOZTRBgtPRxANQ6ICFE/3mCn6zYQvXp1u0h rWXtKVLiMU+TaeZMDlr6IzrnvioCWIosLxmb3zShPMyQzEpwrvG9rz2gEourktZsfJ UWMf1zjD9HGUeV8uFldkNV/RCPLmgX5y/VsMdzE/iGSq0K/c3Z9jNDBvE4SLemAqmV ESvCusYAXeYIbH069Dd6PDj96ampNB2mZdlIF0Htl4ULJ/EiG0h8M3d+vsvxww4vgj YMIwUa8deWcxQ== X-Archived-By: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sat, 05 Dec 2026 01:17:14 +0100 Message-Id: To: "Alok Kumar" From: "Danilo Krummrich" Subject: Re: [PATCH v6 22/34] gpu: nova-core: vgpu: add instance create/destroy Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: In-Reply-To: X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed Dec 2, 2026 at 9:28 AM CET, Alok Kumar wrote: > @@ -390,7 +390,9 @@ unsafe fn new( > #[pin_data] > pub(crate) struct Gpu<'gpu> { > pub(crate) spec: Spec, > - vgpu: Option>, > + /// Drops before the MM and BAR1 mappings needed for instance teardo= wn. > + #[uses('bar_user, 'chid_pool)] > + vgpu: Option>>>, Ugh, I don't like this, but there's currently no alternative. I thought that we could probably add a new pin::Option type (internally usi= ng MaybeUninit) to overcome this, so I asked Gary about it. Turns out that Ben= no has a WIP implementation with exactly this for quite a while. Gary mentioned that he'd be happy to provide an implementation for this, bu= t there's of course no reason to block this series on it. > /// GSP event interrupt registration, and the enable of its subtree. > /// > /// Must be kept declared *before* `gsp_resources`, so that the hand= ler is unregistered, and > @@ -403,7 +405,8 @@ pub(crate) struct Gpu<'gpu> { > /// > /// Must be kept declared *before* `gsp_resources`, so that its comp= onents are dropped while > /// the GSP is still operational. > - mm: GpuMm<'gpu>, > + #[pin] > + mm: SharedGpuMm<'gpu>, As mentioned previously, that shouldn't be needed. > +/// A vGPU instance and the resources reserved for it. > +#[expect(dead_code)] > +struct VgpuInstance<'pool, 'gpu> { Technically this could be unified, but I assume it's easier not to do so fo= r storing it in the registry. In any case, I think the names are confusing, both could be generic lifetim= es, but 'gpu should probably be 'res and 'pool actually comes from the VramBloc= k, right? > + gfid: Gfid, > + dbdf: Dbdf, > + vgpu_type: VgpuType, > + vm_pid: u32, > + chids: ChannelIdReservation<'gpu>, > + vram_slot: VgpuVramSlot<'pool>, > +} > + > +/// Identity and firmware profile used to allocate an instance. > +pub(super) struct InstanceInfo { > + gfid: Gfid, > + dbdf: Dbdf, > + vgpu_type: VgpuType, > + vm_pid: u32, > +} > + > +#[expect(dead_code)] > +impl InstanceInfo { > + pub(super) fn new(gfid: Gfid, dbdf: Dbdf, properties: &VgpuPropertie= s, vm_pid: u32) -> Self { > + Self { > + gfid, > + dbdf, > + vgpu_type: VgpuType::from(properties), > + vm_pid, > + } > + } > +} > + > +/// Instance registry and cached VRAM pool for one physical GPU. > +pub(super) struct VgpuInstances<'gpu> { > + pool: Option>>>, > +} I'd just use a generic lifetime for this. > + > +/// Instances borrow the pool, and are destroyed before its backing allo= cation. > +#[pin_data] > +struct VgpuInstancePool<'gpu> { Same here, 'pool as an invariant lifetime is fine though. > +/// Registry of instances borrowing one layout's pool. > +struct InstanceRegistry<'pool, 'gpu> { > + instances: KVec>, > + pool: &'pool VgpuVramSlotPool, > +} Should probably be 'res instead of 'gpu. 'pool seems fine, but could also j= ust be a generic lifetime.