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.133.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 4813B19E7D1 for ; Fri, 17 Jan 2025 19:39:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737142789; cv=none; b=PRXURSWFuZqwyggqlVHoQuxEJUcqGE+Mpgy0kgVQYL0YwAKsPHcRAxjNNAcU/trBziS2xqy4XyTImbN4FNvTyYaTLj9BildUdOIxeUBy88PmqdSwNZ7Nw57mRrKl64sLky5Hmhlv53PEc4GOJpBqnuSsrRWiLod2SajTyotKeN8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737142789; c=relaxed/simple; bh=+NaeP7GVnPCxrd1310AzmfZTsRXB4TI9L8n8gh6ZR8Q=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tm/syca5nuOuNQOyZpbr9ECE7EXbvNSRF906Y+YU88Nh8jqzNA/rB9Vinwaj5NWRsgVfugfT3A0xLvVMTz+s4GdOfeQCQh58SYAaf8SJK3fVvY4VeymcCGpbEhOdEJFklWD3YArtTAJB44h0Le5n4fAnUz5kcrQLuGEjt4SFg3A= 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=C0dJnm38; arc=none smtp.client-ip=170.10.133.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="C0dJnm38" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737142787; 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=RhFaS26ZX3er7z2oL2KGkvKw+0jM0A4abyRAVN7hf/Y=; b=C0dJnm38wdthy+cVctsdB5nFsXRJhkklKgOQKLvuajrlOe6eWKEulQF1vgZ7UAnv/wp+wZ SKDl8fuBWQeTcEhzemk6xSAB8JrZDWSw1vZBNuYmV2w/LbbLLdDOq2X99HDJhSF5zQhXkk 8FHsDeHnNVaTsJTNuoeEiPCTu/rbssc= 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-612-UqSlOLttPJSfchUGMgOy3A-1; Fri, 17 Jan 2025 14:39:46 -0500 X-MC-Unique: UqSlOLttPJSfchUGMgOy3A-1 X-Mimecast-MFC-AGG-ID: UqSlOLttPJSfchUGMgOy3A Received: by mail-io1-f72.google.com with SMTP id ca18e2360f4ac-849cc81984eso11631539f.1 for ; Fri, 17 Jan 2025 11:39:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737142785; x=1737747585; h=content-transfer-encoding:mime-version:organization: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=RhFaS26ZX3er7z2oL2KGkvKw+0jM0A4abyRAVN7hf/Y=; b=T15LhboaEl+WanawpYtsNvBYDW8eK1Fxas7N5JebsrlKWFg3/VD/Wj98s4FtkRJ6l0 +/9PvvVxhKwNfKwAOL7D1yzZ6EdzZ/wZNny3N2sARChu3g+yAXiI8VYeOdmZSb0qess1 LN1YNyQdaFgDBlhC8NHkwQYoCw9sk+lAUS4PTiucxvSBUB0TNVZywLGpeNqaaXRtA43u +/sAnGYTswa0JDchSHh4dcyHNQegQPKzWW7KX+j93aaSiB/YGH+XN3vI+p/OeqRVJHdn JGPwXxFqXUgTbDm3yk99w0lWy4rUEkwkNoSiuE94kIlxr/V+ZqNT9ipB5N8GcTmNzr73 ncCQ== X-Forwarded-Encrypted: i=1; AJvYcCUIj1EVsnRttcXbkFJe91y5qHZPAEEICvXxxN/UAn+kUyT1Q2w9hf9bXj0gnR1u+x2yuPMCWD8EC/HtFTQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxaK1x57jGJ8oKrIRRHMKabPMdO+9vQhtqbI8ZpCgnLNJwSlRp9 4UcKLX1C/ZaKP2MPFAEHkDPexc7M9OQaM0hf5Hv2gNvS2Cw5JR/WD5h2UZpbMB/r4b9720KDDeB 2l8mWbSFk4RbGT6f6eUUEdGsgCI7FlsR6rYnugNO6vqoJlJsNe3A9Q/NQ6Vz0Ag== X-Gm-Gg: ASbGnct8Ak7FBRI6zLcgyexdrTSCxGY2/01G7H51yMOXoeZWO+qf7N5i7CEXl89KKPb dgid9QmTXiBzmvRvXCRJOVIU7I5n1kvjTwn914QPqlvRdjSWzKv4+6+LNqjQomG1aK6qBxImFql 9vjIspaPscaNkJSqlEzMHWuT70NIKTYJTH2jJsvBkHTEdKrnJ7sTt8zyX4U5h9T7AUVDFXhLi6/ +oSmcDqb8OrDYklXmYuDerhdowWtEdgidHTAS53gqd6w7fdjxEaiwNVDEhB X-Received: by 2002:a92:cdac:0:b0:3ce:67f2:a98b with SMTP id e9e14a558f8ab-3cf7449705cmr9464735ab.3.1737142785320; Fri, 17 Jan 2025 11:39:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1KTPUbjnbifY0k6s2to3F0S4DF9lrhTcf/98kcmU2Kcr/pNHddL7xKY8ycvVucn0YtorgbQ== X-Received: by 2002:a92:cdac:0:b0:3ce:67f2:a98b with SMTP id e9e14a558f8ab-3cf7449705cmr9464635ab.3.1737142784978; Fri, 17 Jan 2025 11:39:44 -0800 (PST) Received: from redhat.com ([38.15.36.11]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3cf71a758a8sm7272445ab.13.2025.01.17.11.39.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 11:39:44 -0800 (PST) Date: Fri, 17 Jan 2025 14:39:28 -0500 From: Alex Williamson To: Ankit Agrawal Cc: Jason Gunthorpe , Yishai Hadas , "shameerali.kolothum.thodi@huawei.com" , "kevin.tian@intel.com" , Zhi Wang , Aniket Agashe , Neo Jia , Kirti Wankhede , "Tarun Gupta (SW-GPU)" , Vikram Sethi , Andy Currid , Alistair Popple , John Hubbard , Dan Williams , "Anuj Aggarwal (SW-GPU)" , Matt Ochs , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3 3/3] vfio/nvgrace-gpu: Check the HBM training and C2C link status Message-ID: <20250117143928.13edc014.alex.williamson@redhat.com> In-Reply-To: References: <20250117152334.2786-1-ankita@nvidia.com> <20250117152334.2786-4-ankita@nvidia.com> <20250117132736.408954ac.alex.williamson@redhat.com> Organization: Red Hat 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-Transfer-Encoding: quoted-printable On Fri, 17 Jan 2025 19:19:42 +0000 Ankit Agrawal wrote: > >> +/* > >> + * To reduce the system bootup time, the HBM training has > >> + * been moved out of the UEFI on the Grace-Blackwell systems. > >> + * > >> + * The onus of checking whether the HBM training has completed > >> + * thus falls on the module. The HBM training status can be > >> + * determined from a BAR0 register. > >> + * > >> + * Similarly, another BAR0 register exposes the status of the > >> + * CPU-GPU chip-to-chip (C2C) cache coherent interconnect. > >> + * > >> + * Poll these register and check for 30s. If the HBM training is > >> + * not complete or if the C2C link is not ready, fail the probe. > >> + * > >> + * While the wait is not required on Grace Hopper systems, it > >> + * is beneficial to make the check to ensure the device is in an > >> + * expected state. > >> + */ > >> +static int nvgrace_gpu_wait_device_ready(struct pci_dev *pdev) > >> +{ > >> +=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long timeout =3D jiffies + msecs_to= _jiffies(POLL_TIMEOUT_MS); > >> +=C2=A0=C2=A0=C2=A0=C2=A0 void __iomem *io; > >> +=C2=A0=C2=A0=C2=A0=C2=A0 int ret =3D -ETIME; > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0 io =3D pci_iomap(pdev, 0, 0); > >> +=C2=A0=C2=A0=C2=A0=C2=A0 if (!io) > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 return -ENOMEM; > >> + > >> +=C2=A0=C2=A0=C2=A0=C2=A0 do { > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 if ((ioread32(io + C2C_LINK_BAR0_OFFSET) =3D=3D STATUS_READY) && > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 (ioread32(io + HBM_TRAINING_BAR0_OFFSET) =3D=3D= STATUS_READY)) { > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret =3D 0; > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto reg_check_exit; > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 } > >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 msleep(POLL_QUANTUM_MS); > >> +=C2=A0=C2=A0=C2=A0=C2=A0 } while (!time_after(jiffies, timeout)); > >> + > >> +reg_check_exit: > >> +=C2=A0=C2=A0=C2=A0=C2=A0 pci_iounmap(pdev, io); > >> +=C2=A0=C2=A0=C2=A0=C2=A0 return ret; =20 > > > > We're accessing device memory here but afaict the memory enable bit of > > the command register is in an indeterminate state.=C2=A0 What happens i= f you > > use setpci to clear the memory enable bit or 'echo 0 > enable' before > > binding the driver?=C2=A0 Thanks, > > > > Alex =20 >=20 > Hi Alex, sorry I didn't understand how we are accessing device memory her= e if > the C2C_LINK_BAR0_OFFSET and HBM_TRAINING_BAR0_OFFSET are BAR0 regs. > But anyways, I tried 'echo 0 > /enable' before device bind. I= am not > observing any issue and the bind goes through. >=20 > Or am I missing something?=20 BAR0 is what I'm referring to as device memory. We cannot access registers in BAR0 unless the memory space enable bit of the command register is set. The nvgrace-gpu driver makes no effort to enable this and I don't think the PCI core does before probe either. Disabling through sysfs will only disable if it was previously enabled, so possibly that test was invalid. Please try with setpci: # Read command register $ setpci -s xxxx:xx:xx.x COMMAND # Clear memory enable $ setpci -s xxxx:xx:xx.x COMMAND=3D0:2 # Re-read command register $ setpci -s xxxx:xx:xx.x COMMAND Probe driver here now that the memory enable bit should re--back as unset. Thanks, Alex