two trivial PMU fixes
cover two trivial PMU fixes
Two trivial PMU-related fixes for Tegra:
- Add a dummy func member to GK20A, since nvkm_pmmu_pgob() unconditionally dereferences it
- Check whether a PMU actually exists before calling nvkm_pmmu_pgob(). During early bringup we are likely to not have a PMU
Alexandre Courbot (2):
pmu/gk20a: add dummy func
gr/gf100: do not assume a PMU is present
drm/nouveau/nvkm/engine/gr/gf100.c | 3 ++- drm/nouveau/nvkm/subdev/pmu/gk20a.c | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-)
Signature · 6 lines
2.5.1 _______________________________________________ Nouveau mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 1441261955-3577-1-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
PATCH 1/2 pmu/gk20a: add dummy func
Some parts of the driver expect the PMU to have a func member, so set one for GK20A to avoid NULL pointer derefences.
--- drm/nouveau/nvkm/subdev/pmu/gk20a.c | 5 +++++ 1 file changed, 5 insertions(+)
drm/nouveau/nvkm/subdev/pmu/gk20a.c +5 -0
@@ -202,6 +202,10 @@ gk20a_dvfs_data= { .p_smooth = 1, }; +static const struct nvkm_pmu_func +gk20a_pmu_func = { +}; +static const struct nvkm_subdev_func gk20a_pmu = { .init = gk20a_pmu_init,
@@ -221,6 +225,7 @@ gk20a_pmu_new(struct nvkm_device *device, int index, struct nvkm_pmu **ppmu) *ppmu = &pmu->base;nvkm_subdev_ctor (&gk20a_pmu, device, index,0 , &pmu->base.subdev); + pmu->base.func = &gk20a_pmu_func; pmu->data = &gk20a_dvfs_data;nvkm_alarm_init (&pmu->alarm, gk20a_pmu_dvfs_work);return 0 ;
Signature · 6 lines
2.5.1 _______________________________________________ Nouveau mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 1441261955-3577-2-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
Re: [PATCH 1/2] pmu/gk20a: add dummy func
Quoted 2 lines · Alexandre Courbot
Some parts of the driver expect the PMU to have a func member, so set one for GK20A to avoid NULL pointer derefences.
This part should already be done in the current code.
Quoted 32 lines
Signed-off-by Alexandre Courbot <[email protected]>--- drm/nouveau/nvkm/subdev/pmu/gk20a.c | 5 +++++ 1 file changed, 5 insertions(+)drm/nouveau/nvkm/subdev/pmu/gk20a.c +5
-1@@ -202,6 +202,10 @@ gk20a_dvfs_data= { .p_smooth = 1, }; +static const struct nvkm_pmu_func +gk20a_pmu_func = { +}; +static const struct nvkm_subdev_func gk20a_pmu = { .init = gk20a_pmu_init,@@ -221,6 +225,7 @@ gk20a_pmu_new(struct nvkm_device *device, int index, struct nvkm_pmu **ppmu) *ppmu = &pmu->base;nvkm_subdev_ctor (&gk20a_pmu, device, index,0 , &pmu->base.subdev); + pmu->base.func = &gk20a_pmu_func; pmu->data = &gk20a_dvfs_data;nvkm_alarm_init (&pmu->alarm, gk20a_pmu_dvfs_work);return 0 ; --2.5.1
Quoted 4 lines
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CACAvsv76bsij+UsXAe7-icM9NU9O9zBrjpT6h7e5E-8t847-Yg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 1/2] pmu/gk20a: add dummy func
Quoted 4 lines · Ben Skeggs
Quoted 2 lines · Alexandre Courbot
Some parts of the driver expect the PMU to have a func member, so set one for GK20A to avoid NULL pointer derefences.
This part should already be done in the current code.
Ah indeed, it was right before my eyes:
static const struct nvkm_pmu_func func = {};
...
pmu->base.func = &func;Dropping this patch, sorry about the noise.
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 2/2 gr/gf100: do not assume a PMU is present
In reply to a message not in the archiveSome devices may not have a PMU. Avoid a NULL pointer dereference in such cases.
--- drm/nouveau/nvkm/engine/gr/gf100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drm/nouveau/nvkm/engine/gr/gf100.c +2 -1
@@ -1499,7 +1499,8 @@ gf100_gr_oneinit(struct nvkm_gr *base)struct nvkm_device *device = gr->base.engine.subdev.device;int ret, i, j; -nvkm_pmu_pgob (device->pmu, false); +if (device->pmu) +nvkm_pmu_pgob (device->pmu, false); ret =nvkm_memory_new (device,NVKM_MEM_TARGET_INST ,0x1000 ,256 , false, &gr->unk4188b4);
Signature · 6 lines
2.5.1 _______________________________________________ Nouveau mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 1441261955-3577-3-git-send-email-acourbot-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org
Re: [PATCH 2/2] gr/gf100: do not assume a PMU is present
Quoted 13 lines · Alexandre Courbot
Some devices may not have a PMU. Avoid a NULL pointer dereference in such cases.
Signed-off-by Alexandre Courbot <[email protected]>--- drm/nouveau/nvkm/engine/gr/gf100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drm/nouveau/nvkm/engine/gr/gf100.c +0
-0
drm/nouveau/nvkm/engine/gr/gf100.c gf100_gr_oneinit(struct nvkm_gr *base) · line 1503
Quoted 6 lines
drm/nouveau/nvkm/engine/gr/gf100.c +2
-1@@ -1499,7 +1499,8 @@ gf100_gr_oneinit(struct nvkm_gr *base)struct nvkm_device *device = gr->base.engine.subdev.device;int ret, i, j; -nvkm_pmu_pgob (device->pmu, false); +if (device->pmu) +nvkm_pmu_pgob (device->pmu, false);
I'd probably just change the condition in nvkm_pmu_pgob() to (pmu && pmu->func->pgob) ?
Quoted 10 lines
drm/nouveau/nvkm/engine/gr/gf100.c +0
-1ret =nvkm_memory_new (device,NVKM_MEM_TARGET_INST ,0x1000 ,256 , false, &gr->unk4188b4); --2.5.1
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CACAvsv4GYEy--Byi5zOphW1V2BLyJnfHMAnmXDkGPqks=63w7w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 2/2] gr/gf100: do not assume a PMU is present
Quoted 17 lines · Ben Skeggs
Quoted 16 lines · Alexandre Courbot
Some devices may not have a PMU. Avoid a NULL pointer dereference in such cases.
Signed-off-by Alexandre Courbot <[email protected]>--- drm/nouveau/nvkm/engine/gr/gf100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drm/nouveau/nvkm/engine/gr/gf100.c +0
-0@@ -1499,7 +1499,8 @@ gf100_gr_oneinit(struct nvkm_gr *base)struct nvkm_device *device = gr->base.engine.subdev.device;int ret, i, j;
Quoted 5 lines
drm/nouveau/nvkm/engine/gr/gf100.c gf100_gr_oneinit(struct nvkm_gr *base) · line 1503
Quoted 3 lines
drm/nouveau/nvkm/engine/gr/gf100.c +2
-1-nvkm_pmu_pgob (device->pmu, false); +if (device->pmu) +nvkm_pmu_pgob (device->pmu, false);I'd probably just change the condition in
nvkm_pmu_pgob()to (pmu &&pmu->func->pgob) ?
It seems logical to me that the caller should check that the object it tries to call a method on is valid (just like in C++ you don't expect methods to check whether this == NULL), but your call.
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CAAVeFu+y6XkTKNx+W+kxc_oe0XhFC-9FODck5fKTa=2GzOZuKg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 2/2] gr/gf100: do not assume a PMU is present
Quoted 24 lines · Alexandre Courbot
Quoted 17 lines · Ben Skeggs
Quoted 16 lines · Alexandre Courbot
Some devices may not have a PMU. Avoid a NULL pointer dereference in such cases.
Signed-off-by Alexandre Courbot <[email protected]>--- drm/nouveau/nvkm/engine/gr/gf100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drm/nouveau/nvkm/engine/gr/gf100.c +0
-0@@ -1499,7 +1499,8 @@ gf100_gr_oneinit(struct nvkm_gr *base)struct nvkm_device *device = gr->base.engine.subdev.device;int ret, i, j;Quoted 5 lines
drm/nouveau/nvkm/engine/gr/gf100.c gf100_gr_oneinit(struct nvkm_gr *base) · line 1503
Quoted 3 lines
drm/nouveau/nvkm/engine/gr/gf100.c +2
-1-nvkm_pmu_pgob (device->pmu, false); +if (device->pmu) +nvkm_pmu_pgob (device->pmu, false);I'd probably just change the condition in
nvkm_pmu_pgob()to (pmu &&pmu->func->pgob) ?
Quoted 3 lines
It seems logical to me that the caller should check that the object it tries to call a method on is valid (just like in C++ you don't expect methods to check whether this == NULL), but your call.
Yeah, I had similar thoughts when writing some of these accessor functions, and decided on treating them as "helper" functions that act as a stub when the object doesn't exist or doesn't support a particular function. Mainly to avoid having duplicated checks in multiple places that can get out of sync.
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CACAvsv70qg2ScfAhHAq-dcsXFoS+N_1JzMKP5Os5Br8gf3NWSg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 2/2] gr/gf100: do not assume a PMU is present
Quoted 25 lines · Ben Skeggs
Quoted 24 lines · Alexandre Courbot
Quoted 22 lines · Ben Skeggs
Quoted 13 lines · Alexandre Courbot
Some devices may not have a PMU. Avoid a NULL pointer dereference in such cases.
Signed-off-by Alexandre Courbot <[email protected]>--- drm/nouveau/nvkm/engine/gr/gf100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drm/nouveau/nvkm/engine/gr/gf100.c +0
-0drm/nouveau/nvkm/engine/gr/gf100.c gf100_gr_oneinit(struct nvkm_gr *base) · line 1503
Quoted 6 lines
drm/nouveau/nvkm/engine/gr/gf100.c +2
-1@@ -1499,7 +1499,8 @@ gf100_gr_oneinit(struct nvkm_gr *base)struct nvkm_device *device = gr->base.engine.subdev.device;int ret, i, j; -nvkm_pmu_pgob (device->pmu, false); +if (device->pmu) +nvkm_pmu_pgob (device->pmu, false);I'd probably just change the condition in
nvkm_pmu_pgob()to (pmu &&pmu->func->pgob) ?
Quoted 8 lines
Quoted 3 lines
It seems logical to me that the caller should check that the object it tries to call a method on is valid (just like in C++ you don't expect methods to check whether this == NULL), but your call.
Yeah, I had similar thoughts when writing some of these accessor functions, and decided on treating them as "helper" functions that act as a stub when the object doesn't exist or doesn't support a particular function. Mainly to avoid having duplicated checks in multiple places that can get out of sync.
Ok then. I will wait for your feedback on patch 3/3 before resending.
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CAAVeFuJZ3beF-9bY2L8Knd-qv6fCMHeA5A_8wCbJ29myEmiMJA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 2/2] gr/gf100: do not assume a PMU is present
Quoted 29 lines · Alexandre Courbot
Quoted 28 lines · Ben Skeggs
Quoted 27 lines · Alexandre Courbot
Quoted 17 lines · Ben Skeggs
Quoted 16 lines · Alexandre Courbot
Some devices may not have a PMU. Avoid a NULL pointer dereference in such cases.
Signed-off-by Alexandre Courbot <[email protected]>--- drm/nouveau/nvkm/engine/gr/gf100.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drm/nouveau/nvkm/engine/gr/gf100.c +0
-0@@ -1499,7 +1499,8 @@ gf100_gr_oneinit(struct nvkm_gr *base)struct nvkm_device *device = gr->base.engine.subdev.device;int ret, i, j;Quoted 5 lines
drm/nouveau/nvkm/engine/gr/gf100.c gf100_gr_oneinit(struct nvkm_gr *base) · line 1503
Quoted 3 lines
drm/nouveau/nvkm/engine/gr/gf100.c +2
-1-nvkm_pmu_pgob (device->pmu, false); +if (device->pmu) +nvkm_pmu_pgob (device->pmu, false);I'd probably just change the condition in
nvkm_pmu_pgob()to (pmu &&pmu->func->pgob) ?It seems logical to me that the caller should check that the object it tries to call a method on is valid (just like in C++ you don't expect methods to check whether this == NULL), but your call.
Quoted 7 lines
Quoted 5 lines
Yeah, I had similar thoughts when writing some of these accessor functions, and decided on treating them as "helper" functions that act as a stub when the object doesn't exist or doesn't support a particular function. Mainly to avoid having duplicated checks in multiple places that can get out of sync.
Ok then. I will wait for your feedback on patch 3/3 before resending.
3/3 looks fine to me from a quick glance, I'll take your word that it works, and it doesn't effect dGPUs at all anyway :)
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau
Quoted 5 lines · Alexandre Courbot
Two trivial PMU-related fixes for Tegra:
- Add a dummy func member to GK20A, sincenvkm_pmmu_pgob()unconditionally dereferences it
- Check whether a PMU actually exists before callingnvkm_pmmu_pgob(). During early bringup we are likely to not have a PMU
Forgot to mention: it would be nice to have these merged in the 4.3 cycle, since GK20A needs at least the first patch to probe successfully.
Thanks!
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau