[PATCH] pci: Warn if BME cannot be turned off during kexec

From: Deepa Dinamani
Date: Sat Jan 04 2020 - 17:51:18 EST


BME not being off is a security risk, so for whatever
reason if we cannot disable it, print a warning.

Signed-off-by: Deepa Dinamani <deepa.kernel@xxxxxxxxx>
---
drivers/pci/pci-driver.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 0454ca0e4e3f..6c866a81f46c 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -491,8 +491,12 @@ static void pci_device_shutdown(struct device *dev)
* If it is not a kexec reboot, firmware will hit the PCI
* devices with big hammer and stop their DMA any way.
*/
- if (kexec_in_progress && (pci_dev->current_state <= PCI_D3hot))
- pci_clear_master(pci_dev);
+ if (kexec_in_progress) {
+ if (likely(pci_dev->current_state <= PCI_D3hot))
+ pci_clear_master(pci_dev);
+ else
+ dev_warn(dev, "Unable to turn off BME during kexec");
+ }
}

#ifdef CONFIG_PM
--
2.17.1