From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from vps-ovh.mhejs.net (vps-ovh.mhejs.net [145.239.82.108]) (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 C0DA91ABED9; Wed, 8 Jan 2025 20:18:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=145.239.82.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736367507; cv=none; b=ZbwLbf1sXGHw3avxltW2crD5p9n3jas1xgFBLcnQh6LIrA2f+rAhwv08ocpIXVHtVl/Gs3mncjWBtG/nZEKAzjNb+NUVDVnFQzJ9w5yq+ucRz6Ei/0hMI2D7nDgsxRPRCDepXHZnpoDp1dMQrHjy6kuUJBn5wCoCtrkM6WeOWC8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736367507; c=relaxed/simple; bh=eQvOD5oObR9xJhsrh/E1FQya3AOWCKVE8dKE+vvzmTw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=k4Vt1RlfAa6K5RLUAabIqJUKfyvT7C2TFe2odAa+DckagYFgQt2MjI1+Au+e5rTkzSvsRk0JSHH6t6FT5H8cQzED7dR5OZ4Md4JEKfM7nllnfKKPGbLBrvG0+bUcOZbiWb0eZAFw5grMWiiLdt+Jt93tde+O02H+FVl57Nv1XKU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=maciej.szmigiero.name; spf=pass smtp.mailfrom=vps-ovh.mhejs.net; arc=none smtp.client-ip=145.239.82.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=maciej.szmigiero.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vps-ovh.mhejs.net Received: from MUA by vps-ovh.mhejs.net with esmtpsa (TLS1.3) tls TLS_AES_128_GCM_SHA256 (Exim 4.98) (envelope-from ) id 1tVcVM-00000005Q2v-1LVe; Wed, 08 Jan 2025 21:18:16 +0100 Message-ID: Date: Wed, 8 Jan 2025 21:18:11 +0100 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] net: wwan: iosm: Fix hibernation by re-binding the driver around it To: "Rafael J. Wysocki" Cc: Bjorn Helgaas , M Chetan Kumar , Sergey Ryazanov , Loic Poulain , Johannes Berg , Bjorn Helgaas , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, "Rafael J. Wysocki" , linux-pm@vger.kernel.org References: <20250108195109.GA224965@bhelgaas> <5df4a525-dc5d-405a-be07-5b33e94f5a4f@maciej.szmigiero.name> Content-Language: en-US, pl-PL From: "Maciej S. Szmigiero" Autocrypt: addr=mail@maciej.szmigiero.name; keydata= xsFNBFpGusUBEADXUMM2t7y9sHhI79+2QUnDdpauIBjZDukPZArwD+sDlx5P+jxaZ13XjUQc 6oJdk+jpvKiyzlbKqlDtw/Y2Ob24tg1g/zvkHn8AVUwX+ZWWewSZ0vcwp7u/LvA+w2nJbIL1 N0/QUUdmxfkWTHhNqgkNX5hEmYqhwUPozFR0zblfD/6+XFR7VM9yT0fZPLqYLNOmGfqAXlxY m8nWmi+lxkd/PYqQQwOq6GQwxjRFEvSc09m/YPYo9hxh7a6s8hAP88YOf2PD8oBB1r5E7KGb Fv10Qss4CU/3zaiyRTExWwOJnTQdzSbtnM3S8/ZO/sL0FY/b4VLtlZzERAraxHdnPn8GgxYk oPtAqoyf52RkCabL9dsXPWYQjkwG8WEUPScHDy8Uoo6imQujshG23A99iPuXcWc/5ld9mIo/ Ee7kN50MOXwS4vCJSv0cMkVhh77CmGUv5++E/rPcbXP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oyurU86/4sxjIbyhqL6ZiTzuZAmB0RICOIGilm5x03ESkDztiuCtQL2u xNT833IQSNqyuEnxG9/M82yYa+9ClBiRKM2JyvgnBEbiWA15rAQkOqZGJfFJ3bmTFePx4R/I ZVehUxCRY5IS1FLe16tymf9lCASrPXnkO2+hkHpBCwt75wnccS3DwtIGqwagVVmciCxAFg9E WZ4dI5B0IUziKtBxgwJG4xY5rp7WbzywjCeaaKubtcLQ9bSBkkK4U8Fu58g6Hg== In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: mhej@vps-ovh.mhejs.net On 8.01.2025 21:17, Rafael J. Wysocki wrote: > On Wed, Jan 8, 2025 at 9:04 PM Maciej S. Szmigiero > wrote: >> >> On 8.01.2025 20:51, Bjorn Helgaas wrote: >>> [+cc Rafael, linux-pm because they *are* PM experts :)] >>> >>> On Wed, Jan 08, 2025 at 02:15:28AM +0200, Sergey Ryazanov wrote: >>>> On 08.01.2025 01:45, Bjorn Helgaas wrote: >>>>> On Wed, Jan 08, 2025 at 01:13:41AM +0200, Sergey Ryazanov wrote: >>>>>> On 05.01.2025 19:39, Maciej S. Szmigiero wrote: >>>>>>> Currently, the driver is seriously broken with respect to the >>>>>>> hibernation (S4): after image restore the device is back into >>>>>>> IPC_MEM_EXEC_STAGE_BOOT (which AFAIK means bootloader stage) and needs >>>>>>> full re-launch of the rest of its firmware, but the driver restore >>>>>>> handler treats the device as merely sleeping and just sends it a >>>>>>> wake-up command. >>>>>>> >>>>>>> This wake-up command times out but device nodes (/dev/wwan*) remain >>>>>>> accessible. >>>>>>> However attempting to use them causes the bootloader to crash and >>>>>>> enter IPC_MEM_EXEC_STAGE_CD_READY stage (which apparently means "a crash >>>>>>> dump is ready"). >>>>>>> >>>>>>> It seems that the device cannot be re-initialized from this crashed >>>>>>> stage without toggling some reset pin (on my test platform that's >>>>>>> apparently what the device _RST ACPI method does). >>>>>>> >>>>>>> While it would theoretically be possible to rewrite the driver to tear >>>>>>> down the whole MUX / IPC layers on hibernation (so the bootloader does >>>>>>> not crash from improper access) and then re-launch the device on >>>>>>> restore this would require significant refactoring of the driver >>>>>>> (believe me, I've tried), since there are quite a few assumptions >>>>>>> hard-coded in the driver about the device never being partially >>>>>>> de-initialized (like channels other than devlink cannot be closed, >>>>>>> for example). >>>>>>> Probably this would also need some programming guide for this hardware. >>>>>>> >>>>>>> Considering that the driver seems orphaned [1] and other people are >>>>>>> hitting this issue too [2] fix it by simply unbinding the PCI driver >>>>>>> before hibernation and re-binding it after restore, much like >>>>>>> USB_QUIRK_RESET_RESUME does for USB devices that exhibit a similar >>>>>>> problem. >>>>>>> >>>>>>> Tested on XMM7360 in HP EliteBook 855 G7 both with s2idle (which uses >>>>>>> the existing suspend / resume handlers) and S4 (which uses the new code). >>>>>>> >>>>>>> [1]: https://lore.kernel.org/all/c248f0b4-2114-4c61-905f-466a786bdebb@leemhuis.info/ >>>>>>> [2]: >>>>>>> https://github.com/xmm7360/xmm7360-pci/issues/211#issuecomment-1804139413 >>>>>>> >>>>>>> Signed-off-by: Maciej S. Szmigiero >>>>>> >>>>>> Generally looks good to me. Lets wait for approval from PCI >>>>>> maintainers to be sure that there no unexpected side effects. >>>>> >>>>> I have nothing useful to contribute here. Seems like kind of a >>>>> mess. But Intel claims to maintain this, so it would be nice if >>>>> they would step up and make this work nicely. >>>> >>>> Suddenly, Intel lost their interest in the modems market and, as >>>> Maciej mentioned, the driver was abandon for a quite time now. The >>>> author no more works for Intel. You will see the bounce. >>> >>> Well, that's unfortunate :) Maybe step 0 is to remove the Intel >>> entry from MAINTAINERS for this driver. >>> >>>> Bjorn, could you suggest how to deal easily with the device that is >>>> incapable to seamlessly recover from hibernation? I am totally >>>> hopeless regarding the PM topic. Or is the deep driver rework the >>>> only option? >>> >>> I'm pretty PM-illiterate myself. Based on >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/pm/sleep-states.rst?id=v6.12#n109, >>> I assume that when we resume after hibernate, devices are in the same >>> state as after a fresh boot, i.e., the state driver .probe() methods >>> see. >>> >>> So I assume that some combination of dev_pm_ops methods must be able >>> to do basically the same as .probe() to get the device usable again >>> after it was completely powered off and back on. >> >> You are right that it should be theoretically possible to fix this issue >> by re-initializing the driver in the hibernation restore/thaw callbacks >> and I even have tried to do so in the beginning. >> >> But as I wrote in this patch description, doing so would need significant >> refactoring of the driver as it is not currently capable of being >> de-initialized and re-initialized partially. >> >> Hence this patch approach of simply re-binding the driver which also >> seemed safer in the absence of any real programming docs for this hardware. > > While this may not be elegant, it may actually get the job done. > > Can you please resend the patch with a CC to linux-pm@vger.kernel.org? Will do. Thanks, Maciej