mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-09-15 11:28:36 +10:00
-----BEGIN PGP SIGNATURE----- iQJIBAABCgAyFiEEgMe7l+5h9hnxdsnuWYigwDrT+vwFAmhAa9EUHGJoZWxnYWFz QGdvb2dsZS5jb20ACgkQWYigwDrT+vyA3w//aX8d73z/xVxkYLMN/6XQA5fdmd4d Dv4n0Pjf0WCMKbsgRCdXEYLvcHV8VhH5iCR/b2UsFm9LjxSIRuqE5XosY3bNhrHn xVKEh2prq2XZOibWrFkJ+RZ0FF7Ogq1Uy5gUBbBHbE1q1byZzrOALaF3FWGaDIZQ 6QLLAFtd3UtqOOUu8J8P9N15uFR8gunyfuM9U7TLMcy4B8txk6T6m/9xAWtRURuJ I6WN8lO+g8Nl2mL9m27+wyWiVT3tKqoMwp8rVtym/L5JQOmHycYhn0WQAr2dPCMs Xbgmoeei0je7mZvk5btpt68NAKQ3ZnCVkxbbINBkUxAjI0dbI6h37EhW18ShYVUk CCo4fmaFtwP8qNN9tSvDN8vZdGB44fN5tIz4lmGzKk5gt+oV50RC/APrzC+PJBQ0 +2SdDVKj71Gr2H1VnI6uLB7oQ+tp7TOdhg+DGV4bdc6QFnsM+BpKWRq5f1UQcau/ XVDmorM/2t6z0DNktAv3NFwSodUjk1loWESr/pRBH1AqAWZTK98PWIg97XYsal59 zbJ3dLrnCqUNozeVgjtZo1LWD2FZaVTvhq2NY7D+QPpnMGhFUhHxNliZUXiQa1q4 boI2hEFdu3IQP/OC2a1zGJyMRLU43d5rhZ1U5xQSVtM0c3lgCY7rn/t26LymQVPA SYdg2jBcnhe6gXo= =eWJw -----END PGP SIGNATURE----- Merge tag 'pci-v6.16-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci Pull pci updates from Bjorn Helgaas: "Enumeration: - Print the actual delay time in pci_bridge_wait_for_secondary_bus() instead of assuming it was 1000ms (Wilfred Mallawa) - Revert 'iommu/amd: Prevent binding other PCI drivers to IOMMU PCI devices', which broke resume from system sleep on AMD platforms and has been fixed by other commits (Lukas Wunner) Resource management: - Remove mtip32xx use of pcim_iounmap_regions(), which is deprecated and unnecessary (Philipp Stanner) - Remove pcim_iounmap_regions() and pcim_request_region_exclusive() and related flags since all uses have been removed (Philipp Stanner) - Rework devres 'request' functions so they are no longer 'hybrid', i.e., their behavior no longer depends on whether pcim_enable_device or pci_enable_device() was used, and remove related code (Philipp Stanner) - Warn (not BUG()) about failure to assign optional resources (Ilpo Järvinen) Error handling: - Log the DPC Error Source ID only when it's actually valid (when ERR_FATAL or ERR_NONFATAL was received from a downstream device) and decode into bus/device/function (Bjorn Helgaas) - Determine AER log level once and save it so all related messages use the same level (Karolina Stolarek) - Use KERN_WARNING, not KERN_ERR, when logging PCIe Correctable Errors (Karolina Stolarek) - Ratelimit PCIe Correctable and Non-Fatal error logging, with sysfs controls on interval and burst count, to avoid flooding logs and RCU stall warnings (Jon Pan-Doh) Power management: - Increment PM usage counter when probing reset methods so we don't try to read config space of a powered-off device (Alex Williamson) - Set all devices to D0 during enumeration to ensure ACPI opregion is connected via _REG (Mario Limonciello) Power control: - Rename pwrctrl Kconfig symbols from 'PWRCTL' to 'PWRCTRL' to match the filename paths. Retain old deprecated symbols for compatibility, except for the pwrctrl slot driver (PCI_PWRCTRL_SLOT) (Johan Hovold) - When unregistering pwrctrl, cancel outstanding rescan work before cleaning up data structures to avoid use-after-free issues (Brian Norris) Bandwidth control: - Simplify link bandwidth controller by replacing the count of Link Bandwidth Management Status (LBMS) events with a PCI_LINK_LBMS_SEEN flag (Ilpo Järvinen) - Update the Link Speed after retraining, since the Link Speed may have changed (Ilpo Järvinen) PCIe native device hotplug: - Ignore Presence Detect Changed caused by DPC. pciehp already ignores Link Down/Up events caused by DPC, but on slots using in-band presence detect, DPC causes a spurious Presence Detect Changed event (Lukas Wunner) - Ignore Link Down/Up caused by Secondary Bus Reset. On hotplug ports using in-band presence detect, the reset causes a Presence Detect Changed event, which mistakenly caused teardown and re-enumeration of the device. Drivers may need to annotate code that resets their device (Lukas Wunner) Virtualization: - Add an ACS quirk for Loongson Root Ports that don't advertise ACS but don't allow peer-to-peer transactions between Root Ports; the quirk allows each Root Port to be in a separate IOMMU group (Huacai Chen) Endpoint framework: - For fixed-size BARs, retain both the actual size and the possibly larger size allocated to accommodate iATU alignment requirements (Jerome Brunet) - Simplify ctrl/SPAD space allocation and avoid allocating more space than needed (Jerome Brunet) - Correct MSI-X PBA offset calculations for DesignWare and Cadence endpoint controllers (Niklas Cassel) - Align the return value (number of interrupts) encoding for pci_epc_get_msi()/pci_epc_ops::get_msi() and pci_epc_get_msix()/pci_epc_ops::get_msix() (Niklas Cassel) - Align the nr_irqs parameter encoding for pci_epc_set_msi()/pci_epc_ops::set_msi() and pci_epc_set_msix()/pci_epc_ops::set_msix() (Niklas Cassel) Common host controller library: - Convert pci-host-common to a library so platforms that don't need native host controller drivers don't need to include these helper functions (Manivannan Sadhasivam) Apple PCIe controller driver: - Extract ECAM bridge creation helper from pci_host_common_probe() to separate driver-specific things like MSI from PCI things (Marc Zyngier) - Dynamically allocate RID-to_SID bitmap to prepare for SoCs with varying capabilities (Marc Zyngier) - Skip ports disabled in DT when setting up ports (Janne Grunau) - Add t6020 compatible string (Alyssa Rosenzweig) - Add T602x PCIe support (Hector Martin) - Directly set/clear INTx mask bits because T602x dropped the accessors that could do this without locking (Marc Zyngier) - Move port PHY registers to their own reg items to accommodate T602x, which moves them around; retain default offsets for existing DTs that lack phy%d entries with the reg offsets (Hector Martin) - Stop polling for core refclk, which doesn't work on T602x and the bootloader has already done anyway (Hector Martin) - Use gpiod_set_value_cansleep() when asserting PERST# in probe because we're allowed to sleep there (Hector Martin) Cadence PCIe controller driver: - Drop a runtime PM 'put' to resolve a runtime atomic count underflow (Hans Zhang) - Make the cadence core buildable as a module (Kishon Vijay Abraham I) - Add cdns_pcie_host_disable() and cdns_pcie_ep_disable() for use by loadable drivers when they are removed (Siddharth Vadapalli) Freescale i.MX6 PCIe controller driver: - Apply link training workaround only on IMX6Q, IMX6SX, IMX6SP (Richard Zhu) - Remove redundant dw_pcie_wait_for_link() from imx_pcie_start_link(); since the DWC core does this, imx6 only needs it when retraining for a faster link speed (Richard Zhu) - Toggle i.MX95 core reset to align with PHY powerup (Richard Zhu) - Set SYS_AUX_PWR_DET to work around i.MX95 ERR051624 erratum: in some cases, the controller can't exit 'L23 Ready' through Beacon or PERST# deassertion (Richard Zhu) - Clear GEN3_ZRXDC_NONCOMPL to work around i.MX95 ERR051586 erratum: controller can't meet 2.5 GT/s ZRX-DC timing when operating at 8 GT/s, causing timeouts in L1 (Richard Zhu) - Wait for i.MX95 PLL lock before enabling controller (Richard Zhu) - Save/restore i.MX95 LUT for suspend/resume (Richard Zhu) Mobiveil PCIe controller driver: - Return bool (not int) for link-up check in mobiveil_pab_ops.link_up() and layerscape-gen4, mobiveil (Hans Zhang) NVIDIA Tegra194 PCIe controller driver: - Create debugfs directory for 'aspm_state_cnt' only when CONFIG_PCIEASPM is enabled, since there are no other entries (Hans Zhang) Qualcomm PCIe controller driver: - Add OF support for parsing DT 'eq-presets-<N>gts' property for lane equalization presets (Krishna Chaitanya Chundru) - Read Maximum Link Width from the Link Capabilities register if DT lacks 'num-lanes' property (Krishna Chaitanya Chundru) - Add Physical Layer 64 GT/s Capability ID and register offsets for 8, 32, and 64 GT/s lane equalization registers (Krishna Chaitanya Chundru) - Add generic dwc support for configuring lane equalization presets (Krishna Chaitanya Chundru) - Add DT and driver support for PCIe on IPQ5018 SoC (Nitheesh Sekar) Renesas R-Car PCIe controller driver: - Describe endpoint BAR 4 as being fixed size (Jerome Brunet) - Document how to obtain R-Car V4H (r8a779g0) controller firmware (Yoshihiro Shimoda) Rockchip PCIe controller driver: - Reorder rockchip_pci_core_rsts because reset_control_bulk_deassert() deasserts in reverse order, to fix a link training regression (Jensen Huang) - Mark RK3399 as being capable of raising INTx interrupts (Niklas Cassel) Rockchip DesignWare PCIe controller driver: - Check only PCIE_LINKUP, not LTSSM status, to determine whether the link is up (Shawn Lin) - Increase N_FTS (used in L0s->L0 transitions) and enable ASPM L0s for Root Complex and Endpoint modes (Shawn Lin) - Hide the broken ATS Capability in rockchip_pcie_ep_init() instead of rockchip_pcie_ep_pre_init() so it stays hidden after PERST# resets non-sticky registers (Shawn Lin) - Call phy_power_off() before phy_exit() in rockchip_pcie_phy_deinit() (Diederik de Haas) Synopsys DesignWare PCIe controller driver: - Set PORT_LOGIC_LINK_WIDTH to one lane to make initial link training more robust; this will not affect the intended link width if all lanes are functional (Wenbin Yao) - Return bool (not int) for link-up check in dw_pcie_ops.link_up() and armada8k, dra7xx, dw-rockchip, exynos, histb, keembay, keystone, kirin, meson, qcom, qcom-ep, rcar_gen4, spear13xx, tegra194, uniphier, visconti (Hans Zhang) - Add debugfs support for exposing DWC device-specific PTM context (Manivannan Sadhasivam) TI J721E PCIe driver: - Make j721e buildable as a loadable and removable module (Siddharth Vadapalli) - Fix j721e host/endpoint dependencies that result in link failures in some configs (Arnd Bergmann) Device tree bindings: - Add qcom DT binding for 'global' interrupt (PCIe controller and link-specific events) for ipq8074, ipq8074-gen3, ipq6018, sa8775p, sc7280, sc8180x sdm845, sm8150, sm8250, sm8350 (Manivannan Sadhasivam) - Add qcom DT binding for 8 MSI SPI interrupts for msm8998, ipq8074, ipq8074-gen3, ipq6018 (Manivannan Sadhasivam) - Add dw rockchip DT binding for rk3576 and rk3562 (Kever Yang) - Correct indentation and style of examples in brcm,stb-pcie, cdns,cdns-pcie-ep, intel,keembay-pcie-ep, intel,keembay-pcie, microchip,pcie-host, rcar-pci-ep, rcar-pci-host, xilinx-versal-cpm (Krzysztof Kozlowski) - Convert Marvell EBU (dove, kirkwood, armada-370, armada-xp) and armada8k from text to schema DT bindings (Rob Herring) - Remove obsolete .txt DT bindings for content that has been moved to schemas (Rob Herring) - Add qcom DT binding for MHI registers in IPQ5332, IPQ6018, IPQ8074 and IPQ9574 (Varadarajan Narayanan) - Convert v3,v360epc-pci from text to DT schema binding (Rob Herring) - Change microchip,pcie-host DT binding to be 'dma-noncoherent' since PolarFire may be configured that way (Conor Dooley) Miscellaneous: - Drop 'pci' suffix from intel_mid_pci.c filename to match similar files (Andy Shevchenko) - All platforms with PCI have an MMU, so add PCI Kconfig dependency on MMU to simplify build testing and avoid inadvertent build regressions (Arnd Bergmann) - Update Krzysztof Wilczyński's email address in MAINTAINERS (Krzysztof Wilczyński) - Update Manivannan Sadhasivam's email address in MAINTAINERS (Manivannan Sadhasivam)" * tag 'pci-v6.16-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci: (147 commits) MAINTAINERS: Update Manivannan Sadhasivam email address PCI: j721e: Fix host/endpoint dependencies PCI: j721e: Add support to build as a loadable module PCI: cadence-ep: Introduce cdns_pcie_ep_disable() helper for cleanup PCI: cadence-host: Introduce cdns_pcie_host_disable() helper for cleanup PCI: cadence: Add support to build pcie-cadence library as a kernel module MAINTAINERS: Update Krzysztof Wilczyński email address PCI: Remove unnecessary linesplit in __pci_setup_bridge() PCI: WARN (not BUG()) when we fail to assign optional resources PCI: Remove unused pci_printk() PCI: qcom: Replace PERST# sleep time with proper macro PCI: dw-rockchip: Replace PERST# sleep time with proper macro PCI: host-common: Convert to library for host controller drivers PCI/ERR: Remove misleading TODO regarding kernel panic PCI: cadence: Remove duplicate message code definitions PCI: endpoint: Align pci_epc_set_msix(), pci_epc_ops::set_msix() nr_irqs encoding PCI: endpoint: Align pci_epc_set_msi(), pci_epc_ops::set_msi() nr_irqs encoding PCI: endpoint: Align pci_epc_get_msix(), pci_epc_ops::get_msix() return value encoding PCI: endpoint: Align pci_epc_get_msi(), pci_epc_ops::get_msi() return value encoding PCI: cadence-ep: Correct PBA offset in .set_msix() callback ...
632 lines
22 KiB
C
632 lines
22 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* pm_runtime.h - Device run-time power management helper functions.
|
|
*
|
|
* Copyright (C) 2009 Rafael J. Wysocki <rjw@sisk.pl>
|
|
*/
|
|
|
|
#ifndef _LINUX_PM_RUNTIME_H
|
|
#define _LINUX_PM_RUNTIME_H
|
|
|
|
#include <linux/device.h>
|
|
#include <linux/notifier.h>
|
|
#include <linux/pm.h>
|
|
|
|
#include <linux/jiffies.h>
|
|
|
|
/* Runtime PM flag argument bits */
|
|
#define RPM_ASYNC 0x01 /* Request is asynchronous */
|
|
#define RPM_NOWAIT 0x02 /* Don't wait for concurrent
|
|
state change */
|
|
#define RPM_GET_PUT 0x04 /* Increment/decrement the
|
|
usage_count */
|
|
#define RPM_AUTO 0x08 /* Use autosuspend_delay */
|
|
|
|
/*
|
|
* Use this for defining a set of PM operations to be used in all situations
|
|
* (system suspend, hibernation or runtime PM).
|
|
*
|
|
* Note that the behaviour differs from the deprecated UNIVERSAL_DEV_PM_OPS()
|
|
* macro, which uses the provided callbacks for both runtime PM and system
|
|
* sleep, while DEFINE_RUNTIME_DEV_PM_OPS() uses pm_runtime_force_suspend()
|
|
* and pm_runtime_force_resume() for its system sleep callbacks.
|
|
*
|
|
* If the underlying dev_pm_ops struct symbol has to be exported, use
|
|
* EXPORT_RUNTIME_DEV_PM_OPS() or EXPORT_GPL_RUNTIME_DEV_PM_OPS() instead.
|
|
*/
|
|
#define DEFINE_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
|
|
_DEFINE_DEV_PM_OPS(name, pm_runtime_force_suspend, \
|
|
pm_runtime_force_resume, suspend_fn, \
|
|
resume_fn, idle_fn)
|
|
|
|
#define EXPORT_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
|
|
EXPORT_DEV_PM_OPS(name) = { \
|
|
RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
|
|
}
|
|
#define EXPORT_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
|
|
EXPORT_GPL_DEV_PM_OPS(name) = { \
|
|
RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
|
|
}
|
|
#define EXPORT_NS_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
|
|
EXPORT_NS_DEV_PM_OPS(name, ns) = { \
|
|
RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
|
|
}
|
|
#define EXPORT_NS_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
|
|
EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
|
|
RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
|
|
}
|
|
|
|
#ifdef CONFIG_PM
|
|
extern struct workqueue_struct *pm_wq;
|
|
|
|
static inline bool queue_pm_work(struct work_struct *work)
|
|
{
|
|
return queue_work(pm_wq, work);
|
|
}
|
|
|
|
extern int pm_generic_runtime_suspend(struct device *dev);
|
|
extern int pm_generic_runtime_resume(struct device *dev);
|
|
extern bool pm_runtime_need_not_resume(struct device *dev);
|
|
extern int pm_runtime_force_suspend(struct device *dev);
|
|
extern int pm_runtime_force_resume(struct device *dev);
|
|
|
|
extern int __pm_runtime_idle(struct device *dev, int rpmflags);
|
|
extern int __pm_runtime_suspend(struct device *dev, int rpmflags);
|
|
extern int __pm_runtime_resume(struct device *dev, int rpmflags);
|
|
extern int pm_runtime_get_if_active(struct device *dev);
|
|
extern int pm_runtime_get_if_in_use(struct device *dev);
|
|
extern int pm_schedule_suspend(struct device *dev, unsigned int delay);
|
|
extern int __pm_runtime_set_status(struct device *dev, unsigned int status);
|
|
extern int pm_runtime_barrier(struct device *dev);
|
|
extern bool pm_runtime_block_if_disabled(struct device *dev);
|
|
extern void pm_runtime_unblock(struct device *dev);
|
|
extern void pm_runtime_enable(struct device *dev);
|
|
extern void __pm_runtime_disable(struct device *dev, bool check_resume);
|
|
extern void pm_runtime_allow(struct device *dev);
|
|
extern void pm_runtime_forbid(struct device *dev);
|
|
extern void pm_runtime_no_callbacks(struct device *dev);
|
|
extern void pm_runtime_irq_safe(struct device *dev);
|
|
extern void __pm_runtime_use_autosuspend(struct device *dev, bool use);
|
|
extern void pm_runtime_set_autosuspend_delay(struct device *dev, int delay);
|
|
extern u64 pm_runtime_autosuspend_expiration(struct device *dev);
|
|
extern void pm_runtime_set_memalloc_noio(struct device *dev, bool enable);
|
|
extern void pm_runtime_get_suppliers(struct device *dev);
|
|
extern void pm_runtime_put_suppliers(struct device *dev);
|
|
extern void pm_runtime_new_link(struct device *dev);
|
|
extern void pm_runtime_drop_link(struct device_link *link);
|
|
extern void pm_runtime_release_supplier(struct device_link *link);
|
|
|
|
int devm_pm_runtime_set_active_enabled(struct device *dev);
|
|
extern int devm_pm_runtime_enable(struct device *dev);
|
|
int devm_pm_runtime_get_noresume(struct device *dev);
|
|
|
|
/**
|
|
* pm_suspend_ignore_children - Set runtime PM behavior regarding children.
|
|
* @dev: Target device.
|
|
* @enable: Whether or not to ignore possible dependencies on children.
|
|
*
|
|
* The dependencies of @dev on its children will not be taken into account by
|
|
* the runtime PM framework going forward if @enable is %true, or they will
|
|
* be taken into account otherwise.
|
|
*/
|
|
static inline void pm_suspend_ignore_children(struct device *dev, bool enable)
|
|
{
|
|
dev->power.ignore_children = enable;
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_get_noresume - Bump up runtime PM usage counter of a device.
|
|
* @dev: Target device.
|
|
*/
|
|
static inline void pm_runtime_get_noresume(struct device *dev)
|
|
{
|
|
atomic_inc(&dev->power.usage_count);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_put_noidle - Drop runtime PM usage counter of a device.
|
|
* @dev: Target device.
|
|
*
|
|
* Decrement the runtime PM usage counter of @dev unless it is 0 already.
|
|
*/
|
|
static inline void pm_runtime_put_noidle(struct device *dev)
|
|
{
|
|
atomic_add_unless(&dev->power.usage_count, -1, 0);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_suspended - Check whether or not a device is runtime-suspended.
|
|
* @dev: Target device.
|
|
*
|
|
* Return %true if runtime PM is enabled for @dev and its runtime PM status is
|
|
* %RPM_SUSPENDED, or %false otherwise.
|
|
*
|
|
* Note that the return value of this function can only be trusted if it is
|
|
* called under the runtime PM lock of @dev or under conditions in which
|
|
* runtime PM cannot be either disabled or enabled for @dev and its runtime PM
|
|
* status cannot change.
|
|
*/
|
|
static inline bool pm_runtime_suspended(struct device *dev)
|
|
{
|
|
return dev->power.runtime_status == RPM_SUSPENDED
|
|
&& !dev->power.disable_depth;
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_active - Check whether or not a device is runtime-active.
|
|
* @dev: Target device.
|
|
*
|
|
* Return %true if runtime PM is disabled for @dev or its runtime PM status is
|
|
* %RPM_ACTIVE, or %false otherwise.
|
|
*
|
|
* Note that the return value of this function can only be trusted if it is
|
|
* called under the runtime PM lock of @dev or under conditions in which
|
|
* runtime PM cannot be either disabled or enabled for @dev and its runtime PM
|
|
* status cannot change.
|
|
*/
|
|
static inline bool pm_runtime_active(struct device *dev)
|
|
{
|
|
return dev->power.runtime_status == RPM_ACTIVE
|
|
|| dev->power.disable_depth;
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_status_suspended - Check if runtime PM status is "suspended".
|
|
* @dev: Target device.
|
|
*
|
|
* Return %true if the runtime PM status of @dev is %RPM_SUSPENDED, or %false
|
|
* otherwise, regardless of whether or not runtime PM has been enabled for @dev.
|
|
*
|
|
* Note that the return value of this function can only be trusted if it is
|
|
* called under the runtime PM lock of @dev or under conditions in which the
|
|
* runtime PM status of @dev cannot change.
|
|
*/
|
|
static inline bool pm_runtime_status_suspended(struct device *dev)
|
|
{
|
|
return dev->power.runtime_status == RPM_SUSPENDED;
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_enabled - Check if runtime PM is enabled.
|
|
* @dev: Target device.
|
|
*
|
|
* Return %true if runtime PM is enabled for @dev or %false otherwise.
|
|
*
|
|
* Note that the return value of this function can only be trusted if it is
|
|
* called under the runtime PM lock of @dev or under conditions in which
|
|
* runtime PM cannot be either disabled or enabled for @dev.
|
|
*/
|
|
static inline bool pm_runtime_enabled(struct device *dev)
|
|
{
|
|
return !dev->power.disable_depth;
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_blocked - Check if runtime PM enabling is blocked.
|
|
* @dev: Target device.
|
|
*
|
|
* Do not call this function outside system suspend/resume code paths.
|
|
*/
|
|
static inline bool pm_runtime_blocked(struct device *dev)
|
|
{
|
|
return dev->power.last_status == RPM_BLOCKED;
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_has_no_callbacks - Check if runtime PM callbacks may be present.
|
|
* @dev: Target device.
|
|
*
|
|
* Return %true if @dev is a special device without runtime PM callbacks or
|
|
* %false otherwise.
|
|
*/
|
|
static inline bool pm_runtime_has_no_callbacks(struct device *dev)
|
|
{
|
|
return dev->power.no_callbacks;
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_mark_last_busy - Update the last access time of a device.
|
|
* @dev: Target device.
|
|
*
|
|
* Update the last access time of @dev used by the runtime PM autosuspend
|
|
* mechanism to the current time as returned by ktime_get_mono_fast_ns().
|
|
*/
|
|
static inline void pm_runtime_mark_last_busy(struct device *dev)
|
|
{
|
|
WRITE_ONCE(dev->power.last_busy, ktime_get_mono_fast_ns());
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_is_irq_safe - Check if runtime PM can work in interrupt context.
|
|
* @dev: Target device.
|
|
*
|
|
* Return %true if @dev has been marked as an "IRQ-safe" device (with respect
|
|
* to runtime PM), in which case its runtime PM callabcks can be expected to
|
|
* work correctly when invoked from interrupt handlers.
|
|
*/
|
|
static inline bool pm_runtime_is_irq_safe(struct device *dev)
|
|
{
|
|
return dev->power.irq_safe;
|
|
}
|
|
|
|
extern u64 pm_runtime_suspended_time(struct device *dev);
|
|
|
|
#else /* !CONFIG_PM */
|
|
|
|
static inline bool queue_pm_work(struct work_struct *work) { return false; }
|
|
|
|
static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
|
|
static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
|
|
static inline bool pm_runtime_need_not_resume(struct device *dev) {return true; }
|
|
static inline int pm_runtime_force_suspend(struct device *dev) { return 0; }
|
|
static inline int pm_runtime_force_resume(struct device *dev) { return 0; }
|
|
|
|
static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
|
|
{
|
|
return -ENOSYS;
|
|
}
|
|
static inline int __pm_runtime_suspend(struct device *dev, int rpmflags)
|
|
{
|
|
return -ENOSYS;
|
|
}
|
|
static inline int __pm_runtime_resume(struct device *dev, int rpmflags)
|
|
{
|
|
return 1;
|
|
}
|
|
static inline int pm_schedule_suspend(struct device *dev, unsigned int delay)
|
|
{
|
|
return -ENOSYS;
|
|
}
|
|
static inline int pm_runtime_get_if_in_use(struct device *dev)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
static inline int pm_runtime_get_if_active(struct device *dev)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
static inline int __pm_runtime_set_status(struct device *dev,
|
|
unsigned int status) { return 0; }
|
|
static inline int pm_runtime_barrier(struct device *dev) { return 0; }
|
|
static inline bool pm_runtime_block_if_disabled(struct device *dev) { return true; }
|
|
static inline void pm_runtime_unblock(struct device *dev) {}
|
|
static inline void pm_runtime_enable(struct device *dev) {}
|
|
static inline void __pm_runtime_disable(struct device *dev, bool c) {}
|
|
static inline bool pm_runtime_blocked(struct device *dev) { return true; }
|
|
static inline void pm_runtime_allow(struct device *dev) {}
|
|
static inline void pm_runtime_forbid(struct device *dev) {}
|
|
|
|
static inline int devm_pm_runtime_set_active_enabled(struct device *dev) { return 0; }
|
|
static inline int devm_pm_runtime_enable(struct device *dev) { return 0; }
|
|
static inline int devm_pm_runtime_get_noresume(struct device *dev) { return 0; }
|
|
|
|
static inline void pm_suspend_ignore_children(struct device *dev, bool enable) {}
|
|
static inline void pm_runtime_get_noresume(struct device *dev) {}
|
|
static inline void pm_runtime_put_noidle(struct device *dev) {}
|
|
static inline bool pm_runtime_suspended(struct device *dev) { return false; }
|
|
static inline bool pm_runtime_active(struct device *dev) { return true; }
|
|
static inline bool pm_runtime_status_suspended(struct device *dev) { return false; }
|
|
static inline bool pm_runtime_enabled(struct device *dev) { return false; }
|
|
|
|
static inline void pm_runtime_no_callbacks(struct device *dev) {}
|
|
static inline void pm_runtime_irq_safe(struct device *dev) {}
|
|
static inline bool pm_runtime_is_irq_safe(struct device *dev) { return false; }
|
|
|
|
static inline bool pm_runtime_has_no_callbacks(struct device *dev) { return false; }
|
|
static inline void pm_runtime_mark_last_busy(struct device *dev) {}
|
|
static inline void __pm_runtime_use_autosuspend(struct device *dev,
|
|
bool use) {}
|
|
static inline void pm_runtime_set_autosuspend_delay(struct device *dev,
|
|
int delay) {}
|
|
static inline u64 pm_runtime_autosuspend_expiration(
|
|
struct device *dev) { return 0; }
|
|
static inline void pm_runtime_set_memalloc_noio(struct device *dev,
|
|
bool enable){}
|
|
static inline void pm_runtime_get_suppliers(struct device *dev) {}
|
|
static inline void pm_runtime_put_suppliers(struct device *dev) {}
|
|
static inline void pm_runtime_new_link(struct device *dev) {}
|
|
static inline void pm_runtime_drop_link(struct device_link *link) {}
|
|
static inline void pm_runtime_release_supplier(struct device_link *link) {}
|
|
|
|
#endif /* !CONFIG_PM */
|
|
|
|
/**
|
|
* pm_runtime_idle - Conditionally set up autosuspend of a device or suspend it.
|
|
* @dev: Target device.
|
|
*
|
|
* Invoke the "idle check" callback of @dev and, depending on its return value,
|
|
* set up autosuspend of @dev or suspend it (depending on whether or not
|
|
* autosuspend has been enabled for it).
|
|
*/
|
|
static inline int pm_runtime_idle(struct device *dev)
|
|
{
|
|
return __pm_runtime_idle(dev, 0);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_suspend - Suspend a device synchronously.
|
|
* @dev: Target device.
|
|
*/
|
|
static inline int pm_runtime_suspend(struct device *dev)
|
|
{
|
|
return __pm_runtime_suspend(dev, 0);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_autosuspend - Set up autosuspend of a device or suspend it.
|
|
* @dev: Target device.
|
|
*
|
|
* Set up autosuspend of @dev or suspend it (depending on whether or not
|
|
* autosuspend is enabled for it) without engaging its "idle check" callback.
|
|
*/
|
|
static inline int pm_runtime_autosuspend(struct device *dev)
|
|
{
|
|
return __pm_runtime_suspend(dev, RPM_AUTO);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_resume - Resume a device synchronously.
|
|
* @dev: Target device.
|
|
*/
|
|
static inline int pm_runtime_resume(struct device *dev)
|
|
{
|
|
return __pm_runtime_resume(dev, 0);
|
|
}
|
|
|
|
/**
|
|
* pm_request_idle - Queue up "idle check" execution for a device.
|
|
* @dev: Target device.
|
|
*
|
|
* Queue up a work item to run an equivalent of pm_runtime_idle() for @dev
|
|
* asynchronously.
|
|
*/
|
|
static inline int pm_request_idle(struct device *dev)
|
|
{
|
|
return __pm_runtime_idle(dev, RPM_ASYNC);
|
|
}
|
|
|
|
/**
|
|
* pm_request_resume - Queue up runtime-resume of a device.
|
|
* @dev: Target device.
|
|
*/
|
|
static inline int pm_request_resume(struct device *dev)
|
|
{
|
|
return __pm_runtime_resume(dev, RPM_ASYNC);
|
|
}
|
|
|
|
/**
|
|
* pm_request_autosuspend - Queue up autosuspend of a device.
|
|
* @dev: Target device.
|
|
*
|
|
* Queue up a work item to run an equivalent pm_runtime_autosuspend() for @dev
|
|
* asynchronously.
|
|
*/
|
|
static inline int pm_request_autosuspend(struct device *dev)
|
|
{
|
|
return __pm_runtime_suspend(dev, RPM_ASYNC | RPM_AUTO);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_get - Bump up usage counter and queue up resume of a device.
|
|
* @dev: Target device.
|
|
*
|
|
* Bump up the runtime PM usage counter of @dev and queue up a work item to
|
|
* carry out runtime-resume of it.
|
|
*/
|
|
static inline int pm_runtime_get(struct device *dev)
|
|
{
|
|
return __pm_runtime_resume(dev, RPM_GET_PUT | RPM_ASYNC);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_get_sync - Bump up usage counter of a device and resume it.
|
|
* @dev: Target device.
|
|
*
|
|
* Bump up the runtime PM usage counter of @dev and carry out runtime-resume of
|
|
* it synchronously.
|
|
*
|
|
* The possible return values of this function are the same as for
|
|
* pm_runtime_resume() and the runtime PM usage counter of @dev remains
|
|
* incremented in all cases, even if it returns an error code.
|
|
* Consider using pm_runtime_resume_and_get() instead of it, especially
|
|
* if its return value is checked by the caller, as this is likely to result
|
|
* in cleaner code.
|
|
*/
|
|
static inline int pm_runtime_get_sync(struct device *dev)
|
|
{
|
|
return __pm_runtime_resume(dev, RPM_GET_PUT);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_resume_and_get - Bump up usage counter of a device and resume it.
|
|
* @dev: Target device.
|
|
*
|
|
* Resume @dev synchronously and if that is successful, increment its runtime
|
|
* PM usage counter. Return 0 if the runtime PM usage counter of @dev has been
|
|
* incremented or a negative error code otherwise.
|
|
*/
|
|
static inline int pm_runtime_resume_and_get(struct device *dev)
|
|
{
|
|
int ret;
|
|
|
|
ret = __pm_runtime_resume(dev, RPM_GET_PUT);
|
|
if (ret < 0) {
|
|
pm_runtime_put_noidle(dev);
|
|
return ret;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_put - Drop device usage counter and queue up "idle check" if 0.
|
|
* @dev: Target device.
|
|
*
|
|
* Decrement the runtime PM usage counter of @dev and if it turns out to be
|
|
* equal to 0, queue up a work item for @dev like in pm_request_idle().
|
|
*/
|
|
static inline int pm_runtime_put(struct device *dev)
|
|
{
|
|
return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC);
|
|
}
|
|
|
|
DEFINE_FREE(pm_runtime_put, struct device *, if (_T) pm_runtime_put(_T))
|
|
|
|
/**
|
|
* __pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
|
|
* @dev: Target device.
|
|
*
|
|
* Decrement the runtime PM usage counter of @dev and if it turns out to be
|
|
* equal to 0, queue up a work item for @dev like in pm_request_autosuspend().
|
|
*/
|
|
static inline int __pm_runtime_put_autosuspend(struct device *dev)
|
|
{
|
|
return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
|
|
* @dev: Target device.
|
|
*
|
|
* Decrement the runtime PM usage counter of @dev and if it turns out to be
|
|
* equal to 0, queue up a work item for @dev like in pm_request_autosuspend().
|
|
*/
|
|
static inline int pm_runtime_put_autosuspend(struct device *dev)
|
|
{
|
|
return __pm_runtime_suspend(dev,
|
|
RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_put_sync - Drop device usage counter and run "idle check" if 0.
|
|
* @dev: Target device.
|
|
*
|
|
* Decrement the runtime PM usage counter of @dev and if it turns out to be
|
|
* equal to 0, invoke the "idle check" callback of @dev and, depending on its
|
|
* return value, set up autosuspend of @dev or suspend it (depending on whether
|
|
* or not autosuspend has been enabled for it).
|
|
*
|
|
* The possible return values of this function are the same as for
|
|
* pm_runtime_idle() and the runtime PM usage counter of @dev remains
|
|
* decremented in all cases, even if it returns an error code.
|
|
*/
|
|
static inline int pm_runtime_put_sync(struct device *dev)
|
|
{
|
|
return __pm_runtime_idle(dev, RPM_GET_PUT);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_put_sync_suspend - Drop device usage counter and suspend if 0.
|
|
* @dev: Target device.
|
|
*
|
|
* Decrement the runtime PM usage counter of @dev and if it turns out to be
|
|
* equal to 0, carry out runtime-suspend of @dev synchronously.
|
|
*
|
|
* The possible return values of this function are the same as for
|
|
* pm_runtime_suspend() and the runtime PM usage counter of @dev remains
|
|
* decremented in all cases, even if it returns an error code.
|
|
*/
|
|
static inline int pm_runtime_put_sync_suspend(struct device *dev)
|
|
{
|
|
return __pm_runtime_suspend(dev, RPM_GET_PUT);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_put_sync_autosuspend - Drop device usage counter and autosuspend if 0.
|
|
* @dev: Target device.
|
|
*
|
|
* Decrement the runtime PM usage counter of @dev and if it turns out to be
|
|
* equal to 0, set up autosuspend of @dev or suspend it synchronously (depending
|
|
* on whether or not autosuspend has been enabled for it).
|
|
*
|
|
* The possible return values of this function are the same as for
|
|
* pm_runtime_autosuspend() and the runtime PM usage counter of @dev remains
|
|
* decremented in all cases, even if it returns an error code.
|
|
*/
|
|
static inline int pm_runtime_put_sync_autosuspend(struct device *dev)
|
|
{
|
|
return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_AUTO);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_set_active - Set runtime PM status to "active".
|
|
* @dev: Target device.
|
|
*
|
|
* Set the runtime PM status of @dev to %RPM_ACTIVE and ensure that dependencies
|
|
* of it will be taken into account.
|
|
*
|
|
* It is not valid to call this function for devices with runtime PM enabled.
|
|
*/
|
|
static inline int pm_runtime_set_active(struct device *dev)
|
|
{
|
|
return __pm_runtime_set_status(dev, RPM_ACTIVE);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_set_suspended - Set runtime PM status to "suspended".
|
|
* @dev: Target device.
|
|
*
|
|
* Set the runtime PM status of @dev to %RPM_SUSPENDED and ensure that
|
|
* dependencies of it will be taken into account.
|
|
*
|
|
* It is not valid to call this function for devices with runtime PM enabled.
|
|
*/
|
|
static inline int pm_runtime_set_suspended(struct device *dev)
|
|
{
|
|
return __pm_runtime_set_status(dev, RPM_SUSPENDED);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_disable - Disable runtime PM for a device.
|
|
* @dev: Target device.
|
|
*
|
|
* Prevent the runtime PM framework from working with @dev by incrementing its
|
|
* "disable" counter.
|
|
*
|
|
* If the counter is zero when this function runs and there is a pending runtime
|
|
* resume request for @dev, it will be resumed. If the counter is still zero at
|
|
* that point, all of the pending runtime PM requests for @dev will be canceled
|
|
* and all runtime PM operations in progress involving it will be waited for to
|
|
* complete.
|
|
*
|
|
* For each invocation of this function for @dev, there must be a matching
|
|
* pm_runtime_enable() call, so that runtime PM is eventually enabled for it
|
|
* again.
|
|
*/
|
|
static inline void pm_runtime_disable(struct device *dev)
|
|
{
|
|
__pm_runtime_disable(dev, true);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_use_autosuspend - Allow autosuspend to be used for a device.
|
|
* @dev: Target device.
|
|
*
|
|
* Allow the runtime PM autosuspend mechanism to be used for @dev whenever
|
|
* requested (or "autosuspend" will be handled as direct runtime-suspend for
|
|
* it).
|
|
*
|
|
* NOTE: It's important to undo this with pm_runtime_dont_use_autosuspend()
|
|
* at driver exit time unless your driver initially enabled pm_runtime
|
|
* with devm_pm_runtime_enable() (which handles it for you).
|
|
*/
|
|
static inline void pm_runtime_use_autosuspend(struct device *dev)
|
|
{
|
|
__pm_runtime_use_autosuspend(dev, true);
|
|
}
|
|
|
|
/**
|
|
* pm_runtime_dont_use_autosuspend - Prevent autosuspend from being used.
|
|
* @dev: Target device.
|
|
*
|
|
* Prevent the runtime PM autosuspend mechanism from being used for @dev which
|
|
* means that "autosuspend" will be handled as direct runtime-suspend for it
|
|
* going forward.
|
|
*/
|
|
static inline void pm_runtime_dont_use_autosuspend(struct device *dev)
|
|
{
|
|
__pm_runtime_use_autosuspend(dev, false);
|
|
}
|
|
|
|
#endif
|