RE: [PATCH RFC v2 04/15] vfio/nvgrace-gpu: Introduce functions to fetch and save EGM info
From: Shameer Kolothum Thodi
Date: Thu Feb 26 2026 - 10:31:31 EST
> -----Original Message-----
> From: Ankit Agrawal <ankita@xxxxxxxxxx>
> Sent: 23 February 2026 15:55
> To: Ankit Agrawal <ankita@xxxxxxxxxx>; Vikram Sethi <vsethi@xxxxxxxxxx>;
> Jason Gunthorpe <jgg@xxxxxxxxxx>; Matt Ochs <mochs@xxxxxxxxxx>;
> jgg@xxxxxxxx; Shameer Kolothum Thodi <skolothumtho@xxxxxxxxxx>;
> alex@xxxxxxxxxxx
> Cc: Neo Jia <cjia@xxxxxxxxxx>; Zhi Wang <zhiw@xxxxxxxxxx>; Krishnakant
> Jaju <kjaju@xxxxxxxxxx>; Yishai Hadas <yishaih@xxxxxxxxxx>;
> kevin.tian@xxxxxxxxx; kvm@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
> Subject: [PATCH RFC v2 04/15] vfio/nvgrace-gpu: Introduce functions to fetch
> and save EGM info
>
> From: Ankit Agrawal <ankita@xxxxxxxxxx>
>
> The nvgrace-gpu module tracks the various EGM regions on the system.
> The EGM region information - Base SPA and size - are part of the ACPI
> tables. This can be fetched from the DSD table using the GPU handle.
>
> When the GPUs are bound to the nvgrace-gpu module, it fetches the EGM
> region information from the ACPI table using the GPU's pci_dev. The
> EGM regions are tracked in a list and the information per region is
> maintained in the nvgrace_egm_dev.
>
> Signed-off-by: Ankit Agrawal <ankita@xxxxxxxxxx>
> ---
> drivers/vfio/pci/nvgrace-gpu/egm_dev.c | 24 +++++++++++++++++++++++-
> drivers/vfio/pci/nvgrace-gpu/egm_dev.h | 4 +++-
> drivers/vfio/pci/nvgrace-gpu/main.c | 8 ++++++--
> include/linux/nvgrace-egm.h | 2 ++
> 4 files changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/vfio/pci/nvgrace-gpu/egm_dev.c
> b/drivers/vfio/pci/nvgrace-gpu/egm_dev.c
> index 0bf95688a486..20291504aca8 100644
> --- a/drivers/vfio/pci/nvgrace-gpu/egm_dev.c
> +++ b/drivers/vfio/pci/nvgrace-gpu/egm_dev.c
> @@ -17,6 +17,26 @@ int nvgrace_gpu_has_egm_property(struct pci_dev
> *pdev, u64 *pegmpxm)
> pegmpxm);
> }
>
> +int nvgrace_gpu_fetch_egm_property(struct pci_dev *pdev, u64 *pegmphys,
> + u64 *pegmlength)
> +{
> + int ret;
> +
> + /*
> + * The memory information is present in the system ACPI tables as DSD
> + * properties nvidia,egm-base-pa and nvidia,egm-size.
> + */
> + ret = device_property_read_u64(&pdev->dev, "nvidia,egm-size",
> + pegmlength);
> + if (ret)
> + return ret;
> +
> + ret = device_property_read_u64(&pdev->dev, "nvidia,egm-base-pa",
> + pegmphys);
> +
> + return ret;
> +}
> +
> int add_gpu(struct nvgrace_egm_dev *egm_dev, struct pci_dev *pdev)
> {
> struct gpu_node *node;
> @@ -54,7 +74,7 @@ static void nvgrace_gpu_release_aux_device(struct
> device *device)
>
> struct nvgrace_egm_dev *
> nvgrace_gpu_create_aux_device(struct pci_dev *pdev, const char *name,
> - u64 egmpxm)
> + u64 egmphys, u64 egmlength, u64 egmpxm)
> {
> struct nvgrace_egm_dev *egm_dev;
> int ret;
> @@ -64,6 +84,8 @@ nvgrace_gpu_create_aux_device(struct pci_dev *pdev,
> const char *name,
> goto create_err;
>
> egm_dev->egmpxm = egmpxm;
> + egm_dev->egmphys = egmphys;
> + egm_dev->egmlength = egmlength;
> INIT_LIST_HEAD(&egm_dev->gpus);
>
> egm_dev->aux_dev.id = egmpxm;
> diff --git a/drivers/vfio/pci/nvgrace-gpu/egm_dev.h
> b/drivers/vfio/pci/nvgrace-gpu/egm_dev.h
> index 1635753c9e50..2e1612445898 100644
> --- a/drivers/vfio/pci/nvgrace-gpu/egm_dev.h
> +++ b/drivers/vfio/pci/nvgrace-gpu/egm_dev.h
> @@ -16,6 +16,8 @@ void remove_gpu(struct nvgrace_egm_dev *egm_dev,
> struct pci_dev *pdev);
>
> struct nvgrace_egm_dev *
> nvgrace_gpu_create_aux_device(struct pci_dev *pdev, const char *name,
> - u64 egmphys);
> + u64 egmphys, u64 egmlength, u64 egmpxm);
>
> +int nvgrace_gpu_fetch_egm_property(struct pci_dev *pdev, u64 *pegmphys,
> + u64 *pegmlength);
> #endif /* EGM_DEV_H */
> diff --git a/drivers/vfio/pci/nvgrace-gpu/main.c b/drivers/vfio/pci/nvgrace-
> gpu/main.c
> index 3dd0c57e5789..b356e941340a 100644
> --- a/drivers/vfio/pci/nvgrace-gpu/main.c
> +++ b/drivers/vfio/pci/nvgrace-gpu/main.c
> @@ -78,7 +78,7 @@ static struct list_head egm_dev_list;
> static int nvgrace_gpu_create_egm_aux_device(struct pci_dev *pdev)
> {
> struct nvgrace_egm_dev_entry *egm_entry = NULL;
> - u64 egmpxm;
> + u64 egmphys, egmlength, egmpxm;
> int ret = 0;
> bool is_new_region = false;
>
> @@ -91,6 +91,10 @@ static int nvgrace_gpu_create_egm_aux_device(struct
> pci_dev *pdev)
> if (nvgrace_gpu_has_egm_property(pdev, &egmpxm))
> goto exit;
>
> + ret = nvgrace_gpu_fetch_egm_property(pdev, &egmphys,
> &egmlength);
> + if (ret)
> + goto exit;
> +
This should only be done if this is not the add_gpu case below
Also, patch #3 has a comment:
" Skip the EGM region information fetch if
* already done through a differnt GPU on the same socket."
That probably belongs here instead.
Thanks,
Shameer