Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1464855ybl; Tue, 13 Aug 2019 13:07:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqydoKUqxUO7mgNaGiGim1m4y7+9Rm5llwHQTNlXdCHPcZBA5gylSMxXbPk+BZOy2SMK7KXY X-Received: by 2002:a17:90a:8d09:: with SMTP id c9mr3840345pjo.131.1565726867591; Tue, 13 Aug 2019 13:07:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565726867; cv=none; d=google.com; s=arc-20160816; b=ffFmHn5WugKP9sKVJp376g3EAB53fwG5R2vxaa+kH1ZJQ19sYefQMvpDhpoeYuSl/E bHUj4l6JFp/kCUMg9eqcleL4h0xsy650yiyInIYm3clVagW80woNffnjL2kzFqCh76Hs H6wy94InvI+kmEvfjKhz98SVt5BTOrxfIw0grIT0jq9imdYOQU2fhYywBezQPgo4x15m WEJ5pUkji8pzJb42ol+MpfG6aVwzE7ig4A0k3sf9DxXgDya1I+3XzjMyRUOWD0Det/Fd 4RmaqN0/pzVuCIdymVL2ryoTqlz5w97FWXAc6V1tSB9NXccJhMhxTKqzkgjKg/2QoPKF G/Rg== 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-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=laK/xYTz7MQ5eyBm7I6p3e0pG+Fo7RwcXiOEzdNSZMI=; b=tJa/7U1XFiL+fWtMIRQpWTTcR81hp74FOzPDxAAXDYO7yW4F/zNtwCvp76Y9qPsykG +gujXOr4ol87jqdoy/I6v+edS8pnLGcLHzxA4RBYNk4NLXGYlWuksa9s5taRrh+B8xb7 6gAmLDkS0/veucxdhzwlnP0Op3rTnN/+cM7pMs3q9NGiLuWrPkIjkAgZhQ84M+y8DFBT XFFsbkzqeQWUeDmi50O/eBqDXa6NYrxTxJBPM5HtSKlwPqEN1WFtTNebu7vkWtHk/ws5 FNLcgq/Nt3UFB1YwG+FsXlUBdHFsdbZjxn2Fpkzrd7TpPthKjq0td+3e4ryElXZyUggy ZIhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=E3Pt3KdL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 1si42182780plz.351.2019.08.13.13.07.30; Tue, 13 Aug 2019 13:07:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=E3Pt3KdL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726637AbfHMUG1 (ORCPT + 99 others); Tue, 13 Aug 2019 16:06:27 -0400 Received: from vps.xff.cz ([195.181.215.36]:57938 "EHLO vps.xff.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726126AbfHMUG1 (ORCPT ); Tue, 13 Aug 2019 16:06:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1565726784; bh=BJj4IKkIVoRjnCmUwYtLOi3KBn/hCwT44LH7rC3kdoM=; h=Date:From:To:Cc:Subject:References:X-My-GPG-KeyId:From; b=E3Pt3KdLd9W8HHq139AvIwYXOeG0lTAHVvI2JcIzZ1HZ915O+TzrXrcXhszIYQiUf uL64qv/She2OnBWhhScfJWgnm/L6Rbj4BNLcLnR4AaHzhUkA3fdth+dcQo2e0fJFGh BH/DXYmITMyqoSUb2Ghke0tTeWnHpqBU6p6VzpZk= Date: Tue, 13 Aug 2019 22:06:23 +0200 From: =?utf-8?Q?Ond=C5=99ej?= Jirman To: Vasily Khoruzhick Cc: Frank Lee , Mark Rutland , devicetree , Linux PM , Maxime Ripard , Greg Kroah-Hartman , Daniel Lezcano , linux-kernel , Eduardo Valentin , Chen-Yu Tsai , Rob Herring , Jonathan.Cameron@huawei.com, Mauro Carvalho Chehab , rui.zhang@intel.com, "David S. Miller" , arm-linux Subject: Re: [PATCH v5 08/18] thermal: sun8i: support mod clocks Message-ID: <20190813200623.2dmxcwibuyolnuhh@core.my.home> Mail-Followup-To: Vasily Khoruzhick , Frank Lee , Mark Rutland , devicetree , Linux PM , Maxime Ripard , Greg Kroah-Hartman , Daniel Lezcano , linux-kernel , Eduardo Valentin , Chen-Yu Tsai , Rob Herring , Jonathan.Cameron@huawei.com, Mauro Carvalho Chehab , rui.zhang@intel.com, "David S. Miller" , arm-linux References: <20190810052829.6032-1-tiny.windzz@gmail.com> <20190810052829.6032-9-tiny.windzz@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 Mon, Aug 12, 2019 at 04:54:15PM -0700, Vasily Khoruzhick wrote: > On Mon, Aug 12, 2019 at 4:46 PM Frank Lee wrote: > > > > HI Vasily, > > > > On Sat, Aug 10, 2019 at 2:17 PM Vasily Khoruzhick wrote: > > > > > > On Fri, Aug 9, 2019 at 10:31 PM Yangtao Li wrote: > > > > > > > > H3 has extra clock, so introduce something in ths_thermal_chip/ths_device > > > > and adds the process of the clock. > > > > > > > > This is pre-work for supprt it. > > > > > > > > Signed-off-by: Yangtao Li > > > > --- > > > > drivers/thermal/sun8i_thermal.c | 17 ++++++++++++++++- > > > > 1 file changed, 16 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c > > > > index b934bc81eba7..6f4294c2aba7 100644 > > > > --- a/drivers/thermal/sun8i_thermal.c > > > > +++ b/drivers/thermal/sun8i_thermal.c > > > > @@ -54,6 +54,7 @@ struct tsensor { > > > > }; > > > > > > > > struct ths_thermal_chip { > > > > + bool has_mod_clk; > > > > int sensor_num; > > > > int offset; > > > > int scale; > > > > @@ -69,6 +70,7 @@ struct ths_device { > > > > struct regmap *regmap; > > > > struct reset_control *reset; > > > > struct clk *bus_clk; > > > > + struct clk *mod_clk; > > > > struct tsensor sensor[MAX_SENSOR_NUM]; > > > > }; > > > > > > > > @@ -274,6 +276,12 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev) > > > > if (IS_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)) > > > > + return PTR_ERR(tmdev->mod_clk); > > > > + } > > > > + > > > > ret = reset_control_deassert(tmdev->reset); > > > > if (ret) > > > > return ret; > > > > @@ -282,12 +290,18 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev) > > > > if (ret) > > > > goto assert_reset; > > > > > > > > - ret = sun50i_ths_calibrate(tmdev); > > > > + ret = clk_prepare_enable(tmdev->mod_clk); > > > > > > You have to set rate of modclk before enabling it since you can't rely > > > on whatever bootloader left for you. > > > > > > Also I found that parameters you're using for PC_TEMP_PERIOD, ACQ0 and > > > ACQ1 are too aggressive and may result in high interrupt rate to the > > > point when it may stall RCU. I changed driver a bit to use params from > > > Philipp Rossak's work (modclk set to 4MHz, PC_TEMP_PERIOD is 7, ACQ0 > > > is 255, ACQ1 is 63) and it fixed RCU stalls for me, see [1] for > > > details. > > > > Why is the RCU stall happening, is it caused by a deadlock? > > Can you provide log information and your configuration? > > I am a bit curious. > > It's not deadlock, I believe it just can't handle that many interrupts > when running at lowest CPU frequency. Even with Philipp's settings > there's ~20 interrupts a second from ths. I don't remember how many > interrupts were there with your settings. > > Unfortunately there's nothing interesting in backtraces, I'm using > Pine64-LTS board. Recently there was a similar issue, with buggy CCU driver that caused CIR interrupts being fired constantly, and it also resulted in RCU stalls. Looks like a comon cause of RCU stalls. THS timing settings probably need to be made specific to the SoC, because I noticed that the same settings lead to wildly different timings on different SoCs. It would be good to measure how often ths interrupt fires with this driver on various SoCs. 20 times a second and more sounds like overkill. I'd expect a useful range to be at most 5-10 times a second. That should be enough to stop overheating the SoC due to suddenly increased load, even without a heatsink. regards, o. > > Thx, > > Yangtao > > > > > > > > [1] https://github.com/anarsoul/linux-2.6/commit/46b8bb0fe2ccd1cd88fa9181a2ecbf79e8d513b2 > > > > > > > > > > if (ret) > > > > goto bus_disable; > > > > > > > > + ret = sun50i_ths_calibrate(tmdev); > > > > + if (ret) > > > > + goto mod_disable; > > > > + > > > > return 0; > > > > > > > > +mod_disable: > > > > + clk_disable_unprepare(tmdev->mod_clk); > > > > bus_disable: > > > > clk_disable_unprepare(tmdev->bus_clk); > > > > assert_reset: > > > > @@ -395,6 +409,7 @@ static int sun8i_ths_remove(struct platform_device *pdev) > > > > { > > > > struct ths_device *tmdev = platform_get_drvdata(pdev); > > > > > > > > + clk_disable_unprepare(tmdev->mod_clk); > > > > clk_disable_unprepare(tmdev->bus_clk); > > > > reset_control_assert(tmdev->reset); > > > > > > > > -- > > > > 2.17.1 > > > > > > > > > > > > _______________________________________________ > > > > linux-arm-kernel mailing list > > > > linux-arm-kernel@lists.infradead.org > > > > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel