Updated State of my clk patches
cover Updated State of my clk patches
Last update here: https://lists.freedesktop.org/archives/nouveau/2017-September/028848.html
Basically big cleanup, reordering, simplifications and some renaming to make the code easier to read and to review. I also moved some bugfixes to the front so they can be merged prior the other patches.
There was also a bug related to the therm daemon triggering a pstate change leading to PMU lockups, because the timer wasn't disabled on fini.
I think we are getting close with this and hope we can merge this soon.
Karol Herbst (32):
bios/vpstate: There are some fermi vbios with no boost or tdp entry
debugfs: Wake up GPU before doing any reclocking
therm: Split return code and value in nvkm_get_temp
hwmon: Properly check for errors
clk: Improve names of pstate/cstate related variables and fields
clk: Add NVKM_CLK_PSTATE_BOOT
clk: Rename NVKM_CLK_CSTATE_HIGHEST to NVKM_CLK_CSTATE_AUTO
clk: Rename nvkm_clk.states to pstates
clk: Rename nvkm_pstate.list to cstates
clk: Remove dstate
clk: Rename nvkm_pstate_calc to nvkm_clk_update and export it
clk: Use list_for_each_entry_from_reverse in nvkm_cstate_find_best
clk: We should pass the pstate id around not the index in the list
clk: Hold information about the current cstate status
clk: Refactor the base and boost clock limits so that we can limit
pstates
therm: Move the temp readout into nvkm_therm_update core/device: Move therm behind clk
therm: Trigger reclock in temperature daemon
bios: Add thermal policies table
therm: Cancel the timer only in fini
clk: Parse thermal policies for throttling thresholds
clk: Thermal throttling
clk: Skip unchanging parts of the reclock
clk: Save the max clock we can set
nvif: Add boost info and set operations
debugfs: Add boost interface to change the boost_mode bios/vpstate: Parse max battery id
clk: Implement limiting pstates just like we do for cstates
clk: Limit clocks on battery
secboot/acr352: Reset PMU after secboot
device: Enable clk for Maxwell2
clk: Add trace message when setting a new cstate
drm/nouveau/include/nvif/if0001.h | 15 + drm/nouveau/include/nvkm/core/device.h | 2 +- drm/nouveau/include/nvkm/subdev/bios/boost.h | 2 +- drm/nouveau/include/nvkm/subdev/bios/perf.h | 2 +- .../include/nvkm/subdev/bios/thermal_policies.h | 25 ++ drm/nouveau/include/nvkm/subdev/bios/vpstate.h | 1 + drm/nouveau/include/nvkm/subdev/clk.h | 40 +- drm/nouveau/include/nvkm/subdev/therm.h | 2 +- drm/nouveau/nouveau_debugfs.c | 99 ++++- drm/nouveau/nouveau_hwmon.c | 48 ++- drm/nouveau/nvkm/engine/device/base.c | 3 + drm/nouveau/nvkm/engine/device/ctrl.c | 73 +++- drm/nouveau/nvkm/subdev/bios/Kbuild | 1 + drm/nouveau/nvkm/subdev/bios/boost.c | 11 +- drm/nouveau/nvkm/subdev/bios/perf.c | 2 +- drm/nouveau/nvkm/subdev/bios/thermal_policies.c | 81 ++++ drm/nouveau/nvkm/subdev/bios/vpstate.c | 13 +- drm/nouveau/nvkm/subdev/clk/base.c | 427 ++++++++++++++------- drm/nouveau/nvkm/subdev/clk/gk104.c | 10 +- drm/nouveau/nvkm/subdev/clk/gk20a.c | 4 +- drm/nouveau/nvkm/subdev/pmu/gk20a.c | 9 +- drm/nouveau/nvkm/subdev/secboot/acr_r352.c | 14 + drm/nouveau/nvkm/subdev/therm/base.c | 52 ++- drm/nouveau/nvkm/subdev/therm/g84.c | 13 +- drm/nouveau/nvkm/subdev/therm/gp100.c | 9 +- drm/nouveau/nvkm/subdev/therm/nv40.c | 9 +- drm/nouveau/nvkm/subdev/therm/nv50.c | 9 +- drm/nouveau/nvkm/subdev/therm/priv.h | 4 +- drm/nouveau/nvkm/subdev/therm/temp.c | 16 +- drm/nouveau/nvkm/subdev/volt/base.c | 3 + lib/include/nvif/list.h | 5 + 31 files changed, 758 insertions(+), 246 deletions(-) create mode 100644 drm/nouveau/include/nvkm/subdev/bios/thermal_policies.h create mode 100644 drm/nouveau/nvkm/subdev/bios/thermal_policies.c
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 20171117000436.2432-1-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 1/32 bios/vpstate: There are some fermi vbios with no boost or tdp entry
--- drm/nouveau/nvkm/subdev/bios/vpstate.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drm/nouveau/nvkm/subdev/bios/vpstate.c +8 -2
@@ -58,8 +58,14 @@ nvbios_vpstate_parse(struct nvkm_bios *b, struct nvbios_vpstate_header *h) h->ecount =nvbios_rd08 (b, h->offset +0x5 ); h->base_id =nvbios_rd08 (b, h->offset +0x0f ); - h->boost_id =nvbios_rd08 (b, h->offset +0x10 ); - h->tdp_id =nvbios_rd08 (b, h->offset +0x11 ); +if (h->hlen >0x10 ) + h->boost_id =nvbios_rd08 (b, h->offset +0x10 ); +else + h->boost_id =0xff ; +if (h->hlen >0x11 ) + h->tdp_id =nvbios_rd08 (b, h->offset +0x11 ); +else + h->tdp_id =0xff ;return 0 ;default :return -EINVAL ;
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 20171117000436.2432-2-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 01/32] bios/vpstate: There are some fermi vbios with no boost or tdp entry
On 17/11/17 02:04, Karol Herbst wrote:
Please add here something like this:
If the entry size is too small, default to invalid values for both boost_id and tdp_id, so as to default to the base clock in both cases.
Quoted 1 line
Signed-off-by Karol Herbst <[email protected]>
With the better commit message, this patch is:
Quoted 16 lines
--- drm/nouveau/nvkm/subdev/bios/vpstate.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drm/nouveau/nvkm/subdev/bios/vpstate.c +1
-2@@ -58,8 +58,14 @@ nvbios_vpstate_parse(struct nvkm_bios *b, struct nvbios_vpstate_header *h) h->ecount =nvbios_rd08 (b, h->offset +0x5 ); h->base_id =nvbios_rd08 (b, h->offset +0x0f ); - h->boost_id =nvbios_rd08 (b, h->offset +0x10 ); - h->tdp_id =nvbios_rd08 (b, h->offset +0x11 ); +if (h->hlen >0x10 )
drm/nouveau/nvkm/subdev/bios/vpstate.c nvbios_vpstate_parse(struct nvkm_bios *b, struct nvbios_vpstate_header *h) · line 71
Quoted 10 lines
drm/nouveau/nvkm/subdev/bios/vpstate.c +7
-0+ h->boost_id =nvbios_rd08 (b, h->offset +0x10 ); + else + h->boost_id = 0xff; +if (h->hlen >0x11 ) + h->tdp_id =nvbios_rd08 (b, h->offset +0x11 ); +else + h->tdp_id =0xff ;return 0 ;default :return -EINVAL ;
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 6fd6503a-0d97-9148-0ebf-cba6f8bb0180-GANU6spQydw@public.gmane.org
Re: [PATCH 01/32] bios/vpstate: There are some fermi vbios with no boost or tdp entry
Quoted 7 lines · Martin Peres
On 17/11/17 02:04, Karol Herbst wrote:
Please add here something like this:
If the entry size is too small, default to invalid values for both
boost_idandtdp_id, so as to default to the base clock in both cases.
well actually we still have the option to go max clocks, there is no entry for that. The entire table just defines limits, which may be enabled or not.
Quoted 28 lines
Quoted 1 line
Signed-off-by Karol Herbst <[email protected]>With the better commit message, this patch is:
Signed-off-by Martin Peres <[email protected]>Quoted 23 lines
--- drm/nouveau/nvkm/subdev/bios/vpstate.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drm/nouveau/nvkm/subdev/bios/vpstate.c +8
-2@@ -58,8 +58,14 @@ nvbios_vpstate_parse(struct nvkm_bios *b, struct nvbios_vpstate_header *h) h->ecount =nvbios_rd08 (b, h->offset +0x5 ); h->base_id =nvbios_rd08 (b, h->offset +0x0f ); - h->boost_id =nvbios_rd08 (b, h->offset +0x10 ); - h->tdp_id =nvbios_rd08 (b, h->offset +0x11 ); +if (h->hlen >0x10 ) + h->boost_id =nvbios_rd08 (b, h->offset +0x10 ); +else + h->boost_id =0xff ; +if (h->hlen >0x11 ) + h->tdp_id =nvbios_rd08 (b, h->offset +0x11 ); +else + h->tdp_id =0xff ;return 0 ;
Quoted 8 lines
drm/nouveau/nvkm/subdev/bios/vpstate.c nvbios_vpstate_parse(struct nvkm_bios *b, struct nvbios_vpstate_header *h) · line 71
Quoted 3 lines
drm/nouveau/nvkm/subdev/bios/vpstate.c +0
-0default :return -EINVAL ;_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 2/32 debugfs: Wake up GPU before doing any reclocking
In reply to a message not in the archiveFixes various reclocking related issues on prime systems.
--- drm/nouveau/nouveau_debugfs.c | 4 ++++ 1 file changed, 4 insertions(+)
drm/nouveau/nouveau_debugfs.c +4 -0
@@ -160,7 +160,11 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf, args.ustate = value; } + ret =pm_runtime_get_sync (drm->dev); +if (IS_ERR_VALUE (ret) && ret != -EACCES ) +return ret; ret =nvif_mthd (ctrl,NVIF_CONTROL_PSTATE_USER , &args,sizeof (args)); +pm_runtime_put_autosuspend (drm->dev);if (ret <0 )return ret;
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 20171117000436.2432-3-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 02/32] debugfs: Wake up GPU before doing any reclocking
Quoted 1 line · Karol Herbst
Fixes various reclocking related issues on prime systems.
Is that the only place that was not covered? Could you check if other places would need this code too?
In any case, this patch is (assuming you are calling the right functions to prevent the GPU from sleeping):
Quoted 13 lines
Signed-off-by Karol Herbst <[email protected]>--- drm/nouveau/nouveau_debugfs.c | 4 ++++ 1 file changed, 4 insertions(+)drm/nouveau/nouveau_debugfs.c +0
-0@@ -160,7 +160,11 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf, args.ustate = value;
drm/nouveau/nouveau_debugfs.c nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf, · line 170
Quoted 10 lines
drm/nouveau/nouveau_debugfs.c +4
-0} + ret =pm_runtime_get_sync (drm->dev); +if (IS_ERR_VALUE (ret) && ret != -EACCES ) +return ret; ret =nvif_mthd (ctrl,NVIF_CONTROL_PSTATE_USER , &args,sizeof (args)); +pm_runtime_put_autosuspend (drm->dev);if (ret <0 )return ret;
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): b719fba2-3f0f-298e-a816-5992b587b293-GANU6spQydw@public.gmane.org
Re: [PATCH 02/32] debugfs: Wake up GPU before doing any reclocking
Quoted 6 lines · Martin Peres
Quoted 1 line · Karol Herbst
Fixes various reclocking related issues on prime systems.
Is that the only place that was not covered? Could you check if other places would need this code too?
I had quite a discussion with Ben about this and all the other cases should be handled implicitly already. There are some follow patches to fix some of those cases as well. Like having the therm subdev moved in order.
Quoted 17 lines
In any case, this patch is (assuming you are calling the right functions to prevent the GPU from sleeping):
Signed-off-by Martin Peres <[email protected]>Quoted 14 lines
Signed-off-by Karol Herbst <[email protected]>--- drm/nouveau/nouveau_debugfs.c | 4 ++++ 1 file changed, 4 insertions(+)drm/nouveau/nouveau_debugfs.c +0
-0@@ -160,7 +160,11 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf, args.ustate = value; }
Quoted 14 lines
drm/nouveau/nouveau_debugfs.c nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf, · line 170
Quoted 9 lines
drm/nouveau/nouveau_debugfs.c +4
-0+ ret =pm_runtime_get_sync (drm->dev); +if (IS_ERR_VALUE (ret) && ret != -EACCES ) +return ret; ret =nvif_mthd (ctrl,NVIF_CONTROL_PSTATE_USER , &args,sizeof (args)); +pm_runtime_put_autosuspend (drm->dev);if (ret <0 )return ret;_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 3/32 therm: Split return code and value in nvkm_get_temp
In reply to a message not in the archiveThe current hwmon code doesn't check if the returned value was actually an error.
Since Kepler temperature sensors are able to report negative values. Those negative values are not for error reporting, but rather when you buried your GPU in snow somewhere in Antarctica and still want a valid temperature to be reported (unverified).
Since Pascal (and maybe earlier) we have sensors with improved precision.
Adjust the nvkm_get_temp method to be able to deal with those changes and let hwmon return an error properly.
--- drm/nouveau/include/nvkm/subdev/clk.h | 4 ++-- drm/nouveau/include/nvkm/subdev/therm.h | 2 +- drm/nouveau/nouveau_hwmon.c | 15 +++++++++------ drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/therm/base.c | 19 ++++++++++++++----- drm/nouveau/nvkm/subdev/therm/g84.c | 13 ++++++++----- drm/nouveau/nvkm/subdev/therm/gp100.c | 9 +++++---- drm/nouveau/nvkm/subdev/therm/nv40.c | 9 +++------ drm/nouveau/nvkm/subdev/therm/nv50.c | 9 +++------ drm/nouveau/nvkm/subdev/therm/priv.h | 4 ++-- drm/nouveau/nvkm/subdev/therm/temp.c | 16 ++++++++++++---- 11 files changed, 60 insertions(+), 42 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +2 -2
@@ -100,7 +100,7 @@ struct nvkm_clk {int ustate_dc;/* user-requested (-1 disabled, -2 perfmon) */ int astate;/* perfmon adjustment (base) */ int dstate;/* display adjustment (min+) */ -u8 temp; +int temp;bool allow_reclock;#define NVKM_CLK_BOOST_NONE 0x0
@@ -122,7 +122,7 @@ int nvkm_clk_read(struct nvkm_clk *, enum nv_clk_src);int nvkm_clk_ustate (struct nvkm_clk *,int req,int pwr);int nvkm_clk_astate (struct nvkm_clk *,int req,int rel,bool wait);int nvkm_clk_dstate (struct nvkm_clk *,int req,int rel); -int nvkm_clk_tstate (struct nvkm_clk *,u8 temperature); +int nvkm_clk_tstate (struct nvkm_clk *,int temperature);int nv04_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);int nv40_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);
drm/nouveau/include/nvkm/subdev/therm.h +1 -1
@@ -86,7 +86,7 @@ struct nvkm_therm {int (*attr_set)(struct nvkm_therm *,enum nvkm_therm_attr_type ,int ); }; -int nvkm_therm_temp_get (struct nvkm_therm *); +int nvkm_therm_temp_get (struct nvkm_therm *,int *);int nvkm_therm_fan_sense (struct nvkm_therm *);int nvkm_therm_cstate (struct nvkm_therm *,int ,int );
drm/nouveau/nouveau_hwmon.c +9 -6
@@ -326,8 +326,9 @@ nouveau_temp_is_visible(const void *data, u32 attr, int channel) {struct nouveau_drm *drm =nouveau_drm ((struct drm_device *)data);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); +int val; -if (therm && therm->attr_get &&nvkm_therm_temp_get (therm) <0 ) +if (therm && therm->attr_get &&nvkm_therm_temp_get (therm, &val))return 0 ;switch (attr) {
@@ -421,15 +422,16 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)struct drm_device *drm_dev =dev_get_drvdata (dev);struct nouveau_drm *drm =nouveau_drm (drm_dev);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); -int ret; +int ret =0 ; +int temp;if (!therm || !therm->attr_get)return -EOPNOTSUPP ;switch (attr) {case hwmon_temp_input: - ret =nvkm_therm_temp_get (therm); - *val = ret <0 ? ret : (ret *1000 ); + ret =nvkm_therm_temp_get (therm, &temp); + *val = temp *1000 ;break ;case hwmon_temp_max: *val = therm->attr_get (therm,NVKM_THERM_ATTR_THRS_DOWN_CLK )
@@ -459,7 +461,7 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)return -EOPNOTSUPP ; } -return 0 ; +return ret; } static int
@@ -713,6 +715,7 @@ nouveau_hwmon_init(struct drm_device *dev)struct device *hwmon_dev;int ret =0 ;int i =0 ; +int val; hwmon = drm->hwmon =kzalloc (sizeof (*hwmon),GFP_KERNEL );if (!hwmon)
@@ -720,7 +723,7 @@ nouveau_hwmon_init(struct drm_device *dev) hwmon->dev = dev;if (therm && therm->attr_get && therm->attr_set) { -if (nvkm_therm_temp_get (therm) >=0 ) +if (!nvkm_therm_temp_get (therm, &val)) special_groups[i++] = &temp1_auto_point_sensor_group;if (therm->fan_get && therm->fan_get (therm) >=0 ) special_groups[i++] = &pwm_fan_sensor_group;
drm/nouveau/nvkm/subdev/clk/base.c +1 -1
@@ -540,7 +540,7 @@ nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait) }int -nvkm_clk_tstate (struct nvkm_clk *clk,u8 temp) +nvkm_clk_tstate (struct nvkm_clk *clk,int temp) {if (clk->temp == temp)return 0 ;
drm/nouveau/nvkm/subdev/therm/base.c +14 -5
@@ -24,22 +24,26 @@#include "priv.h" int -nvkm_therm_temp_get (struct nvkm_therm *therm) +nvkm_therm_temp_get (struct nvkm_therm *therm,int *val) {if (therm->func->temp_get) -return therm->func->temp_get (therm); +return therm->func->temp_get (therm, val);return -ENODEV ; }static int nvkm_therm_update_trip (struct nvkm_therm *therm) { +int temp, ret;struct nvbios_therm_trip_point *trip = therm->fan->bios.trip, *cur_trip =NULL , *last_trip = therm->last_trip; -u8 temp = therm->func->temp_get (therm);u16 duty, i; + ret = therm->func->temp_get (therm, &temp); +if (ret <0 ) +return ret; +/* look for the trip point corresponding to the current temperature */ cur_trip =NULL ;for (i =0 ; i < therm->fan->bios.nr_fan_trip; i++) {
@@ -67,9 +71,13 @@ static int nvkm_therm_compute_linear_duty(struct nvkm_therm *therm, u8 linear_min_temp, u8 linear_max_temp) { - u8 temp = therm->func->temp_get(therm); + int temp, ret;u16 duty; + ret = therm->func->temp_get (therm, &temp); +if (ret <0 ) +return ret; +/* handle the non-linear part first */ if (temp < linear_min_temp)return therm->fan->bios.min_duty;
@@ -182,6 +190,7 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode) {struct nvkm_subdev *subdev = &therm->subdev;struct nvkm_device *device = subdev->device; +int val;static const char *name[] = {"disabled" ,"manual" ,
@@ -197,7 +206,7 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode)/* do not allow automatic fan management if the thermal sensor is * not available */ if (mode ==NVKM_THERM_CTRL_AUTO && - therm->func->temp_get (therm) <0 ) + therm->func->temp_get (therm, &val))return -EINVAL ;if (therm->mode == mode)
drm/nouveau/nvkm/subdev/therm/g84.c +8 -5
@@ -27,14 +27,15 @@#include <subdev/fuse.h> int -g84_temp_get (struct nvkm_therm *therm) +g84_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device; -if (nvkm_fuse_read (device->fuse,0x1a8 ) ==1 ) -return nvkm_rd32 (device,0x20400 ); -else +if (nvkm_fuse_read (device->fuse,0x1a8 ) !=1 )return -ENODEV ; + + *val =nvkm_rd32 (device,0x20400 ); +return 0 ; }void
@@ -114,8 +115,10 @@ g84_therm_threshold_hyst_emulation(struct nvkm_therm *therm, new_state =NVKM_THERM_THRS_LOWER ; } +if (therm->func->temp_get (therm, &cur)) +return ; +/* fix the state (in case someone reprogrammed the alarms) */ - cur = therm->func->temp_get (therm);if (new_state ==NVKM_THERM_THRS_LOWER && cur > thrs->temp) new_state =NVKM_THERM_THRS_HIGHER ; else if (new_state == NVKM_THERM_THRS_HIGHER &&
drm/nouveau/nvkm/subdev/therm/gp100.c +5 -4
@@ -24,7 +24,7 @@#include "priv.h" static int -gp100_temp_get (struct nvkm_therm *therm) +gp100_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvkm_subdev *subdev = &therm->subdev;
@@ -36,9 +36,10 @@ gp100_temp_get(struct nvkm_therm *therm)nvkm_trace (subdev,"reading temperature from SHADOWed sensor\n" );/* device valid */ -if (tsensor &0x20000000 ) -return (inttemp >>8 ); -else +if (tsensor &0x20000000 ) { + *val = inttemp >>8 ; +return 0 ; + }else return -ENODEV ; }
drm/nouveau/nvkm/subdev/therm/nv40.c +3 -6
@@ -70,7 +70,7 @@ nv40_sensor_setup(struct nvkm_therm *therm) }static int -nv40_temp_get (struct nvkm_therm *therm) +nv40_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvbios_therm_sensor *sensor = &therm->bios_sensor;
@@ -95,11 +95,8 @@ nv40_temp_get(struct nvkm_therm *therm) core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant -8 ; -/* reserve negative temperatures for errors */ -if (core_temp <0 ) - core_temp =0 ; - -return core_temp; + *val = core_temp; +return 0 ; } static int
drm/nouveau/nvkm/subdev/therm/nv50.c +3 -6
@@ -126,7 +126,7 @@ nv50_sensor_setup(struct nvkm_therm *therm) }static int -nv50_temp_get (struct nvkm_therm *therm) +nv50_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvbios_therm_sensor *sensor = &therm->bios_sensor;
@@ -143,11 +143,8 @@ nv50_temp_get(struct nvkm_therm *therm) core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant -8 ; -/* reserve negative temperatures for errors */ -if (core_temp <0 ) - core_temp =0 ; - -return core_temp; + *val = core_temp; +return 0 ; } static void
drm/nouveau/nvkm/subdev/therm/priv.h +2 -2
@@ -91,7 +91,7 @@ struct nvkm_therm_func {int (*pwm_set)(struct nvkm_therm *,int line,u32 ,u32 );int (*pwm_clock)(struct nvkm_therm *,int line); -int (*temp_get)(struct nvkm_therm *); +int (*temp_get)(struct nvkm_therm *,int *);int (*fan_sense)(struct nvkm_therm *);
@@ -105,7 +105,7 @@ int nv50_fan_pwm_get(struct nvkm_therm *, int, u32 *, u32 *);int nv50_fan_pwm_set (struct nvkm_therm *,int ,u32 ,u32 );int nv50_fan_pwm_clock (struct nvkm_therm *,int ); -int g84_temp_get (struct nvkm_therm *); +int g84_temp_get (struct nvkm_therm *,int *);void g84_sensor_setup (struct nvkm_therm *);void g84_therm_fini (struct nvkm_therm *);
drm/nouveau/nvkm/subdev/therm/temp.c +12 -4
@@ -86,7 +86,10 @@ nvkm_therm_sensor_event(struct nvkm_therm *therm, enum nvkm_therm_thrs thrs,static const char *const thresholds[] = {"fanboost" ,"downclock" ,"critical" ,"shutdown" }; -int temperature = therm->func->temp_get (therm); +int temperature; + +if (therm->func->temp_get (therm, &temperature)) +return ;if (thrs <0 || thrs >3 )return ;
@@ -140,7 +143,10 @@ nvkm_therm_threshold_hyst_polling(struct nvkm_therm *therm, {enum nvkm_therm_thrs_direction direction;enum nvkm_therm_thrs_state prev_state, new_state; -int temp = therm->func->temp_get (therm); +int temp; + +if (therm->func->temp_get (therm, &temp)) +return ; prev_state =nvkm_therm_sensor_get_threshold_state (therm, thrs_name);
@@ -166,6 +172,7 @@ alarm_timer_callback(struct nvkm_alarm *alarm)struct nvbios_therm_sensor *sensor = &therm->bios_sensor;struct nvkm_timer *tmr = therm->subdev.device->timer;unsigned long flags; +int val;spin_lock_irqsave (&therm->sensor.alarm_program_lock, flags);
@@ -185,7 +192,7 @@ alarm_timer_callback(struct nvkm_alarm *alarm)spin_unlock_irqrestore (&therm->sensor.alarm_program_lock, flags);/* schedule the next poll in one second */ -if (therm->func->temp_get (therm) >=0 ) +if (!therm->func->temp_get (therm, &val))nvkm_timer_alarm (tmr,1000000000ULL , alarm); }
@@ -227,9 +234,10 @@ nvkm_therm_sensor_fini(struct nvkm_therm *therm, bool suspend)void nvkm_therm_sensor_preinit (struct nvkm_therm *therm) { +int val;const char *sensor_avail ="yes" ; -if (therm->func->temp_get (therm) <0 ) +if (therm->func->temp_get (therm, &val)) sensor_avail ="no" ;nvkm_debug (&therm->subdev,"internal sensor: %s\n" , sensor_avail);
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 20171117000436.2432-4-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 03/32] therm: Split return code and value in nvkm_get_temp
Quoted 8 lines · Karol Herbst
The current hwmon code doesn't check if the returned value was actually an error.
Since Kepler temperature sensors are able to report negative values. Those negative values are not for error reporting, but rather when you buried your GPU in snow somewhere in Antarctica and still want a valid temperature to be reported (unverified).
Quoted 4 lines
Since Pascal (and maybe earlier) we have sensors with improved precision.
Adjust the
nvkm_get_tempmethod to be able to deal with those changes and let hwmon return an error properly.
Where did you get this information? And if it is the case, then we will royally screw up the value because we don't even know on how many bits 0x20400 uses...
If you are indeed right, I would like to see g84.c's temp_get().
Quoted 378 lines
Signed-off-by Karol Herbst <[email protected]>--- drm/nouveau/include/nvkm/subdev/clk.h | 4 ++-- drm/nouveau/include/nvkm/subdev/therm.h | 2 +- drm/nouveau/nouveau_hwmon.c | 15 +++++++++------ drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/therm/base.c | 19 ++++++++++++++----- drm/nouveau/nvkm/subdev/therm/g84.c | 13 ++++++++----- drm/nouveau/nvkm/subdev/therm/gp100.c | 9 +++++---- drm/nouveau/nvkm/subdev/therm/nv40.c | 9 +++------ drm/nouveau/nvkm/subdev/therm/nv50.c | 9 +++------ drm/nouveau/nvkm/subdev/therm/priv.h | 4 ++-- drm/nouveau/nvkm/subdev/therm/temp.c | 16 ++++++++++++---- 11 files changed, 60 insertions(+), 42 deletions(-)drm/nouveau/include/nvkm/subdev/clk.h +2
-2@@ -100,7 +100,7 @@ struct nvkm_clk {int ustate_dc;/* user-requested (-1 disabled, -2 perfmon) */ int astate;/* perfmon adjustment (base) */ int dstate;/* display adjustment (min+) */ -u8 temp; +int temp;bool allow_reclock;#define NVKM_CLK_BOOST_NONE 0x0@@ -122,7 +122,7 @@ int nvkm_clk_read(struct nvkm_clk *, enum nv_clk_src);int nvkm_clk_ustate (struct nvkm_clk *,int req,int pwr);int nvkm_clk_astate (struct nvkm_clk *,int req,int rel,bool wait);int nvkm_clk_dstate (struct nvkm_clk *,int req,int rel); -int nvkm_clk_tstate (struct nvkm_clk *,u8 temperature); +int nvkm_clk_tstate (struct nvkm_clk *,int temperature);int nv04_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);int nv40_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);drm/nouveau/include/nvkm/subdev/therm.h +1
-1@@ -86,7 +86,7 @@ struct nvkm_therm {int (*attr_set)(struct nvkm_therm *,enum nvkm_therm_attr_type ,int ); }; -int nvkm_therm_temp_get (struct nvkm_therm *); +int nvkm_therm_temp_get (struct nvkm_therm *,int *);int nvkm_therm_fan_sense (struct nvkm_therm *);int nvkm_therm_cstate (struct nvkm_therm *,int ,int );drm/nouveau/nouveau_hwmon.c +9
-6@@ -326,8 +326,9 @@ nouveau_temp_is_visible(const void *data, u32 attr, int channel) {struct nouveau_drm *drm =nouveau_drm ((struct drm_device *)data);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); +int val; -if (therm && therm->attr_get &&nvkm_therm_temp_get (therm) <0 ) +if (therm && therm->attr_get &&nvkm_therm_temp_get (therm, &val))return 0 ;switch (attr) {@@ -421,15 +422,16 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)struct drm_device *drm_dev =dev_get_drvdata (dev);struct nouveau_drm *drm =nouveau_drm (drm_dev);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); -int ret; +int ret =0 ; +int temp;if (!therm || !therm->attr_get)return -EOPNOTSUPP ;switch (attr) {case hwmon_temp_input: - ret =nvkm_therm_temp_get (therm); - *val = ret <0 ? ret : (ret *1000 ); + ret =nvkm_therm_temp_get (therm, &temp); + *val = temp *1000 ;break ;case hwmon_temp_max: *val = therm->attr_get (therm,NVKM_THERM_ATTR_THRS_DOWN_CLK )@@ -459,7 +461,7 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)return -EOPNOTSUPP ; } -return 0 ; +return ret; } static int@@ -713,6 +715,7 @@ nouveau_hwmon_init(struct drm_device *dev)struct device *hwmon_dev;int ret =0 ;int i =0 ; +int val; hwmon = drm->hwmon =kzalloc (sizeof (*hwmon),GFP_KERNEL );if (!hwmon)@@ -720,7 +723,7 @@ nouveau_hwmon_init(struct drm_device *dev) hwmon->dev = dev;if (therm && therm->attr_get && therm->attr_set) { -if (nvkm_therm_temp_get (therm) >=0 ) +if (!nvkm_therm_temp_get (therm, &val)) special_groups[i++] = &temp1_auto_point_sensor_group;if (therm->fan_get && therm->fan_get (therm) >=0 ) special_groups[i++] = &pwm_fan_sensor_group;drm/nouveau/nvkm/subdev/clk/base.c +1
-1@@ -540,7 +540,7 @@ nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait) }int -nvkm_clk_tstate (struct nvkm_clk *clk,u8 temp) +nvkm_clk_tstate (struct nvkm_clk *clk,int temp) {if (clk->temp == temp)return 0 ;drm/nouveau/nvkm/subdev/therm/base.c +14
-5@@ -24,22 +24,26 @@#include "priv.h" int -nvkm_therm_temp_get (struct nvkm_therm *therm) +nvkm_therm_temp_get (struct nvkm_therm *therm,int *val) {if (therm->func->temp_get) -return therm->func->temp_get (therm); +return therm->func->temp_get (therm, val);return -ENODEV ; }static int nvkm_therm_update_trip (struct nvkm_therm *therm) { +int temp, ret;struct nvbios_therm_trip_point *trip = therm->fan->bios.trip, *cur_trip =NULL , *last_trip = therm->last_trip; -u8 temp = therm->func->temp_get (therm);u16 duty, i; + ret = therm->func->temp_get (therm, &temp); +if (ret <0 ) +return ret; +/* look for the trip point corresponding to the current temperature */ cur_trip =NULL ;for (i =0 ; i < therm->fan->bios.nr_fan_trip; i++) {@@ -67,9 +71,13 @@ static int nvkm_therm_compute_linear_duty(struct nvkm_therm *therm, u8 linear_min_temp, u8 linear_max_temp) { - u8 temp = therm->func->temp_get(therm); + int temp, ret;u16 duty; + ret = therm->func->temp_get (therm, &temp); +if (ret <0 ) +return ret; +/* handle the non-linear part first */ if (temp < linear_min_temp)return therm->fan->bios.min_duty;@@ -182,6 +190,7 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode) {struct nvkm_subdev *subdev = &therm->subdev;struct nvkm_device *device = subdev->device; +int val;static const char *name[] = {"disabled" ,"manual" ,@@ -197,7 +206,7 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode)/* do not allow automatic fan management if the thermal sensor is * not available */ if (mode ==NVKM_THERM_CTRL_AUTO && - therm->func->temp_get (therm) <0 ) + therm->func->temp_get (therm, &val))return -EINVAL ;if (therm->mode == mode)drm/nouveau/nvkm/subdev/therm/g84.c +8
-5@@ -27,14 +27,15 @@#include <subdev/fuse.h> int -g84_temp_get (struct nvkm_therm *therm) +g84_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device; -if (nvkm_fuse_read (device->fuse,0x1a8 ) ==1 ) -return nvkm_rd32 (device,0x20400 ); -else +if (nvkm_fuse_read (device->fuse,0x1a8 ) !=1 )return -ENODEV ; + + *val =nvkm_rd32 (device,0x20400 ); +return 0 ; }void @@ -114,8 +115,10 @@ g84_therm_threshold_hyst_emulation(struct nvkm_therm *therm, new_state =NVKM_THERM_THRS_LOWER ; } +if (therm->func->temp_get (therm, &cur)) +return ; +/* fix the state (in case someone reprogrammed the alarms) */ - cur = therm->func->temp_get (therm);if (new_state ==NVKM_THERM_THRS_LOWER && cur > thrs->temp) new_state =NVKM_THERM_THRS_HIGHER ; else if (new_state == NVKM_THERM_THRS_HIGHER &&drm/nouveau/nvkm/subdev/therm/gp100.c +5
-4@@ -24,7 +24,7 @@#include "priv.h" static int -gp100_temp_get (struct nvkm_therm *therm) +gp100_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvkm_subdev *subdev = &therm->subdev;@@ -36,9 +36,10 @@ gp100_temp_get(struct nvkm_therm *therm)nvkm_trace (subdev,"reading temperature from SHADOWed sensor\n" );/* device valid */ -if (tsensor &0x20000000 ) -return (inttemp >>8 ); -else +if (tsensor &0x20000000 ) { + *val = inttemp >>8 ; +return 0 ; + }else return -ENODEV ; }drm/nouveau/nvkm/subdev/therm/nv40.c +3
-6@@ -70,7 +70,7 @@ nv40_sensor_setup(struct nvkm_therm *therm) }static int -nv40_temp_get (struct nvkm_therm *therm) +nv40_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvbios_therm_sensor *sensor = &therm->bios_sensor;@@ -95,11 +95,8 @@ nv40_temp_get(struct nvkm_therm *therm) core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant -8 ; -/* reserve negative temperatures for errors */ -if (core_temp <0 ) - core_temp =0 ; - -return core_temp; + *val = core_temp; +return 0 ; } static intdrm/nouveau/nvkm/subdev/therm/nv50.c +3
-6@@ -126,7 +126,7 @@ nv50_sensor_setup(struct nvkm_therm *therm) }static int -nv50_temp_get (struct nvkm_therm *therm) +nv50_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvbios_therm_sensor *sensor = &therm->bios_sensor;@@ -143,11 +143,8 @@ nv50_temp_get(struct nvkm_therm *therm) core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant -8 ; -/* reserve negative temperatures for errors */ -if (core_temp <0 ) - core_temp =0 ; - -return core_temp; + *val = core_temp; +return 0 ; } static voiddrm/nouveau/nvkm/subdev/therm/priv.h +2
-2@@ -91,7 +91,7 @@ struct nvkm_therm_func {int (*pwm_set)(struct nvkm_therm *,int line,u32 ,u32 );int (*pwm_clock)(struct nvkm_therm *,int line); -int (*temp_get)(struct nvkm_therm *); +int (*temp_get)(struct nvkm_therm *,int *);int (*fan_sense)(struct nvkm_therm *);@@ -105,7 +105,7 @@ int nv50_fan_pwm_get(struct nvkm_therm *, int, u32 *, u32 *);int nv50_fan_pwm_set (struct nvkm_therm *,int ,u32 ,u32 );int nv50_fan_pwm_clock (struct nvkm_therm *,int ); -int g84_temp_get (struct nvkm_therm *); +int g84_temp_get (struct nvkm_therm *,int *);void g84_sensor_setup (struct nvkm_therm *);void g84_therm_fini (struct nvkm_therm *);drm/nouveau/nvkm/subdev/therm/temp.c +10
-3@@ -86,7 +86,10 @@ nvkm_therm_sensor_event(struct nvkm_therm *therm, enum nvkm_therm_thrs thrs,static const char *const thresholds[] = {"fanboost" ,"downclock" ,"critical" ,"shutdown" }; -int temperature = therm->func->temp_get (therm); +int temperature; + +if (therm->func->temp_get (therm, &temperature)) +return ;if (thrs <0 || thrs >3 )return ;@@ -140,7 +143,10 @@ nvkm_therm_threshold_hyst_polling(struct nvkm_therm *therm, {enum nvkm_therm_thrs_direction direction;enum nvkm_therm_thrs_state prev_state, new_state; -int temp = therm->func->temp_get (therm); +int temp; + +if (therm->func->temp_get (therm, &temp)) +return ; prev_state =nvkm_therm_sensor_get_threshold_state (therm, thrs_name);@@ -166,6 +172,7 @@ alarm_timer_callback(struct nvkm_alarm *alarm)struct nvbios_therm_sensor *sensor = &therm->bios_sensor;struct nvkm_timer *tmr = therm->subdev.device->timer;unsigned long flags; +int val;spin_lock_irqsave (&therm->sensor.alarm_program_lock, flags);@@ -185,7 +192,7 @@ alarm_timer_callback(struct nvkm_alarm *alarm)spin_unlock_irqrestore (&therm->sensor.alarm_program_lock, flags);/* schedule the next poll in one second */ -if (therm->func->temp_get (therm) >=0 ) +if (!therm->func->temp_get (therm, &val))nvkm_timer_alarm (tmr,1000000000ULL , alarm); }@@ -227,9 +234,10 @@ nvkm_therm_sensor_fini(struct nvkm_therm *therm, bool suspend)void
drm/nouveau/nvkm/subdev/therm/temp.c nvkm_therm_sensor_fini(struct nvkm_therm *therm, bool suspend) · line 243
Quoted 10 lines
drm/nouveau/nvkm/subdev/therm/temp.c +2
-1nvkm_therm_sensor_preinit(struct nvkm_therm *therm) { +int val;const char *sensor_avail ="yes" ; -if (therm->func->temp_get (therm) <0 ) +if (therm->func->temp_get (therm, &val)) sensor_avail ="no" ;nvkm_debug (&therm->subdev,"internal sensor: %s\n" , sensor_avail);
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): e6b18baa-46d5-0ff0-bd55-c5255d22e770-GANU6spQydw@public.gmane.org
Re: [PATCH 03/32] therm: Split return code and value in nvkm_get_temp
Quoted 11 lines · Martin Peres
Quoted 10 lines · Karol Herbst
The current hwmon code doesn't check if the returned value was actually an error.
Since Kepler temperature sensors are able to report negative values. Those negative values are not for error reporting, but rather when you buried your GPU in snow somewhere in Antarctica and still want a valid temperature to be reported (unverified).
Since Pascal (and maybe earlier) we have sensors with improved precision.
Quoted 9 lines
Quoted 2 lines
Adjust the
nvkm_get_tempmethod to be able to deal with those changes and let hwmon return an error properly.Where did you get this information? And if it is the case, then we will royally screw up the value because we don't even know on how many bits
0x20400uses...If you are indeed right, I would like to see g84.c's
temp_get().
Nvidia uses 0x020460 on Pascal and I thought we had that in envytools already?
[0] 228.412618 MMIO32 R 0x020460 0x20002f20 PTHERM.I2C_SLAVE+0x60 => 0x20002f20
[0] 229.413039 MMIO32 R 0x020460 0x20002f10 PTHERM.I2C_SLAVE+0x60 => 0x20002f10
[0] 230.416976 MMIO32 R 0x020460 0x20002f68 PTHERM.I2C_SLAVE+0x60 => 0x20002f68
[0] 231.417407 MMIO32 R 0x020460 0x20002fe8 PTHERM.I2C_SLAVE+0x60 => 0x20002fe8
[0] 232.417742 MMIO32 R 0x020460 0x20002ff0 PTHERM.I2C_SLAVE+0x60 => 0x20002ff0
[0] 233.417742 MMIO32 R 0x020460 0x20003020 PTHERM.I2C_SLAVE+0x60 => 0x20003020
or nvapeek 0x20400 && nvapeek 0x020460;
00020400: 0000002c
00020460: 20002c60
Quoted 386 lines
Quoted 386 lines
Signed-off-by Karol Herbst <[email protected]>--- drm/nouveau/include/nvkm/subdev/clk.h | 4 ++-- drm/nouveau/include/nvkm/subdev/therm.h | 2 +- drm/nouveau/nouveau_hwmon.c | 15 +++++++++------ drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/therm/base.c | 19 ++++++++++++++----- drm/nouveau/nvkm/subdev/therm/g84.c | 13 ++++++++----- drm/nouveau/nvkm/subdev/therm/gp100.c | 9 +++++---- drm/nouveau/nvkm/subdev/therm/nv40.c | 9 +++------ drm/nouveau/nvkm/subdev/therm/nv50.c | 9 +++------ drm/nouveau/nvkm/subdev/therm/priv.h | 4 ++-- drm/nouveau/nvkm/subdev/therm/temp.c | 16 ++++++++++++---- 11 files changed, 60 insertions(+), 42 deletions(-)drm/nouveau/include/nvkm/subdev/clk.h +2
-2@@ -100,7 +100,7 @@ struct nvkm_clk {int ustate_dc;/* user-requested (-1 disabled, -2 perfmon) */ int astate;/* perfmon adjustment (base) */ int dstate;/* display adjustment (min+) */ -u8 temp; +int temp;bool allow_reclock;#define NVKM_CLK_BOOST_NONE 0x0@@ -122,7 +122,7 @@ int nvkm_clk_read(struct nvkm_clk *, enum nv_clk_src);int nvkm_clk_ustate (struct nvkm_clk *,int req,int pwr);int nvkm_clk_astate (struct nvkm_clk *,int req,int rel,bool wait);int nvkm_clk_dstate (struct nvkm_clk *,int req,int rel); -int nvkm_clk_tstate (struct nvkm_clk *,u8 temperature); +int nvkm_clk_tstate (struct nvkm_clk *,int temperature);int nv04_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);int nv40_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);drm/nouveau/include/nvkm/subdev/therm.h +1
-1@@ -86,7 +86,7 @@ struct nvkm_therm {int (*attr_set)(struct nvkm_therm *,enum nvkm_therm_attr_type ,int ); }; -int nvkm_therm_temp_get (struct nvkm_therm *); +int nvkm_therm_temp_get (struct nvkm_therm *,int *);int nvkm_therm_fan_sense (struct nvkm_therm *);int nvkm_therm_cstate (struct nvkm_therm *,int ,int );drm/nouveau/nouveau_hwmon.c +9
-6@@ -326,8 +326,9 @@ nouveau_temp_is_visible(const void *data, u32 attr, int channel) {struct nouveau_drm *drm =nouveau_drm ((struct drm_device *)data);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); +int val; -if (therm && therm->attr_get &&nvkm_therm_temp_get (therm) <0 ) +if (therm && therm->attr_get &&nvkm_therm_temp_get (therm, &val))return 0 ;switch (attr) {@@ -421,15 +422,16 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)struct drm_device *drm_dev =dev_get_drvdata (dev);struct nouveau_drm *drm =nouveau_drm (drm_dev);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); -int ret; +int ret =0 ; +int temp;if (!therm || !therm->attr_get)return -EOPNOTSUPP ;switch (attr) {case hwmon_temp_input: - ret =nvkm_therm_temp_get (therm); - *val = ret <0 ? ret : (ret *1000 ); + ret =nvkm_therm_temp_get (therm, &temp); + *val = temp *1000 ;break ;case hwmon_temp_max: *val = therm->attr_get (therm,NVKM_THERM_ATTR_THRS_DOWN_CLK )@@ -459,7 +461,7 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)return -EOPNOTSUPP ; } -return 0 ; +return ret; } static int@@ -713,6 +715,7 @@ nouveau_hwmon_init(struct drm_device *dev)struct device *hwmon_dev;int ret =0 ;int i =0 ; +int val; hwmon = drm->hwmon =kzalloc (sizeof (*hwmon),GFP_KERNEL );if (!hwmon)@@ -720,7 +723,7 @@ nouveau_hwmon_init(struct drm_device *dev) hwmon->dev = dev;if (therm && therm->attr_get && therm->attr_set) { -if (nvkm_therm_temp_get (therm) >=0 ) +if (!nvkm_therm_temp_get (therm, &val)) special_groups[i++] = &temp1_auto_point_sensor_group;if (therm->fan_get && therm->fan_get (therm) >=0 ) special_groups[i++] = &pwm_fan_sensor_group;drm/nouveau/nvkm/subdev/clk/base.c +1
-1@@ -540,7 +540,7 @@ nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait) }int -nvkm_clk_tstate (struct nvkm_clk *clk,u8 temp) +nvkm_clk_tstate (struct nvkm_clk *clk,int temp) {if (clk->temp == temp)return 0 ;drm/nouveau/nvkm/subdev/therm/base.c +14
-5@@ -24,22 +24,26 @@#include "priv.h" int -nvkm_therm_temp_get (struct nvkm_therm *therm) +nvkm_therm_temp_get (struct nvkm_therm *therm,int *val) {if (therm->func->temp_get) -return therm->func->temp_get (therm); +return therm->func->temp_get (therm, val);return -ENODEV ; }static int nvkm_therm_update_trip (struct nvkm_therm *therm) { +int temp, ret;struct nvbios_therm_trip_point *trip = therm->fan->bios.trip, *cur_trip =NULL , *last_trip = therm->last_trip; -u8 temp = therm->func->temp_get (therm);u16 duty, i; + ret = therm->func->temp_get (therm, &temp); +if (ret <0 ) +return ret; +/* look for the trip point corresponding to the current temperature */ cur_trip =NULL ;for (i =0 ; i < therm->fan->bios.nr_fan_trip; i++) {@@ -67,9 +71,13 @@ static int nvkm_therm_compute_linear_duty(struct nvkm_therm *therm, u8 linear_min_temp, u8 linear_max_temp) { - u8 temp = therm->func->temp_get(therm); + int temp, ret;u16 duty; + ret = therm->func->temp_get (therm, &temp); +if (ret <0 ) +return ret; +/* handle the non-linear part first */ if (temp < linear_min_temp)return therm->fan->bios.min_duty;@@ -182,6 +190,7 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode) {struct nvkm_subdev *subdev = &therm->subdev;struct nvkm_device *device = subdev->device; +int val;static const char *name[] = {"disabled" ,"manual" ,@@ -197,7 +206,7 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode)/* do not allow automatic fan management if the thermal sensor is * not available */ if (mode ==NVKM_THERM_CTRL_AUTO && - therm->func->temp_get (therm) <0 ) + therm->func->temp_get (therm, &val))return -EINVAL ;if (therm->mode == mode)drm/nouveau/nvkm/subdev/therm/g84.c +8
-5@@ -27,14 +27,15 @@#include <subdev/fuse.h> int -g84_temp_get (struct nvkm_therm *therm) +g84_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device; -if (nvkm_fuse_read (device->fuse,0x1a8 ) ==1 ) -return nvkm_rd32 (device,0x20400 ); -else +if (nvkm_fuse_read (device->fuse,0x1a8 ) !=1 )return -ENODEV ; + + *val =nvkm_rd32 (device,0x20400 ); +return 0 ; }void @@ -114,8 +115,10 @@ g84_therm_threshold_hyst_emulation(struct nvkm_therm *therm, new_state =NVKM_THERM_THRS_LOWER ; } +if (therm->func->temp_get (therm, &cur)) +return ; +/* fix the state (in case someone reprogrammed the alarms) */ - cur = therm->func->temp_get (therm);if (new_state ==NVKM_THERM_THRS_LOWER && cur > thrs->temp) new_state =NVKM_THERM_THRS_HIGHER ; else if (new_state == NVKM_THERM_THRS_HIGHER &&drm/nouveau/nvkm/subdev/therm/gp100.c +5
-4@@ -24,7 +24,7 @@#include "priv.h" static int -gp100_temp_get (struct nvkm_therm *therm) +gp100_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvkm_subdev *subdev = &therm->subdev;@@ -36,9 +36,10 @@ gp100_temp_get(struct nvkm_therm *therm)nvkm_trace (subdev,"reading temperature from SHADOWed sensor\n" );/* device valid */ -if (tsensor &0x20000000 ) -return (inttemp >>8 ); -else +if (tsensor &0x20000000 ) { + *val = inttemp >>8 ; +return 0 ; + }else return -ENODEV ; }drm/nouveau/nvkm/subdev/therm/nv40.c +3
-6@@ -70,7 +70,7 @@ nv40_sensor_setup(struct nvkm_therm *therm) }static int -nv40_temp_get (struct nvkm_therm *therm) +nv40_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvbios_therm_sensor *sensor = &therm->bios_sensor;@@ -95,11 +95,8 @@ nv40_temp_get(struct nvkm_therm *therm) core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant -8 ; -/* reserve negative temperatures for errors */ -if (core_temp <0 ) - core_temp =0 ; - -return core_temp; + *val = core_temp; +return 0 ; } static intdrm/nouveau/nvkm/subdev/therm/nv50.c +3
-6@@ -126,7 +126,7 @@ nv50_sensor_setup(struct nvkm_therm *therm) }static int -nv50_temp_get (struct nvkm_therm *therm) +nv50_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvbios_therm_sensor *sensor = &therm->bios_sensor;@@ -143,11 +143,8 @@ nv50_temp_get(struct nvkm_therm *therm) core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant -8 ; -/* reserve negative temperatures for errors */ -if (core_temp <0 ) - core_temp =0 ; - -return core_temp; + *val = core_temp; +return 0 ; } static voiddrm/nouveau/nvkm/subdev/therm/priv.h +2
-2@@ -91,7 +91,7 @@ struct nvkm_therm_func {int (*pwm_set)(struct nvkm_therm *,int line,u32 ,u32 );int (*pwm_clock)(struct nvkm_therm *,int line); -int (*temp_get)(struct nvkm_therm *); +int (*temp_get)(struct nvkm_therm *,int *);int (*fan_sense)(struct nvkm_therm *);@@ -105,7 +105,7 @@ int nv50_fan_pwm_get(struct nvkm_therm *, int, u32 *, u32 *);int nv50_fan_pwm_set (struct nvkm_therm *,int ,u32 ,u32 );int nv50_fan_pwm_clock (struct nvkm_therm *,int ); -int g84_temp_get (struct nvkm_therm *); +int g84_temp_get (struct nvkm_therm *,int *);void g84_sensor_setup (struct nvkm_therm *);void g84_therm_fini (struct nvkm_therm *);drm/nouveau/nvkm/subdev/therm/temp.c +12
-4@@ -86,7 +86,10 @@ nvkm_therm_sensor_event(struct nvkm_therm *therm, enum nvkm_therm_thrs thrs,static const char *const thresholds[] = {"fanboost" ,"downclock" ,"critical" ,"shutdown" }; -int temperature = therm->func->temp_get (therm); +int temperature; + +if (therm->func->temp_get (therm, &temperature)) +return ;if (thrs <0 || thrs >3 )return ;@@ -140,7 +143,10 @@ nvkm_therm_threshold_hyst_polling(struct nvkm_therm *therm, {enum nvkm_therm_thrs_direction direction;enum nvkm_therm_thrs_state prev_state, new_state; -int temp = therm->func->temp_get (therm); +int temp; + +if (therm->func->temp_get (therm, &temp)) +return ; prev_state =nvkm_therm_sensor_get_threshold_state (therm, thrs_name);@@ -166,6 +172,7 @@ alarm_timer_callback(struct nvkm_alarm *alarm)struct nvbios_therm_sensor *sensor = &therm->bios_sensor;struct nvkm_timer *tmr = therm->subdev.device->timer;unsigned long flags; +int val;spin_lock_irqsave (&therm->sensor.alarm_program_lock, flags);@@ -185,7 +192,7 @@ alarm_timer_callback(struct nvkm_alarm *alarm)spin_unlock_irqrestore (&therm->sensor.alarm_program_lock, flags);/* schedule the next poll in one second */ -if (therm->func->temp_get (therm) >=0 ) +if (!therm->func->temp_get (therm, &val))nvkm_timer_alarm (tmr,1000000000ULL , alarm); }@@ -227,9 +234,10 @@ nvkm_therm_sensor_fini(struct nvkm_therm *therm, bool suspend)void nvkm_therm_sensor_preinit (struct nvkm_therm *therm) { +int val;const char *sensor_avail ="yes" ; -if (therm->func->temp_get (therm) <0 ) +if (therm->func->temp_get (therm, &val)) sensor_avail ="no" ;
Quoted 7 lines
drm/nouveau/nvkm/subdev/therm/temp.c nvkm_therm_sensor_fini(struct nvkm_therm *therm, bool suspend) · line 243
Quoted 2 lines
drm/nouveau/nvkm/subdev/therm/temp.c +0
-0nvkm_debug (&therm->subdev,"internal sensor: %s\n" , sensor_avail);_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): CACO55tvzR_iQqQY4SoECbq3MN1Tax-znrTBQsntYsGzjXGTMHg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 03/32] therm: Split return code and value in nvkm_get_temp
Quoted 15 lines · Karol Herbst
Quoted 14 lines · Martin Peres
Quoted 12 lines · Karol Herbst
The current hwmon code doesn't check if the returned value was actually an error.
Since Kepler temperature sensors are able to report negative values. Those negative values are not for error reporting, but rather when you buried your GPU in snow somewhere in Antarctica and still want a valid temperature to be reported (unverified).
Since Pascal (and maybe earlier) we have sensors with improved precision.
Adjust the
nvkm_get_tempmethod to be able to deal with those changes and let hwmon return an error properly.
Quoted 8 lines
Quoted 6 lines
Where did you get this information? And if it is the case, then we will royally screw up the value because we don't even know on how many bits
0x20400uses...If you are indeed right, I would like to see g84.c's
temp_get().Nvidia uses
0x020460on Pascal and I thought we had that in envytools already?
Nothing in nvbios.
Quoted 11 lines
[0] 228.412618 MMIO32 R
0x0204600x20002f20PTHERM.I2C_SLAVE+0x60=>0x20002f20
[0] 229.413039 MMIO32 R0x0204600x20002f10PTHERM.I2C_SLAVE+0x60=>0x20002f10
[0] 230.416976 MMIO32 R0x0204600x20002f68PTHERM.I2C_SLAVE+0x60=>0x20002f68
[0] 231.417407 MMIO32 R0x0204600x20002fe8PTHERM.I2C_SLAVE+0x60=>0x20002fe8
[0] 232.417742 MMIO32 R0x0204600x20002ff0PTHERM.I2C_SLAVE+0x60=>0x20002ff0
[0] 233.417742 MMIO32 R0x0204600x20003020PTHERM.I2C_SLAVE+0x60=>0x20003020or nvapeek
0x20400&& nvapeek0x020460;
00020400:0000002c
00020460:20002c60
Cool that they increased the accuracy, but where do you get that the value can be negative? And if it is, how many bits are used? 16 or more? What are those high bits?
Quoted 387 lines
Quoted 387 lines
Quoted 387 lines
Signed-off-by Karol Herbst <[email protected]>--- drm/nouveau/include/nvkm/subdev/clk.h | 4 ++-- drm/nouveau/include/nvkm/subdev/therm.h | 2 +- drm/nouveau/nouveau_hwmon.c | 15 +++++++++------ drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/therm/base.c | 19 ++++++++++++++----- drm/nouveau/nvkm/subdev/therm/g84.c | 13 ++++++++----- drm/nouveau/nvkm/subdev/therm/gp100.c | 9 +++++---- drm/nouveau/nvkm/subdev/therm/nv40.c | 9 +++------ drm/nouveau/nvkm/subdev/therm/nv50.c | 9 +++------ drm/nouveau/nvkm/subdev/therm/priv.h | 4 ++-- drm/nouveau/nvkm/subdev/therm/temp.c | 16 ++++++++++++---- 11 files changed, 60 insertions(+), 42 deletions(-)drm/nouveau/include/nvkm/subdev/clk.h +2
-2@@ -100,7 +100,7 @@ struct nvkm_clk {int ustate_dc;/* user-requested (-1 disabled, -2 perfmon) */ int astate;/* perfmon adjustment (base) */ int dstate;/* display adjustment (min+) */ -u8 temp; +int temp;bool allow_reclock;#define NVKM_CLK_BOOST_NONE 0x0@@ -122,7 +122,7 @@ int nvkm_clk_read(struct nvkm_clk *, enum nv_clk_src);int nvkm_clk_ustate (struct nvkm_clk *,int req,int pwr);int nvkm_clk_astate (struct nvkm_clk *,int req,int rel,bool wait);int nvkm_clk_dstate (struct nvkm_clk *,int req,int rel); -int nvkm_clk_tstate (struct nvkm_clk *,u8 temperature); +int nvkm_clk_tstate (struct nvkm_clk *,int temperature);int nv04_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);int nv40_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);drm/nouveau/include/nvkm/subdev/therm.h +1
-1@@ -86,7 +86,7 @@ struct nvkm_therm {int (*attr_set)(struct nvkm_therm *,enum nvkm_therm_attr_type ,int ); }; -int nvkm_therm_temp_get (struct nvkm_therm *); +int nvkm_therm_temp_get (struct nvkm_therm *,int *);int nvkm_therm_fan_sense (struct nvkm_therm *);int nvkm_therm_cstate (struct nvkm_therm *,int ,int );drm/nouveau/nouveau_hwmon.c +9
-6@@ -326,8 +326,9 @@ nouveau_temp_is_visible(const void *data, u32 attr, int channel) {struct nouveau_drm *drm =nouveau_drm ((struct drm_device *)data);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); +int val; -if (therm && therm->attr_get &&nvkm_therm_temp_get (therm) <0 ) +if (therm && therm->attr_get &&nvkm_therm_temp_get (therm, &val))return 0 ;switch (attr) {@@ -421,15 +422,16 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)struct drm_device *drm_dev =dev_get_drvdata (dev);struct nouveau_drm *drm =nouveau_drm (drm_dev);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); -int ret; +int ret =0 ; +int temp;if (!therm || !therm->attr_get)return -EOPNOTSUPP ;switch (attr) {case hwmon_temp_input: - ret =nvkm_therm_temp_get (therm); - *val = ret <0 ? ret : (ret *1000 ); + ret =nvkm_therm_temp_get (therm, &temp); + *val = temp *1000 ;break ;case hwmon_temp_max: *val = therm->attr_get (therm,NVKM_THERM_ATTR_THRS_DOWN_CLK )@@ -459,7 +461,7 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)return -EOPNOTSUPP ; } -return 0 ; +return ret; } static int@@ -713,6 +715,7 @@ nouveau_hwmon_init(struct drm_device *dev)struct device *hwmon_dev;int ret =0 ;int i =0 ; +int val; hwmon = drm->hwmon =kzalloc (sizeof (*hwmon),GFP_KERNEL );if (!hwmon)@@ -720,7 +723,7 @@ nouveau_hwmon_init(struct drm_device *dev) hwmon->dev = dev;if (therm && therm->attr_get && therm->attr_set) { -if (nvkm_therm_temp_get (therm) >=0 ) +if (!nvkm_therm_temp_get (therm, &val)) special_groups[i++] = &temp1_auto_point_sensor_group;if (therm->fan_get && therm->fan_get (therm) >=0 ) special_groups[i++] = &pwm_fan_sensor_group;drm/nouveau/nvkm/subdev/clk/base.c +1
-1@@ -540,7 +540,7 @@ nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait) }int -nvkm_clk_tstate (struct nvkm_clk *clk,u8 temp) +nvkm_clk_tstate (struct nvkm_clk *clk,int temp) {if (clk->temp == temp)return 0 ;drm/nouveau/nvkm/subdev/therm/base.c +14
-5@@ -24,22 +24,26 @@#include "priv.h" int -nvkm_therm_temp_get (struct nvkm_therm *therm) +nvkm_therm_temp_get (struct nvkm_therm *therm,int *val) {if (therm->func->temp_get) -return therm->func->temp_get (therm); +return therm->func->temp_get (therm, val);return -ENODEV ; }static int nvkm_therm_update_trip (struct nvkm_therm *therm) { +int temp, ret;struct nvbios_therm_trip_point *trip = therm->fan->bios.trip, *cur_trip =NULL , *last_trip = therm->last_trip; -u8 temp = therm->func->temp_get (therm);u16 duty, i; + ret = therm->func->temp_get (therm, &temp); +if (ret <0 ) +return ret; +/* look for the trip point corresponding to the current temperature */ cur_trip =NULL ;for (i =0 ; i < therm->fan->bios.nr_fan_trip; i++) {@@ -67,9 +71,13 @@ static int nvkm_therm_compute_linear_duty(struct nvkm_therm *therm, u8 linear_min_temp, u8 linear_max_temp) { - u8 temp = therm->func->temp_get(therm); + int temp, ret;u16 duty; + ret = therm->func->temp_get (therm, &temp); +if (ret <0 ) +return ret; +/* handle the non-linear part first */ if (temp < linear_min_temp)return therm->fan->bios.min_duty;@@ -182,6 +190,7 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode) {struct nvkm_subdev *subdev = &therm->subdev;struct nvkm_device *device = subdev->device; +int val;static const char *name[] = {"disabled" ,"manual" ,@@ -197,7 +206,7 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode)/* do not allow automatic fan management if the thermal sensor is * not available */ if (mode ==NVKM_THERM_CTRL_AUTO && - therm->func->temp_get (therm) <0 ) + therm->func->temp_get (therm, &val))return -EINVAL ;if (therm->mode == mode)drm/nouveau/nvkm/subdev/therm/g84.c +8
-5@@ -27,14 +27,15 @@#include <subdev/fuse.h> int -g84_temp_get (struct nvkm_therm *therm) +g84_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device; -if (nvkm_fuse_read (device->fuse,0x1a8 ) ==1 ) -return nvkm_rd32 (device,0x20400 ); -else +if (nvkm_fuse_read (device->fuse,0x1a8 ) !=1 )return -ENODEV ; + + *val =nvkm_rd32 (device,0x20400 ); +return 0 ; }void @@ -114,8 +115,10 @@ g84_therm_threshold_hyst_emulation(struct nvkm_therm *therm, new_state =NVKM_THERM_THRS_LOWER ; } +if (therm->func->temp_get (therm, &cur)) +return ; +/* fix the state (in case someone reprogrammed the alarms) */ - cur = therm->func->temp_get (therm);if (new_state ==NVKM_THERM_THRS_LOWER && cur > thrs->temp) new_state =NVKM_THERM_THRS_HIGHER ; else if (new_state == NVKM_THERM_THRS_HIGHER &&drm/nouveau/nvkm/subdev/therm/gp100.c +5
-4@@ -24,7 +24,7 @@#include "priv.h" static int -gp100_temp_get (struct nvkm_therm *therm) +gp100_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvkm_subdev *subdev = &therm->subdev;@@ -36,9 +36,10 @@ gp100_temp_get(struct nvkm_therm *therm)nvkm_trace (subdev,"reading temperature from SHADOWed sensor\n" );/* device valid */ -if (tsensor &0x20000000 ) -return (inttemp >>8 ); -else +if (tsensor &0x20000000 ) { + *val = inttemp >>8 ; +return 0 ; + }else return -ENODEV ; }drm/nouveau/nvkm/subdev/therm/nv40.c +3
-6@@ -70,7 +70,7 @@ nv40_sensor_setup(struct nvkm_therm *therm) }static int -nv40_temp_get (struct nvkm_therm *therm) +nv40_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvbios_therm_sensor *sensor = &therm->bios_sensor;@@ -95,11 +95,8 @@ nv40_temp_get(struct nvkm_therm *therm) core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant -8 ; -/* reserve negative temperatures for errors */ -if (core_temp <0 ) - core_temp =0 ; - -return core_temp; + *val = core_temp; +return 0 ; } static intdrm/nouveau/nvkm/subdev/therm/nv50.c +3
-6@@ -126,7 +126,7 @@ nv50_sensor_setup(struct nvkm_therm *therm) }static int -nv50_temp_get (struct nvkm_therm *therm) +nv50_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvbios_therm_sensor *sensor = &therm->bios_sensor;@@ -143,11 +143,8 @@ nv50_temp_get(struct nvkm_therm *therm) core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant -8 ; -/* reserve negative temperatures for errors */ -if (core_temp <0 ) - core_temp =0 ; - -return core_temp; + *val = core_temp; +return 0 ; } static voiddrm/nouveau/nvkm/subdev/therm/priv.h +2
-2@@ -91,7 +91,7 @@ struct nvkm_therm_func {int (*pwm_set)(struct nvkm_therm *,int line,u32 ,u32 );int (*pwm_clock)(struct nvkm_therm *,int line); -int (*temp_get)(struct nvkm_therm *); +int (*temp_get)(struct nvkm_therm *,int *);int (*fan_sense)(struct nvkm_therm *);@@ -105,7 +105,7 @@ int nv50_fan_pwm_get(struct nvkm_therm *, int, u32 *, u32 *);int nv50_fan_pwm_set (struct nvkm_therm *,int ,u32 ,u32 );int nv50_fan_pwm_clock (struct nvkm_therm *,int ); -int g84_temp_get (struct nvkm_therm *); +int g84_temp_get (struct nvkm_therm *,int *);void g84_sensor_setup (struct nvkm_therm *);void g84_therm_fini (struct nvkm_therm *);drm/nouveau/nvkm/subdev/therm/temp.c +12
-4@@ -86,7 +86,10 @@ nvkm_therm_sensor_event(struct nvkm_therm *therm, enum nvkm_therm_thrs thrs,static const char *const thresholds[] = {"fanboost" ,"downclock" ,"critical" ,"shutdown" }; -int temperature = therm->func->temp_get (therm); +int temperature; + +if (therm->func->temp_get (therm, &temperature)) +return ;if (thrs <0 || thrs >3 )return ;@@ -140,7 +143,10 @@ nvkm_therm_threshold_hyst_polling(struct nvkm_therm *therm, {enum nvkm_therm_thrs_direction direction;enum nvkm_therm_thrs_state prev_state, new_state; -int temp = therm->func->temp_get (therm); +int temp; + +if (therm->func->temp_get (therm, &temp)) +return ; prev_state =nvkm_therm_sensor_get_threshold_state (therm, thrs_name);@@ -166,6 +172,7 @@ alarm_timer_callback(struct nvkm_alarm *alarm)struct nvbios_therm_sensor *sensor = &therm->bios_sensor;struct nvkm_timer *tmr = therm->subdev.device->timer;unsigned long flags; +int val;spin_lock_irqsave (&therm->sensor.alarm_program_lock, flags);@@ -185,7 +192,7 @@ alarm_timer_callback(struct nvkm_alarm *alarm)spin_unlock_irqrestore (&therm->sensor.alarm_program_lock, flags);/* schedule the next poll in one second */ -if (therm->func->temp_get (therm) >=0 ) +if (!therm->func->temp_get (therm, &val))nvkm_timer_alarm (tmr,1000000000ULL , alarm); }@@ -227,9 +234,10 @@ nvkm_therm_sensor_fini(struct nvkm_therm *therm, bool suspend)void nvkm_therm_sensor_preinit (struct nvkm_therm *therm) { +int val;const char *sensor_avail ="yes" ; -if (therm->func->temp_get (therm) <0 ) +if (therm->func->temp_get (therm, &val)) sensor_avail ="no" ;
Quoted 7 lines
Quoted 7 lines
drm/nouveau/nvkm/subdev/therm/temp.c nvkm_therm_sensor_fini(struct nvkm_therm *therm, bool suspend) · line 243
Quoted 2 lines
drm/nouveau/nvkm/subdev/therm/temp.c +0
-0nvkm_debug (&therm->subdev,"internal sensor: %s\n" , sensor_avail);_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
A message that is not in the archive (sent off-list or not yet received): 9ff53665-3058-31a0-7020-bdbd6ba00f24-GANU6spQydw@public.gmane.org
Re: [PATCH 03/32] therm: Split return code and value in nvkm_get_temp
Quoted 35 lines · Martin Peres
Quoted 15 lines · Karol Herbst
Quoted 14 lines · Martin Peres
Quoted 12 lines · Karol Herbst
The current hwmon code doesn't check if the returned value was actually an error.
Since Kepler temperature sensors are able to report negative values. Those negative values are not for error reporting, but rather when you buried your GPU in snow somewhere in Antarctica and still want a valid temperature to be reported (unverified).
Since Pascal (and maybe earlier) we have sensors with improved precision.
Adjust the
nvkm_get_tempmethod to be able to deal with those changes and let hwmon return an error properly.Quoted 8 lines
Quoted 6 lines
Where did you get this information? And if it is the case, then we will royally screw up the value because we don't even know on how many bits
0x20400uses...If you are indeed right, I would like to see g84.c's
temp_get().Nvidia uses
0x020460on Pascal and I thought we had that in envytools already?Nothing in nvbios.
Quoted 8 lines
[0] 228.412618 MMIO32 R
0x0204600x20002f20PTHERM.I2C_SLAVE+0x60=>0x20002f20
[0] 229.413039 MMIO32 R0x0204600x20002f10PTHERM.I2C_SLAVE+0x60=>0x20002f10
[0] 230.416976 MMIO32 R0x0204600x20002f68PTHERM.I2C_SLAVE+0x60=>0x20002f68
[0] 231.417407 MMIO32 R0x0204600x20002fe8PTHERM.I2C_SLAVE+0x60=>0x20002fe8
[0] 232.417742 MMIO32 R0x0204600x20002ff0PTHERM.I2C_SLAVE+0x60=>0x20002ff0
[0] 233.417742 MMIO32 R0x0204600x20003020PTHERM.I2C_SLAVE+0x60=>0x20003020
Quoted 8 lines
Quoted 3 lines
or nvapeek
0x20400&& nvapeek0x020460;
00020400:0000002c
00020460:20002c60Cool that they increased the accuracy, but where do you get that the value can be negative? And if it is, how many bits are used? 16 or more? What are those high bits?
I was asking rhyskidd to add stuff to rnndb, because he wrote the nouveau patch for those sensors, check out for more details:
https://github.com/skeggsb/nouveau/blob/master/drm/nouveau/nvkm/subdev/therm/gp100.c#L27
regarding negative values, we have 0x02044c + 0x020450 for that and I could imagine that 0x020460 can display negative values as well... nobody tried for sure, but it seems plausible.
Anyway, moving from u8 to int should make life much easier for us if we decide to really care about the higher precision. Currently our code can't handle that for multiple reasons, but this solves one of those at least.
Quoted 387 lines
Quoted 387 lines
Quoted 387 lines
Quoted 387 lines
Signed-off-by Karol Herbst <[email protected]>--- drm/nouveau/include/nvkm/subdev/clk.h | 4 ++-- drm/nouveau/include/nvkm/subdev/therm.h | 2 +- drm/nouveau/nouveau_hwmon.c | 15 +++++++++------ drm/nouveau/nvkm/subdev/clk/base.c | 2 +- drm/nouveau/nvkm/subdev/therm/base.c | 19 ++++++++++++++----- drm/nouveau/nvkm/subdev/therm/g84.c | 13 ++++++++----- drm/nouveau/nvkm/subdev/therm/gp100.c | 9 +++++---- drm/nouveau/nvkm/subdev/therm/nv40.c | 9 +++------ drm/nouveau/nvkm/subdev/therm/nv50.c | 9 +++------ drm/nouveau/nvkm/subdev/therm/priv.h | 4 ++-- drm/nouveau/nvkm/subdev/therm/temp.c | 16 ++++++++++++---- 11 files changed, 60 insertions(+), 42 deletions(-)drm/nouveau/include/nvkm/subdev/clk.h +2
-2@@ -100,7 +100,7 @@ struct nvkm_clk {int ustate_dc;/* user-requested (-1 disabled, -2 perfmon) */ int astate;/* perfmon adjustment (base) */ int dstate;/* display adjustment (min+) */ -u8 temp; +int temp;bool allow_reclock;#define NVKM_CLK_BOOST_NONE 0x0@@ -122,7 +122,7 @@ int nvkm_clk_read(struct nvkm_clk *, enum nv_clk_src);int nvkm_clk_ustate (struct nvkm_clk *,int req,int pwr);int nvkm_clk_astate (struct nvkm_clk *,int req,int rel,bool wait);int nvkm_clk_dstate (struct nvkm_clk *,int req,int rel); -int nvkm_clk_tstate (struct nvkm_clk *,u8 temperature); +int nvkm_clk_tstate (struct nvkm_clk *,int temperature);int nv04_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);int nv40_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);drm/nouveau/include/nvkm/subdev/therm.h +1
-1@@ -86,7 +86,7 @@ struct nvkm_therm {int (*attr_set)(struct nvkm_therm *,enum nvkm_therm_attr_type ,int ); }; -int nvkm_therm_temp_get (struct nvkm_therm *); +int nvkm_therm_temp_get (struct nvkm_therm *,int *);int nvkm_therm_fan_sense (struct nvkm_therm *);int nvkm_therm_cstate (struct nvkm_therm *,int ,int );drm/nouveau/nouveau_hwmon.c +9
-6@@ -326,8 +326,9 @@ nouveau_temp_is_visible(const void *data, u32 attr, int channel) {struct nouveau_drm *drm =nouveau_drm ((struct drm_device *)data);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); +int val; -if (therm && therm->attr_get &&nvkm_therm_temp_get (therm) <0 ) +if (therm && therm->attr_get &&nvkm_therm_temp_get (therm, &val))return 0 ;switch (attr) {@@ -421,15 +422,16 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)struct drm_device *drm_dev =dev_get_drvdata (dev);struct nouveau_drm *drm =nouveau_drm (drm_dev);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); -int ret; +int ret =0 ; +int temp;if (!therm || !therm->attr_get)return -EOPNOTSUPP ;switch (attr) {case hwmon_temp_input: - ret =nvkm_therm_temp_get (therm); - *val = ret <0 ? ret : (ret *1000 ); + ret =nvkm_therm_temp_get (therm, &temp); + *val = temp *1000 ;break ;case hwmon_temp_max: *val = therm->attr_get (therm,NVKM_THERM_ATTR_THRS_DOWN_CLK )@@ -459,7 +461,7 @@ nouveau_temp_read(struct device *dev, u32 attr, int channel, long *val)return -EOPNOTSUPP ; } -return 0 ; +return ret; } static int@@ -713,6 +715,7 @@ nouveau_hwmon_init(struct drm_device *dev)struct device *hwmon_dev;int ret =0 ;int i =0 ; +int val; hwmon = drm->hwmon =kzalloc (sizeof (*hwmon),GFP_KERNEL );if (!hwmon)@@ -720,7 +723,7 @@ nouveau_hwmon_init(struct drm_device *dev) hwmon->dev = dev;if (therm && therm->attr_get && therm->attr_set) { -if (nvkm_therm_temp_get (therm) >=0 ) +if (!nvkm_therm_temp_get (therm, &val)) special_groups[i++] = &temp1_auto_point_sensor_group;if (therm->fan_get && therm->fan_get (therm) >=0 ) special_groups[i++] = &pwm_fan_sensor_group;drm/nouveau/nvkm/subdev/clk/base.c +1
-1@@ -540,7 +540,7 @@ nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait) }int -nvkm_clk_tstate (struct nvkm_clk *clk,u8 temp) +nvkm_clk_tstate (struct nvkm_clk *clk,int temp) {if (clk->temp == temp)return 0 ;drm/nouveau/nvkm/subdev/therm/base.c +14
-5@@ -24,22 +24,26 @@#include "priv.h" int -nvkm_therm_temp_get (struct nvkm_therm *therm) +nvkm_therm_temp_get (struct nvkm_therm *therm,int *val) {if (therm->func->temp_get) -return therm->func->temp_get (therm); +return therm->func->temp_get (therm, val);return -ENODEV ; }static int nvkm_therm_update_trip (struct nvkm_therm *therm) { +int temp, ret;struct nvbios_therm_trip_point *trip = therm->fan->bios.trip, *cur_trip =NULL , *last_trip = therm->last_trip; -u8 temp = therm->func->temp_get (therm);u16 duty, i; + ret = therm->func->temp_get (therm, &temp); +if (ret <0 ) +return ret; +/* look for the trip point corresponding to the current temperature */ cur_trip =NULL ;for (i =0 ; i < therm->fan->bios.nr_fan_trip; i++) {@@ -67,9 +71,13 @@ static int nvkm_therm_compute_linear_duty(struct nvkm_therm *therm, u8 linear_min_temp, u8 linear_max_temp) { - u8 temp = therm->func->temp_get(therm); + int temp, ret;u16 duty; + ret = therm->func->temp_get (therm, &temp); +if (ret <0 ) +return ret; +/* handle the non-linear part first */ if (temp < linear_min_temp)return therm->fan->bios.min_duty;@@ -182,6 +190,7 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode) {struct nvkm_subdev *subdev = &therm->subdev;struct nvkm_device *device = subdev->device; +int val;static const char *name[] = {"disabled" ,"manual" ,@@ -197,7 +206,7 @@ nvkm_therm_fan_mode(struct nvkm_therm *therm, int mode)/* do not allow automatic fan management if the thermal sensor is * not available */ if (mode ==NVKM_THERM_CTRL_AUTO && - therm->func->temp_get (therm) <0 ) + therm->func->temp_get (therm, &val))return -EINVAL ;if (therm->mode == mode)drm/nouveau/nvkm/subdev/therm/g84.c +8
-5@@ -27,14 +27,15 @@#include <subdev/fuse.h> int -g84_temp_get (struct nvkm_therm *therm) +g84_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device; -if (nvkm_fuse_read (device->fuse,0x1a8 ) ==1 ) -return nvkm_rd32 (device,0x20400 ); -else +if (nvkm_fuse_read (device->fuse,0x1a8 ) !=1 )return -ENODEV ; + + *val =nvkm_rd32 (device,0x20400 ); +return 0 ; }void @@ -114,8 +115,10 @@ g84_therm_threshold_hyst_emulation(struct nvkm_therm *therm, new_state =NVKM_THERM_THRS_LOWER ; } +if (therm->func->temp_get (therm, &cur)) +return ; +/* fix the state (in case someone reprogrammed the alarms) */ - cur = therm->func->temp_get (therm);if (new_state ==NVKM_THERM_THRS_LOWER && cur > thrs->temp) new_state =NVKM_THERM_THRS_HIGHER ; else if (new_state == NVKM_THERM_THRS_HIGHER &&drm/nouveau/nvkm/subdev/therm/gp100.c +5
-4@@ -24,7 +24,7 @@#include "priv.h" static int -gp100_temp_get (struct nvkm_therm *therm) +gp100_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvkm_subdev *subdev = &therm->subdev;@@ -36,9 +36,10 @@ gp100_temp_get(struct nvkm_therm *therm)nvkm_trace (subdev,"reading temperature from SHADOWed sensor\n" );/* device valid */ -if (tsensor &0x20000000 ) -return (inttemp >>8 ); -else +if (tsensor &0x20000000 ) { + *val = inttemp >>8 ; +return 0 ; + }else return -ENODEV ; }drm/nouveau/nvkm/subdev/therm/nv40.c +3
-6@@ -70,7 +70,7 @@ nv40_sensor_setup(struct nvkm_therm *therm) }static int -nv40_temp_get (struct nvkm_therm *therm) +nv40_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvbios_therm_sensor *sensor = &therm->bios_sensor;@@ -95,11 +95,8 @@ nv40_temp_get(struct nvkm_therm *therm) core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant -8 ; -/* reserve negative temperatures for errors */ -if (core_temp <0 ) - core_temp =0 ; - -return core_temp; + *val = core_temp; +return 0 ; } static intdrm/nouveau/nvkm/subdev/therm/nv50.c +3
-6@@ -126,7 +126,7 @@ nv50_sensor_setup(struct nvkm_therm *therm) }static int -nv50_temp_get (struct nvkm_therm *therm) +nv50_temp_get (struct nvkm_therm *therm,int *val) {struct nvkm_device *device = therm->subdev.device;struct nvbios_therm_sensor *sensor = &therm->bios_sensor;@@ -143,11 +143,8 @@ nv50_temp_get(struct nvkm_therm *therm) core_temp = core_temp + sensor->offset_num / sensor->offset_den; core_temp = core_temp + sensor->offset_constant -8 ; -/* reserve negative temperatures for errors */ -if (core_temp <0 ) - core_temp =0 ; - -return core_temp; + *val = core_temp; +return 0 ; } static voiddrm/nouveau/nvkm/subdev/therm/priv.h +2
-2@@ -91,7 +91,7 @@ struct nvkm_therm_func {int (*pwm_set)(struct nvkm_therm *,int line,u32 ,u32 );int (*pwm_clock)(struct nvkm_therm *,int line); -int (*temp_get)(struct nvkm_therm *); +int (*temp_get)(struct nvkm_therm *,int *);int (*fan_sense)(struct nvkm_therm *);@@ -105,7 +105,7 @@ int nv50_fan_pwm_get(struct nvkm_therm *, int, u32 *, u32 *);int nv50_fan_pwm_set (struct nvkm_therm *,int ,u32 ,u32 );int nv50_fan_pwm_clock (struct nvkm_therm *,int ); -int g84_temp_get (struct nvkm_therm *); +int g84_temp_get (struct nvkm_therm *,int *);void g84_sensor_setup (struct nvkm_therm *);void g84_therm_fini (struct nvkm_therm *);drm/nouveau/nvkm/subdev/therm/temp.c +12
-4@@ -86,7 +86,10 @@ nvkm_therm_sensor_event(struct nvkm_therm *therm, enum nvkm_therm_thrs thrs,static const char *const thresholds[] = {"fanboost" ,"downclock" ,"critical" ,"shutdown" }; -int temperature = therm->func->temp_get (therm); +int temperature; + +if (therm->func->temp_get (therm, &temperature)) +return ;if (thrs <0 || thrs >3 )return ;@@ -140,7 +143,10 @@ nvkm_therm_threshold_hyst_polling(struct nvkm_therm *therm, {enum nvkm_therm_thrs_direction direction;enum nvkm_therm_thrs_state prev_state, new_state; -int temp = therm->func->temp_get (therm); +int temp; + +if (therm->func->temp_get (therm, &temp)) +return ; prev_state =nvkm_therm_sensor_get_threshold_state (therm, thrs_name);@@ -166,6 +172,7 @@ alarm_timer_callback(struct nvkm_alarm *alarm)struct nvbios_therm_sensor *sensor = &therm->bios_sensor;struct nvkm_timer *tmr = therm->subdev.device->timer;unsigned long flags; +int val;spin_lock_irqsave (&therm->sensor.alarm_program_lock, flags);@@ -185,7 +192,7 @@ alarm_timer_callback(struct nvkm_alarm *alarm)spin_unlock_irqrestore (&therm->sensor.alarm_program_lock, flags);/* schedule the next poll in one second */ -if (therm->func->temp_get (therm) >=0 ) +if (!therm->func->temp_get (therm, &val))nvkm_timer_alarm (tmr,1000000000ULL , alarm); }@@ -227,9 +234,10 @@ nvkm_therm_sensor_fini(struct nvkm_therm *therm, bool suspend)void nvkm_therm_sensor_preinit (struct nvkm_therm *therm) { +int val;const char *sensor_avail ="yes" ; -if (therm->func->temp_get (therm) <0 ) +if (therm->func->temp_get (therm, &val)) sensor_avail ="no" ;
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
drm/nouveau/nvkm/subdev/therm/temp.c nvkm_therm_sensor_fini(struct nvkm_therm *therm, bool suspend) · line 243
Quoted 2 lines
drm/nouveau/nvkm/subdev/therm/temp.c +0
-0nvkm_debug (&therm->subdev,"internal sensor: %s\n" , sensor_avail);_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 4/32 hwmon: Properly check for errors
In reply to a message not in the archiveOtherwise hwmon interprets error codes as real values.
--- drm/nouveau/nouveau_hwmon.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-)
drm/nouveau/nouveau_hwmon.c +26 -7
@@ -470,18 +470,23 @@ nouveau_fan_read(struct device *dev, u32 attr, int channel, long *val)struct drm_device *drm_dev =dev_get_drvdata (dev);struct nouveau_drm *drm =nouveau_drm (drm_dev);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); +int ret;if (!therm)return -EOPNOTSUPP ;switch (attr) {case hwmon_fan_input: - *val =nvkm_therm_fan_sense (therm); + ret =nvkm_therm_fan_sense (therm);break ;default :return -EOPNOTSUPP ; } +if (ret <0 ) +return ret; + + *val = ret;return 0 ; }
@@ -491,7 +496,7 @@ nouveau_in_read(struct device *dev, u32 attr, int channel, long *val)struct drm_device *drm_dev =dev_get_drvdata (dev);struct nouveau_drm *drm =nouveau_drm (drm_dev);struct nvkm_volt *volt =nvxx_volt (&drm->client.device); -int ret; +int ret =0 ;if (!volt)return -EOPNOTSUPP ;
@@ -499,7 +504,8 @@ nouveau_in_read(struct device *dev, u32 attr, int channel, long *val)switch (attr) {case hwmon_in_input: ret =nvkm_volt_get (volt); - *val = ret <0 ? ret : (ret /1000 ); +if (ret >=0 ) + *val = ret /1000 ;break ;case hwmon_in_min: *val = volt->min_uv >0 ? (volt->min_uv /1000 ) : -ENODEV ;
@@ -511,7 +517,7 @@ nouveau_in_read(struct device *dev, u32 attr, int channel, long *val)return -EOPNOTSUPP ; } -return 0 ; +return ret; } static int
@@ -520,21 +526,26 @@ nouveau_pwm_read(struct device *dev, u32 attr, int channel, long *val)struct drm_device *drm_dev =dev_get_drvdata (dev);struct nouveau_drm *drm =nouveau_drm (drm_dev);struct nvkm_therm *therm =nvxx_therm (&drm->client.device); +int ret;if (!therm || !therm->attr_get || !therm->fan_get)return -EOPNOTSUPP ;switch (attr) {case hwmon_pwm_enable: - *val = therm->attr_get (therm,NVKM_THERM_ATTR_FAN_MODE ); + ret = therm->attr_get (therm,NVKM_THERM_ATTR_FAN_MODE );break ;case hwmon_pwm_input: - *val = therm->fan_get (therm); + ret = therm->fan_get (therm);break ;default :return -EOPNOTSUPP ; } +if (ret <0 ) +return ret; + + *val = ret;return 0 ; }
@@ -544,18 +555,26 @@ nouveau_power_read(struct device *dev, u32 attr, int channel, long *val)struct drm_device *drm_dev =dev_get_drvdata (dev);struct nouveau_drm *drm =nouveau_drm (drm_dev);struct nvkm_iccsense *iccsense =nvxx_iccsense (&drm->client.device); +int ret;if (!iccsense)return -EOPNOTSUPP ;switch (attr) {case hwmon_power_input: - *val =nvkm_iccsense_read_all (iccsense); + ret =nvkm_iccsense_read_all (iccsense); +if (ret <0 ) +return ret; + *val = ret;break ;case hwmon_power_max: +if (iccsense->power_w_max <=0 ) +return -ENODEV ; *val = iccsense->power_w_max;break ;case hwmon_power_crit: +if (iccsense->power_w_crit <=0 ) +return -ENODEV ; *val = iccsense->power_w_crit;break ;default :
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 5/32 clk: Improve names of pstate/cstate related variables and fields
In reply to a message not in the archiveFrom: Karol Herbst <[email protected]>
id: id of the state
idx: index of the state inside the parent list
pstate/cstate: the struct itself
--- drm/nouveau/include/nvkm/subdev/bios/boost.h | 2 +- drm/nouveau/include/nvkm/subdev/bios/perf.h | 2 +- drm/nouveau/include/nvkm/subdev/clk.h | 4 +- drm/nouveau/nouveau_debugfs.c | 14 +++--- drm/nouveau/nvkm/engine/device/ctrl.c | 4 +- drm/nouveau/nvkm/subdev/bios/boost.c | 11 +++-- drm/nouveau/nvkm/subdev/bios/perf.c | 2 +- drm/nouveau/nvkm/subdev/clk/base.c | 70 ++++++++++++++-------------- drm/nouveau/nvkm/subdev/clk/gk20a.c | 2 +- drm/nouveau/nvkm/subdev/pmu/gk20a.c | 4 +- 10 files changed, 59 insertions(+), 56 deletions(-)
drm/nouveau/include/nvkm/subdev/bios/boost.h +1 -1
@@ -3,7 +3,7 @@u32 nvbios_boostTe (struct nvkm_bios *,u8 *,u8 *,u8 *,u8 *,u8 *,u8 *);struct nvbios_boostE { -u8 pstate; +u8 pstate_id;u32 min;u32 max; };
drm/nouveau/include/nvkm/subdev/bios/perf.h +1 -1
@@ -4,7 +4,7 @@ u32 nvbios_perf_table(struct nvkm_bios *, u8 *ver, u8 *hdr, u8 *cnt, u8 *len, u8 *snr, u8 *ssz);struct nvbios_perfE { -u8 pstate; +u8 pstate_id;u8 fanspeed;u8 voltage;u32 core;
drm/nouveau/include/nvkm/subdev/clk.h +2 -2
@@ -63,7 +63,7 @@ struct nvkm_pstate {struct list_head head;struct list_head list;/* c-states */ struct nvkm_cstate base; -u8 pstate; +u8 id;u8 fanspeed;enum nvkm_pcie_speed pcie_speed;u8 pcie_width;
@@ -95,7 +95,7 @@ struct nvkm_clk {struct nvkm_notify pwrsrc_ntfy;int pwrsrc; -int pstate;/* current */ +int pstate_idx;/* current */ int ustate_ac;/* user-requested (-1 disabled, -2 perfmon) */ int ustate_dc;/* user-requested (-1 disabled, -2 perfmon) */ int astate;/* perfmon adjustment (base) */
drm/nouveau/nouveau_debugfs.c +7 -7
@@ -63,10 +63,10 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data)return ret;for (i =0 ; i < info.count +1 ; i++) { -const s32 state = i < info.count ? i : +const s32 state_idx = i < info.count ? i :NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT ;struct nvif_control_pstate_attr_v0 attr = { - .state = state, + .state = state_idx, .index =0 , };
@@ -83,7 +83,7 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data) attr.index =0 ; do { - attr.state = state; + attr.state = state_idx; ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_ATTR, &attr, sizeof(attr)); if (ret)
@@ -95,12 +95,12 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data)seq_printf (m," %s" , attr.unit); }while (attr.index); -if (state >=0 ) { -if (info.ustate_ac == state) +if (state_idx >=0 ) { +if (info.ustate_ac == state_idx)seq_printf (m," AC" ); -if (info.ustate_dc == state) +if (info.ustate_dc == state_idx)seq_printf (m," DC" ); -if (info.pstate == state) +if (info.pstate == state_idx)seq_printf (m," *" ); }else {if (info.ustate_ac <-1 )
drm/nouveau/nvkm/engine/device/ctrl.c +2 -2
@@ -52,7 +52,7 @@ nvkm_control_mthd_pstate_info(struct nvkm_control *ctrl, void *data, u32 size) args->v0.ustate_ac = clk->ustate_ac; args->v0.ustate_dc = clk->ustate_dc; args->v0.pwrsrc = clk->pwrsrc; - args->v0.pstate = clk->pstate; + args->v0.pstate = clk->pstate_idx; }else { args->v0.count =0 ; args->v0.ustate_ac =NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE ;
@@ -115,7 +115,7 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size) hi =max (hi, cstate->domain[domain->name]); } - args->v0.state = pstate->pstate; + args->v0.state = pstate->id; }else { lo =max (nvkm_clk_read (clk, domain->name),0 ); hi = lo;
drm/nouveau/nvkm/subdev/bios/boost.c +6 -5
@@ -78,20 +78,21 @@ nvbios_boostEp(struct nvkm_bios *bios, int idx,u32 data =nvbios_boostEe (bios, idx, ver, hdr, cnt, len);memset (info,0x00 ,sizeof (*info));if (data) { - info->pstate = (nvbios_rd16 (bios, data +0x00 ) &0x01e0 ) >>5 ; - info->min =nvbios_rd16 (bios, data +0x02 ) *1000 ; - info->max =nvbios_rd16 (bios, data +0x04 ) *1000 ; + info->pstate_id = + (nvbios_rd16 (bios, data +0x00 ) &0x01e0 ) >>5 ; + info->min =nvbios_rd16 (bios, data +0x02 ) *1000 ; + info->max =nvbios_rd16 (bios, data +0x04 ) *1000 ; }return data; }u32 -nvbios_boostEm (struct nvkm_bios *bios,u8 pstate, +nvbios_boostEm (struct nvkm_bios *bios,u8 pstate_id,u8 *ver,u8 *hdr,u8 *cnt,u8 *len,struct nvbios_boostE *info) {u32 data, idx =0 ;while ((data =nvbios_boostEp (bios, idx++, ver, hdr, cnt, len, info))) { -if (info->pstate == pstate) +if (info->pstate_id == pstate_id)break ; }return data;
drm/nouveau/nvkm/subdev/bios/perf.c +1 -1
@@ -97,7 +97,7 @@ nvbios_perfEp(struct nvkm_bios *bios, int idx, {u32 perf =nvbios_perf_entry (bios, idx, ver, hdr, cnt, len);memset (info,0x00 ,sizeof (*info)); - info->pstate =nvbios_rd08 (bios, perf +0x00 ); + info->pstate_id =nvbios_rd08 (bios, perf +0x00 );switch (!!perf * *ver) {case 0x12 :case 0x13 :
drm/nouveau/nvkm/subdev/clk/base.c +36 -34
197 lines not on this page · raw message
drm/nouveau/nvkm/subdev/clk/gk20a.c +1 -1
@@ -622,7 +622,7 @@ gk20a_clk_ctor(struct nvkm_device *device, int index,/* Finish initializing the pstates */ for (i =0 ; i < func->nr_pstates; i++) {INIT_LIST_HEAD (&func->pstates[i].list); - func->pstates[i].pstate = i +1 ; + func->pstates[i].id = i +1 ; } clk->params = params;
drm/nouveau/nvkm/subdev/pmu/gk20a.c +2 -2
@@ -60,7 +60,7 @@ gk20a_pmu_dvfs_get_cur_state(struct gk20a_pmu *pmu, int *state) {struct nvkm_clk *clk = pmu->base.subdev.device->clk; - *state = clk->pstate; + *state = clk->pstate_idx; } static int
@@ -72,7 +72,7 @@ gk20a_pmu_dvfs_get_target_state(struct gk20a_pmu *pmu,int cur_level, level;/* For GK20A, the performance level is directly mapped to pstate */ - level = cur_level = clk->pstate; + level = cur_level = clk->pstate_idx;if (load > data->p_load_max) { level =min (clk->state_nr -1 , level + (clk->state_nr /3 ));
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 6/32 clk: Add NVKM_CLK_PSTATE_BOOT
In reply to a message not in the archiveFrom: Karol Herbst <[email protected]>
It is better using a constant than -1.
--- drm/nouveau/include/nvkm/subdev/clk.h | 2 ++ drm/nouveau/nvkm/subdev/clk/base.c | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +2 -0
@@ -6,6 +6,8 @@struct nvbios_pll ;struct nvkm_pll_vals ; +#define NVKM_CLK_PSTATE_BOOT -1/* POSTed default */ +#define NVKM_CLK_CSTATE_DEFAULT -1/* POSTed default */ #define NVKM_CLK_CSTATE_BASE -2/* pstate base */ #define NVKM_CLK_CSTATE_HIGHEST -3/* highest possible */
drm/nouveau/nvkm/subdev/clk/base.c +5 -5
@@ -313,12 +313,12 @@ nvkm_pstate_work(struct work_struct *work) clk->astate, clk->temp, clk->dstate); pstate_idx = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc; -if (clk->state_nr && pstate_idx !=-1 ) { +if (clk->state_nr && pstate_idx !=NVKM_CLK_PSTATE_BOOT ) { pstate_idx = (pstate_idx <0 ) ? clk->astate : pstate_idx; pstate_idx =min (pstate_idx, clk->state_nr -1 ); pstate_idx =max (pstate_idx, clk->dstate); }else { - pstate_idx = clk->pstate_idx =-1 ; + pstate_idx = clk->pstate_idx =NVKM_CLK_PSTATE_BOOT ; }nvkm_trace (subdev,"-> %d\n" , pstate_idx);
@@ -618,7 +618,7 @@ nvkm_clk_init(struct nvkm_subdev *subdev) clk->astate = clk->state_nr -1 ; clk->dstate =0 ; - clk->pstate_idx =-1 ; + clk->pstate_idx =NVKM_CLK_PSTATE_BOOT ; clk->temp =90 ;/* reasonable default value */ nvkm_pstate_calc (clk, true);return 0 ;
@@ -673,8 +673,8 @@ nvkm_clk_ctor(const struct nvkm_clk_func *func, struct nvkm_device *device, clk->func = func;INIT_LIST_HEAD (&clk->states); clk->domains = func->domains; - clk->ustate_ac =-1 ; - clk->ustate_dc =-1 ; + clk->ustate_ac =NVKM_CLK_PSTATE_BOOT ; + clk->ustate_dc =NVKM_CLK_PSTATE_BOOT ; clk->allow_reclock = allow_reclock;INIT_WORK (&clk->work, nvkm_pstate_work);
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 7/32 clk: Rename NVKM_CLK_CSTATE_HIGHEST to NVKM_CLK_CSTATE_AUTO
In reply to a message not in the archiveFrom: Karol Herbst <[email protected]>
It is better describing what it is.
--- drm/nouveau/include/nvkm/subdev/clk.h | 2 +- drm/nouveau/nvkm/subdev/clk/base.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +1 -1
@@ -10,7 +10,7 @@ struct nvkm_pll_vals;#define NVKM_CLK_CSTATE_DEFAULT -1/* POSTed default */ #define NVKM_CLK_CSTATE_BASE -2/* pstate base */ -#define NVKM_CLK_CSTATE_HIGHEST -3/* highest possible */ +#define NVKM_CLK_CSTATE_AUTO -3/* highest possible */ enum nv_clk_src { nv_clk_src_crystal,
drm/nouveau/nvkm/subdev/clk/base.c +2 -2
@@ -147,7 +147,7 @@ static struct nvkm_cstate * nvkm_cstate_get(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstate_id) { struct nvkm_cstate *cstate; -if (cstate_id ==NVKM_CLK_CSTATE_HIGHEST ) +if (cstate_id ==NVKM_CLK_CSTATE_AUTO )return list_last_entry (&pstate->list,typeof (*cstate), head);else {list_for_each_entry (cstate, &pstate->list, head) {
@@ -294,7 +294,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstate_idx) ram->func->tidy (ram); } -return nvkm_cstate_prog (clk, pstate,NVKM_CLK_CSTATE_HIGHEST ); +return nvkm_cstate_prog (clk, pstate,NVKM_CLK_CSTATE_AUTO ); } static void
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 8/32 clk: Rename nvkm_clk.states to pstates
In reply to a message not in the archiveFrom: Karol Herbst <[email protected]>
Those are pstates, so call them that way.
--- drm/nouveau/include/nvkm/subdev/clk.h | 4 ++-- drm/nouveau/nvkm/engine/device/ctrl.c | 6 +++--- drm/nouveau/nvkm/subdev/clk/base.c | 26 +++++++++++++------------- drm/nouveau/nvkm/subdev/pmu/gk20a.c | 5 +++-- 4 files changed, 21 insertions(+), 20 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +2 -2
@@ -88,8 +88,8 @@ struct nvkm_clk {const struct nvkm_domain *domains;struct nvkm_pstate bstate; -struct list_head states; -int state_nr; +struct list_head pstates; +int pstates_cnt;struct work_struct work;wait_queue_head_t wait;
drm/nouveau/nvkm/engine/device/ctrl.c +3 -3
@@ -48,7 +48,7 @@ nvkm_control_mthd_pstate_info(struct nvkm_control *ctrl, void *data, u32 size)return ret;if (clk) { - args->v0.count = clk->state_nr; + args->v0.count = clk->pstates_cnt; args->v0.ustate_ac = clk->ustate_ac; args->v0.ustate_dc = clk->ustate_dc; args->v0.pwrsrc = clk->pwrsrc;
@@ -87,7 +87,7 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)return -ENODEV ;if (args->v0.state <NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT )return -EINVAL ; -if (args->v0.state >= clk->state_nr) +if (args->v0.state >= clk->pstates_cnt)return -EINVAL ; }else return ret;
@@ -103,7 +103,7 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)return -EINVAL ;if (args->v0.state !=NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT ) { -list_for_each_entry (pstate, &clk->states, head) { +list_for_each_entry (pstate, &clk->pstates, head) {if (i++ == args->v0.state)break ; }
drm/nouveau/nvkm/subdev/clk/base.c +13 -13
@@ -273,7 +273,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstate_idx)struct nvkm_pstate *pstate;int ret, idx =0 ; -list_for_each_entry (pstate, &clk->states, head) { +list_for_each_entry (pstate, &clk->pstates, head) {if (idx++ == pstate_idx)break ; }
@@ -313,9 +313,9 @@ nvkm_pstate_work(struct work_struct *work) clk->astate, clk->temp, clk->dstate); pstate_idx = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc; -if (clk->state_nr && pstate_idx !=NVKM_CLK_PSTATE_BOOT ) { +if (clk->pstates_cnt && pstate_idx !=NVKM_CLK_PSTATE_BOOT ) { pstate_idx = (pstate_idx <0 ) ? clk->astate : pstate_idx; - pstate_idx =min (pstate_idx, clk->state_nr -1 ); + pstate_idx =min (pstate_idx, clk->pstates_cnt -1 ); pstate_idx =max (pstate_idx, clk->dstate); }else { pstate_idx = clk->pstate_idx =NVKM_CLK_PSTATE_BOOT ;
@@ -463,8 +463,8 @@ nvkm_pstate_new(struct nvkm_clk *clk, int idx) }nvkm_pstate_info (clk, pstate); -list_add_tail (&pstate->head, &clk->states); - clk->state_nr++; +list_add_tail (&pstate->head, &clk->pstates); + clk->pstates_cnt++;return 0 ; }
@@ -481,7 +481,7 @@ nvkm_clk_ustate_update(struct nvkm_clk *clk, int req)return -ENOSYS ;if (req !=-1 && req !=-2 ) { -list_for_each_entry (pstate, &clk->states, head) { +list_for_each_entry (pstate, &clk->pstates, head) {if (pstate->id == req)break ; i++;
@@ -536,7 +536,7 @@ nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait) {if (!rel) clk->astate = req;if ( rel) clk->astate += rel; - clk->astate =min (clk->astate, clk->state_nr -1 ); + clk->astate =min (clk->astate, clk->pstates_cnt -1 ); clk->astate =max (clk->astate,0 );return nvkm_pstate_calc (clk, wait); }
@@ -555,7 +555,7 @@ nvkm_clk_dstate(struct nvkm_clk *clk, int req, int rel) {if (!rel) clk->dstate = req;if ( rel) clk->dstate += rel; - clk->dstate =min (clk->dstate, clk->state_nr -1 ); + clk->dstate =min (clk->dstate, clk->pstates_cnt -1 ); clk->dstate =max (clk->dstate,0 );return nvkm_pstate_calc (clk, true); }
@@ -616,7 +616,7 @@ nvkm_clk_init(struct nvkm_subdev *subdev)if (clk->func->init)return clk->func->init (clk); - clk->astate = clk->state_nr -1 ; + clk->astate = clk->pstates_cnt -1 ; clk->dstate =0 ; clk->pstate_idx =NVKM_CLK_PSTATE_BOOT ; clk->temp =90 ;/* reasonable default value */
@@ -636,7 +636,7 @@ nvkm_clk_dtor(struct nvkm_subdev *subdev)if (clk->func->pstates)return clk; -list_for_each_entry_safe (pstate, temp, &clk->states, head) { +list_for_each_entry_safe (pstate, temp, &clk->pstates, head) {nvkm_pstate_del (pstate); }
@@ -671,7 +671,7 @@ nvkm_clk_ctor(const struct nvkm_clk_func *func, struct nvkm_device *device, } clk->func = func; -INIT_LIST_HEAD (&clk->states); +INIT_LIST_HEAD (&clk->pstates); clk->domains = func->domains; clk->ustate_ac =NVKM_CLK_PSTATE_BOOT ; clk->ustate_dc =NVKM_CLK_PSTATE_BOOT ;
@@ -689,8 +689,8 @@ nvkm_clk_ctor(const struct nvkm_clk_func *func, struct nvkm_device *device, }while (ret ==0 ); }else {for (idx =0 ; idx < func->nr_pstates; idx++) -list_add_tail (&func->pstates[idx].head, &clk->states); - clk->state_nr = func->nr_pstates; +list_add_tail (&func->pstates[idx].head, &clk->pstates); + clk->pstates_cnt = func->nr_pstates; } ret = nvkm_notify_init(NULL, &device->event, nvkm_clk_pwrsrc, true,
drm/nouveau/nvkm/subdev/pmu/gk20a.c +3 -2
@@ -75,12 +75,13 @@ gk20a_pmu_dvfs_get_target_state(struct gk20a_pmu *pmu, level = cur_level = clk->pstate_idx;if (load > data->p_load_max) { - level =min (clk->state_nr -1 , level + (clk->state_nr /3 )); + level =min (clk->pstates_cnt -1 , + level + (clk->pstates_cnt /3 )); }else { level += ((load - data->p_load_target) *10 / data->p_load_target) /2 ; level =max (0 , level); - level =min (clk->state_nr -1 , level); + level =min (clk->pstates_cnt -1 , level); } nvkm_trace(&pmu->base.subdev, "cur level = %d, new level = %d\n",
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 9/32 clk: Rename nvkm_pstate.list to cstates
In reply to a message not in the archiveFrom: Karol Herbst <[email protected]>
It was always confusing that the list was called list.
--- drm/nouveau/include/nvkm/subdev/clk.h | 2 +- drm/nouveau/nvkm/engine/device/ctrl.c | 2 +- drm/nouveau/nvkm/subdev/clk/base.c | 18 +++++++++--------- drm/nouveau/nvkm/subdev/clk/gk20a.c | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +1 -1
@@ -63,7 +63,7 @@ struct nvkm_cstate {struct nvkm_pstate {struct list_head head; -struct list_head list;/* c-states */ +struct list_head cstates;/* c-states */ struct nvkm_cstate base;u8 id;u8 fanspeed;
drm/nouveau/nvkm/engine/device/ctrl.c +1 -1
@@ -110,7 +110,7 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size) lo = pstate->base.domain[domain->name]; hi = lo; -list_for_each_entry (cstate, &pstate->list, head) { +list_for_each_entry (cstate, &pstate->cstates, head) { lo =min (lo, cstate->domain[domain->name]); hi =max (hi, cstate->domain[domain->name]); }
drm/nouveau/nvkm/subdev/clk/base.c +9 -9
@@ -134,7 +134,7 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate, max_volt =min (max_volt,nvkm_volt_map (volt, volt->max2_id, clk->temp)); -for (cstate = start; &cstate->head != &pstate->list; +for (cstate = start; &cstate->head != &pstate->cstates; cstate =list_entry (cstate->head.prev,typeof (*cstate), head)) {if (nvkm_cstate_valid (clk, cstate, max_volt, clk->temp))break ;
@@ -148,9 +148,9 @@ nvkm_cstate_get(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstate_id) {struct nvkm_cstate *cstate;if (cstate_id ==NVKM_CLK_CSTATE_AUTO ) -return list_last_entry (&pstate->list,typeof (*cstate), head); +return list_last_entry (&pstate->cstates,typeof (*cstate), head);else { -list_for_each_entry (cstate, &pstate->list, head) { +list_for_each_entry (cstate, &pstate->cstates, head) {if (cstate->id == cstate_id)return cstate; }
@@ -169,7 +169,7 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate,struct nvkm_cstate *cstate;int ret; -if (!list_empty (&pstate->list)) { +if (!list_empty (&pstate->cstates)) { cstate =nvkm_cstate_get (clk, pstate, cstate_id); cstate =nvkm_cstate_find_best (clk, pstate, cstate); }else {
@@ -257,7 +257,7 @@ nvkm_cstate_new(struct nvkm_clk *clk, int idx, struct nvkm_pstate *pstate) domain++; } -list_add (&cstate->head, &pstate->list); +list_add (&cstate->head, &pstate->cstates);return 0 ; }
@@ -364,7 +364,7 @@ nvkm_pstate_info(struct nvkm_clk *clk, struct nvkm_pstate *pstate)continue ;nvkm_debug (subdev,"%02x: %10d KHz\n" , clock->name, lo); -list_for_each_entry (cstate, &pstate->list, head) { +list_for_each_entry (cstate, &pstate->cstates, head) {u32 freq = cstate->domain[clock->name]; lo =min (lo, freq); hi =max (hi, freq);
@@ -392,7 +392,7 @@ nvkm_pstate_del(struct nvkm_pstate *pstate) {struct nvkm_cstate *cstate, *temp; -list_for_each_entry_safe (cstate, temp, &pstate->list, head) { +list_for_each_entry_safe (cstate, temp, &pstate->cstates, head) {nvkm_cstate_del (cstate); }
@@ -423,7 +423,7 @@ nvkm_pstate_new(struct nvkm_clk *clk, int idx)if (!pstate)return -ENOMEM ; -INIT_LIST_HEAD (&pstate->list); +INIT_LIST_HEAD (&pstate->cstates); pstate->id = perfE.pstate_id; pstate->fanspeed = perfE.fanspeed;
@@ -598,7 +598,7 @@ nvkm_clk_init(struct nvkm_subdev *subdev)int ret;memset (&clk->bstate,0x00 ,sizeof (clk->bstate)); -INIT_LIST_HEAD (&clk->bstate.list); +INIT_LIST_HEAD (&clk->bstate.cstates); clk->bstate.id =0xff ;while (clock->name != nv_clk_src_max) {
drm/nouveau/nvkm/subdev/clk/gk20a.c +1 -1
@@ -621,7 +621,7 @@ gk20a_clk_ctor(struct nvkm_device *device, int index,/* Finish initializing the pstates */ for (i =0 ; i < func->nr_pstates; i++) { -INIT_LIST_HEAD (&func->pstates[i].list); +INIT_LIST_HEAD (&func->pstates[i].cstates); func->pstates[i].id = i +1 ; }
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 10/32 clk: Remove dstate
In reply to a message not in the archiveWe won't need it now, because we will adjust the clocks depending on engine loads later on anyway or a static lookup table. It also simplifies the clocking logic.
This code was nowhere used anyway and just a mock up.
v2: fixed typo in commit message
--- drm/nouveau/include/nvkm/subdev/clk.h | 2 -- drm/nouveau/nvkm/subdev/clk/base.c | 16 ++-------------- 2 files changed, 2 insertions(+), 16 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +0 -2
@@ -101,7 +101,6 @@ struct nvkm_clk {int ustate_ac;/* user-requested (-1 disabled, -2 perfmon) */ int ustate_dc;/* user-requested (-1 disabled, -2 perfmon) */ int astate;/* perfmon adjustment (base) */ -int dstate;/* display adjustment (min+) */ int temp;bool allow_reclock;
@@ -123,7 +122,6 @@ struct nvkm_clk {int nvkm_clk_read (struct nvkm_clk *,enum nv_clk_src );int nvkm_clk_ustate (struct nvkm_clk *,int req,int pwr);int nvkm_clk_astate (struct nvkm_clk *,int req,int rel,bool wait); -int nvkm_clk_dstate (struct nvkm_clk *,int req,int rel);int nvkm_clk_tstate (struct nvkm_clk *,int temperature);int nv04_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);
drm/nouveau/nvkm/subdev/clk/base.c +2 -14
@@ -308,15 +308,14 @@ nvkm_pstate_work(struct work_struct *work)return ; clk->pwrsrc =power_supply_is_system_supplied (); -nvkm_trace (subdev,"P %d PWR %d U(AC) %d U(DC) %d A %d T %d°C D %d\n" , +nvkm_trace (subdev,"P %d PWR %d U(AC) %d U(DC) %d A %d T %d°C\n" , clk->pstate_idx, clk->pwrsrc, clk->ustate_ac, clk->ustate_dc, - clk->astate, clk->temp, clk->dstate); + clk->astate, clk->temp); pstate_idx = clk->pwrsrc ? clk->ustate_ac : clk->ustate_dc;if (clk->pstates_cnt && pstate_idx !=NVKM_CLK_PSTATE_BOOT ) { pstate_idx = (pstate_idx <0 ) ? clk->astate : pstate_idx; pstate_idx =min (pstate_idx, clk->pstates_cnt -1 ); - pstate_idx =max (pstate_idx, clk->dstate); }else { pstate_idx = clk->pstate_idx =NVKM_CLK_PSTATE_BOOT ; }
@@ -550,16 +549,6 @@ nvkm_clk_tstate(struct nvkm_clk *clk, int temp)return nvkm_pstate_calc (clk, false); } -int -nvkm_clk_dstate (struct nvkm_clk *clk,int req,int rel) -{ -if (!rel) clk->dstate = req; -if ( rel) clk->dstate += rel; - clk->dstate =min (clk->dstate, clk->pstates_cnt -1 ); - clk->dstate =max (clk->dstate,0 ); -return nvkm_pstate_calc (clk, true); -} -static int nvkm_clk_pwrsrc (struct nvkm_notify *notify) {
@@ -617,7 +606,6 @@ nvkm_clk_init(struct nvkm_subdev *subdev)return clk->func->init (clk); clk->astate = clk->pstates_cnt -1 ; - clk->dstate =0 ; clk->pstate_idx =NVKM_CLK_PSTATE_BOOT ; clk->temp =90 ;/* reasonable default value */ nvkm_pstate_calc (clk, true);
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 11/32 clk: Rename nvkm_pstate_calc to nvkm_clk_update and export it
In reply to a message not in the archiveThis function will be used to update the current clock state.
This will happen for various reasons:
* Temperature changes
* User changes clocking state
* Load changes
v2: remove parameter name
--- drm/nouveau/include/nvkm/subdev/clk.h | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +1 -0
@@ -123,6 +123,7 @@ int nvkm_clk_read(struct nvkm_clk *, enum nv_clk_src);int nvkm_clk_ustate (struct nvkm_clk *,int req,int pwr);int nvkm_clk_astate (struct nvkm_clk *,int req,int rel,bool wait);int nvkm_clk_tstate (struct nvkm_clk *,int temperature); +int nvkm_clk_update (struct nvkm_clk *,bool wait);int nv04_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);int nv40_clk_new (struct nvkm_device *,int ,struct nvkm_clk **);
drm/nouveau/nvkm/subdev/clk/base.c +15 -9
@@ -298,7 +298,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstate_idx) }static void -nvkm_pstate_work (struct work_struct *work) +nvkm_clk_update_work (struct work_struct *work) {struct nvkm_clk *clk =container_of (work,typeof (*clk), work);struct nvkm_subdev *subdev = &clk->subdev;
@@ -333,9 +333,15 @@ nvkm_pstate_work(struct work_struct *work)nvkm_notify_get (&clk->pwrsrc_ntfy); } -static int -nvkm_pstate_calc (struct nvkm_clk *clk,bool wait) +int +nvkm_clk_update (struct nvkm_clk *clk,bool wait) { +if (!clk) +return -EINVAL ; + +if (!clk->allow_reclock) +return -ENODEV ; +atomic_set (&clk->waiting,1 );schedule_work (&clk->work);if (wait)
@@ -525,7 +531,7 @@ nvkm_clk_ustate(struct nvkm_clk *clk, int req, int pwr)if (ret >=0 ) {if (ret -=2 , pwr) clk->ustate_ac = ret;else clk->ustate_dc = ret; -return nvkm_pstate_calc (clk, true); +return nvkm_clk_update (clk, true); }return ret; }
@@ -537,7 +543,7 @@ nvkm_clk_astate(struct nvkm_clk *clk, int req, int rel, bool wait)if ( rel) clk->astate += rel; clk->astate =min (clk->astate, clk->pstates_cnt -1 ); clk->astate =max (clk->astate,0 ); -return nvkm_pstate_calc (clk, wait); +return nvkm_clk_update (clk, wait); }int
@@ -546,7 +552,7 @@ nvkm_clk_tstate(struct nvkm_clk *clk, int temp)if (clk->temp == temp)return 0 ; clk->temp = temp; -return nvkm_pstate_calc (clk, false); +return nvkm_clk_update (clk, false); } static int
@@ -554,7 +560,7 @@ nvkm_clk_pwrsrc(struct nvkm_notify *notify) {struct nvkm_clk *clk =container_of (notify,typeof (*clk), pwrsrc_ntfy); -nvkm_pstate_calc (clk, false); +nvkm_clk_update (clk, false);return NVKM_NOTIFY_DROP ; }
@@ -608,7 +614,7 @@ nvkm_clk_init(struct nvkm_subdev *subdev) clk->astate = clk->pstates_cnt -1 ; clk->pstate_idx =NVKM_CLK_PSTATE_BOOT ; clk->temp =90 ;/* reasonable default value */ -nvkm_pstate_calc (clk, true); +nvkm_clk_update (clk, true);return 0 ; }
@@ -665,7 +671,7 @@ nvkm_clk_ctor(const struct nvkm_clk_func *func, struct nvkm_device *device, clk->ustate_dc =NVKM_CLK_PSTATE_BOOT ; clk->allow_reclock = allow_reclock; -INIT_WORK (&clk->work, nvkm_pstate_work); +INIT_WORK (&clk->work, nvkm_clk_update_work);init_waitqueue_head (&clk->wait);atomic_set (&clk->waiting,0 );
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 12/32 clk: Use list_for_each_entry_from_reverse in nvkm_cstate_find_best
In reply to a message not in the archiveFrom: Karol Herbst <[email protected]>
--- drm/nouveau/nvkm/subdev/clk/base.c | 10 ++++------ lib/include/nvif/list.h | 5 +++++ 2 files changed, 9 insertions(+), 6 deletions(-)
drm/nouveau/nvkm/subdev/clk/base.c +4 -6
@@ -110,18 +110,17 @@ nvkm_cstate_valid(struct nvkm_clk *clk, struct nvkm_cstate *cstate,static struct nvkm_cstate *nvkm_cstate_find_best (struct nvkm_clk *clk,struct nvkm_pstate *pstate, -struct nvkm_cstate *start) +struct nvkm_cstate *cstate) {struct nvkm_device *device = clk->subdev.device;struct nvkm_volt *volt = device->volt; -struct nvkm_cstate *cstate;int max_volt; -if (!pstate || !start) +if (!pstate || !cstate)return NULL ;if (!volt) -return start; +return cstate; max_volt = volt->max_uv;if (volt->max0_id !=0xff )
@@ -134,8 +133,7 @@ nvkm_cstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate, max_volt =min (max_volt,nvkm_volt_map (volt, volt->max2_id, clk->temp)); -for (cstate = start; &cstate->head != &pstate->cstates; - cstate =list_entry (cstate->head.prev,typeof (*cstate), head)) { +list_for_each_entry_from_reverse (cstate, &pstate->cstates, head) {if (nvkm_cstate_valid (clk, cstate, max_volt, clk->temp))break ; }
lib/include/nvif/list.h +5 -0
@@ -355,4 +355,9 @@ list_empty(struct list_head *head) &pos->member != (head); \ pos = __container_of(pos->member.next, pos, member)) +#define list_for_each_entry_from_reverse (pos, head, member) \ + for (; \ + &pos->member != (head); \ + pos = __container_of(pos->member.prev, pos, member)) +#endif
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 13/32 clk: We should pass the pstate id around not the index in the list
In reply to a message not in the archiveThis makes the code easier, because we can compare the id with pstate->id.
v2: reword commit message
--- drm/nouveau/include/nvkm/subdev/clk.h | 2 +- drm/nouveau/nouveau_debugfs.c | 6 +-- drm/nouveau/nvkm/engine/device/ctrl.c | 2 +- drm/nouveau/nvkm/subdev/clk/base.c | 98 ++++++++++++++++------------------- drm/nouveau/nvkm/subdev/pmu/gk20a.c | 4 +- 5 files changed, 52 insertions(+), 60 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +1 -1
@@ -97,7 +97,7 @@ struct nvkm_clk {struct nvkm_notify pwrsrc_ntfy;int pwrsrc; -int pstate_idx;/* current */ +int pstate_id;/* current */ int ustate_ac;/* user-requested (-1 disabled, -2 perfmon) */ int ustate_dc;/* user-requested (-1 disabled, -2 perfmon) */ int astate;/* perfmon adjustment (base) */
drm/nouveau/nouveau_debugfs.c +3 -3
@@ -96,11 +96,11 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data) }while (attr.index);if (state_idx >=0 ) { -if (info.ustate_ac == state_idx) +if (info.ustate_ac == attr.state)seq_printf (m," AC" ); -if (info.ustate_dc == state_idx) +if (info.ustate_dc == attr.state)seq_printf (m," DC" ); -if (info.pstate == state_idx) +if (info.pstate == attr.state)seq_printf (m," *" ); }else {if (info.ustate_ac <-1 )
drm/nouveau/nvkm/engine/device/ctrl.c +1 -1
@@ -52,7 +52,7 @@ nvkm_control_mthd_pstate_info(struct nvkm_control *ctrl, void *data, u32 size) args->v0.ustate_ac = clk->ustate_ac; args->v0.ustate_dc = clk->ustate_dc; args->v0.pwrsrc = clk->pwrsrc; - args->v0.pstate = clk->pstate_idx; + args->v0.pstate = clk->pstate_id; }else { args->v0.count =0 ; args->v0.ustate_ac =NVIF_CONTROL_PSTATE_INFO_V0_USTATE_DISABLE ;
drm/nouveau/nvkm/subdev/clk/base.c +45 -53
160 lines not on this page · raw message
drm/nouveau/nvkm/subdev/pmu/gk20a.c +2 -2
@@ -60,7 +60,7 @@ gk20a_pmu_dvfs_get_cur_state(struct gk20a_pmu *pmu, int *state) {struct nvkm_clk *clk = pmu->base.subdev.device->clk; - *state = clk->pstate_idx; + *state = clk->pstate_id; } static int
@@ -72,7 +72,7 @@ gk20a_pmu_dvfs_get_target_state(struct gk20a_pmu *pmu,int cur_level, level;/* For GK20A, the performance level is directly mapped to pstate */ - level = cur_level = clk->pstate_idx; + level = cur_level = clk->pstate_id;if (load > data->p_load_max) { level = min(clk->pstates_cnt - 1,
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 14/32 clk: Hold information about the current cstate status
In reply to a message not in the archiveLater we will have situations where the expected and the current state isn't the same.
--- drm/nouveau/include/nvkm/subdev/clk.h | 9 +++++---- drm/nouveau/nvkm/subdev/clk/base.c | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +5 -4
@@ -6,11 +6,11 @@struct nvbios_pll ;struct nvkm_pll_vals ; -#define NVKM_CLK_PSTATE_BOOT -1/* POSTed default */ +#define NVKM_CLK_PSTATE_BOOT -1/* POSTed default */ -#define NVKM_CLK_CSTATE_DEFAULT -1/* POSTed default */ -#define NVKM_CLK_CSTATE_BASE -2/* pstate base */ -#define NVKM_CLK_CSTATE_AUTO -3/* highest possible */ +#define NVKM_CLK_CSTATE_BOOT -1/* POSTed default */ +#define NVKM_CLK_CSTATE_BASE -2/* pstate base */ +#define NVKM_CLK_CSTATE_AUTO -3/* highest possible */ enum nv_clk_src { nv_clk_src_crystal,
@@ -101,6 +101,7 @@ struct nvkm_clk {int ustate_ac;/* user-requested (-1 disabled, -2 perfmon) */ int ustate_dc;/* user-requested (-1 disabled, -2 perfmon) */ int astate;/* perfmon adjustment (base) */ +int cstate_id;int temp;bool allow_reclock;
drm/nouveau/nvkm/subdev/clk/base.c +5 -0
@@ -167,6 +167,9 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate,struct nvkm_cstate *cstate;int ret; +if (cstate_id ==NVKM_CLK_CSTATE_BOOT ) +return 0 ; +if (!list_empty (&pstate->cstates)) { cstate =nvkm_cstate_get (clk, pstate, cstate_id); cstate =nvkm_cstate_find_best (clk, pstate, cstate);
@@ -196,6 +199,7 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, ret = clk->func->prog (clk); clk->func->tidy (clk); } + clk->cstate_id = cstate->id;if (volt) { ret = nvkm_volt_set_id(volt, cstate->voltage,
@@ -603,6 +607,7 @@ nvkm_clk_init(struct nvkm_subdev *subdev) clk->astate =NVKM_CLK_PSTATE_BOOT ; clk->pstate_id =NVKM_CLK_PSTATE_BOOT ; + clk->cstate_id =NVKM_CLK_CSTATE_BOOT ; clk->temp =90 ;/* reasonable default value */ nvkm_clk_update (clk, true);return 0 ;
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 15/32 clk: Refactor the base and boost clock limits so that we can limit pstates
In reply to a message not in the archive--- drm/nouveau/include/nvkm/subdev/clk.h | 9 +++++-- drm/nouveau/nvkm/subdev/clk/base.c | 51 +++++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 19 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +7 -2
@@ -81,6 +81,11 @@ struct nvkm_domain {int mdiv; }; +struct nvkm_clk_limit { +u8 pstate; +u32 max_khz; +}; +struct nvkm_clk {const struct nvkm_clk_func *func;struct nvkm_subdev subdev;
@@ -109,8 +114,8 @@ struct nvkm_clk {#define NVKM_CLK_BOOST_BIOS 0x1#define NVKM_CLK_BOOST_FULL 0x2u8 boost_mode; -u32 base_khz; -u32 boost_khz; +struct nvkm_clk_limit base_limit; +struct nvkm_clk_limit boost_limit;/*XXX: die, these are here *only* to support the completely * bat-shit insane what-was-nouveau_hw.c code
drm/nouveau/nvkm/subdev/clk/base.c +34 -17
71 lines not on this page · raw message
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 16/32 therm: Move the temp readout into nvkm_therm_update
In reply to a message not in the archiveIt makes more sense to read out the temperature in the alarm, because we want to do various things with it:
1. adjust the fans
2. notify the clk subdev about the changed temperature
v2: move into nvkm_therm_update
--- drm/nouveau/nvkm/subdev/therm/base.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-)
drm/nouveau/nvkm/subdev/therm/base.c +14 -20
@@ -32,18 +32,13 @@ nvkm_therm_temp_get(struct nvkm_therm *therm, int *val) }static int -nvkm_therm_update_trip (struct nvkm_therm *therm) +nvkm_therm_update_trip (struct nvkm_therm *therm,int temp) { -int temp, ret;struct nvbios_therm_trip_point *trip = therm->fan->bios.trip, *cur_trip =NULL , *last_trip = therm->last_trip;u16 duty, i; - ret = therm->func->temp_get (therm, &temp); -if (ret <0 ) -return ret; -/* look for the trip point corresponding to the current temperature */ cur_trip =NULL ;for (i =0 ; i < therm->fan->bios.nr_fan_trip; i++) {
@@ -69,15 +64,10 @@ nvkm_therm_update_trip(struct nvkm_therm *therm)static int nvkm_therm_compute_linear_duty (struct nvkm_therm *therm,u8 linear_min_temp, -u8 linear_max_temp) +u8 linear_max_temp,int temp) { -int temp, ret;u16 duty; - ret = therm->func->temp_get (therm, &temp); -if (ret <0 ) -return ret; -/* handle the non-linear part first */ if (temp < linear_min_temp)return therm->fan->bios.min_duty;
@@ -93,18 +83,18 @@ nvkm_therm_compute_linear_duty(struct nvkm_therm *therm, u8 linear_min_temp, }static int -nvkm_therm_update_linear (struct nvkm_therm *therm) +nvkm_therm_update_linear (struct nvkm_therm *therm,int temp) {u8 min = therm->fan->bios.linear_min_temp;u8 max = therm->fan->bios.linear_max_temp; -return nvkm_therm_compute_linear_duty (therm, min, max); +return nvkm_therm_compute_linear_duty (therm, min, max, temp); }static int -nvkm_therm_update_linear_fallback (struct nvkm_therm *therm) +nvkm_therm_update_linear_fallback (struct nvkm_therm *therm,int temp) {u8 max = therm->bios_sensor.thrs_fan_boost.temp; -return nvkm_therm_compute_linear_duty (therm,30 , max); +return nvkm_therm_compute_linear_duty (therm,30 , max, temp); } static void
@@ -116,6 +106,10 @@ nvkm_therm_update(struct nvkm_therm *therm, int mode)bool immd = true;bool poll = true;int duty =-1 ; +int temp; + +if (nvkm_therm_temp_get (therm, &temp)) +return ;spin_lock_irqsave (&therm->lock, flags);if (mode <0 )
@@ -133,17 +127,17 @@ nvkm_therm_update(struct nvkm_therm *therm, int mode)case NVKM_THERM_CTRL_AUTO :switch (therm->fan->bios.fan_mode) {case NVBIOS_THERM_FAN_TRIP : - duty =nvkm_therm_update_trip (therm); + duty =nvkm_therm_update_trip (therm, temp);break ;case NVBIOS_THERM_FAN_LINEAR : - duty =nvkm_therm_update_linear (therm); + duty =nvkm_therm_update_linear (therm, temp);break ;case NVBIOS_THERM_FAN_OTHER :if (therm->cstate) duty = therm->cstate;else - duty =nvkm_therm_update_linear_fallback (therm); - poll = false; + duty =nvkm_therm_update_linear_fallback (therm, + temp);break ; } immd = false;
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 17/32 core/device: Move therm behind clk
In reply to a message not in the archiveLater therm will depend on clk reporting new temperatures and triggereing reclocks for thermal throttling or therm related voltage/clock adjustments.
--- drm/nouveau/include/nvkm/core/device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drm/nouveau/include/nvkm/core/device.h +1 -1
@@ -24,8 +24,8 @@ enum nvkm_devidx {NVKM_SUBDEV_PMU ,NVKM_SUBDEV_VOLT ,NVKM_SUBDEV_ICCSENSE , -NVKM_SUBDEV_THERM ,NVKM_SUBDEV_CLK , +NVKM_SUBDEV_THERM ,NVKM_SUBDEV_SECBOOT , NVKM_ENGINE_BSP,
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 18/32 therm: Trigger reclock in temperature daemon
In reply to a message not in the archiveDepending on the temperature, cstates might become unreachable or the maped voltage of a cstate changes. We want to adjust to that.
--- drm/nouveau/nvkm/subdev/therm/base.c | 6 ++++++ 1 file changed, 6 insertions(+)
drm/nouveau/nvkm/subdev/therm/base.c +6 -0
@@ -23,6 +23,8 @@*/ #include "priv.h" +#include <subdev/clk.h> +int nvkm_therm_temp_get (struct nvkm_therm *therm,int *val) {
@@ -102,6 +104,7 @@ nvkm_therm_update(struct nvkm_therm *therm, int mode) {struct nvkm_subdev *subdev = &therm->subdev;struct nvkm_timer *tmr = subdev->device->timer; +struct nvkm_clk *clk = subdev->device->clk;unsigned long flags;bool immd = true;bool poll = true;
@@ -156,6 +159,9 @@ nvkm_therm_update(struct nvkm_therm *therm, int mode)nvkm_debug (subdev,"FAN target request: %d%%\n" , duty);nvkm_therm_fan_set (therm, immd, duty); } + +if (clk) +nvkm_clk_tstate (clk, temp); }int
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 19/32 bios: Add thermal policies table
In reply to a message not in the archive--- .../include/nvkm/subdev/bios/thermal_policies.h | 25 +++++++ drm/nouveau/nvkm/subdev/bios/Kbuild | 1 + drm/nouveau/nvkm/subdev/bios/thermal_policies.c | 81 ++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 drm/nouveau/include/nvkm/subdev/bios/thermal_policies.h create mode 100644 drm/nouveau/nvkm/subdev/bios/thermal_policies.c
drm/nouveau/include/nvkm/subdev/bios/thermal_policies.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef __NVBIOS_THERMAL_POLICIES_H__ +#define __NVBIOS_THERMAL_POLICIES_H__ + +struct nvbios_thermal_policies_header { +u32 offset; + +u8 version; +u8 hlen; +u8 ecount; +u8 elen; +}; +struct nvbios_thermal_policies_entry { +u8 mode; +u16 t0; +s16 down_offset; +s16 up_offset; +}; + +int nvbios_thermal_policies_parse (struct nvkm_bios *, +struct nvbios_thermal_policies_header *); +int nvbios_thermal_policies_entry (struct nvkm_bios *, +struct nvbios_thermal_policies_header *, +u8 idx, +struct nvbios_thermal_policies_entry *); +#endif
drm/nouveau/nvkm/subdev/bios/Kbuild +1 -0
@@ -30,6 +30,7 @@ nvkm-y += nvkm/subdev/bios/shadowramin.o nvkm-y += nvkm/subdev/bios/shadowrom.o nvkm-y += nvkm/subdev/bios/timing.o nvkm-y += nvkm/subdev/bios/therm.o +nvkm-y += nvkm/subdev/bios/thermal_policies.o nvkm-y += nvkm/subdev/bios/vmap.o nvkm-y += nvkm/subdev/bios/volt.o nvkm-y += nvkm/subdev/bios/vpstate.o
drm/nouveau/nvkm/subdev/bios/thermal_policies.c new file +81 -0
81 lines not on this page · raw message
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 20/32 therm: Cancel the timer only in fini
In reply to a message not in the archiveWe will need a always running therm daemon to adjust the voltage/clocks on the fly.
--- drm/nouveau/nvkm/subdev/therm/base.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drm/nouveau/nvkm/subdev/therm/base.c +7 -6
@@ -107,7 +107,6 @@ nvkm_therm_update(struct nvkm_therm *therm, int mode)struct nvkm_clk *clk = subdev->device->clk;unsigned long flags;bool immd = true; -bool poll = true;int duty =-1 ;int temp;
@@ -121,11 +120,9 @@ nvkm_therm_update(struct nvkm_therm *therm, int mode)switch (mode) {case NVKM_THERM_CTRL_MANUAL : -nvkm_timer_alarm (tmr,0 , &therm->alarm); duty =nvkm_therm_fan_get (therm);if (duty <0 ) duty =100 ; - poll = false;break ;case NVKM_THERM_CTRL_AUTO :switch (therm->fan->bios.fan_mode) {
@@ -147,11 +144,10 @@ nvkm_therm_update(struct nvkm_therm *therm, int mode)break ;case NVKM_THERM_CTRL_NONE :default : -nvkm_timer_alarm (tmr,0 , &therm->alarm); - poll = false; +break ; } -if (poll) +if (list_empty (&therm->alarm.head))nvkm_timer_alarm (tmr,1000000000ULL , &therm->alarm);spin_unlock_irqrestore (&therm->lock, flags);
@@ -318,6 +314,11 @@ static int nvkm_therm_fini(struct nvkm_subdev *subdev, bool suspend) {struct nvkm_therm *therm =nvkm_therm (subdev); +struct nvkm_timer *tmr = subdev->device->timer; + +/* cancel the timer */ +if (!list_empty (&therm->alarm.head)) +nvkm_timer_alarm (tmr,0 , &therm->alarm);if (therm->func->fini) therm->func->fini (therm);
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 21/32 clk: Parse thermal policies for throttling thresholds
In reply to a message not in the archivev2: use min_t
--- drm/nouveau/include/nvkm/subdev/clk.h | 2 ++ drm/nouveau/nvkm/subdev/clk/base.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
drm/nouveau/include/nvkm/subdev/clk.h +2 -0
@@ -108,6 +108,8 @@ struct nvkm_clk {int astate;/* perfmon adjustment (base) */ int cstate_id;int temp; +int max_temp; +int relax_temp;bool allow_reclock;#define NVKM_CLK_BOOST_NONE 0x0
drm/nouveau/nvkm/subdev/clk/base.c +42 -0
60 lines not on this page · raw message
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 22/32 clk: Thermal throttling
In reply to a message not in the archivev2: make message about relaxed throttling an info
rework reporting about current clk state
--- drm/nouveau/include/nvkm/subdev/clk.h | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 47 +++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 10 deletions(-)
drm/nouveau/include/nvkm/subdev/clk.h +1 -0
@@ -110,6 +110,7 @@ struct nvkm_clk {int temp;int max_temp;int relax_temp; +bool throttled;bool allow_reclock;#define NVKM_CLK_BOOST_NONE 0x0
drm/nouveau/nvkm/subdev/clk/base.c +37 -10
77 lines not on this page · raw message
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 23/32 clk: Skip unchanging parts of the reclock
In reply to a message not in the archiveIf just the voltage is updated, we don't need to update the pstate or cstate as well. Same goes for changing the cstate without the pstate.
--- drm/nouveau/nvkm/subdev/clk/base.c | 23 +++++++++++++++-------- drm/nouveau/nvkm/subdev/volt/base.c | 3 +++ 2 files changed, 18 insertions(+), 8 deletions(-)
drm/nouveau/nvkm/subdev/clk/base.c +15 -8
@@ -174,7 +174,7 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate,struct nvkm_therm *therm = device->therm;struct nvkm_volt *volt = device->volt;struct nvkm_cstate *cstate; -int ret; +int ret =0 ;if (cstate_id ==NVKM_CLK_CSTATE_BOOT )return 0 ;
@@ -191,6 +191,11 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, cstate = &pstate->base; } +/* if the cstate matches, just update the voltage */ +if (clk->cstate_id == cstate->id) +return nvkm_volt_set_id (volt, cstate->voltage, + pstate->base.voltage, clk->temp,0 ); +if (therm) { ret =nvkm_therm_cstate (therm, pstate->fanspeed,+1 );if (ret && ret != -ENODEV ) {
@@ -297,6 +302,9 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstate_id)break ; } +if (clk->pstate_id == pstate_id) + goto cstate; +if (!pstate)return -EINVAL ;
@@ -316,6 +324,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstate_id) ram->func->tidy (ram); } +cstate:return nvkm_cstate_prog (clk, pstate,NVKM_CLK_CSTATE_AUTO ); }
@@ -324,7 +333,7 @@ nvkm_clk_update_work(struct work_struct *work) {struct nvkm_clk *clk =container_of (work,typeof (*clk), work);struct nvkm_subdev *subdev = &clk->subdev; -int pstate_id; +int pstate_id, ret;if (!atomic_xchg (&clk->waiting,0 ))return ;
@@ -346,12 +355,10 @@ nvkm_clk_update_work(struct work_struct *work) clk->pwrsrc, clk->ustate_ac, clk->ustate_dc, clk->astate, clk->temp, pstate_id); -if (pstate_id != clk->pstate_id) { -int ret =nvkm_pstate_prog (clk, pstate_id); -if (ret) { -nvkm_error (subdev,"error setting pstate %d: %d\n" , - pstate_id, ret); - } + ret =nvkm_pstate_prog (clk, pstate_id); +if (ret) { +nvkm_error (subdev,"error setting pstate %d: %d\n" , + pstate_id, ret); }wake_up_all (&clk->wait);
drm/nouveau/nvkm/subdev/volt/base.c +3 -0
@@ -162,6 +162,9 @@ nvkm_volt_set_id(struct nvkm_volt *volt, u8 id, u8 min_id, u8 temp, {int ret; +if (!volt) +return -ENODEV ; +if (volt->func->set_id)return volt->func->set_id (volt, id, condition);
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 24/32 clk: Save the max clock we can set
In reply to a message not in the archiveSaving the highest possible clock from the vpstate domain makes it easier to read it out whenever we want.
--- drm/nouveau/include/nvkm/subdev/clk.h | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 2 ++ 2 files changed, 3 insertions(+)
drm/nouveau/include/nvkm/subdev/clk.h +1 -0
@@ -119,6 +119,7 @@ struct nvkm_clk {u8 boost_mode;struct nvkm_clk_limit base_limit;struct nvkm_clk_limit boost_limit; +u32 max_khz;/*XXX: die, these are here *only* to support the completely * bat-shit insane what-was-nouveau_hw.c code
drm/nouveau/nvkm/subdev/clk/base.c +2 -0
@@ -274,6 +274,8 @@ nvkm_cstate_new(struct nvkm_clk *clk, int idx, struct nvkm_pstate *pstate)u32 freq =nvkm_clk_adjust (clk, true, pstate->id, domain->bios, cstepX.freq); cstate->domain[domain->name] = freq; +if (domain->flags &NVKM_CLK_DOM_FLAG_VPSTATE ) + clk->max_khz =max (clk->max_khz, freq); } domain++; }
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 25/32 nvif: Add boost info and set operations
In reply to a message not in the archivev5: Return ENODEV on devices without any vpstates.
Fail earlier if not supported.
--- drm/nouveau/include/nvif/if0001.h | 15 +++++++++ drm/nouveau/nvkm/engine/device/ctrl.c | 61 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+)
drm/nouveau/include/nvif/if0001.h +15 -0
@@ -4,6 +4,8 @@#define NVIF_CONTROL_PSTATE_INFO 0x00#define NVIF_CONTROL_PSTATE_ATTR 0x01#define NVIF_CONTROL_PSTATE_USER 0x02 +#define NVIF_CONTROL_BOOST_INFO 0x03 +#define NVIF_CONTROL_BOOST_SET 0x04struct nvif_control_pstate_info_v0 {__u8 version;
@@ -43,4 +45,17 @@ struct nvif_control_pstate_user_v0 {__s8 pwrsrc;/* in: target power source */ __u8 pad03[5]; }; + +struct nvif_control_boost_info_v0 { +__u8 version; +__u8 mode; +__u16 base_mhz; +__u16 boost_mhz; +__u16 max_mhz; +}; + +struct nvif_control_boost_set_v0 { +__u8 version; +__u8 mode; +};#endif
drm/nouveau/nvkm/engine/device/ctrl.c +61 -0
73 lines not on this page · raw message
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 26/32 debugfs: Add boost interface to change the boost_mode
In reply to a message not in the archive--- drm/nouveau/nouveau_debugfs.c | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
drm/nouveau/nouveau_debugfs.c +81 -0
@@ -184,6 +184,86 @@ static const struct file_operations nouveau_pstate_fops = { .write = nouveau_debugfs_pstate_set, }; +static void +nouveau_debugfs_boost_get_entry (struct seq_file *m,u8 mode,u8 entry, +u16 value) +{ +if (value) { +if (mode == entry) +seq_printf (m,"*%i" , entry); +else +seq_printf (m," %i" , entry); +seq_printf (m,": %u MHz\n" , value); + } +} + +static int +nouveau_debugfs_boost_get (struct seq_file *m,void *data) +{ +struct drm_device *drm = m->private; +struct nouveau_debugfs *debugfs =nouveau_debugfs (drm); +struct nvif_object *ctrl = &debugfs->ctrl; +struct nvif_control_boost_info_v0 info = {}; +int ret; + + ret =nvif_mthd (ctrl,NVIF_CONTROL_BOOST_INFO , &info,sizeof (info)); +if (ret) +return ret; + +nouveau_debugfs_boost_get_entry (m, info.mode,0 , info.base_mhz); +nouveau_debugfs_boost_get_entry (m, info.mode,1 , info.boost_mhz); +nouveau_debugfs_boost_get_entry (m, info.mode,2 , info.max_mhz); +return 0 ; +} + +static ssize_t +nouveau_debugfs_boost_set (struct file *file,const char __user *ubuf, +size_t len,loff_t *offp) +{ +struct seq_file *m = file->private_data; +struct drm_device *drm = m->private; +struct nouveau_debugfs *debugfs =nouveau_debugfs (drm); +struct nvif_object *ctrl = &debugfs->ctrl; +struct nvif_control_boost_set_v0 args = {}; +char buf[3 ] = {}; +long ret; +u8 value; + +if (len >=sizeof (buf)) +return -EINVAL ; + +if (copy_from_user (buf, ubuf, len)) +return -EFAULT ; + + ret =kstrtou8 (buf,10 , &value); +if (ret) +return ret; + + args.mode = value; + ret =pm_runtime_get_sync (drm->dev); +if (IS_ERR_VALUE (ret) && ret != -EACCES ) +return ret; + ret =nvif_mthd (ctrl,NVIF_CONTROL_BOOST_SET , &args,sizeof (args)); +pm_runtime_put_autosuspend (drm->dev); +if (ret) +return ret; + +return len; +} + +static int +nouveau_debugfs_boost_open (struct inode *inode,struct file *file) +{ +return single_open (file, nouveau_debugfs_boost_get, inode->i_private); +} + +static const struct file_operations nouveau_boost_fops = { + .owner =THIS_MODULE , + .open = nouveau_debugfs_boost_open, + .read = seq_read, + .write = nouveau_debugfs_boost_set, +}; +static struct drm_info_list nouveau_debugfs_list[] = { {"vbios.rom" , nouveau_debugfs_vbios_image,0 ,NULL }, };
@@ -193,6 +273,7 @@ static const struct nouveau_debugfs_files {const char *name;const struct file_operations *fops; } nouveau_debugfs_files[] = { + {"boost", &nouveau_boost_fops}, {"pstate", &nouveau_pstate_fops}, };
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 27/32 bios/vpstate: Parse max battery id
In reply to a message not in the archive--- drm/nouveau/include/nvkm/subdev/bios/vpstate.h | 1 + drm/nouveau/nvkm/subdev/bios/vpstate.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
drm/nouveau/include/nvkm/subdev/bios/vpstate.h +1 -0
@@ -10,6 +10,7 @@ struct nvbios_vpstate_header {u8 scount;u8 slen; +u8 battery_id;u8 base_id;u8 boost_id;u8 tdp_id;
drm/nouveau/nvkm/subdev/bios/vpstate.c +2 -1
@@ -57,7 +57,8 @@ nvbios_vpstate_parse(struct nvkm_bios *b, struct nvbios_vpstate_header *h) h->scount =nvbios_rd08 (b, h->offset +0x4 ); h->ecount =nvbios_rd08 (b, h->offset +0x5 ); - h->base_id =nvbios_rd08 (b, h->offset +0x0f ); + h->battery_id =nvbios_rd08 (b, h->offset +0x0c ); + h->base_id =nvbios_rd08 (b, h->offset +0x0f );if (h->hlen >0x10 ) h->boost_id =nvbios_rd08 (b, h->offset +0x10 );else
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 28/32 clk: Implement limiting pstates just like we do for cstates
In reply to a message not in the archive--- drm/nouveau/nvkm/subdev/clk/base.c | 61 ++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 9 deletions(-)
drm/nouveau/nvkm/subdev/clk/base.c +52 -9
@@ -287,6 +287,51 @@ nvkm_cstate_new(struct nvkm_clk *clk, int idx, struct nvkm_pstate *pstate)/****************************************************************************** * P-States *****************************************************************************/ +static struct nvkm_pstate * +nvkm_pstate_find_best (struct nvkm_clk *clk,struct nvkm_pstate *pstate) +{ +u8 limit; + +switch (clk->boost_mode) { +case NVKM_CLK_BOOST_NONE : + limit = clk->base_limit.pstate; +if (limit) +break ; +case NVKM_CLK_BOOST_BIOS : + limit = clk->boost_limit.pstate; +break ; +default : + limit =0 ; +break ; + } + +if (!limit) +return pstate; + +list_for_each_entry_from_reverse (pstate, &clk->pstates, head) { +if (limit >= pstate->id) +break ; + } +return pstate; +} + +static struct nvkm_pstate * +nvkm_pstate_get (struct nvkm_clk *clk,int pstateid) +{ +struct nvkm_pstate *pstate; + +switch (pstateid) { +case NVKM_CLK_PSTATE_BOOT : +return NULL ; +default : +list_for_each_entry (pstate, &clk->pstates, head) { +if (pstate->id == pstateid) +return pstate; + } + } +return NULL ; +} +static int nvkm_pstate_prog (struct nvkm_clk *clk,int pstate_id) {
@@ -299,19 +344,17 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstate_id)if (pstate_id ==NVKM_CLK_PSTATE_BOOT )return 0 ; -list_for_each_entry (pstate, &clk->pstates, head) { -if (pstate->id == pstate_id) -break ; - } - -if (clk->pstate_id == pstate_id) - goto cstate; + pstate =nvkm_pstate_get (clk, pstate_id); + pstate =nvkm_pstate_find_best (clk, pstate);if (!pstate)return -EINVAL ; -nvkm_debug (subdev,"setting performance state %x\n" , pstate_id); - clk->pstate_id = pstate_id; +if (clk->pstate_id == pstate_id) + goto cstate; + +nvkm_debug (subdev,"setting performance state %x\n" , pstate->id); + clk->pstate_id = pstate->id;nvkm_pcie_set_link (pci, pstate->pcie_speed, pstate->pcie_width);
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 29/32 clk: Limit clocks on battery
In reply to a message not in the archive--- drm/nouveau/include/nvkm/subdev/clk.h | 1 + drm/nouveau/nvkm/subdev/clk/base.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+)
drm/nouveau/include/nvkm/subdev/clk.h +1 -0
@@ -119,6 +119,7 @@ struct nvkm_clk {u8 boost_mode;struct nvkm_clk_limit base_limit;struct nvkm_clk_limit boost_limit; +struct nvkm_clk_limit batt_limit;u32 max_khz;/*XXX: die, these are here *only* to support the completely
drm/nouveau/nvkm/subdev/clk/base.c +20 -0
@@ -99,6 +99,15 @@ nvkm_cstate_valid(struct nvkm_clk *clk, struct nvkm_cstate *cstate,break ; } +if (!clk->pwrsrc) { +u32 blimit = clk->batt_limit.max_khz; + +if (!limit) + limit = blimit; +else if (blimit) + limit =min (blimit, limit); + } +if (limit) {for (; domain && domain->name != nv_clk_src_max; domain++) {if (!(domain->flags &NVKM_CLK_DOM_FLAG_VPSTATE ))
@@ -305,6 +314,15 @@ nvkm_pstate_find_best(struct nvkm_clk *clk, struct nvkm_pstate *pstate)break ; } +if (!clk->pwrsrc) { +u8 blimit = clk->batt_limit.pstate; + +if (!limit) + limit = blimit; +else if (blimit) + limit =min (blimit, limit); + } +if (!limit)return pstate;
@@ -791,6 +809,8 @@ nvkm_clk_ctor(const struct nvkm_clk_func *func, struct nvkm_device *device,nvkm_clk_fill_limit (&clk->boost_limit, &vpe);if (!nvbios_vpstate_entry (bios, &h, h.base_id, &vpe))nvkm_clk_fill_limit (&clk->base_limit, &vpe); +if (!nvbios_vpstate_entry (bios, &h, h.battery_id, &vpe)) +nvkm_clk_fill_limit (&clk->batt_limit, &vpe); } clk->func = func;
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 30/32 secboot/acr352: Reset PMU after secboot
In reply to a message not in the archiveThis is needed for using Nouveaus PMU image after performing secboot. This will be helpful for Maxwell2 reclocking on boards without externally controlled fans like on most laptops or fanless boards.
--- drm/nouveau/nvkm/subdev/secboot/acr_r352.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drm/nouveau/nvkm/subdev/secboot/acr_r352.c +14 -0
@@ -924,6 +924,20 @@ acr_r352_bootstrap(struct acr_r352 *acr, struct nvkm_secboot *sb) } } +/* reset the PMU if needed */ +if (acr->base.boot_falcon ==NVKM_SECBOOT_FALCON_PMU && + !nvkm_secboot_is_managed (sb,NVKM_SECBOOT_FALCON_PMU )) { +struct nvkm_pmu *pmu = subdev->device->pmu; + +if (pmu) { + ret =nvkm_subdev_init (&pmu->subdev); +if (ret <0 ) { +nvkm_error (subdev,"Failed to reset PMU\n" ); +return ret; + } + } + } +return 0 ; }
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 31/32 device: Enable clk for Maxwell2
In reply to a message not in the archiveReclokcing will only be enabled by setting NvFanless to true.
--- drm/nouveau/nvkm/engine/device/base.c | 3 +++ drm/nouveau/nvkm/subdev/clk/gk104.c | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-)
drm/nouveau/nvkm/engine/device/base.c +3 -0
@@ -2029,6 +2029,7 @@ nv120_chipset = { .bar = gm107_bar_new, .bios = nvkm_bios_new, .bus = gf100_bus_new, + .clk = gk104_clk_new, .devinit = gm200_devinit_new, .fb = gm200_fb_new, .fuse = gm107_fuse_new,
@@ -2064,6 +2065,7 @@ nv124_chipset = { .bar = gm107_bar_new, .bios = nvkm_bios_new, .bus = gf100_bus_new, + .clk = gk104_clk_new, .devinit = gm200_devinit_new, .fb = gm200_fb_new, .fuse = gm107_fuse_new,
@@ -2099,6 +2101,7 @@ nv126_chipset = { .bar = gm107_bar_new, .bios = nvkm_bios_new, .bus = gf100_bus_new, + .clk = gk104_clk_new, .devinit = gm200_devinit_new, .fb = gm200_fb_new, .fuse = gm107_fuse_new,
drm/nouveau/nvkm/subdev/clk/gk104.c +9 -1
@@ -25,6 +25,7 @@#include "priv.h" #include "pll.h" +#include <core/option.h> #include <subdev/timer.h> #include <subdev/bios.h> #include <subdev/bios/pll.h>
@@ -507,10 +508,17 @@ int gk104_clk_new(struct nvkm_device *device, int index, struct nvkm_clk **pclk) { struct gk104_clk *clk; +bool reclocking;if (!(clk =kzalloc (sizeof (*clk),GFP_KERNEL )))return -ENOMEM ; *pclk = &clk->base; -return nvkm_clk_ctor (&gk104_clk, device, index, true, &clk->base); +if (device->chipset >=0x120 ) + reclocking =nvkm_boolopt (device->cfgopt,"NvFanless" , false); +else + reclocking = true; + +return nvkm_clk_ctor (&gk104_clk, device, index, reclocking, + &clk->base); }
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 32/32 clk: Add trace message when setting a new cstate
In reply to a message not in the archiveFrom: Karol Herbst <[email protected]>
--- drm/nouveau/nvkm/subdev/clk/base.c | 2 ++ 1 file changed, 2 insertions(+)
drm/nouveau/nvkm/subdev/clk/base.c +2 -0
@@ -205,6 +205,8 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate,return nvkm_volt_set_id (volt, cstate->voltage, pstate->base.voltage, clk->temp,0 ); +nvkm_trace (subdev,"setting cstate to %d\n" , cstate->id); +if (therm) { ret =nvkm_therm_cstate (therm, pstate->fanspeed,+1 );if (ret && ret != -ENODEV ) {
Signature · 6 lines
2.15.0 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau