From nobody Wed Jun 12 19:16:51 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 4VzwJh1xSQz5NHkF; Wed, 12 Jun 2024 19:16:52 +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 4VzwJh0wJ4z56vh; Wed, 12 Jun 2024 19:16:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718219812; 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=NgMbcaHN6TnYbNfMb3XlNI3GxFjCgWsQeZIK67yGH6I=; b=MTJ6RvyN7byGPyA8U7olsU3CSGvxJTfk0zZ2BslUSNZ6XiJMaX/UrOqT/oJJcifByMUxvj 2S+J57S5ExPrkDJ8hIIYThTyiFND2BNCmaSsPC/+UAyMuk2jFkmeYBmaTIeNI/oY8UrNqS WSuRnPUPxmQAVBNEvJH093DCDyHin1py/k78v+xmDdP9YOcdy1qOUI9hwp8F4d8CVs8n8O DIqTFkwEzo2g1jr+zbCT0GMDb75yEbnBuNeIrHFNE6pxZJOzDdZuU5BMV7sujiWPbIovuT 0pjDnAobx/GToXjVMsfGgkIBDXTX8ODeh14p+ziFd1TTm78A0JMbpr9Xe1KnbA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718219812; a=rsa-sha256; cv=none; b=d5Fkoyno9CJNja+cpY6DjqTPYhdTDyKEUDZ+YeBRMwHOFUypCE7UD5RenFvC22z6lgDZkp eE7EL6tVaFNEtK4is3QnCtjNx+ev8YZV1HuBs7z+En6XpimBEpES0VCw35lKKxNjExJ9vt bWAZm5py0vvi6dHAVGrwLecbQTMR62UU6Sr083NFdei7+ZwbgJjbOf7LgE4JuKkgACyeLc DRi9SC9avanJedJ4Mm2f9aprbLXSPVuifo/Uv6aQopfOljMQk7hkCBMpkif+ZNgtiCHNzN TRZZ0lGU7mwL0ZfY6nPSwcr2brVuLq7kd+F9Go/nYoHfSg3bhR4ki+rzd9Jk1g== 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=1718219812; 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=NgMbcaHN6TnYbNfMb3XlNI3GxFjCgWsQeZIK67yGH6I=; b=rb+DcPWfPQ+iFmtV+COIRV79qdYr3bpAGajuTIyjlCO6QEi3s5v7ND+U78qy3a4IVmdc4h bAhGrqC3AtGGPeBTDCqRb9hEXemAkRNOFuhqHbFSq3B1cUBG/JrfhePdYrcNOfPKswACvh cQxKUUxv8Dhn5iqd5s9Ptsx/L1JODv2vd2uURUgEXxAb0eAUeWeq9+0o1Od0AzWRb4MhB+ Lk/Eo/4vwirREJ08z5Kzxo3HYmHpZN6HKp2L68w2X1eccrabKWxVs9Ljr6EZR2ZgMVfVHH 3gpGp6+FBhZwWB6yZKNV5F9Vp/AwJUq2PvTfjgzhwCtB7ppbjgER0QVxs4KzOQ== 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 4VzwJh0Wf0z14jH; Wed, 12 Jun 2024 19:16:52 +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 45CJGp84004167; Wed, 12 Jun 2024 19:16:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45CJGpYx004164; Wed, 12 Jun 2024 19:16:51 GMT (envelope-from git) Date: Wed, 12 Jun 2024 19:16:51 GMT Message-Id: <202406121916.45CJGpYx004164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 947dfe1e01f3 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 947dfe1e01f31819b2a37c1400731ac367bacebe Auto-Submitted: auto-generated The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=947dfe1e01f31819b2a37c1400731ac367bacebe commit 947dfe1e01f31819b2a37c1400731ac367bacebe Author: Bjoern A. Zeeb AuthorDate: 2024-04-06 21:15:16 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-06-12 16:58:11 +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 Differential Revision: https://reviews.freebsd.org/D45358 (cherry picked from commit 3753988c5d22393fbdefb6aa16b5a5a699d05642) --- 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 53be7399579d..79e1ed8ba1c6 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. @@ -54,25 +54,26 @@ struct dev_pm_domain { 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 = { \ @@ -82,6 +83,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 d3804e9ecf05..81127bf364f9 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2773,6 +2773,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;