[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<CH3PR12MB75483B12E8BFFECDAEB9E3BAABD0A@CH3PR12MB7548.namprd12.prod.outlook.com>
Date: Mon, 24 Nov 2025 18:22:28 +0000
From: Shameer Kolothum <skolothumtho@...dia.com>
To: Ankit Agrawal <ankita@...dia.com>, "jgg@...pe.ca" <jgg@...pe.ca>, Yishai
Hadas <yishaih@...dia.com>, "kevin.tian@...el.com" <kevin.tian@...el.com>,
"alex@...zbot.org" <alex@...zbot.org>, Aniket Agashe <aniketa@...dia.com>,
Vikram Sethi <vsethi@...dia.com>, Matt Ochs <mochs@...dia.com>
CC: "Yunxiang.Li@....com" <Yunxiang.Li@....com>, "yi.l.liu@...el.com"
<yi.l.liu@...el.com>, "zhangdongdong@...incomputing.com"
<zhangdongdong@...incomputing.com>, Avihai Horon <avihaih@...dia.com>,
"bhelgaas@...gle.com" <bhelgaas@...gle.com>, "peterx@...hat.com"
<peterx@...hat.com>, "pstanner@...hat.com" <pstanner@...hat.com>, Alistair
Popple <apopple@...dia.com>, "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Neo Jia
<cjia@...dia.com>, Kirti Wankhede <kwankhede@...dia.com>, "Tarun Gupta
(SW-GPU)" <targupta@...dia.com>, Zhi Wang <zhiw@...dia.com>, Dan Williams
<danw@...dia.com>, Dheeraj Nigam <dnigam@...dia.com>, Krishnakant Jaju
<kjaju@...dia.com>
Subject: RE: [PATCH v5 5/7] vfio/nvgrace-gpu: split the code to wait for GPU
ready
> -----Original Message-----
> From: Ankit Agrawal <ankita@...dia.com>
> Sent: 24 November 2025 11:59
> To: Ankit Agrawal <ankita@...dia.com>; jgg@...pe.ca; Yishai Hadas
> <yishaih@...dia.com>; Shameer Kolothum <skolothumtho@...dia.com>;
> kevin.tian@...el.com; alex@...zbot.org; Aniket Agashe
> <aniketa@...dia.com>; Vikram Sethi <vsethi@...dia.com>; Matt Ochs
> <mochs@...dia.com>
> Cc: Yunxiang.Li@....com; yi.l.liu@...el.com;
> zhangdongdong@...incomputing.com; Avihai Horon <avihaih@...dia.com>;
> bhelgaas@...gle.com; peterx@...hat.com; pstanner@...hat.com; Alistair
> Popple <apopple@...dia.com>; kvm@...r.kernel.org; linux-
> kernel@...r.kernel.org; Neo Jia <cjia@...dia.com>; Kirti Wankhede
> <kwankhede@...dia.com>; Tarun Gupta (SW-GPU) <targupta@...dia.com>;
> Zhi Wang <zhiw@...dia.com>; Dan Williams <danw@...dia.com>; Dheeraj
> Nigam <dnigam@...dia.com>; Krishnakant Jaju <kjaju@...dia.com>
> Subject: [PATCH v5 5/7] vfio/nvgrace-gpu: split the code to wait for GPU ready
>
> From: Ankit Agrawal <ankita@...dia.com>
>
> Split the function that check for the GPU device being ready on
> the probe.
>
> Move the code to wait for the GPU to be ready through BAR0 register
> reads to a separate function. This would help reuse the code.
>
> Signed-off-by: Ankit Agrawal <ankita@...dia.com>
Reviewed-by: Shameer Kolothum <skolothumtho@...dia.com>
With a nit below:
> drivers/vfio/pci/nvgrace-gpu/main.c | 33 ++++++++++++++++++-----------
> 1 file changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/vfio/pci/nvgrace-gpu/main.c b/drivers/vfio/pci/nvgrace-
> gpu/main.c
> index c84c01954c9e..3e45b8bd1a89 100644
> --- a/drivers/vfio/pci/nvgrace-gpu/main.c
> +++ b/drivers/vfio/pci/nvgrace-gpu/main.c
> @@ -130,6 +130,24 @@ static void nvgrace_gpu_close_device(struct
> vfio_device *core_vdev)
> vfio_pci_core_close_device(core_vdev);
> }
>
> +static int nvgrace_gpu_wait_device_ready(void __iomem *io)
> +{
> + unsigned long timeout = jiffies +
> msecs_to_jiffies(POLL_TIMEOUT_MS);
> + int ret = -ETIME;
> +
> + do {
> + if ((ioread32(io + C2C_LINK_BAR0_OFFSET) ==
> STATUS_READY) &&
> + (ioread32(io + HBM_TRAINING_BAR0_OFFSET) ==
> STATUS_READY)) {
> + ret = 0;
> + goto ready_check_exit;
You could return directly here and avoid that goto.
Thanks,
Shameer
> + }
> + msleep(POLL_QUANTUM_MS);
> + } while (!time_after(jiffies, timeout));
> +
> +ready_check_exit:
> + return ret;
> +}
> +
> static vm_fault_t nvgrace_gpu_vfio_pci_huge_fault(struct vm_fault *vmf,
> unsigned int order)
> {
> @@ -930,9 +948,8 @@ static bool nvgrace_gpu_has_mig_hw_bug(struct
> pci_dev *pdev)
> * Ensure that the BAR0 region is enabled before accessing the
> * registers.
> */
> -static int nvgrace_gpu_wait_device_ready(struct pci_dev *pdev)
> +static int nvgrace_gpu_probe_check_device_ready(struct pci_dev *pdev)
> {
> - unsigned long timeout = jiffies +
> msecs_to_jiffies(POLL_TIMEOUT_MS);
> void __iomem *io;
> int ret = -ETIME;
>
> @@ -950,16 +967,8 @@ static int nvgrace_gpu_wait_device_ready(struct
> pci_dev *pdev)
> goto iomap_exit;
> }
>
> - do {
> - if ((ioread32(io + C2C_LINK_BAR0_OFFSET) ==
> STATUS_READY) &&
> - (ioread32(io + HBM_TRAINING_BAR0_OFFSET) ==
> STATUS_READY)) {
> - ret = 0;
> - goto reg_check_exit;
> - }
> - msleep(POLL_QUANTUM_MS);
> - } while (!time_after(jiffies, timeout));
> + ret = nvgrace_gpu_wait_device_ready(io);
>
> -reg_check_exit:
> pci_iounmap(pdev, io);
> iomap_exit:
> pci_release_selected_regions(pdev, 1 << 0);
> @@ -976,7 +985,7 @@ static int nvgrace_gpu_probe(struct pci_dev *pdev,
> u64 memphys, memlength;
> int ret;
>
> - ret = nvgrace_gpu_wait_device_ready(pdev);
> + ret = nvgrace_gpu_probe_check_device_ready(pdev);
> if (ret)
> return ret;
>
> --
> 2.34.1
Powered by blists - more mailing lists