Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp562774ybt; Wed, 8 Jul 2020 06:34:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrQxxugaAP8GNEpxpXbLEBcE5cQkxciRsk4xyD8LyxjHDBzLDa/TkAqj7VHsdgeKIL1g3/ X-Received: by 2002:a05:6402:14c1:: with SMTP id f1mr69473257edx.342.1594215264485; Wed, 08 Jul 2020 06:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594215264; cv=none; d=google.com; s=arc-20160816; b=hDg2paBNmUtI9pfqOmSl1RFd4nR0qAKALgOlm3D0aZq6kqWLKxiiiVMwuqD7gKCQ3D PAighZ+RpJ9aj02/CSKYnl7YlgBwZupQNqhciAe1KG19FSZmyszNTVWWePV82UfUnli0 yvxXgWIqB/2cTKArL4GCaNfe8QCgRcKcn1lZN3PENX6+Xpt+H4cZAuZzUkmgxajIzpkL SINsuVbLmHixiIT43n9tDQ75J9eKgfL/aEHdnifoy2VbsIBGAkk9RHoMIhW3+T79Nb+8 PgdkxAuPmoSsYcI1RmTI59YuY/aWaurLycdjuJTfn+JWXZ4omHBZVWWgQVyQymh60AQv L9cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=Uizg+tVTiJ3aLp8Ii4GB1McZDtJg/ge0xD5qUwTW7cU=; b=ra7XJ6U3ayIjxaLugn4kbS+o4aik8KswkmB7WG8J7DhoGyzHmkge445Br96qSt9xvy PsoV46fNDyr7CGFMpQXscz/Y4VUebnoXc3vqRc/TvmLO61GUltaahfa+5LQMx9EX+fCG LdTVVnGbAqK4Y7kcSaf6GowZZP9dDRymHJfVE6RdBZ5KWYixK6fXGZe4dJDf1OWYZbVh MXHOJqXBfEgB8Q5L/k/EW6p3z4I6PwBoGQEJ6Evntqc3DZT2XCvOO6o3cOr6N5YSus31 yMAfdR8z2niuYH4htznqn4uTfdIdFNvgGNsplf1OHvQsobL7N+mljrT+3rQQCAQgjkxi jOPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=Rp56wWkG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=megous.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b2si17055904ejk.469.2020.07.08.06.34.01; Wed, 08 Jul 2020 06:34:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=Rp56wWkG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=megous.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729643AbgGHNdH (ORCPT + 99 others); Wed, 8 Jul 2020 09:33:07 -0400 Received: from vps.xff.cz ([195.181.215.36]:51824 "EHLO vps.xff.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729147AbgGHNdH (ORCPT ); Wed, 8 Jul 2020 09:33:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1594215185; bh=idGKF3JzxhsuONqMIcvOgw3WlXUUbr9YQZ9VScLBUYg=; h=Date:From:To:Cc:Subject:References:X-My-GPG-KeyId:From; b=Rp56wWkG9R4RLksIW7bT1P61QkUVxcyv2wX+/7vHCpxeoUMSrE1Bi6DgyZSXgqc8+ y/DikjqGDtr6N9UFBztaPkoS+vvTdOUXWMHEQ4t/na3QL9r1uv9Fim0TQ0sifgFNcO iqkuaF/HsWznZrrsKSlbyTFB8bEPCgx8GX356vho= Date: Wed, 8 Jul 2020 15:33:05 +0200 From: =?utf-8?Q?Ond=C5=99ej?= Jirman To: Frank Lee Cc: linux-sunxi@googlegroups.com, Vasily Khoruzhick , Zhang Rui , Daniel Lezcano , Amit Kucheria , Maxime Ripard , Chen-Yu Tsai , "open list:ALLWINNER THERMAL DRIVER" , "moderated list:ARM/Allwinner sunXi SoC support" , open list Subject: Re: [PATCH] thermal: sun8i: Be loud when probe fails Message-ID: <20200708133305.hpvxybbsy3xdxtmp@core.my.home> Mail-Followup-To: =?utf-8?Q?Ond=C5=99ej?= Jirman , Frank Lee , linux-sunxi@googlegroups.com, Vasily Khoruzhick , Zhang Rui , Daniel Lezcano , Amit Kucheria , Maxime Ripard , Chen-Yu Tsai , "open list:ALLWINNER THERMAL DRIVER" , "moderated list:ARM/Allwinner sunXi SoC support" , open list References: <20200708105527.868987-1-megous@megous.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-My-GPG-KeyId: EBFBDDE11FB918D44D1F56C1F9F0A873BE9777ED Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 08, 2020 at 07:55:40PM +0800, Frank Lee wrote: > HI Ondrej, > On Wed, Jul 8, 2020 at 6:55 PM Ondrej Jirman wrote: > > > > 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); > > When the driver fails, there will be this print. Isn't it superfluous > for you to add these? > > sun8i-thermal: probe of 5070400.thermal-sensor failed with error Thinking more about it. You're right. This is probably only shown for non-EPROBE_DEFER errors. So this printk is superfluous, since EPROBE_DEFER from nvmem/sid is already shown elsewhere in this patch. thanks, o. > > Yangtao