* Patch "cxl: use pcibios_free_controller_deferred() when removing vPHBs" has been added to the 4.7-stable tree
@ 2016-09-22 13:34 gregkh
2016-09-28 8:29 ` Andrew Donnellan
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2016-09-22 13:34 UTC (permalink / raw)
To: andrew.donnellan, benh, gregkh, imunsie, mrochs; +Cc: stable, stable-commits
This is a note to let you know that I've just added the patch titled
cxl: use pcibios_free_controller_deferred() when removing vPHBs
to the 4.7-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
cxl-use-pcibios_free_controller_deferred-when-removing-vphbs.patch
and it can be found in the queue-4.7 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
>From 6f38a8b9a45833495dc878c335c5431cd98a16ed Mon Sep 17 00:00:00 2001
From: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Date: Thu, 18 Aug 2016 17:35:14 +1000
Subject: cxl: use pcibios_free_controller_deferred() when removing vPHBs
From: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
commit 6f38a8b9a45833495dc878c335c5431cd98a16ed upstream.
When cxl removes a vPHB, it's possible that the pci_controller may be freed
before all references to the devices on the vPHB have been released. This
in turn causes an invalid memory access when the devices are eventually
released, as pcibios_release_device() attempts to call the phb's
release_device hook.
In cxl_pci_vphb_remove(), remove the existing call to
pcibios_free_controller(). Instead, use
pcibios_free_controller_deferred() to free the pci_controller after all
devices have been released. Export pci_set_host_bridge_release() so we can
do this.
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/misc/cxl/vphb.c | 10 +++++++++-
drivers/pci/host-bridge.c | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
--- a/drivers/misc/cxl/vphb.c
+++ b/drivers/misc/cxl/vphb.c
@@ -243,6 +243,11 @@ int cxl_pci_vphb_add(struct cxl_afu *afu
if (phb->bus == NULL)
return -ENXIO;
+ /* Set release hook on root bus */
+ pci_set_host_bridge_release(to_pci_host_bridge(phb->bus->bridge),
+ pcibios_free_controller_deferred,
+ (void *) phb);
+
/* Claim resources. This might need some rework as well depending
* whether we are doing probe-only or not, like assigning unassigned
* resources etc...
@@ -269,7 +274,10 @@ void cxl_pci_vphb_remove(struct cxl_afu
afu->phb = NULL;
pci_remove_root_bus(phb->bus);
- pcibios_free_controller(phb);
+ /*
+ * We don't free phb here - that's handled by
+ * pcibios_free_controller_deferred()
+ */
}
bool cxl_pci_is_vphb_device(struct pci_dev *dev)
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -44,6 +44,7 @@ void pci_set_host_bridge_release(struct
bridge->release_fn = release_fn;
bridge->release_data = release_data;
}
+EXPORT_SYMBOL_GPL(pci_set_host_bridge_release);
void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
struct resource *res)
Patches currently in stable-queue which might be from andrew.donnellan@au1.ibm.com are
queue-4.7/cxl-use-pcibios_free_controller_deferred-when-removing-vphbs.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Patch "cxl: use pcibios_free_controller_deferred() when removing vPHBs" has been added to the 4.7-stable tree
2016-09-22 13:34 gregkh
@ 2016-09-28 8:29 ` Andrew Donnellan
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Donnellan @ 2016-09-28 8:29 UTC (permalink / raw)
To: gregkh, benh, imunsie, mrochs
Cc: stable, stable-commits, Mauricio Faria de Oliveira
Hi Greg
On 22/09/16 23:34, gregkh@linuxfoundation.org wrote:
>
> This is a note to let you know that I've just added the patch titled
>
> cxl: use pcibios_free_controller_deferred() when removing vPHBs
>
> to the 4.7-stable tree which can be found at:
> http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
>
I notice this was dropped due to build breakage - I was away on leave
during the review cycle so I didn't spot this.
This patch depends on 2dd9c11b9d4dfbd6c070eab7b81197f65e82f1a0 which
fixes an equivalent problem for pseries PCI controller hotplug. For some
reason it didn't end up being cc'd to stable. (I've Cc'd Mauricio here.)
Andrew
--
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com IBM Australia Limited
^ permalink raw reply [flat|nested] 3+ messages in thread
* Patch "cxl: use pcibios_free_controller_deferred() when removing vPHBs" has been added to the 4.7-stable tree
@ 2016-10-10 8:45 gregkh
0 siblings, 0 replies; 3+ messages in thread
From: gregkh @ 2016-10-10 8:45 UTC (permalink / raw)
To: andrew.donnellan, benh, gregkh, imunsie, mrochs; +Cc: stable, stable-commits
This is a note to let you know that I've just added the patch titled
cxl: use pcibios_free_controller_deferred() when removing vPHBs
to the 4.7-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
cxl-use-pcibios_free_controller_deferred-when-removing-vphbs.patch
and it can be found in the queue-4.7 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
>From 6f38a8b9a45833495dc878c335c5431cd98a16ed Mon Sep 17 00:00:00 2001
From: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Date: Thu, 18 Aug 2016 17:35:14 +1000
Subject: cxl: use pcibios_free_controller_deferred() when removing vPHBs
From: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
commit 6f38a8b9a45833495dc878c335c5431cd98a16ed upstream.
When cxl removes a vPHB, it's possible that the pci_controller may be freed
before all references to the devices on the vPHB have been released. This
in turn causes an invalid memory access when the devices are eventually
released, as pcibios_release_device() attempts to call the phb's
release_device hook.
In cxl_pci_vphb_remove(), remove the existing call to
pcibios_free_controller(). Instead, use
pcibios_free_controller_deferred() to free the pci_controller after all
devices have been released. Export pci_set_host_bridge_release() so we can
do this.
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/misc/cxl/vphb.c | 10 +++++++++-
drivers/pci/host-bridge.c | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
--- a/drivers/misc/cxl/vphb.c
+++ b/drivers/misc/cxl/vphb.c
@@ -243,6 +243,11 @@ int cxl_pci_vphb_add(struct cxl_afu *afu
if (phb->bus == NULL)
return -ENXIO;
+ /* Set release hook on root bus */
+ pci_set_host_bridge_release(to_pci_host_bridge(phb->bus->bridge),
+ pcibios_free_controller_deferred,
+ (void *) phb);
+
/* Claim resources. This might need some rework as well depending
* whether we are doing probe-only or not, like assigning unassigned
* resources etc...
@@ -269,7 +274,10 @@ void cxl_pci_vphb_remove(struct cxl_afu
afu->phb = NULL;
pci_remove_root_bus(phb->bus);
- pcibios_free_controller(phb);
+ /*
+ * We don't free phb here - that's handled by
+ * pcibios_free_controller_deferred()
+ */
}
bool cxl_pci_is_vphb_device(struct pci_dev *dev)
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -44,6 +44,7 @@ void pci_set_host_bridge_release(struct
bridge->release_fn = release_fn;
bridge->release_data = release_data;
}
+EXPORT_SYMBOL_GPL(pci_set_host_bridge_release);
void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
struct resource *res)
Patches currently in stable-queue which might be from andrew.donnellan@au1.ibm.com are
queue-4.7/cxl-use-pcibios_free_controller_deferred-when-removing-vphbs.patch
queue-4.7/powerpc-pseries-use-pci_host_bridge.release_fn-to-kfree-phb.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-10 8:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-10 8:45 Patch "cxl: use pcibios_free_controller_deferred() when removing vPHBs" has been added to the 4.7-stable tree gregkh
-- strict thread matches above, loose matches on Subject: below --
2016-09-22 13:34 gregkh
2016-09-28 8:29 ` Andrew Donnellan
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).