提交 7a22c737 编写于 作者: I Ilia Mirkin 提交者: Ben Skeggs

drm/nouveau: fix temp/pwm visibility, skip hwmon when no sensors exist

A NV34 GPU was seeing temp and pwm entries in hwmon, which would error
out when read. These should not have been visible, but also the whole
hwmon object should just not have been registered in the first place.
Signed-off-by: NIlia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
上级 f43cda5c
...@@ -327,7 +327,7 @@ nouveau_temp_is_visible(const void *data, u32 attr, int channel) ...@@ -327,7 +327,7 @@ nouveau_temp_is_visible(const void *data, u32 attr, int channel)
struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data); struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
if (therm && therm->attr_get && nvkm_therm_temp_get(therm) < 0) if (!therm || !therm->attr_get || nvkm_therm_temp_get(therm) < 0)
return 0; return 0;
switch (attr) { switch (attr) {
...@@ -351,8 +351,8 @@ nouveau_pwm_is_visible(const void *data, u32 attr, int channel) ...@@ -351,8 +351,8 @@ nouveau_pwm_is_visible(const void *data, u32 attr, int channel)
struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data); struct nouveau_drm *drm = nouveau_drm((struct drm_device *)data);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
if (therm && therm->attr_get && therm->fan_get && if (!therm || !therm->attr_get || !therm->fan_get ||
therm->fan_get(therm) < 0) therm->fan_get(therm) < 0)
return 0; return 0;
switch (attr) { switch (attr) {
...@@ -707,13 +707,20 @@ nouveau_hwmon_init(struct drm_device *dev) ...@@ -707,13 +707,20 @@ nouveau_hwmon_init(struct drm_device *dev)
{ {
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)) #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_drm *drm = nouveau_drm(dev);
struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device);
struct nvkm_therm *therm = nvxx_therm(&drm->client.device); struct nvkm_therm *therm = nvxx_therm(&drm->client.device);
struct nvkm_volt *volt = nvxx_volt(&drm->client.device);
const struct attribute_group *special_groups[N_ATTR_GROUPS]; const struct attribute_group *special_groups[N_ATTR_GROUPS];
struct nouveau_hwmon *hwmon; struct nouveau_hwmon *hwmon;
struct device *hwmon_dev; struct device *hwmon_dev;
int ret = 0; int ret = 0;
int i = 0; int i = 0;
if (!iccsense && !therm && !volt) {
NV_DEBUG(drm, "Skipping hwmon registration\n");
return 0;
}
hwmon = drm->hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL); hwmon = drm->hwmon = kzalloc(sizeof(*hwmon), GFP_KERNEL);
if (!hwmon) if (!hwmon)
return -ENOMEM; return -ENOMEM;
...@@ -749,6 +756,9 @@ nouveau_hwmon_fini(struct drm_device *dev) ...@@ -749,6 +756,9 @@ nouveau_hwmon_fini(struct drm_device *dev)
#if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)) #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
struct nouveau_hwmon *hwmon = nouveau_hwmon(dev); struct nouveau_hwmon *hwmon = nouveau_hwmon(dev);
if (!hwmon)
return;
if (hwmon->hwmon) if (hwmon->hwmon)
hwmon_device_unregister(hwmon->hwmon); hwmon_device_unregister(hwmon->hwmon);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册