Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp366952pxb; Thu, 21 Oct 2021 00:47:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzJCdJrqT7Xb0SI4oa5oLQ2/oRni9hGtpnV054QkI/8QCpkx234AEFZ0LLlaydzySXoybO X-Received: by 2002:a50:9b06:: with SMTP id o6mr5709703edi.284.1634802441296; Thu, 21 Oct 2021 00:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634802441; cv=none; d=google.com; s=arc-20160816; b=sBmsWghYi2/cbzmJ3tU9NI3IjCItYTWwwITpaOo2TgZyP+mdj3Rsem4nQ6lZ5P3+nr tOgJq2lXReRoz9QkHx1Vd4863iRb/A/Rme/zEZreJQOo56xmxLv8oYioHBBB53G043MA +xmKwWglZa9H/FHtVyPbgcu1e+uD+B1290ViXUhCvSYeHnXTq3MrqfDookKnouepN5dA Pp/fotwQjspULPo0WpATHmKuOg3YDhG9CX0ug2I6Hpvkfj5f6po4cSNrSVMXsVNf3hqV tdftSZv1SzFfRvT3THdCgsElyInoFFeTNQrofRjv1XKYN8ST5fWrETSqrsxExvtZnHyY VlqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=WAdOIJ+GdNDKuMV1ZUKEZxDsVVhnzQAW5U/Cc2WF2fg=; b=QiUwtFcgr8Ri5Q24voy+X7v2ofdN4SKDG53F5R4PSWcfl8HQxcycJMcd8d2gInpaEB i7OTzYXkhItjvIgCGH93lI8690DEiU690bVbX/wb+43VfCaB6TRqVOOlD2kP+Ht6J42B 5FV+h43YzrFehgk+y/SswiqhRMGDrtSRJpQK6K5udXO7pfyqd2bBDiF2sCx57xnAmuKJ C2GfxYE9KzA0pCWY7f4e4HmrdGQg1KUxTpjZ5jhc4fbh4lPOwKB0Etxwfr2mfz40fJpZ ph5XOFfXLVRxt+WrknjMHSUpD8FehkneO3WobrCmoY46YSbDlWvwvZOVY7yqfkS1pZHO 8pFQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sb15si7487304ejc.427.2021.10.21.00.46.58; Thu, 21 Oct 2021 00:47:21 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231319AbhJUHrV (ORCPT + 99 others); Thu, 21 Oct 2021 03:47:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231287AbhJUHrU (ORCPT ); Thu, 21 Oct 2021 03:47:20 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F334DC061749 for ; Thu, 21 Oct 2021 00:45:04 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mdSl1-0002iG-3h; Thu, 21 Oct 2021 09:44:59 +0200 Received: from ore by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1mdSky-0000cq-M2; Thu, 21 Oct 2021 09:44:56 +0200 Date: Thu, 21 Oct 2021 09:44:56 +0200 From: Oleksij Rempel To: Daniel Lezcano Cc: Petr Benes , Michal =?utf-8?B?Vm9rw6HEjQ==?= , linux-pm@vger.kernel.org, Shawn Guo , Sascha Hauer , Amit Kucheria , linux-kernel@vger.kernel.org, Andrzej Pietrasiewicz , NXP Linux Team , Pengutronix Kernel Team , David Jander , Zhang Rui , Fabio Estevam , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2] thermal: imx: implement runtime PM support Message-ID: <20211021074456.GD2298@pengutronix.de> References: <20211019130809.21281-1-o.rempel@pengutronix.de> <20211020050459.GE16320@pengutronix.de> <20211021072000.GC2298@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 09:43:36 up 245 days, 11:07, 119 users, load average: 0.15, 0.12, 0.12 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 21, 2021 at 09:41:35AM +0200, Daniel Lezcano wrote: > On 21/10/2021 09:20, Oleksij Rempel wrote: > > Hi Petr, > > > > On Wed, Oct 20, 2021 at 05:53:03PM +0200, Petr Benes wrote: > >> On Wed, 20 Oct 2021 at 07:05, Oleksij Rempel wrote: > >>> > >>> Hi Petr and Michal, > >>> > >>> I forgot to add you for v2 in CC. Please test/review this version. > >> > >> Hi Oleksij, > >> > >> It works good. with PM as well as without PM. The only minor issue I found is, > >> that the first temperature reading (when the driver probes) fails. That is > >> (val & soc_data->temp_valid_mask) == 0) holds true. How does > >> pm_runtime_resume_and_get() behave in imx_thermal_probe()? > >> Does it go through imx_thermal_runtime_resume() with usleep_range()? > > > > On the first temperature reading, the PM and part of HW is not > > initialized. Current probe sequence is racy and has at least following > > issues: > > - thermal_zone_device_register is executed before HW init was completed. > > It kind of worked before my patch, becaus part of reinit was done by > > temperature init. It worked, since the irq_enabled flag was not set, > > but potentially would run enable_irq() two times if device is > > overheated on probe. > > - the imx_thermal core is potentially disable after first race > > condition: > > CPU0 CPU1 > > thermal_zone_device_register() > > imx_get_temp() > > irq_enabled == false > > power_up > > read_temp > > power_up > > power_down > > irq_enabled = true; > > > > ... at this point imx_thermal is powered down for some amount of time, > > over temperature IRQ will not be triggered for some amount of time. > > > > - if some part after thermal_zone_device_register() would fail or > > deferred, the worker polling temperature will run in to NULL pointer. > > This issue already happened... > > > > After migrating to runtime PM, one of issues started to be visible even > > on normal conditions. > > I'll send one more patch with reworking probe sequence. > > Are you planning to send a v3 with this patch? Or a separate patch? I'm OK with both variants. What do you prefer? I'll do i on top of PM patch to reduce refactoring overhead, if you OK about it. Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |