Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp426018lqt; Thu, 6 Jun 2024 07:39:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZmC427vzJLeBhcE6E1cJBot4iBPVJqVCcf1yHF3m9ydEU6ptLeaU0hTPBIj8CM3G8pO4wopM5dQJ9MeXJVqBSs3hmExGy8OlytPLXkQ== X-Google-Smtp-Source: AGHT+IGAT6Ux9eUnYoLmA7Dq4CTkGw0/+Rg1BadkaoNA8boXNw6Fmjb8cRS/HH/ha+fNdmw149w0 X-Received: by 2002:a05:6a21:2785:b0:1b0:14ee:3b1b with SMTP id adf61e73a8af0-1b2b712257fmr5004880637.38.1717684796876; Thu, 06 Jun 2024 07:39:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717684796; cv=pass; d=google.com; s=arc-20160816; b=FeNGUmqLQhqADvD7tLSqdsi0/jG/u79B8pHOYD0/w+YuJJOXYCodfWRdTZ7eE/Fw8D 1io5UJh9z0AgDHSuXc/B9+wmRvoJ1RJCIOkGWkYn/iF1oOLdWPEFT+IG/Ry61RlcUl7p Nq4L8oOMEFipDxQRRHe50Ou0vGaKVTTI6MpSZQ1PXo2bMe3hUGDITLsQNaftmTt/l7hb 6QIyZ5ZA8XNQ5GqjsQrl4xYXebDHHpfW9cvJDnXxNPe/oK5wI5hPTSqN5x9RfZ8m6dBd OYUFjgx+4JJIpvVIlZgjti1aMofn8Oq6bq/oClHiHYxHwMK6JifTU+z3OwrUKBCDs0Xe penQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=SL57AMK3JCuf5BTOsSqsHb8MSAXRd7+PXMtAMIWg3T4=; fh=EHsoirzb6y+LNITVNqUZbxyhlDCCljKUIAbCJI+9XSo=; b=AuC0kmayTQ6ddx4kfdoFlsbu86WgMBNpL4k+QBXuPtwbcVj8xYLv3PPfWrF3LoHLYg fMYVf4gw6ZZ6bv6d89HjjFNYaP1Pz/MZCNOvtWY/FB23B39tD8ufqUJGSangXFyp59s+ 23H4gzo0m7c81r/HmAxIqa4tUewPpy4s6PH4ztLJtTEe0V2OTIUET/poT2bjiuRz3lZN m5NH+s3crWlDV9CehZLyTlXFkNTQMiTSw6SjosphPZjl76dgoHSMc4bgH9mAIlGGvq0M qAM0aT3x5qr5jggF07Cg/ZqevOgzZxue9INxBkXr0T5XtDYIJV2xDnyaAcyxZJMLzo2p sF8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VF7kITSp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-204436-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204436-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de275fe4c0si1227500a12.508.2024.06.06.07.39.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 07:39:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-204436-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VF7kITSp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-204436-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-204436-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 761B42859F0 for ; Thu, 6 Jun 2024 14:39:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C01B21BE22C; Thu, 6 Jun 2024 14:18:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VF7kITSp" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC21A1BD515; Thu, 6 Jun 2024 14:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683529; cv=none; b=CE4H9Diw48VxjKmnT/XvTMpLKA/oilg0dML+VJWYyElflynTWIYajCuIPP/0wRVRHYy9RwBmQ8N91oyQqvIR9x7fN/U+aci4S1ZtL2z1X2W+2vFDwGHVhTyzjijpFFdGuEo/lOyoqumhpcF+osVUXQUhc83D+yb1dxD3nDB8ves= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683529; c=relaxed/simple; bh=YYYTroV05/ffOg/2MOMOK0Q5DM2WQSttah0HBo7odRE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZOry2x2Z5lACgNISTWQqV5mEtHfL0gy4xJBru44Dn9jr8xeP6/JVXB/9VJljA5BEjaxt4KYPson2Y31C01UuDDCM74AZwoZRkzThW4pdCFYQlmHfxtZ6bF/zemMqCvv3FW/GFpQ3i1m6+VFA8m0Jp817dcydoAq+aNBIFk4BxCs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VF7kITSp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7247AC4AF07; Thu, 6 Jun 2024 14:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717683528; bh=YYYTroV05/ffOg/2MOMOK0Q5DM2WQSttah0HBo7odRE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=VF7kITSpIgY4KyL8V/XPxYu/IHtOPcdTwdWxZP2r5ILxJxElcMkknv5n3mvF93KOO ijiTMwphiy4NYiId6FlPGGZ+L10ztLFctBtLUvMFABVYnlBQVC7PQ4ZJ/qri38egdH Ati0bxx0t9CkBNXst0FYgn0BARCknxK0b98t1y+nvAsNkEXqsTtkYZF91JPn8Nm8eY nqsVVxrWeCcubzNUCXv9pZMiv7AXijdt+6n1EmBbA8QdHvYiY5bz++zNmfVosMkxmi ErabVl3pDXRUrIj0gUkmUQOY5GXXTYQyAYH0Zopgr9pGn6eqjr40W9hlJPRNSSLp6E 2/SnFxRpOyNKQ== Received: by mail-oo1-f41.google.com with SMTP id 006d021491bc7-5b3364995b4so147269eaf.0; Thu, 06 Jun 2024 07:18:48 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWE9gmlsPhixLihakg/zgPv4kzNJlVICb0ygsTtQlXUK/rwNX6kwGe6kENBWFaJ8hMYBq08JMadRQjtdZRY8gFmAoCLcxusDyunuFTAnrSJFK4BH0Tp4a9ZPpNAoemeMrxCUwiZBJkHmZsx6oUEFFp7BNfhV1DTxQMPlMtAaLgRzXYO X-Gm-Message-State: AOJu0YwmzjHbDQYU2XjCvFq651WaZz7bwpM7tihqqcnVaOsxtPnub7FB TKMchCsLzBJnJGG0yF74vKizsCgZ3rLGil+xZjJU+HRkanP+bjA69rfzRCQw9+tcZazfKjNPqjT 6dVUeOwDLued27wRFrO2njUm49k0= X-Received: by 2002:a05:6820:2b02:b0:5b2:7e47:e914 with SMTP id 006d021491bc7-5ba78d3bb71mr442464eaf.0.1717683527592; Thu, 06 Jun 2024 07:18:47 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <4569763.LvFx2qVVIh@kreacher> <5f93f034-f781-47e0-b8ce-3c8407a709f7@linaro.org> In-Reply-To: From: "Rafael J. Wysocki" Date: Thu, 6 Jun 2024 16:18:35 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1] thermal: core: Do not fail cdev registration because of invalid initial state To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Linux PM , Linux ACPI , LKML , Lukasz Luba , Srinivas Pandruvada , Zhang Rui , Laura Nao Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jun 6, 2024 at 3:42=E2=80=AFPM Rafael J. Wysocki wrote: > > On Thu, Jun 6, 2024 at 3:07=E2=80=AFPM Daniel Lezcano wrote: > > > > On 05/06/2024 21:17, Rafael J. Wysocki wrote: > > > From: Rafael J. Wysocki > > > > > > It is reported that commit 31a0fa0019b0 ("thermal/debugfs: Pass cooli= ng > > > 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 evaluat= ed > > > for the given fan. If this happens, the .get_cur_state() cooling dev= ice > > > callback returns an error and __thermal_cooling_device_register() fai= ls > > > as uses that callback after commit 31a0fa0019b0. > > > > > > Arguably, _FST should not return an inavlid 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 failin= g > > > the cooling device registration where the initial cooling device stat= e > > > is only needed to initialize a thermal debug facility. > > > > > > Accordingly, modify __thermal_cooling_device_register() to pass a > > > negative state value to thermal_debug_cdev_add() instead of failing > > > if the initial .get_cur_state() callback invocation fails and adjust > > > the thermal debug code to ignore negative cooling device state values= . > > > > > > Fixes: 31a0fa0019b0 ("thermal/debugfs: Pass cooling device state to t= hermal_debug_cdev_add()") > > > Closes: https://lore.kernel.org/linux-acpi/20240530153727.843378-1-la= ura.nao@collabora.com > > > Reported-by: Laura Nao > > > Tested-by: Laura Nao > > > Signed-off-by: Rafael J. Wysocki > > > > As it is a driver issue, it should be fixed in the driver, not in the > > core code. The resulting code logic in the core is trying to deal with > > bad driver behavior, it does not really seem appropriate. Besides, I don't quite agree with dismissing it as a driver issue. If a driver cannot determine the cooling device state, it should not be required to make it up. Because .get_cur_state() is specifically designed to be able to return an error, the core should be prepared to deal with errors returned by it and propagating the error is not always the best choice, like in this particular case. > > The core code has been clean up from the high friction it had with the > > legacy ACPI code. It would be nice to continue it this direction. This isn't really ACPI specific. Any driver can return an error from .get_cur_state() if it has a good enough reason. > Essentially, you are saying that .get_cur_state() should not return an > error even if it gets an utterly invalid value from the platform > firmware. > > What value should it return then?