Re: [RFC 02/29] nvkm/vgpu: attach to nvkm as a nvkm client

Zhi Wang
2024-10-14T10:16:24Z

On 26/09/2024 12.21, Greg KH wrote:
> External email: Use caution opening links or attachments
>
>
> On Sun, Sep 22, 2024 at 05:49:24AM -0700, Zhi Wang wrote:
>> nvkm is a HW abstraction layer(HAL) that initializes the HW and
>> allows its clients to manipulate the GPU functions regardless of the
>> generations of GPU HW. On the top layer, it provides generic APIs for a
>> client to connect to NVKM, enumerate the GPU functions, and manipulate
>> the GPU HW.
>>
>> To reach nvkm, the client needs to connect to NVKM layer by layer: driver
>> layer, client layer, and eventually, the device layer, which provides all
>> the access routines to GPU functions. After a client attaches to NVKM,
>> it initializes the HW and is able to serve the clients.
>>
>> Attach to nvkm as a nvkm client.
>>
>> Cc: Neo Jia <cjia@nvidia.com>
>> Signed-off-by: Zhi Wang <zhiw@nvidia.com>
>> ---
>> .../nouveau/include/nvkm/vgpu_mgr/vgpu_mgr.h | 8 ++++
>> .../gpu/drm/nouveau/nvkm/vgpu_mgr/vgpu_mgr.c | 48 ++++++++++++++++++-
>> 2 files changed, 55 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/include/nvkm/vgpu_mgr/vgpu_mgr.h b/drivers/gpu/drm/nouveau/include/nvkm/vgpu_mgr/vgpu_mgr.h
>> index 3163fff1085b..9e10e18306b0 100644
>> --- a/drivers/gpu/drm/nouveau/include/nvkm/vgpu_mgr/vgpu_mgr.h
>> +++ b/drivers/gpu/drm/nouveau/include/nvkm/vgpu_mgr/vgpu_mgr.h
>> @@ -7,6 +7,14 @@
>> struct nvkm_vgpu_mgr {
>> bool enabled;
>> struct nvkm_device *nvkm_dev;
>> +
>> + const struct nvif_driver *driver;
>
> Meta-comment, why is this attempting to act like a "driver" and yet not
> tieing into the driver model code at all? Please fix that up, it's not
> ok to add more layers on top of a broken one like this. We have
> infrastructure for this type of thing, please don't route around it.
>

Thanks for the guidelines. Will try to work with folks and figure out a
solution.

Ben is doing quite some clean-ups of nouveau driver[1], they had been
reviewed and merged by Danilo. Also, the split driver patchset he is
working on seems a meaningful pre-step to fix this, as it also includes
the re-factor of the interface between the nvkm and the nvif stuff.

[1]
https://lore.kernel.org/nouveau/CAPM=9tyW=YuDQrRwrYK_ayuvEnp+9irTuze=MP-zkowm3CFJ9A@mail.gmail.com/T/

[2]
https://lore.kernel.org/dri-devel/20240613170211.88779-1-bskeggs@nvidia.com/T/

> thanks,
>
> greg k-h