Re: [PATCH v4 2/3] vfio/nvgrace-gpu: Expose the blackwell device PF BAR1 to the VM
From: Ankit Agrawal
Date: Mon Jan 20 2025 - 12:13:25 EST
>> + if (!nvdev->has_mig_hw_bug_fix) {
>> + /*
>> + * If the device memory is split to workaround the MIG bug,
>> + * the USEMEM part of the device memory has to be
>> MEMBLK_SIZE
>> + * aligned. This is a hardwired ABI value between the GPU FW
>> and
>> + * VFIO driver. The VM device driver is also aware of it and
>> make
>> + * use of the value for its calculation to determine USEMEM
>> size.
>> + * Note that the device memory may not be 512M aligned.
>> + *
>> + * If the hardware has the fix for MIG, there is no
>> requirement
>> + * for splitting the device memory to create RESMEM. The
>> entire
>> + * device memory is usable and will be USEMEM.
>
> Just double confirm. With the fix it's not required to have the usemem
> 512M aligned, or does hardware guarantee that usemem is always
> 512M aligned?
The first one - On devices without the MIG bug, the device memory
passed to the VM need not be 512M aligned. The devices may still have
non 512M aligned memory.
> And it's clearer to return early when the fix is there so the majority of
> the existing code can be left intact instead of causing unnecessary
> indent here.
I think that can be done. We calculate nvdev->usemem.bar_size down
the function, but I suppose that can be moved up before returning
early.