From patchwork Wed Jul 8 10:55:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 11651343 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B84A6C1 for ; Wed, 8 Jul 2020 10:57:09 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 448D52067D for ; Wed, 8 Jul 2020 10:57:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JTS9mGfp"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=megous.com header.i=@megous.com header.b="oKv3I7Kc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 448D52067D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=megous.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=cPF/o0OHJjJYFW2rDWZYlQQRJQicUDy5S/P0tbE6Glk=; b=JTS9mGfpNy7bYWz0VhpYAukIlZ Zet3Kf2vIAfg6YfryOLCrZYDB0MkfIfsXypWEitgkXaTl0YTHZRk7v7baX0iTJIE3JabEzzhm/snO QFbY5M7o3jmMtvFqzYi1u9nBiltZHD8JY+d2PVqu4BrC0w458SisnepC4mkgT0VHbsnQ7M4a5L53v yXCVTsazE/YwGRabYw59mOhl4151UppHnkFnGH7uEVzQ59q6MtHEzWGDIh0MQNXDUzCEJ0rhHChjM kS0uGbN4V12NX990lHUkXjKhACpOaDiHAy6GTje7xL4Y37EnDGDGjWAHsSMHpmCURVcrmTt+XO3fg MzOU9yzw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jt7jk-0004g8-G2; Wed, 08 Jul 2020 10:55:36 +0000 Received: from vps.xff.cz ([195.181.215.36]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jt7jh-0004fH-Ua for linux-arm-kernel@lists.infradead.org; Wed, 08 Jul 2020 10:55:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1594205730; bh=FjQWXkffSauLT4RFe7L3pGAJhRaFdql4N1eA12iukYs=; h=From:To:Cc:Subject:Date:From; b=oKv3I7KcWEuiP1EnF+jHL6RAcGQpwZunw9eUecnt8AIhsN144n1mEN+RCAJ+9nq9Q OZJVWzRO12OVKWem8iC/PNSZ+f1Z/B0KsanEZ8+Y2JvYCrotI1vtwuwemuySTUlMwG 7qnBmmLwsu9O1SsKNdx1ikc/RupzsSRITxr4gQOE= From: Ondrej Jirman To: linux-sunxi@googlegroups.com Subject: [PATCH] thermal: sun8i: Be loud when probe fails Date: Wed, 8 Jul 2020 12:55:27 +0200 Message-Id: <20200708105527.868987-1-megous@megous.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200708_065534_230456_FDB41E13 X-CRM114-Status: GOOD ( 12.13 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ondrej Jirman , Amit Kucheria , "open list:ALLWINNER THERMAL DRIVER" , Yangtao Li , Daniel Lezcano , open list , Maxime Ripard , Vasily Khoruzhick , Chen-Yu Tsai , Zhang Rui , "moderated list:ARM/Allwinner sunXi SoC support" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org I noticed several mobile Linux distributions failing to enable the thermal regulation correctly, because the kernel is silent when thermal driver fails to probe. Add enough error reporting to debug issues and warn users in case thermal sensor is failing to probe. Failing to notify users means, that SoC can easily overheat under load. Signed-off-by: Ondrej Jirman --- drivers/thermal/sun8i_thermal.c | 55 ++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index 74d73be16496..9065e79ae743 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -287,8 +287,12 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) calcell = devm_nvmem_cell_get(dev, "calibration"); if (IS_ERR(calcell)) { + dev_err(dev, "Failed to get calibration nvmem cell (%ld)\n", + PTR_ERR(calcell)); + if (PTR_ERR(calcell) == -EPROBE_DEFER) return -EPROBE_DEFER; + /* * Even if the external calibration data stored in sid is * not accessible, the THS hardware can still work, although @@ -308,6 +312,8 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) caldata = nvmem_cell_read(calcell, &callen); if (IS_ERR(caldata)) { ret = PTR_ERR(caldata); + dev_err(dev, "Failed to read calibration data (%d)\n", + ret); goto out; } @@ -330,23 +336,35 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev) return PTR_ERR(base); tmdev->regmap = devm_regmap_init_mmio(dev, base, &config); - if (IS_ERR(tmdev->regmap)) + if (IS_ERR(tmdev->regmap)) { + dev_err(dev, "Failed to init regmap (%ld)\n", + PTR_ERR(tmdev->regmap)); return PTR_ERR(tmdev->regmap); + } if (tmdev->chip->has_bus_clk_reset) { tmdev->reset = devm_reset_control_get(dev, NULL); - if (IS_ERR(tmdev->reset)) + if (IS_ERR(tmdev->reset)) { + dev_err(dev, "Failed to get reset (%ld)\n", + PTR_ERR(tmdev->reset)); return PTR_ERR(tmdev->reset); + } tmdev->bus_clk = devm_clk_get(&pdev->dev, "bus"); - if (IS_ERR(tmdev->bus_clk)) + if (IS_ERR(tmdev->bus_clk)) { + dev_err(dev, "Failed to get bus clock (%ld)\n", + PTR_ERR(tmdev->bus_clk)); return PTR_ERR(tmdev->bus_clk); + } } if (tmdev->chip->has_mod_clk) { tmdev->mod_clk = devm_clk_get(&pdev->dev, "mod"); - if (IS_ERR(tmdev->mod_clk)) + if (IS_ERR(tmdev->mod_clk)) { + dev_err(dev, "Failed to get mod clock (%ld)\n", + PTR_ERR(tmdev->mod_clk)); return PTR_ERR(tmdev->mod_clk); + } } ret = reset_control_deassert(tmdev->reset); @@ -471,8 +489,12 @@ static int sun8i_ths_register(struct ths_device *tmdev) i, &tmdev->sensor[i], &ths_ops); - if (IS_ERR(tmdev->sensor[i].tzd)) + if (IS_ERR(tmdev->sensor[i].tzd)) { + dev_err(tmdev->dev, + "Failed to register sensor %d (%ld)\n", + i, PTR_ERR(tmdev->sensor[i].tzd)); return PTR_ERR(tmdev->sensor[i].tzd); + } if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd)) dev_warn(tmdev->dev, @@ -501,19 +523,21 @@ static int sun8i_ths_probe(struct platform_device *pdev) ret = sun8i_ths_resource_init(tmdev); if (ret) - return ret; + goto err_out; irq = platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + if (irq < 0) { + ret = irq; + goto err_out; + } ret = tmdev->chip->init(tmdev); if (ret) - return ret; + goto err_out; ret = sun8i_ths_register(tmdev); if (ret) - return ret; + goto err_out; /* * Avoid entering the interrupt handler, the thermal device is not @@ -523,10 +547,17 @@ static int sun8i_ths_probe(struct platform_device *pdev) ret = devm_request_threaded_irq(dev, irq, NULL, sun8i_irq_thread, IRQF_ONESHOT, "ths", tmdev); - if (ret) - return ret; + if (ret) { + dev_err(dev, "Failed to request irq (%d)\n", ret); + goto err_out; + } + dev_info(dev, "Thermal sensor ready!\n"); return 0; + +err_out: + dev_err(dev, "Failed to probe thermal sensor (%d)\n", ret); + return ret; } static int sun8i_ths_remove(struct platform_device *pdev)