From patchwork Sun Apr 22 21:47:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 10355831 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 811C46023A for ; Sun, 22 Apr 2018 21:47:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66E6A28949 for ; Sun, 22 Apr 2018 21:47:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58ACB28964; Sun, 22 Apr 2018 21:47:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C2A7728949 for ; Sun, 22 Apr 2018 21:47:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4682D89E35; Sun, 22 Apr 2018 21:47:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x241.google.com (mail-qt0-x241.google.com [IPv6:2607:f8b0:400d:c0d::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id A85D289E35; Sun, 22 Apr 2018 21:47:15 +0000 (UTC) Received: by mail-qt0-x241.google.com with SMTP id j3-v6so15601027qtn.9; Sun, 22 Apr 2018 14:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=eA+Lf1kujfjlRPOvpAfsoxM/lAvOwxU8yCT4bRmeM5g=; b=uxY8DcAfB4NTn0/0djUnboZTxSfcFsWJOlPRBQDccNjKS1OYxIu4lZMtpOQmk2orhS I0aLjquMCCYR40Qme5q3JDhWBBkwGMlcGf6AOsonOqhHqCieFa5hTyYMhRebKU5wDyWc j+T8NSlCjpwK9u2Bi78k4lrCHU7Y71JjIe2FxEc/AkjYqRh2zzCGHmaybM/gDHHcS3is YEXRLZ7Br7U328vbQvtkoft56RWmSskxEWTrrTi5R4SpJRsChQrCiRFq+luGNMx7ZvAW CCswxl9lvUHsKi0D6jpqn4iPKjfDZAMSUa5xe9iqxRiDX13E8zTh8F1fUmMtv/MMzunz OzRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=eA+Lf1kujfjlRPOvpAfsoxM/lAvOwxU8yCT4bRmeM5g=; b=ImTBrv+LESditXEECCqfV8d9tHsaim2PEZwjHOVfcWRLuxTheJuJBKBbnOUMg+jrDq niomdB2mAsbz5jp64v6W8yPtJ2mQvZ6Lxc9DMNfncG53UtWNWLWp1Dv6F82gZqICEfqM uXGx3Fez9H+B4tIfihv8PV6g574NGnLCpIJ4RB01jiDE6UE5/nLu+7bT0t7wt2a7Bl40 EjVYSINvQWZZCGC+w06KVqrnLdED0VVJ2JFsijHLAEJnko2DsLY9SdXkTaOfSmiHg2hI gnDreBYj18iznI0XO/LGkBks4FsosPbs6/8yWpDVfUiY70Y0PZt/nYwYGatnIMTV4QiN fR4w== X-Gm-Message-State: ALQs6tA1aNN+Ci4D3/wnLVSdhvBEL8k+nX+KxiWAGmvR8pNUzO9HdZso 6ePJNwlIJttBEh1+0ZY2hyDd5DED X-Google-Smtp-Source: AB8JxZrPR0L9Y3CXaFeLQEPodUQ4jIgIBYUbsNzQ+VLjeFd/hxaVc3/e6pPedggAsk0UAuDgCvcN+A== X-Received: by 2002:aed:30c1:: with SMTP id 59-v6mr20309072qtf.237.1524433634393; Sun, 22 Apr 2018 14:47:14 -0700 (PDT) Received: from athos.fios-router.home (pool-108-46-159-218.nycmny.fios.verizon.net. [108.46.159.218]) by smtp.gmail.com with ESMTPSA id w198sm9042511qkb.64.2018.04.22.14.47.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Apr 2018 14:47:13 -0700 (PDT) From: Ilia Mirkin To: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org Subject: [PATCH] drm/nouveau: fix temp/pwm visibility, skip hwmon when no sensors exist Date: Sun, 22 Apr 2018 17:47:12 -0400 Message-Id: <20180422214712.4220-1-imirkin@alum.mit.edu> X-Mailer: git-send-email 2.16.1 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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: Ilia Mirkin --- drivers/gpu/drm/nouveau/nouveau_hwmon.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_hwmon.c b/drivers/gpu/drm/nouveau/nouveau_hwmon.c index 7c965648df80..44178b4c3599 100644 --- a/drivers/gpu/drm/nouveau/nouveau_hwmon.c +++ b/drivers/gpu/drm/nouveau/nouveau_hwmon.c @@ -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 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; switch (attr) { @@ -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 nvkm_therm *therm = nvxx_therm(&drm->client.device); - if (therm && therm->attr_get && therm->fan_get && - therm->fan_get(therm) < 0) + if (!therm || !therm->attr_get || !therm->fan_get || + therm->fan_get(therm) < 0) return 0; switch (attr) { @@ -707,13 +707,20 @@ nouveau_hwmon_init(struct drm_device *dev) { #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)) 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_volt *volt = nvxx_volt(&drm->client.device); const struct attribute_group *special_groups[N_ATTR_GROUPS]; struct nouveau_hwmon *hwmon; struct device *hwmon_dev; int ret = 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); if (!hwmon) return -ENOMEM; @@ -749,6 +756,9 @@ nouveau_hwmon_fini(struct drm_device *dev) #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)) struct nouveau_hwmon *hwmon = nouveau_hwmon(dev); + if (!hwmon) + return; + if (hwmon->hwmon) hwmon_device_unregister(hwmon->hwmon);