From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25CCA1DDA3C for ; Fri, 24 Jan 2025 22:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737756310; cv=none; b=E7pErce0/ITeF0uFPz4pkS/Rb4IzKGs697ZO5b4XIiGSCowYSURfxvl/JY4uAdGtWIkxkPba/brPAehB+HqwdW7/j2nrvtvp0IFfLWr/4SlojC9EDszgB9072EnYdHITFRybvLAK3CkdJSfMB58Kmr+Po7CkTBjG3m3GCdTsHiw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737756310; c=relaxed/simple; bh=iaP/+3er8DGfdIcFksPz1XPEa/DXz0n7J2i6z2jhHD0=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IVCRFW6ATm28OmPBkgEgrC0/o5/fkl+h2NMVbFGi/IDC8DnEyirJKDmegy10RjeQc2M91o+eXJgLeQbkUXzSaUdUsfMdegVUJjXK1tqSeUSyzQIXzy9A3urlFX/6Ecqh8Pp5bBJmgtZfHRWvzJ9EV1spBDGIQ1MGRUv0nNXpjjA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VRvSB8v9; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VRvSB8v9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737756307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BzPE5HLtsNThgWwwLQzJK1+f2P0M9LXMVhz4OZk1S9A=; b=VRvSB8v9RS3FHnevYEWteNcETd5XepBIA06wHKccPHBQOAmbpXFuZwow/t3WtK0uh4Lwl6 MRmTM31V2P2eE0GsxdU3CB+yACrhcQFEY4DKGzgxrYrCMA/S0ofZJOeAQ3acEC5HAmDj9F nEtOEq5bvFa/Apl6dqxOJfoR6kuG1AE= Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-0HO6rDe2NK-myur0BI0BcA-1; Fri, 24 Jan 2025 17:05:06 -0500 X-MC-Unique: 0HO6rDe2NK-myur0BI0BcA-1 X-Mimecast-MFC-AGG-ID: 0HO6rDe2NK-myur0BI0BcA Received: by mail-io1-f72.google.com with SMTP id ca18e2360f4ac-844e0e20115so29688039f.3 for ; Fri, 24 Jan 2025 14:05:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737756306; x=1738361106; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BzPE5HLtsNThgWwwLQzJK1+f2P0M9LXMVhz4OZk1S9A=; b=efpyg1xhOF8JN6Ztbae+dZE9YYQPgt0nvrRYKJbVpGAT+rbUnveXwd1zSy73RX/Iwy g9JK4Z1rLu+B+t8wl+DFIc5kta8FjqLc2OtjDAIc6FgqA3EPCe9LP3H1j8qN7zid7Qc/ mmzNj289cwfGSPjvEi+R/RUAlPNnCv0IMy0a1vjRugXJh3dzBEnrEHzx9SOxvKXeyOHl wnOuz0BBpj7H3FQWtvMb6ITYP6ESK3JExF80lO0PB6wb/KRFpDym1jw7QBVnrKdxV42/ 5t+Mgj9r9GSVRTvdfPkEvShjxJ4wqhXurhkW+luH4kYBxMlggbmgET4gLOk2eKHmF96v bxsQ== X-Forwarded-Encrypted: i=1; AJvYcCWkW7R9FcsrKVo6PAn7xtD08KMcr7AmI1stmaPK193u3tD2VvPSSQxqHAF0e3kO494ONkgzDf0LsawP+a8=@vger.kernel.org X-Gm-Message-State: AOJu0Yz68Dpw3hJPyU3LhZul9CScba77ZzxQSw4v9oagN91VfGdmdkGu OvIy1IDb8KQwHN0F9Vrbk0PXWEtVOHhfjkqlLDADbYr5QJYRY6eGPv6yxkFSrWUNMjID0ZeAVif VcPa9CHkLNwZnZaWOetNk/nygFCNgczoT1jow/DeGP9U0kTPafAtC9GNx16N43Q== X-Gm-Gg: ASbGncvvEDBJotMvLVmcoOovzae/depT2ux2RmWEsvHa0QVSA5vi3vo2tmEoPzqAI+c EyxmHy2jCqcx6VbI+JAB2kKg3qJjwMyw/kU3WNr0tyiivgV5yr5Y5Z6F3PrJipkbtJQDSZYQ2q/ koqRn+ERZ2bhQZMyjg7Vv7yZnS0/0ORHUXzn+43UofBoSNi5Fg+GDnx6BIaQL6BRt39Y/L3vZfE zkJIt7ZGZLmcHqCcdYls998Cnaktex+48Li5L4ieHQJjR+u15WZg8lv1JDn+cEcvDA0EeLveffr INQXzvfa X-Received: by 2002:a92:cdaf:0:b0:3cb:f2e6:55a6 with SMTP id e9e14a558f8ab-3cfb1273e5dmr33819895ab.0.1737756305749; Fri, 24 Jan 2025 14:05:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5w9xrS5PTSDNP1aKKfYLET4Qdwk3FlXV2mw2SWK96tUHSAN0wHwBeYR/FM3EsAkg9f8obow== X-Received: by 2002:a92:cdaf:0:b0:3cb:f2e6:55a6 with SMTP id e9e14a558f8ab-3cfb1273e5dmr33819655ab.0.1737756305236; Fri, 24 Jan 2025 14:05:05 -0800 (PST) Received: from redhat.com ([38.15.36.11]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4ec1da4ba29sm888534173.70.2025.01.24.14.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 14:05:04 -0800 (PST) Date: Fri, 24 Jan 2025 15:05:03 -0700 From: Alex Williamson To: Cc: , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v6 0/4] vfio/nvgrace-gpu: Enable grace blackwell boards Message-ID: <20250124150503.24a39cea.alex.williamson@redhat.com> In-Reply-To: <20250124183102.3976-1-ankita@nvidia.com> References: <20250124183102.3976-1-ankita@nvidia.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-redhat-linux-gnu) 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-Transfer-Encoding: 7bit On Fri, 24 Jan 2025 18:30:58 +0000 wrote: > From: Ankit Agrawal > > NVIDIA's recently introduced Grace Blackwell (GB) Superchip in > continuation with the Grace Hopper (GH) superchip that provides a > cache coherent access to CPU and GPU to each other's memory with > an internal proprietary chip-to-chip (C2C) cache coherent interconnect. > The in-tree nvgrace-gpu driver manages the GH devices. The intention > is to extend the support to the new Grace Blackwell boards. > > There is a HW defect on GH to support the Multi-Instance GPU (MIG) > feature [1] that necessiated the presence of a 1G carved out from > the device memory and mapped uncached. The 1G region is shown as a > fake BAR (comprising region 2 and 3) to workaround the issue. > > The GB systems differ from GH systems in the following aspects. > 1. The aforementioned HW defect is fixed on GB systems. > 2. There is a usable BAR1 (region 2 and 3) on GB systems for the > GPUdirect RDMA feature [2]. > > This patch series accommodate those GB changes by showing the real > physical device BAR1 (region2 and 3) to the VM instead of the fake > one. This takes care of both the differences. > > The presence of the fix for the HW defect is communicated by the > firmware through a DVSEC PCI config register. The module reads > this to take a different codepath on GB vs GH. > > To improve system bootup time, HBM training is moved out of UEFI > in GB system. Poll for the register indicating the training state. > Also check the C2C link status if it is ready. Fail the probe if > either fails. > > Applied over next-20241220 and the required KVM patch (under review > on the mailing list) to map the GPU device memory as cacheable [3]. > Tested on the Grace Blackwell platform by booting up VM, loading > NVIDIA module [4] and running nvidia-smi in the VM. > > To run CUDA workloads, there is a dependency on the IOMMUFD and the > Nested Page Table patches being worked on separately by Nicolin Chen. > (nicolinc@nvidia.com). NVIDIA has provided git repositories which > includes all the requisite kernel [5] and Qemu [6] patches in case > one wants to try. > > Link: https://www.nvidia.com/en-in/technologies/multi-instance-gpu/ [1] > Link: https://docs.nvidia.com/cuda/gpudirect-rdma/ [2] > Link: https://lore.kernel.org/all/20241118131958.4609-2-ankita@nvidia.com/ [3] > Link: https://github.com/NVIDIA/open-gpu-kernel-modules [4] > Link: https://github.com/NVIDIA/NV-Kernels/tree/6.8_ghvirt [5] > Link: https://github.com/NVIDIA/QEMU/tree/6.8_ghvirt_iommufd_vcmdq [6] > > v5 -> v6 LGTM. I'll give others who have reviewed this a short opportunity to take a final look. We're already in the merge window but I think we're just wrapping up some loose ends and I don't see any benefit to holding it back, so pending comments from others, I'll plan to include it early next week. Thanks, Alex > * Updated the code based on Alex Williamson's suggestion to move the > device id enablement to a new patch and using KBUILD_MODNAME > in place of "vfio-pci" > > v4 -> v5 > * Added code to enable the BAR0 region as per Alex Williamson's suggestion. > * Updated code based on Kevin Tian's suggestion to replace the variable > with the semantic representing the presence of MIG bug. Also reorg the > code to return early for blackwell without any resmem processing. > * Code comments updates. > > v3 -> v4 > * Added code to enable and restore device memory regions before reading > BAR0 registers as per Alex Williamson's suggestion. > > v2 -> v3 > * Incorporated Alex Williamson's suggestion to simplify patch 2/3. > * Updated the code in 3/3 to use time_after() and other miscellaneous > suggestions from Alex Williamson. > > v1 -> v2 > * Rebased to next-20241220. > > v5: > Link: https://lore.kernel.org/all/20250123174854.3338-1-ankita@nvidia.com/ > > Signed-off-by: Ankit Agrawal > > Ankit Agrawal (4): > vfio/nvgrace-gpu: Read dvsec register to determine need for uncached > resmem > vfio/nvgrace-gpu: Expose the blackwell device PF BAR1 to the VM > vfio/nvgrace-gpu: Check the HBM training and C2C link status > vfio/nvgrace-gpu: Add GB200 SKU to the devid table > > drivers/vfio/pci/nvgrace-gpu/main.c | 169 ++++++++++++++++++++++++---- > 1 file changed, 147 insertions(+), 22 deletions(-) >