Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp378186pxb; Thu, 21 Oct 2021 01:04:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqgEdvP6k3QL7tFjcMDSZoe/m091MZvPxcvreXcgpvVTsdhd+d94JzEG4CMC3uvGynbKpE X-Received: by 2002:a17:907:9687:: with SMTP id hd7mr5268010ejc.535.1634803462892; Thu, 21 Oct 2021 01:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634803462; cv=none; d=google.com; s=arc-20160816; b=FF26brHq3Rhu7vqNAI16f6uvLKJaZoXtGYOnWVD6pMAfsTKmzB8Xj6Pto/Vw1b+63G HvGVuJnghhYVQLVWYV7qqGoKtAcgKbO/8FDRJ7Ai5eg7khvi1OnH0pp2M4pTkuAsk62T oGH2SbR6JPTmgjSm/dam+DHXGyOXiXYuKtFtB37LhsXUxq1lqIFXOHCo7F9RJSS/MUle 8gg2MmdLMJRCiGolpVW6rT1o5quleykggTlNxc6FjT8JOgQXw4P3zC4MmU6hdAWF5JSQ qtK6vjONMEag43Tht1GT7OYr83gtol/kmXP7lzNzhj2/BeI25H7na7I2ogmlayNfyq1n dhyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=mpBk3CGGBQxOjdLo0meuYKa3n7EnDSifXrr7ewVJe00=; b=rVGvO6S0v053VnWSxGAPHnH8UBHgyYwsaGeOb7RlLLQrrA7VZE5HB/TtYAsvsIrW30 t2jBy8gZ3mK8laihVk/E1vfzJMe4pM6D6YCHho3U9AbgmIJCN/p043Kbo40xOvJQH858 Ry9wmgbYRcblmXWS70izOtWZKXcORC/62wUofFHuxQE8TtR5PFs8L4jKlT+twpyuxE2b rPNhY/RWjUVDDkvEbb8h+uwMbcG9O+tC+7RKFnpeU3Ja7v+fOMyxz5dR9NV8zQXg/mSm +XE02q5NOqkwbmZddAIlVOlwmnguc1wBMEHxWHwIbP02MLk9QMIe90KXe3yiiwyha4ky Z60g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x2dsJWU0; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o17si9650672edc.228.2021.10.21.01.03.33; Thu, 21 Oct 2021 01:04:22 -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=@linaro.org header.s=google header.b=x2dsJWU0; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230440AbhJUH6e (ORCPT + 99 others); Thu, 21 Oct 2021 03:58:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231158AbhJUH6e (ORCPT ); Thu, 21 Oct 2021 03:58:34 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72571C061749 for ; Thu, 21 Oct 2021 00:56:18 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id o24so14571649wms.0 for ; Thu, 21 Oct 2021 00:56:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=mpBk3CGGBQxOjdLo0meuYKa3n7EnDSifXrr7ewVJe00=; b=x2dsJWU0DmewCEoW4HMlYFcsU1ENwqA1YmdVjuHsflJ6a4qeIdyB9v10R8IgpLhvfj zcGA3WMue61oYUGVvl63bF+d6HOLXZt4zwPc4qx+BC3ospWCTypf3o83PbzgU800Zvj4 +ke6hur0RkUzRAKzTACpteO9pC3H9baH91enXLkXpl14qXi0DE6wBXEiiAC2FX8uxk2O coIz2OzWXqJg0OSOhxtX2lzGc3giqRcio6w+kh7/kPCIdgVTv+lZbkz4hQ4aVyt9JDBw /xvuHhDxECyPH2lqBlYg5i/FEx2l+yUs4PA9csb3FCjgcZ/wOFrFbrLEBJaA+Bm9YZ8Y y1BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mpBk3CGGBQxOjdLo0meuYKa3n7EnDSifXrr7ewVJe00=; b=kptvpEZ17qsUVYI/+WUJkxd3ZDoAmlFGhjOUyVnPdUwFKqWscJ2+9pewdzkUDS0y0R u90/9bdnXVbNz8xpUtSYsg7bTfoyfiKrIk8LtJh3CpR0uqwvJoEI3iHfxUVe/bJvD2/c 8G6t/K1bmBKQvNnb9xY7eYUqJ/85IcOsG81lsiM9/5G9XfLmoHTaaErgqeLSLv/q4cP9 J8B43kHPsf+3GKr0c/9Tm0ynZgRL8ihcd9hdR8xlgHestSUqPEuD3dAuRvFnO+Wl9FMT bTL4EIhe3f7S3S0JFc+YVbA6dclYCG+5D+BzT1wQhP39ZbzXMK3IhATfUX/Z1UefSvDb uttw== X-Gm-Message-State: AOAM53222wRO/g4ucqsihNq+6rgrdF4G0jVlSu2PCRqNWe4oJafelHHb EA7HpNolAmyw2k3DFI6G269azw== X-Received: by 2002:a1c:d1:: with SMTP id 200mr4721550wma.86.1634802976877; Thu, 21 Oct 2021 00:56:16 -0700 (PDT) Received: from ?IPv6:2a01:e34:ed2f:f020:2a2c:7ed:66a0:d637? ([2a01:e34:ed2f:f020:2a2c:7ed:66a0:d637]) by smtp.googlemail.com with ESMTPSA id x24sm7738157wmk.31.2021.10.21.00.56.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Oct 2021 00:56:16 -0700 (PDT) Subject: Re: [PATCH v2] thermal: imx: implement runtime PM support To: Oleksij Rempel Cc: Petr Benes , =?UTF-8?B?TWljaGFsIFZva8OhxI0=?= , 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 References: <20211019130809.21281-1-o.rempel@pengutronix.de> <20211020050459.GE16320@pengutronix.de> <20211021072000.GC2298@pengutronix.de> <20211021074456.GD2298@pengutronix.de> From: Daniel Lezcano Message-ID: Date: Thu, 21 Oct 2021 09:56:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211021074456.GD2298@pengutronix.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/10/2021 09:44, Oleksij Rempel wrote: > 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. I prefer you resend a couple of patches but change the subject of this patch to something like "thermal/drivers/imx: Fix disabled sensor after handling trip temperature" in order to reflect the problem, not the solution. btw: nice fix -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog