mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mingyou Chen <qby140326@gmail.com>
To: "Chris Taraszka" <chris@miget.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Ilya Gladyshev <ilya.gladyshev@linux.dev>,
	Armin Wolf <W_Armin@gmx.de>, KentoNion <kento@kekto.ru>,
	Matias Civadda <matias.civadda2342001@gmail.com>
Subject: Re: [PATCH v2 2/2] platform/x86: bitland-mifs-wmi: Don't fail suspend or resume on profile errors
Date: Mon, 26 Oct 2026 17:30:29 +0800	[thread overview]
Message-ID: <5360953a-ed8a-450b-93c2-f55876af8600@gmail.com> (raw)
In-Reply-To: <20261025195456.43414-3-chris@miget.com>

On 10/26/26 03:54, Chris Taraszka wrote:
> bitland_mifs_wmi_suspend() returns the laptop_profile_get() error to
> the PM core, which aborts the whole system suspend. This happens on any
> machine whose firmware reports a SystemPerMode value that is missing
> from its profile table, and on such a laptop with the lid closed logind
> keeps retrying the suspend, so the machine stays awake and drains its
> battery.
>
> bitland_mifs_wmi_resume() likewise returns any error other than
> -EOPNOTSUPP from restoring the profile, so the resume is reported as
> failed although the machine is fully usable.
>
> Saving and restoring the platform profile is best effort. Warn and
> continue instead of failing the system transition, and skip the restore
> when nothing was saved, so resume does not write a stale or default
> profile.
>
> Fixes: dc1ec4fa86b2 ("platform/x86: bitland-mifs-wmi: Add new Bitland MIFS WMI driver")
> Signed-off-by: Chris Taraszka <chris@miget.com>
> ---
>
> Notes:
>      Tested on the same machine with v13 and this patch, without patch 1,
>      and the firmware in 0x04. v13 alone aborts a pm_test=devices suspend:
>      
>        bitland_mifs_wmi_suspend [bitland_mifs_wmi] returns -22
>        PM: failed to suspend: error -22
>      
>      With this patch the suspend completes, "Failed to save platform
>      profile: -22" is logged and the firmware is still in 0x04 after resume.
>      
>      This supersedes "platform/x86: bitland-mifs-wmi: Don't abort suspend
>      when platform profile access fails" [1], reworked on top of v13 6/7.
>      
>      [1] https://lore.kernel.org/all/20260911182131.461415-1-chris@miget.com/
>
>   drivers/platform/x86/bitland-mifs-wmi.c | 22 +++++++++++++++-------
>   1 file changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86/bitland-mifs-wmi.c
> index 73be63146fd5..df9a931fa939 100644
> --- a/drivers/platform/x86/bitland-mifs-wmi.c
> +++ b/drivers/platform/x86/bitland-mifs-wmi.c
> @@ -237,6 +237,7 @@ struct bitland_mifs_wmi_data {
>   	struct device *pp_dev;
>   	const struct bitland_mifs_quirks *quirks;
>   	enum platform_profile_option saved_profile;
> +	bool profile_saved;
>   };
>   
>   static int bitland_mifs_wmi_call(struct bitland_mifs_wmi_data *data,
> @@ -408,10 +409,15 @@ static int bitland_mifs_wmi_suspend(struct device *dev)
>   		return 0;
>   
>   	ret = laptop_profile_get(data->pp_dev, &profile);
> -	if (ret == 0)
> -		data->saved_profile = profile;
> +	data->profile_saved = !ret;
> +	if (ret) {
> +		dev_warn(dev, "Failed to save platform profile: %d\n", ret);
> +		return 0;
> +	}
>   
> -	return ret;

What value does the firmware respond?

This patch fixes the suspend problem, but it hides the real driver 
problem (unsupported profile entry).

I saw 0x04 in your patch "platform/x86: bitland-mifs-wmi: Add Xiaomi 
Book Pro 14 quirk".

If result.data[0] in laptop_profile_get actually equals 0x04, the 
function should be succeed, but it doesn't.

Is there another no_set (for read only) profile entry for the 
performance profile?

> +	data->saved_profile = profile;
> +
> +	return 0;
>   }
>   
>   static int bitland_mifs_wmi_resume(struct device *dev)
> @@ -419,8 +425,8 @@ static int bitland_mifs_wmi_resume(struct device *dev)
>   	struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev);
>   	int ret;
>   
> -	/* Skip event device */
> -	if (!data->pp_dev)
> +	/* Skip event device, or nothing was saved on suspend */
> +	if (!data->pp_dev || !data->profile_saved)
>   		return 0;
>   
>   	ret = laptop_profile_set(dev, data->saved_profile);
> @@ -436,8 +442,10 @@ static int bitland_mifs_wmi_resume(struct device *dev)
>   		}
>   	}
>   
> -	dev_dbg(dev, "Resuming, restoring profile %d\n", data->saved_profile);
> -	return ret;
> +	if (ret)
> +		dev_warn(dev, "Failed to restore platform profile: %d\n", ret);
> +
> +	return 0;
>   }
>   
>   static DEFINE_SIMPLE_DEV_PM_OPS(bitland_mifs_wmi_pm_ops,

  reply	other threads:[~2026-10-26  9:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-25 19:54 [PATCH v2 0/2] platform/x86: bitland-mifs-wmi: Xiaomi Book Pro 14 support Chris Taraszka
2026-10-25 19:54 ` [PATCH v2 1/2] platform/x86: bitland-mifs-wmi: Add Xiaomi Book Pro 14 quirk Chris Taraszka
2026-10-26  9:22   ` Mingyou Chen
2026-10-25 19:54 ` [PATCH v2 2/2] platform/x86: bitland-mifs-wmi: Don't fail suspend or resume on profile errors Chris Taraszka
2026-10-26  9:30   ` Mingyou Chen [this message]
2026-10-26  9:48     ` Chris Taraszka
2026-10-26 10:05       ` Mingyou Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5360953a-ed8a-450b-93c2-f55876af8600@gmail.com \
    --to=qby140326@gmail.com \
    --cc=W_Armin@gmx.de \
    --cc=chris@miget.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=ilya.gladyshev@linux.dev \
    --cc=kento@kekto.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matias.civadda2342001@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®