From nobody Fri Jun 07 23:48:58 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VwyZy31dZz5N2p0; Fri, 07 Jun 2024 23:48:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VwyZy2Fl0z4Xcd; Fri, 7 Jun 2024 23:48:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717804138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OXDxOIpIPQyNssRS5/ZtBZnVoY5mhy4PDaphk+YZ2Ks=; b=BCqFEif/HbhN9xTPi2MLG2LBImfr744y8PtGwvnTJiUr1njrWVmaXq130v+G1wy3yMSDen qxjmGfnVmaA92vu+acc6Ko+Vy1K0Wk4/tpRoSlbeWbWL0RCS4kkKyeirDi8iN8bmY8OHN1 QEWX4w1bVmO0ezWins+asA2QJjI0HioQAkNFIl7mc5hP5lpGSrHCxdDp+OkjESh4pg0Y9s 7ztp3dmyWCmR8ciaPzeyspVvIL8sw1jcRR/zfn2ffVHDXKmpL3XqidSpN3r2l8/1b/j9cI 14qgZjNqyM30WMhtIRPxQQJ4XbLzap4xlSF8RU9AoYKlVr4dS1MW00K01L85BQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717804138; a=rsa-sha256; cv=none; b=ZhjpjYpDah/CaLuJK2Je9HrQnX83AQ9+WS9GGfrLmP6ak6jU+dyfH4yQ8cBeDwihowK1hc ltDXdxbZvso7nW9Mp3XycwVD1OE3nKd/ka82u6Obq2p6aMXI2/9r1Ih9zD8mWy0TtKNhVR 2IuvQMPsdXnFN/ZH2wpCNKwd2sufaW3zzhkMTqk8oRF1Kfzit5AK7aPeiB/ZyahQGh2Ekd p+0OVhx09NPkIh6w0sJLL8MgqRuub3dqs+q0rraO8UD6rWp95pWh+s6jV7b0yfzH9+k0vT HBvAZBnfVM0d6sbGSRda3VTlF9rFv0EhGSXKlJtCkGImkVG5gamILHDMq3f+wA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717804138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OXDxOIpIPQyNssRS5/ZtBZnVoY5mhy4PDaphk+YZ2Ks=; b=MpcMmbrpXXERVYD7yuBvLOCqC7XGWZtP3J5/CaHFAdGkp7+2ibXByNx/01yp8lP21PvgWB c7MqWLnFCZZpmaASuXjQtabrkMu1zPaB60SJ0PsuTbtIGcmFrBkTAbSeFKlnBZk8vlGa7y n/ncDh+uDi7xrw8dHqwHg4xQT8f0/93sN6qhlUeW8r/K5Q0QveDAQSkP/XlzJn5hkgfgdh 53fiAFbA1D1kuPwS9ozlwFRr4SHpr3IXxZkU0gxHFO8zRBCQYH+vIgA/g+qwWBv9yu9ddd QBk+PY4xgJkZCJGaKa9BDB3PliFSm/qzPu8crzP3e230MPsE3zMyGDBl0AsWdA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VwyZy1kzSzZvq; Fri, 7 Jun 2024 23:48:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 457Nmw7H084079; Fri, 7 Jun 2024 23:48:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 457Nmw8u084076; Fri, 7 Jun 2024 23:48:58 GMT (envelope-from git) Date: Fri, 7 Jun 2024 23:48:58 GMT Message-Id: <202406072348.457Nmw8u084076@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 3753988c5d22 - main - LinuxKPI: pm: add SET_SYSTEM_SLEEP_PM_OPS() and device_can_wakeup() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3753988c5d22393fbdefb6aa16b5a5a699d05642 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=3753988c5d22393fbdefb6aa16b5a5a699d05642 commit 3753988c5d22393fbdefb6aa16b5a5a699d05642 Author: Bjoern A. Zeeb AuthorDate: 2024-04-06 21:15:16 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-06-07 22:57:04 +0000 LinuxKPI: pm: add SET_SYSTEM_SLEEP_PM_OPS() and device_can_wakeup() Add the SET_SYSTEM_SLEEP_PM_OPS() by factoring some other macro code out in order to set the suspend/resume functions when the struct is already given. Such is the case in iwlwifi d3. Also add an initial implementation of device_can_wakeup(). Though this is likely all we need we have no way of setting the flag for it yet so leave a pr_debug() and a comment there as well. Until we want to support WoWLAN this is likely not needed for wireless. Doing it the proper way checking a bool in 'struct dev_pm_info' would change 'struct device' and with that 'struct pci_dev' and break the KBI. In favour of mergeability this version does not implement the full functionality yet. Both help to make an updated iwlwifi d3 compile. Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D45358 --- sys/compat/linuxkpi/common/include/linux/pm.h | 30 +++++++++++++++------------ sys/compat/linuxkpi/common/src/linux_compat.c | 18 ++++++++++++++++ 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pm.h b/sys/compat/linuxkpi/common/include/linux/pm.h index 871c7b587864..c8d943027909 100644 --- a/sys/compat/linuxkpi/common/include/linux/pm.h +++ b/sys/compat/linuxkpi/common/include/linux/pm.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2020 The FreeBSD Foundation + * Copyright (c) 2020-2024 The FreeBSD Foundation * * This software was developed by Björn Zeeb under sponsorship from * the FreeBSD Foundation. @@ -58,25 +58,26 @@ struct dev_pm_info { IS_ENABLED(CONFIG_PM_SLEEP) ? (_p) : NULL #ifdef CONFIG_PM_SLEEP +#define __SET_PM_OPS(_suspendfunc, _resumefunc) \ + .suspend = _suspendfunc, \ + .resume = _resumefunc, \ + .freeze = _suspendfunc, \ + .thaw = _resumefunc, \ + .poweroff = _suspendfunc, \ + .restore = _resumefunc, \ + #define SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ const struct dev_pm_ops _name = { \ - .suspend = _suspendfunc, \ - .resume = _resumefunc, \ - .freeze = _suspendfunc, \ - .thaw = _resumefunc, \ - .poweroff = _suspendfunc, \ - .restore = _resumefunc, \ + __SET_PM_OPS(_suspendfunc, _resumefunc) \ } #define DEFINE_SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ const struct dev_pm_ops _name = { \ - .suspend = _suspendfunc, \ - .resume = _resumefunc, \ - .freeze = _suspendfunc, \ - .thaw = _resumefunc, \ - .poweroff = _suspendfunc, \ - .restore = _resumefunc, \ + __SET_PM_OPS(_suspendfunc, _resumefunc) \ } + +#define SET_SYSTEM_SLEEP_PM_OPS(_suspendfunc, _resumefunc) \ + __SET_PM_OPS(_suspendfunc, _resumefunc) #else #define SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ const struct dev_pm_ops _name = { \ @@ -86,6 +87,9 @@ const struct dev_pm_ops _name = { \ } #endif +bool linuxkpi_device_can_wakeup(struct device *); +#define device_can_wakeup(_dev) linuxkpi_device_can_wakeup(_dev) + static inline void pm_wakeup_event(struct device *dev __unused, unsigned int x __unused) { diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 4c639c1f8459..90d03d480089 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2597,6 +2597,24 @@ io_mapping_create_wc(resource_size_t base, unsigned long size) return (io_mapping_init_wc(mapping, base, size)); } +/* We likely want a linuxkpi_device.c at some point. */ +bool +device_can_wakeup(struct device *dev) +{ + + if (dev == NULL) + return (false); + /* + * XXX-BZ iwlwifi queries it as part of enabling WoWLAN. + * Normally this would be based on a bool in dev->power.XXX. + * Check such as PCI PCIM_PCAP_*PME. We have no way to enable this yet. + * We may get away by directly calling into bsddev for as long as + * we can assume PCI only avoiding changing struct device breaking KBI. + */ + pr_debug("%s:%d: not enabled; see comment.\n", __func__, __LINE__); + return (false); +} + #if defined(__i386__) || defined(__amd64__) bool linux_cpu_has_clflush; struct cpuinfo_x86 boot_cpu_data;