All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
To: Sasha Levin <sashal@kernel.org>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH AUTOSEL 4.14 086/105] PCI / ACPI: Use cached ACPI device state to get PCI device power state
Date: Tue, 16 Jul 2019 11:22:44 +0200	[thread overview]
Message-ID: <01d729e3-9778-9e4f-84d2-16b7353eeee1@intel.com> (raw)
In-Reply-To: <20190715142839.9896-86-sashal@kernel.org>

On 7/15/2019 4:28 PM, Sasha Levin wrote:
> From: Mika Westerberg <mika.westerberg@linux.intel.com>
>
> [ Upstream commit 83a16e3f6d70da99896c7a2639c0b60fff13afb8 ]
>
> The ACPI power state returned by acpi_device_get_power() may depend on
> the configuration of ACPI power resources in the system which may change
> any time after acpi_device_get_power() has returned, unless the
> reference counters of the ACPI power resources in question are set to
> prevent that from happening. Thus it is invalid to use acpi_device_get_power()
> in acpi_pci_get_power_state() the way it is done now and the value of
> the ->power.state field in the corresponding struct acpi_device objects
> (which reflects the ACPI power resources reference counting, among other
> things) should be used instead.
>
> As an example where this becomes an issue is Intel Ice Lake where the
> Thunderbolt controller (NHI), two PCIe root ports (RP0 and RP1) and xHCI
> all share the same power resources. The following picture with power
> resources marked with [] shows the topology:
>
>    Host bridge
>      |
>      +- RP0 ---\
>      +- RP1 ---|--+--> [TBT]
>      +- NHI --/   |
>      |            |
>      |            v
>      +- xHCI --> [D3C]
>
> Here TBT and D3C are the shared ACPI power resources. ACPI _PR3() method
> of the devices in question returns either TBT or D3C or both.
>
> Say we runtime suspend first the root ports RP0 and RP1, then NHI. Now
> since the TBT power resource is still on when the root ports are runtime
> suspended their dev->current_state is set to D3hot. When NHI is runtime
> suspended TBT is finally turned off but state of the root ports remain
> to be D3hot. Now when the xHCI is runtime suspended D3C gets also turned
> off. PCI core thus has power states of these devices cached in their
> dev->current_state as follows:
>
>    RP0 -> D3hot
>    RP1 -> D3hot
>    NHI -> D3cold
>    xHCI -> D3cold
>
> If the user now runs lspci for instance, the result is all 1's like in
> the below output (00:07.0 is the first root port, RP0):
>
> 00:07.0 PCI bridge: Intel Corporation Device 8a1d (rev ff) (prog-if ff)
>      !!! Unknown header type 7f
>      Kernel driver in use: pcieport
>
> In short the hardware state is not in sync with the software state
> anymore. The exact same thing happens with the PME polling thread which
> ends up bringing the root ports back into D0 after they are runtime
> suspended.
>
> For this reason, modify acpi_pci_get_power_state() so that it uses the
> ACPI device power state that was cached by the ACPI core. This makes the
> PCI device power state match the ACPI device power state regardless of
> state of the shared power resources which may still be on at this point.
>
> Link: https://lore.kernel.org/r/20190618161858.77834-2-mika.westerberg@linux.intel.com
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>   drivers/pci/pci-acpi.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
> index a3cedf8de863..688e195e85b4 100644
> --- a/drivers/pci/pci-acpi.c
> +++ b/drivers/pci/pci-acpi.c
> @@ -563,7 +563,8 @@ static pci_power_t acpi_pci_get_power_state(struct pci_dev *dev)
>   	if (!adev || !acpi_device_power_manageable(adev))
>   		return PCI_UNKNOWN;
>   
> -	if (acpi_device_get_power(adev, &state) || state == ACPI_STATE_UNKNOWN)
> +	state = adev->power.state;
> +	if (state == ACPI_STATE_UNKNOWN)
>   		return PCI_UNKNOWN;
>   
>   	return state_conv[state];

This requires additional changes to really work in all cases, please do 
not include it alone into -stable.



  reply	other threads:[~2019-07-16  9:22 UTC|newest]

