Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp505675lqt; Thu, 6 Jun 2024 09:39:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX7EPPAWS0SxR75ImE3SMX1JnVduyzIBrqYugJKey0XFlP9RzqjLwXAR/l1Fotup2KZRVwc7kjrxBymiLVUKQH8gWEUXladB7/x22kCgg== X-Google-Smtp-Source: AGHT+IE0BF+v1v0wauM1tj5apdBgPkttGRp7F3mmTFlpkhD308Mzbun3tLZweThYtWX9etycdlMT X-Received: by 2002:a05:6214:3d0a:b0:6af:c320:5f16 with SMTP id 6a1803df08f44-6b05951119bmr3557896d6.7.1717691958671; Thu, 06 Jun 2024 09:39:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717691958; cv=pass; d=google.com; s=arc-20160816; b=a0HalZhdyUe0z6xnLZin/3FqKmVPLVe7WsMBM3SWk4ZIAlbU6ugR6hJ7eRUGEqRZQn p0rApv1N9/+PXjZsmvsz3bSAIwlK7UoSn/dD5FeQ3daYdisDFBb0w4sZKBfCzQVP9/bW QzyK4LiXwjJUP+ZzJht3ciWLOjqboPWX98sSrJbeZ7WiTeu7AvCW5bSDjANeWPzzLFqK CNIsQw1B2CmZMNfGmDjz9vnR4fXK/8zLTHuZKxQvgQ83jakMek+cFOFLwKu531BDdIj1 Vk9yyHwrB2wuAD22/0atZb5XRMXxP9NKeIU+kuE25bXPJ2ZIDPmdaNYdW/WHw6LrB/B4 ZEDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=BXdSRq/xXQtY4fK65pJyyKeGGdpvh+lT4zYhLPfTB4c=; fh=Uy2um15TM94sl/ZNZyfVPHGaa6iZ2WJ/x7nv018BgWI=; b=m+GnbFTMUZfG83UGNRA/gpApfFC6AMnxKFtb4SWcrV8ef9KXXTJCSAu8SZljZwAVJ2 a/r1aA/CgOO3YJdTmNBZLwOX1ubSOZWDu53c9i1mgGS1Hh4kOXpJZOx7JPNt7f5xU2CZ ZYhHgW59ZXGY5gHSMgZ0gYA4CfzvQG63p1zu5KZBdZDOpqdWcxhu/IEh5jjiglGZ95y6 4e0O8xhxT2EupiA0e5Wq3dq7FtsIqJOsn7QWxLz7drDO6RmN2gXEnFLr6jqjXZDgVgGa Gwr3rv+h5o6Zd3ea5GLoSldHuYW46ngQMnvbMu7Wh8kndIwconqSVirfCUVBay6svS8B mZPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrmS2OSU; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-204710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204710-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-44038b68125si19404141cf.627.2024.06.06.09.39.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 09:39:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LrmS2OSU; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-204710-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204710-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 54AD81C22194 for ; Thu, 6 Jun 2024 16:39:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB29B198A20; Thu, 6 Jun 2024 16:39:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LrmS2OSU" Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27C4C197A8A for ; Thu, 6 Jun 2024 16:39:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717691946; cv=none; b=tmYhiqUvxrsEDQ8s10D/+T+B1GZwluRVoiUGJ8Da8ntc7lIkb0dzU+2Y4rb9CqBLRp8gp98OOB+tuZ+dNDOYS0glRm/pSazs/LNkeuNvLE2ya0htUecCjBJNWBPgMNA1qLS0OoegdxtGc8df/K1pfphyZmcodNq3jEXEuSszwxs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717691946; c=relaxed/simple; bh=0sUhzePxA5ILJh6kcxhT9jhNMheNOJsBhpMUA+zrAr4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FU3QaZUEqZY2OiRKpRYjqPHvAqShmgEPlPIT7vVFtCAmF55GyXHr3wYrjB7aiPn4Yu3IwevrZbb46Kb937gPHOlyM88W4P719lDcSt7kk++0n8jmaOR25lX8XZd4PVwW8+airos8lw5pW8OtQzob4DaRAZ8HMLKVB9IPbeI13lw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=LrmS2OSU; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-35e573c0334so1382362f8f.1 for ; Thu, 06 Jun 2024 09:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717691943; x=1718296743; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=BXdSRq/xXQtY4fK65pJyyKeGGdpvh+lT4zYhLPfTB4c=; b=LrmS2OSUCUbTBiodfAgWSYWBnMDqVBYu654UCCncw8BnmKEab2fmtG3UBUnMs/iZ4U Y6rR4or+YvlJn3ET8aiaNNIMcJh8yC2MqGvhYuFS9fM/aGPSHmwYXKdaSbKfCFfsOdU2 mdkhX48BAncBwkaRhRb3JlYBtUyqkoz+iL6HwJpYZEvxVScQtXMKno38jZpOzuLt0leq w50y1EQSsgPA0+YNZK36o9GjH8ixnSawCSVNUnzlLZRqCJGYBm5bHo7Ciyt6E0SG2HS7 vVzeFAOPa7hESOy3Zaa0LmlnB1sHGLAsWo63dAkbMTRo7r2iM9HXh7mr0oFH1CJR//B0 vUQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717691943; x=1718296743; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BXdSRq/xXQtY4fK65pJyyKeGGdpvh+lT4zYhLPfTB4c=; b=CRU+H8LIhIarcQcPbVf/KmqmaOGdojjJD93QJ+eglf88dX+nClBkEjrRojC21g3uWl z6lZ2yxVEaMqZar2kfjLdYGXmMrWvzb98OaqvCFtlh+9cEfDdfTld+vGRaTm5GuD0Hey feK2H5nVLSvEy4Vuz7w6jgwUvTXtr8S79LmwzPK0b+YtzTpMkF5smaSWy1smuJkhCeAK aJUr86/bv/o3JCll0hxArnDe05KkTsqWC2Ppwx01UZMFZ42O6v1AVPrxNN1C3dpGTkMj kLwEZJEWKjJjPNMigSF5aRINFGPEcI/nHb62oK2IASuIjyU3Z9PjWe6qvl5Al54C5XaO AKFQ== X-Forwarded-Encrypted: i=1; AJvYcCU1wsdEpuHOEaO9P49otVrsmbdiGKTUWMdOiNvlt0W2g9/9oLc5cMyjFGm0o69WdxuK4wCbEPYxhygSyy6MnGxQaglQ0yr6xaIpr+Aj X-Gm-Message-State: AOJu0YwcL8QmLWy6r9dMBOQK5ubt7LrLE4VOS6AqthwGoO5JQSwzwozq ryIcQigzhivXMA3zLvdCAM860pry1eMhzZpFB2HNqx7XXMeAMbBO9rxgrAu5f4Y= X-Received: by 2002:adf:ed52:0:b0:355:b9d2:4667 with SMTP id ffacd0b85a97d-35efea6fa89mr211455f8f.29.1717691943486; Thu, 06 Jun 2024 09:39:03 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:f9a9:3740:b905:9995? ([2a05:6e02:1041:c10:f9a9:3740:b905:9995]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-35ef5d4a827sm1984629f8f.36.2024.06.06.09.39.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Jun 2024 09:39:03 -0700 (PDT) Message-ID: Date: Thu, 6 Jun 2024 18:39:02 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] thermal: core: Do not fail cdev registration because of invalid initial state To: "Rafael J. Wysocki" , Linux PM , Laura Nao Cc: Linux ACPI , LKML , Lukasz Luba , Srinivas Pandruvada , Zhang Rui References: <6056838.lOV4Wx5bFT@kreacher> Content-Language: en-US From: Daniel Lezcano In-Reply-To: <6056838.lOV4Wx5bFT@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 06/06/2024 18:08, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > It is reported that commit 31a0fa0019b0 ("thermal/debugfs: Pass cooling > device state to thermal_debug_cdev_add()") causes the ACPI fan driver > to fail probing on some systems which turns out to be due to the _FST > control method returning an invalid value until _FSL is first evaluated > for the given fan. If this happens, the .get_cur_state() cooling device > callback returns an error and __thermal_cooling_device_register() fails > as uses that callback after commit 31a0fa0019b0. > > Arguably, _FST should not return an invalid value even if it is > evaluated before _FSL, so this may be regarded as a platform firmware > issue, but at the same time it is not a good enough reason for failing > the cooling device registration where the initial cooling device state > is only needed to initialize a thermal debug facility. > > Accordingly, modify __thermal_cooling_device_register() to avoid calling > thermal_debug_cdev_add() instead of returning an error if the initial > .get_cur_state() callback invocation fails. > > Fixes: 31a0fa0019b0 ("thermal/debugfs: Pass cooling device state to thermal_debug_cdev_add()") > Closes: https://lore.kernel.org/linux-acpi/20240530153727.843378-1-laura.nao@collabora.com > Reported-by: Laura Nao > Signed-off-by: Rafael J. Wysocki > --- > > v1 -> v2: > * Instead of making the thermal debug code effectively ignore the invalid > initial cooling device state, simply don't register thermal debugfs for > a cooling device if its initial state returned by the driver's > .get_cur_state() is invalid (Daniel). > > Laura, please test this one even though I don't see why it wouldn't work for > you if the v1 did. > > --- > drivers/thermal/thermal_core.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > Index: linux-pm/drivers/thermal/thermal_core.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_core.c > +++ linux-pm/drivers/thermal/thermal_core.c > @@ -1001,7 +1001,7 @@ __thermal_cooling_device_register(struct > > ret = cdev->ops->get_cur_state(cdev, ¤t_state); > if (ret) > - goto out_cdev_type; > + current_state = ULONG_MAX; Why not move the section ? So we end up below. > > thermal_cooling_device_setup_sysfs(cdev); > > @@ -1016,7 +1016,8 @@ __thermal_cooling_device_register(struct > return ERR_PTR(ret); > } > > - thermal_debug_cdev_add(cdev, current_state); > + if (current_state <= cdev->max_state) > + thermal_debug_cdev_add(cdev, current_state); ret = cdev->ops->get_cur_state(cdev, ¤t_state); if (!ret) thermal_debug_cdev_add(cdev, current_state); Additionally a comment here to explain why get_cur_state can fail and telling it is up to the driver to fix its routine? > /* Add 'this' new cdev to the global cdev list */ > mutex_lock(&thermal_list_lock); > > > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog