All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Maximilian Luz <luzmaximilian@gmail.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-pci@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 03/59] PCI: Use pci_update_current_state() in pci_enable_device_flags()
Date: Thu,  9 Sep 2021 07:58:04 -0400	[thread overview]
Message-ID: <20210909115900.149795-3-sashal@kernel.org> (raw)
In-Reply-To: <20210909115900.149795-1-sashal@kernel.org>

From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>

[ Upstream commit 14858dcc3b3587f4bb5c48e130ee7d68fc2b0a29 ]

Updating the current_state field of struct pci_dev the way it is done
in pci_enable_device_flags() before calling do_pci_enable_device() may
not work.  For example, if the given PCI device depends on an ACPI
power resource whose _STA method initially returns 0 ("off"), but the
config space of the PCI device is accessible and the power state
retrieved from the PCI_PM_CTRL register is D0, the current_state
field in the struct pci_dev representing that device will get out of
sync with the power.state of its ACPI companion object and that will
lead to power management issues going forward.

To avoid such issues, make pci_enable_device_flags() call
pci_update_current_state() which takes ACPI device power management
into account, if present, to retrieve the current power state of the
device.

Link: https://lore.kernel.org/lkml/20210314000439.3138941-1-luzmaximilian@gmail.com/
Reported-by: Maximilian Luz <luzmaximilian@gmail.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Maximilian Luz <luzmaximilian@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/pci/pci.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c847b5554db6..893e1e8e5bd1 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1384,11 +1384,7 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
 	 * so that things like MSI message writing will behave as expected
 	 * (e.g. if the device really is in D0 at enable time).
 	 */
-	if (dev->pm_cap) {
-		u16 pmcsr;
-		pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
-		dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
-	}
+	pci_update_current_state(dev, dev->current_state);
 
 	if (atomic_inc_return(&dev->enable_cnt) > 1)
 		return 0;		/* already enabled */
-- 
2.30.2


  parent reply	other threads:[~2021-09-09 13:10 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09 11:58 [PATCH AUTOSEL 4.14 01/59] media: dib8000: rewrite the init prbs logic Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 02/59] crypto: mxs-dcp - Use sg_mapping_iter to copy data Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58 ` Sasha Levin [this message]
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 04/59] iio: dac: ad5624r: Fix incorrect handling of an optional regulator Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 05/59] ARM: dts: qcom: apq8064: correct clock names Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 06/59] video: fbdev: kyro: fix a DoS bug by restricting user input Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 07/59] netlink: Deal with ESRCH error in nlmsg_notify() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 08/59] Smack: Fix wrong semantics in smk_access_entry() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 09/59] usb: host: fotg210: fix the endpoint's transactional opportunities calculation Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 10/59] usb: host: fotg210: fix the actual_length of an iso packet Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 11/59] usb: gadget: u_ether: fix a potential null pointer dereference Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 12/59] usb: gadget: composite: Allow bMaxPower=0 if self-powered Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 13/59] staging: board: Fix uninitialized spinlock when attaching genpd Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 14/59] tty: serial: jsm: hold port lock when reporting modem line changes Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 15/59] bpf/tests: Fix copy-and-paste error in double word test Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 16/59] bpf/tests: Do not PASS tests without actually testing the result Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 17/59] video: fbdev: asiliantfb: Error out if 'pixclock' equals zero Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 18/59] video: fbdev: kyro: " Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 19/59] video: fbdev: riva: " Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 20/59] ipv4: ip_output.c: Fix out-of-bounds warning in ip_copy_addrs() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 21/59] flow_dissector: Fix out-of-bounds warnings Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 22/59] s390/jump_label: print real address in a case of a jump label bug Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 23/59] serial: 8250: Define RX trigger levels for OxSemi 950 devices Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 24/59] xtensa: ISS: don't panic in rs_init Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 25/59] hvsi: don't panic on tty_register_driver failure Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 26/59] serial: 8250_pci: make setup_port() parameters explicitly unsigned Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 27/59] staging: ks7010: Fix the initialization of the 'sleep_status' structure Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 28/59] ata: sata_dwc_460ex: No need to call phy_exit() befre phy_init() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 29/59] Bluetooth: skip invalid hci_sync_conn_complete_evt Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 30/59] ASoC: Intel: bytcr_rt5640: Move "Platform Clock" routes to the maps for the matching in-/output Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 31/59] bpf: Fix off-by-one in tail call count limiting Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 32/59] media: v4l2-dv-timings.c: fix wrong condition in two for-loops Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 33/59] arm64: dts: qcom: sdm660: use reg value for memory node Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 34/59] net: ethernet: stmmac: Do not use unreachable() in ipq806x_gmac_probe() Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 35/59] Bluetooth: avoid circular locks in sco_sock_connect Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 36/59] gpu: drm: amd: amdgpu: amdgpu_i2c: fix possible uninitialized-variable access in amdgpu_i2c_router_select_ddc_port() Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 37/59] ARM: tegra: tamonten: Fix UART pad setting Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 38/59] ACPICA: iASL: Fix for WPBT table with no command-line arguments Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 39/59] rpc: fix gss_svc_init cleanup on failure Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 40/59] staging: rts5208: Fix get_ms_information() heap buffer size Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 41/59] gfs2: Don't call dlm after protocol is unmounted Sasha Levin
2021-09-09 11:58   ` [Cluster-devel] " Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 42/59] btrfs: subpage: check if there are compressed extents inside one page Sasha Levin
2021-09-09 13:01   ` David Sterba
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 43/59] btrfs: subpage: fix race between prepare_pages() and btrfs_releasepage() Sasha Levin
2021-09-09 13:01   ` David Sterba
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 44/59] ASoC: intel: atom: Revert PCM buffer address setup workaround again Sasha Levin
2021-09-09 12:06   ` Takashi Iwai
2021-09-09 12:06     ` Takashi Iwai
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 45/59] mmc: sdhci-of-arasan: Check return value of non-void funtions Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 46/59] mmc: rtsx_pci: Fix long reads when clock is prescaled Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 47/59] selftests/bpf: Enlarge select() timeout for test_maps Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 48/59] cifs: fix wrong release in sess_alloc_buffer() failed path Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 49/59] Revert "USB: xhci: fix U1/U2 handling for hardware with XHCI_INTEL_HOST quirk set" Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 50/59] usb: musb: musb_dsps: request_irq() after initializing musb Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 51/59] usbip: give back URBs for unsent unlink requests during cleanup Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 52/59] usbip:vhci_hcd USB port can get stuck in the disabled state Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 53/59] ASoC: rockchip: i2s: Fix regmap_ops hang Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 54/59] ASoC: rockchip: i2s: Fixup config for DAIFMT_DSP_A/B Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58   ` Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 55/59] parport: remove non-zero check on count Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 56/59] ath9k: fix OOB read ar9300_eeprom_restore_internal Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 57/59] ath9k: fix sleeping in atomic context Sasha Levin
2021-09-09 11:58 ` [PATCH AUTOSEL 4.14 58/59] net: fix NULL pointer reference in cipso_v4_doi_free Sasha Levin
2021-09-09 11:59 ` [PATCH AUTOSEL 4.14 59/59] net: w5100: check return value after calling platform_get_resource() 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=20210909115900.149795-3-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=rafael.j.wysocki@intel.com \
    --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.