[Nouveau] [PATCH 08/44] drm/nouveau/devinit/tu102-: prepare for GSP-RM

Danilo Krummrich dakr at redhat.com
Mon Sep 18 21:02:20 UTC 2023


On 9/18/23 22:21, Ben Skeggs wrote:
> From: Ben Skeggs <bskeggs at redhat.com>
> 
> - add R535 implementation of DEVINIT, we need some of this for boot
> - add display disable fuse for ga100-
> 
> Signed-off-by: Ben Skeggs <bskeggs at redhat.com>
> ---
>   .../drm/nouveau/nvkm/subdev/devinit/Kbuild    |  2 +
>   .../drm/nouveau/nvkm/subdev/devinit/ga100.c   | 15 ++++++
>   .../drm/nouveau/nvkm/subdev/devinit/priv.h    |  3 ++
>   .../drm/nouveau/nvkm/subdev/devinit/r535.c    | 51 +++++++++++++++++++
>   .../drm/nouveau/nvkm/subdev/devinit/tu102.c   |  4 ++
>   5 files changed, 75 insertions(+)
>   create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/Kbuild
> index d1abb64841da..5f97bffca979 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/Kbuild
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/Kbuild
> @@ -16,3 +16,5 @@ nvkm-y += nvkm/subdev/devinit/gm200.o
>   nvkm-y += nvkm/subdev/devinit/gv100.o
>   nvkm-y += nvkm/subdev/devinit/tu102.o
>   nvkm-y += nvkm/subdev/devinit/ga100.o
> +
> +nvkm-y += nvkm/subdev/devinit/r535.o
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/ga100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/ga100.c
> index 6b280b05c4ca..5f0b12a1fc38 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/ga100.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/ga100.c
> @@ -24,6 +24,7 @@
>   #include <subdev/bios.h>
>   #include <subdev/bios/pll.h>
>   #include <subdev/clk/pll.h>
> +#include <subdev/gsp.h>
>   
>   static int
>   ga100_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
> @@ -62,8 +63,19 @@ ga100_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
>   	return ret;
>   }
>   
> +static void
> +ga100_devinit_disable(struct nvkm_devinit *init)
> +{
> +	struct nvkm_device *device = init->subdev.device;
> +	u32 r820c04 = nvkm_rd32(device, 0x820c04);

I'd probably prefer to use NV_FUSE_STATUS_OPT_DISPLAY or a custom define.
'r820c04' could just be data, reg, val or similar.

> +
> +	if (r820c04 & 0x00000001)
> +		nvkm_subdev_disable(device, NVKM_ENGINE_DISP, 0);
> +}
> +
>   static const struct nvkm_devinit_func
>   ga100_devinit = {
> +	.disable = ga100_devinit_disable,
>   	.init = nv50_devinit_init,
>   	.post = tu102_devinit_post,
>   	.pll_set = ga100_devinit_pll_set,
> @@ -73,5 +85,8 @@ int
>   ga100_devinit_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
>   		  struct nvkm_devinit **pinit)
>   {
> +	if (nvkm_gsp_rm(device->gsp))
> +		return r535_devinit_new(&ga100_devinit, device, type, inst, pinit);
> +
>   	return nv50_devinit_new_(&ga100_devinit, device, type, inst, pinit);
>   }
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/priv.h b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/priv.h
> index a648482d06e9..06bbfdcc788c 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/priv.h
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/priv.h
> @@ -4,6 +4,9 @@
>   #define nvkm_devinit(p) container_of((p), struct nvkm_devinit, subdev)
>   #include <subdev/devinit.h>
>   
> +int r535_devinit_new(const struct nvkm_devinit_func *,
> +		     struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_devinit **);
> +
>   struct nvkm_devinit_func {
>   	void *(*dtor)(struct nvkm_devinit *);
>   	void (*preinit)(struct nvkm_devinit *);
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c
> new file mode 100644
> index 000000000000..666eb93b1742
> --- /dev/null
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/r535.c
> @@ -0,0 +1,51 @@
> +/*
> + * Copyright 2023 Red Hat Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + */> +#include "nv50.h"
> +
> +static void *
> +r535_devinit_dtor(struct nvkm_devinit *devinit)
> +{
> +	kfree(devinit->func);
> +	return devinit;
> +}
> +
> +int
> +r535_devinit_new(const struct nvkm_devinit_func *hw,
> +		 struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
> +		 struct nvkm_devinit **pdevinit)
> +{
> +	struct nvkm_devinit_func *rm;
> +	int ret;
> +
> +	if (!(rm = kzalloc(sizeof(*rm), GFP_KERNEL)))
> +		return -ENOMEM;
> +
> +	rm->dtor = r535_devinit_dtor;
> +	rm->post = hw->post;
> +	rm->disable = hw->disable;
> +
> +	ret = nv50_devinit_new_(rm, device, type, inst, pdevinit);
> +	if (ret)
> +		kfree(rm);
> +
> +	return ret;
> +}
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
> index 40997ad1d101..f406b1525a4a 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c
> @@ -24,6 +24,7 @@
>   #include <subdev/bios.h>
>   #include <subdev/bios/pll.h>
>   #include <subdev/clk/pll.h>
> +#include <subdev/gsp.h>
>   
>   static int
>   tu102_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
> @@ -100,5 +101,8 @@ int
>   tu102_devinit_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
>   		  struct nvkm_devinit **pinit)
>   {
> +	if (nvkm_gsp_rm(device->gsp))
> +		return r535_devinit_new(&tu102_devinit, device, type, inst, pinit);
> +
>   	return nv50_devinit_new_(&tu102_devinit, device, type, inst, pinit);
>   }



More information about the Nouveau mailing list