Thread overview: 118+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-15 14:26 [PATCH AUTOSEL 4.14 001/105] wil6210: fix potential out-of-bounds read Sasha Levin
2019-07-15 14:26 ` [PATCH AUTOSEL 4.14 002/105] ath10k: Do not send probe response template for mesh Sasha Levin
2019-07-15 14:26   ` Sasha Levin
2019-07-15 14:26 ` [PATCH AUTOSEL 4.14 003/105] ath9k: Check for errors when reading SREV register Sasha Levin
2019-07-15 14:26 ` [PATCH AUTOSEL 4.14 004/105] ath6kl: add some bounds checking Sasha Levin
2019-07-15 14:26 ` [PATCH AUTOSEL 4.14 005/105] x86/tsc: Use CPUID.0x16 to calculate missing crystal frequency Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 006/105] ath: DFS JP domain W56 fixed pulse type 3 RADAR detection Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 007/105] batman-adv: fix for leaked TVLV handler Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 008/105] media: dvb: usb: fix use after free in dvb_usb_device_exit Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 009/105] media: spi: IR LED: add missing of table registration Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 010/105] crypto: talitos - fix skcipher failure due to wrong output IV Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 011/105] media: marvell-ccic: fix DMA s/g desc number calculation Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 012/105] media: vpss: fix a potential NULL pointer dereference Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 013/105] media: media_device_enum_links32: clean a reserved field Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 014/105] net: stmmac: dwmac1000: Clear unused address entries Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 015/105] net: stmmac: dwmac4/5: " Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 016/105] qed: Set the doorbell address correctly Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 017/105] signal/pid_namespace: Fix reboot_pid_ns to use send_sig not force_sig Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 018/105] signal/cifs: Fix cifs_put_tcp_session to call send_sig instead of force_sig Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 019/105] af_key: fix leaks in key_pol_get_resp and dump_sp Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 020/105] xfrm: Fix xfrm sel prefix length validation Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 021/105] fscrypt: clean up some BUG_ON()s in block encryption/decryption Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 022/105] Revert "e1000e: fix cyclic resets at link up with active tx" Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 023/105] e1000e: start network tx queue only when link is up Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 024/105] media: mc-device.c: don't memset __user pointer contents Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 025/105] media: staging: media: davinci_vpfe: - Fix for memory leak if decoder initialization fails Sasha Levin
2019-07-15 14:27   ` Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 026/105] net: phy: Check against net_device being NULL Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 027/105] crypto: talitos - properly handle split ICV Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 028/105] crypto: talitos - Align SEC1 accesses to 32 bits boundaries Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 029/105] tua6100: Avoid build warnings Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 030/105] locking/lockdep: Fix merging of hlocks with non-zero references Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 031/105] media: wl128x: Fix some error handling in fm_v4l2_init_video_device() Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 032/105] cpupower : frequency-set -r option misses the last cpu in related cpu list Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 033/105] net: stmmac: dwmac4: fix flow control issue Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 034/105] net: fec: Do not use netdev messages too early Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 035/105] net: axienet: Fix race condition causing TX hang Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 036/105] s390/qdio: handle PENDING state for QEBSM devices Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 037/105] RAS/CEC: Fix pfn insertion Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 038/105] net: sfp: add mutex to prevent concurrent state checks Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 039/105] ipset: Fix memory accounting for hash types on resize Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 040/105] perf cs-etm: Properly set the value of 'old' and 'head' in snapshot mode Sasha Levin
2019-07-15 14:27   ` Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 041/105] perf test 6: Fix missing kvm module load for s390 Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 042/105] media: fdp1: Support M3N and E3 platforms Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 043/105] iommu: Fix a leak in iommu_insert_resv_region Sasha Levin
2019-07-15 14:27   ` Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 044/105] gpio: omap: fix lack of irqstatus_raw0 for OMAP4 Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 045/105] gpio: omap: ensure irq is enabled before wakeup Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 046/105] regmap: fix bulk writes on paged registers Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 047/105] bpf: silence warning messages in core Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 048/105] rcu: Force inlining of rcu_read_lock() Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 049/105] x86/cpufeatures: Add FDP_EXCPTN_ONLY and ZERO_FCS_FDS Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 050/105] blkcg, writeback: dead memcgs shouldn't contribute to writeback ownership arbitration Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 051/105] xfrm: fix sa selector validation Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 052/105] sched/core: Add __sched tag for io_schedule() Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 053/105] sched/fair: Fix "runnable_avg_yN_inv" not used warnings Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 054/105] x86/atomic: Fix smp_mb__{before,after}_atomic() Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 055/105] perf evsel: Make perf_evsel__name() accept a NULL argument Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 056/105] vhost_net: disable zerocopy by default Sasha Levin
2019-07-15 14:27   ` Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 057/105] ipoib: correcly show a VF hardware address Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 058/105] EDAC/sysfs: Fix memory leak when creating a csrow object Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 059/105] ipsec: select crypto ciphers for xfrm_algo Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 060/105] ipvs: defer hook registration to avoid leaks Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 061/105] media: s5p-mfc: Make additional clocks optional Sasha Levin
2019-07-15 14:27   ` Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 062/105] media: i2c: fix warning same module names Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 063/105] ntp: Limit TAI-UTC offset Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 064/105] timer_list: Guard procfs specific code Sasha Levin
2019-07-15 14:27 ` [PATCH AUTOSEL 4.14 065/105] acpi/arm64: ignore 5.1 FADTs that are reported as 5.0 Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 066/105] media: coda: fix mpeg2 sequence number handling Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 067/105] media: coda: fix last buffer handling in V4L2_ENC_CMD_STOP Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 068/105] media: coda: increment sequence offset for the last returned frame Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 069/105] media: vimc: cap: check v4l2_fill_pixfmt return value Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 070/105] media: hdpvr: fix locking and a missing msleep Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 071/105] rtlwifi: rtl8192cu: fix error handle when usb probe failed Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 072/105] mt7601u: do not schedule rx_tasklet when the device has been disconnected Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 073/105] x86/build: Add 'set -e' to mkcapflags.sh to delete broken capflags.c Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 074/105] mt7601u: fix possible memory leak when the device is disconnected Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 075/105] ipvs: fix tinfo memory leak in start_sync_thread Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 076/105] ath10k: add missing error handling Sasha Levin
2019-07-15 14:28   ` Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 077/105] ath10k: fix PCIE device wake up failed Sasha Levin
2019-07-15 14:28   ` Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 078/105] perf tools: Increase MAX_NR_CPUS and MAX_CACHES Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 079/105] libata: don't request sense data on !ZAC ATA devices Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 080/105] clocksource/drivers/exynos_mct: Increase priority over ARM arch timer Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 081/105] rslib: Fix decoding of shortened codes Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 082/105] rslib: Fix handling of of caller provided syndrome Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 083/105] ixgbe: Check DDM existence in transceiver before access Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 084/105] crypto: serpent - mark __serpent_setkey_sbox noinline Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 085/105] crypto: asymmetric_keys - select CRYPTO_HASH where needed Sasha Levin
2019-07-15 14:28   ` Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 086/105] PCI / ACPI: Use cached ACPI device state to get PCI device power state Sasha Levin
2019-07-16  9:22   ` Rafael J. Wysocki [this message]
2019-07-22  0:40     ` Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 087/105] EDAC: Fix global-out-of-bounds write when setting edac_mc_poll_msec Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 088/105] bcache: check c->gc_thread by IS_ERR_OR_NULL in cache_set_flush() Sasha Levin
2019-07-15 14:28   ` Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 089/105] net: hns3: fix a -Wformat-nonliteral compile warning Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 090/105] net: hns3: add some error checking in hclge_tm module Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 091/105] ath10k: destroy sdio workqueue while remove sdio module Sasha Levin
2019-07-15 14:28   ` Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 092/105] iwlwifi: mvm: Drop large non sta frames Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 093/105] perf stat: Make metric event lookup more robust Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 094/105] net: usb: asix: init MAC address buffers Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 095/105] gpiolib: Fix references to gpiod_[gs]et_*value_cansleep() variants Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 096/105] Bluetooth: hci_bcsp: Fix memory leak in rx_skb Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 097/105] Bluetooth: 6lowpan: search for destination address in all peers Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 098/105] Bluetooth: Check state in l2cap_disconnect_rsp Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 099/105] gtp: add missing gtp_encap_disable_sock() in gtp_encap_enable() Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 100/105] Bluetooth: validate BLE connection interval updates Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 101/105] gtp: fix suspicious RCU usage Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 102/105] gtp: fix Illegal context switch in RCU read-side critical section Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 103/105] gtp: fix use-after-free in gtp_encap_destroy() Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 104/105] gtp: fix use-after-free in gtp_newlink() Sasha Levin
2019-07-15 14:28 ` [PATCH AUTOSEL 4.14 105/105] net: mvmdio: defer probe of orion-mdio if a clock is not ready Sasha Levin

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=01d729e3-9778-9e4f-84d2-16b7353eeee1@intel.com \
    --to=rafael.j.wysocki@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=sashal@kernel.org \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.