From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Sasha Levin <sashal@kernel.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>, Nishanth Menon <nm@ti.com>,
Michael Kelley <mikelley@microsoft.com>,
bhelgaas@google.com, linux-pci@vger.kernel.org
Subject: Re: [PATCH AUTOSEL 5.16 36/52] PCI/MSI: Decouple MSI[-X] disable from pcim_release()
Date: Mon, 17 Jan 2022 18:08:34 +0100 [thread overview]
Message-ID: <YeWikhpdcmenkMub@kroah.com> (raw)
In-Reply-To: <20220117165853.1470420-36-sashal@kernel.org>
On Mon, Jan 17, 2022 at 11:58:37AM -0500, Sasha Levin wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
>
> [ Upstream commit 3f35d2cf9fbc656db82579d849cc69c373b1ad0d ]
>
> The MSI core will introduce runtime allocation of MSI related data. This
> data will be devres managed and has to be set up before enabling
> PCI/MSI[-X]. This would introduce an ordering issue vs. pcim_release().
>
> The setup order is:
>
> pcim_enable_device()
> devres_alloc(pcim_release...);
> ...
> pci_irq_alloc()
> msi_setup_device_data()
> devres_alloc(msi_device_data_release, ...)
>
> and once the device is released these release functions are invoked in the
> opposite order:
>
> msi_device_data_release()
> ...
> pcim_release()
> pci_disable_msi[x]()
>
> which is obviously wrong, because pci_disable_msi[x]() requires the MSI
> data to be available to tear down the MSI[-X] interrupts.
>
> Remove the MSI[-X] teardown from pcim_release() and add an explicit action
> to be installed on the attempt of enabling PCI/MSI[-X].
>
> This allows the MSI core data allocation to be ordered correctly in a
> subsequent step.
>
> Reported-by: Nishanth Menon <nm@ti.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Tested-by: Michael Kelley <mikelley@microsoft.com>
> Tested-by: Nishanth Menon <nm@ti.com>
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Link: https://lore.kernel.org/r/87tuf9rdoj.ffs@tglx
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> drivers/pci/msi.c | 33 +++++++++++++++++++++++++++++++++
> drivers/pci/pci.c | 5 -----
> include/linux/pci.h | 3 ++-
> 3 files changed, 35 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
> index d84cf30bb2790..1093f099846eb 100644
> --- a/drivers/pci/msi.c
> +++ b/drivers/pci/msi.c
> @@ -461,6 +461,31 @@ void pci_restore_msi_state(struct pci_dev *dev)
> }
> EXPORT_SYMBOL_GPL(pci_restore_msi_state);
>
> +static void pcim_msi_release(void *pcidev)
> +{
> + struct pci_dev *dev = pcidev;
> +
> + dev->is_msi_managed = false;
> + pci_free_irq_vectors(dev);
> +}
> +
> +/*
> + * Needs to be separate from pcim_release to prevent an ordering problem
> + * vs. msi_device_data_release() in the MSI core code.
> + */
> +static int pcim_setup_msi_release(struct pci_dev *dev)
> +{
> + int ret;
> +
> + if (!pci_is_managed(dev) || dev->is_msi_managed)
> + return 0;
> +
> + ret = devm_add_action(&dev->dev, pcim_msi_release, dev);
> + if (!ret)
> + dev->is_msi_managed = true;
> + return ret;
> +}
> +
> static struct msi_desc *
> msi_setup_entry(struct pci_dev *dev, int nvec, struct irq_affinity *affd)
> {
> @@ -1029,6 +1054,10 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
> if (nvec > maxvec)
> nvec = maxvec;
>
> + rc = pcim_setup_msi_release(dev);
> + if (rc)
> + return rc;
> +
> for (;;) {
> if (affd) {
> nvec = irq_calc_affinity_vectors(minvec, nvec, affd);
> @@ -1072,6 +1101,10 @@ static int __pci_enable_msix_range(struct pci_dev *dev,
> if (WARN_ON_ONCE(dev->msix_enabled))
> return -EINVAL;
>
> + rc = pcim_setup_msi_release(dev);
> + if (rc)
> + return rc;
> +
> for (;;) {
> if (affd) {
> nvec = irq_calc_affinity_vectors(minvec, nvec, affd);
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 3d2fb394986a4..f3f606c232a8a 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -2024,11 +2024,6 @@ static void pcim_release(struct device *gendev, void *res)
> struct pci_devres *this = res;
> int i;
>
> - if (dev->msi_enabled)
> - pci_disable_msi(dev);
> - if (dev->msix_enabled)
> - pci_disable_msix(dev);
> -
> for (i = 0; i < DEVICE_COUNT_RESOURCE; i++)
> if (this->region_mask & (1 << i))
> pci_release_region(dev, i);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 18a75c8e615cd..e26000404e3c3 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -425,7 +425,8 @@ struct pci_dev {
> unsigned int ats_enabled:1; /* Address Translation Svc */
> unsigned int pasid_enabled:1; /* Process Address Space ID */
> unsigned int pri_enabled:1; /* Page Request Interface */
> - unsigned int is_managed:1;
> + unsigned int is_managed:1; /* Managed via devres */
> + unsigned int is_msi_managed:1; /* MSI release via devres installed */
> unsigned int needs_freset:1; /* Requires fundamental reset */
> unsigned int state_saved:1;
> unsigned int is_physfn:1;
> --
> 2.34.1
>
I do not think this is needed for the stable trees, as it only showed up
in the MSI rework that Thomas added for 5.17-rc1. So please drop this
from all of the AUTOSEL kernels.
thanks,
greg k-h
next prev parent reply other threads:[~2022-01-17 17:11 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 16:58 [PATCH AUTOSEL 5.16 01/52] clk: imx: Use div64_ul instead of do_div Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 02/52] clk: samsung: exynos850: Register clocks early Sasha Levin
2022-01-17 17:11 ` Krzysztof Kozlowski
2022-01-17 19:18 ` Sam Protsenko
2022-01-22 18:39 ` Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 03/52] powerpc/6xx: add missing of_node_put Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 04/52] powerpc/powernv: " Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 05/52] powerpc/cell: " Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 06/52] powerpc/btext: " Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 07/52] powerpc/watchdog: Fix missed watchdog reset due to memory ordering race Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 08/52] ASoC: imx-hdmi: add put_device() after of_find_device_by_node() Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 09/52] i2c: i801: Don't silently correct invalid transfer size Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 10/52] powerpc/smp: Move setup_profiling_timer() under CONFIG_PROFILING Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 11/52] i2c: mpc: Correct I2C reset procedure Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 12/52] clk: meson: gxbb: Fix the SDM_EN bit for MPLL0 on GXBB Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 13/52] powerpc/powermac: Add missing lockdep_register_key() Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 14/52] KVM: PPC: Book3S: Suppress warnings when allocating too big memory slots Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 15/52] KVM: PPC: Book3S: Suppress failed alloc warning in H_COPY_TOFROM_GUEST Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 16/52] w1: Misuse of get_user()/put_user() reported by sparse Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 17/52] nvmem: core: set size for sysfs bin file Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 18/52] dm: fix alloc_dax error handling in alloc_dev Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 19/52] dm: make the DAX support depend on CONFIG_FS_DAX Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 20/52] ASoC: test-component: fix null pointer dereference Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 21/52] interconnect: qcom: rpm: Prevent integer overflow in rate Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 22/52] scsi: ufs: Fix a kernel crash during shutdown Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 23/52] scsi: lpfc: Fix leaked lpfc_dmabuf mbox allocations with NPIV Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 24/52] scsi: lpfc: Trigger SLI4 firmware dump before doing driver cleanup Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 25/52] ALSA: seq: Set upper limit of processed events Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 26/52] MIPS: Loongson64: Use three arguments for slti Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 27/52] powerpc/40x: Map 32Mbytes of memory at startup Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 28/52] selftests/powerpc/spectre_v2: Return skip code when miss_percent is high Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 29/52] powerpc: handle kdump appropriately with crash_kexec_post_notifiers option Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 30/52] powerpc/fadump: Fix inaccurate CPU state info in vmcore generated with panic Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 31/52] ASoC: SOF: Intel: hda: add quirks for HDAudio DMA position information Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 32/52] udf: Fix error handling in udf_new_inode() Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 33/52] MIPS: OCTEON: add put_device() after of_find_device_by_node() Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 34/52] irqchip/gic-v4: Disable redistributors' view of the VPE table at boot time Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 35/52] i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 36/52] PCI/MSI: Decouple MSI[-X] disable from pcim_release() Sasha Levin
2022-01-17 17:08 ` Greg Kroah-Hartman [this message]
2022-01-22 18:39 ` Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 37/52] scsi: hisi_sas: Prevent parallel FLR and controller reset Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 38/52] ASoC: SOF: ipc: Add null pointer check for substream->runtime Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 39/52] selftests/powerpc: Add a test of sigreturning to the kernel Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 40/52] MIPS: Octeon: Fix build errors using clang Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 41/52] scsi: sr: Don't use GFP_DMA Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 42/52] scsi: mpi3mr: Fixes around reply request queues Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 43/52] ASoC: mediatek: mt8192-mt6359: fix device_node leak Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 44/52] phy: phy-mtk-tphy: add support efuse setting Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 45/52] ASoC: mediatek: mt8173: fix device_node leak Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 46/52] ASoC: mediatek: mt8183: " Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 47/52] habanalabs: change wait for interrupt timeout to 64 bit Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 48/52] habanalabs: skip read fw errors if dynamic descriptor invalid Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 49/52] phy: mediatek: Fix missing check in mtk_mipi_tx_probe Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 50/52] ASoC: amd: acp: acp-mach: Change default RT1019 amp dev id Sasha Levin
2022-01-18 16:18 ` Mark Brown
2022-01-22 18:43 ` Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 51/52] mailbox: change mailbox-mpfs compatible string Sasha Levin
2022-01-17 16:58 ` [PATCH AUTOSEL 5.16 52/52] leds: leds-fsg: Drop FSG3 LED driver 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=YeWikhpdcmenkMub@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=bhelgaas@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=nm@ti.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).