From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796429845; b=PVvm37WzHHZhWif20zgcTZARGAldK6iLqUYFDadJfui+dtg6QIG4G2iqC7ihD/rqB3TX 7IZT43luxR6YN4XTQTtNPCs0kCjhmfode/Vri1+b7uqK8u198kNLNVLpHF9akJZwS2/uL PlkDtyuxjNaim937/Ba7xBfzy51XVhTXp1oFQ0EMqboTMyK7h+TfTc99NdvRUPO9TBuYr pw3veW/0nqNYh1jCVC2OF1mhnBjKxAssDRhDiyjIAT8jDQNrqCJppT39q4JhzaXFQo4j+ pYj+RG4/8StKagrWnajVm6nk6h4X2HRjHAAdeIcWd2VrNh0igMfBHo9qP/TXx+0TFZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796429845; h=Received:DKIM-Signature:Mime-Version:Content-Transfer-Encoding: Content-Type:Date:Message-Id:To:From:Subject:Cc:References: In-Reply-To; bh=PxTQDoYJSAvyXMsWqnZYQ52zQodnBSMj0vlW1KRHezA=; b=wCDvxOHA4r0CNnknUFq1FDzZaLkqu53rLjrYMrjld/T4vgfmZxHneKCsGLrnpkZ2t2wF 13K7cHNxrNbPTbRdCFrACgtbG6An4GTOyB3A/f1OImYooz1pJVsQSKUUrFGS37fAiVxWV AdFh8bcvMePlYnh7j1/bpQ7HS/9Y7UYbQmCDgiGGjjBl3044XxNjEreDUCX1gixMhfUJI 334XhnO52pqN5CvAmjFDPtwAqnyy0elCNux7WC0Eg1wZAWuDW38O6Z4gIdANXD8c+6m9y ZuTIUbrAsG0aAg+g6kOQXtyGHEAnNQ94N4dHtoE9Fz9sC2xedAVdx1X7r+4kUAR0BTg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iukBDaN3; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C136606A322; Sat, 5 Dec 2026 00:17:25 +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: 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-Mailing-List: nova-gpu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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: 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.