Re: [RFC PATCH v2] PCI/portdrv: Only disable Bus Master on kexec reboot and connected PCI devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/14/2020 02:13 PM, Tiezhu Yang wrote:
On 09/14/2020 12:06 PM, Lukas Wunner wrote:
On Mon, Sep 14, 2020 at 04:29:10AM +0800, Tiezhu Yang wrote:
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -143,6 +144,28 @@ static void pcie_portdrv_remove(struct pci_dev *dev)
      }
        pcie_port_device_remove(dev);
+    pci_disable_device(dev);
+}
+
+static void pcie_portdrv_shutdown(struct pci_dev *dev)
+{
+    if (pci_bridge_d3_possible(dev)) {
+        pm_runtime_forbid(&dev->dev);
+        pm_runtime_get_noresume(&dev->dev);
+        pm_runtime_dont_use_autosuspend(&dev->dev);
+    }
+
+    pcie_port_device_remove(dev);
+
+    /*
+     * If this is a kexec reboot, turn off Bus Master bit on the
+     * device to tell it to not continue to do DMA. Don't touch
+     * devices in D3cold or unknown states.
+     * 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 && (dev->current_state <= PCI_D3hot))
+        pci_disable_device(dev);
The last portion of this function is already executed afterwards by
pci_device_shutdown().  You don't need to duplicate it here:

device_shutdown()
   dev->bus->shutdown() == pci_device_shutdown()
     drv->shutdown() == pcie_portdrv_shutdown()
       pci_disable_device()
     pci_disable_device()

pcie_port_device_remove() deletes pci_disable_device(dev) at the beginning of this patch.

Sorry, I misunderstood your meaning, you are right.



diff <https://lore.kernel.org/linux-pci/CAAhV-H5-X9OcBe3iRxF8PnKW-0j_10FVqm8cbiqW2-Lv4mTTdQ@xxxxxxxxxxxxxx/T/#iZ2e.:..:1600028950-10644-1-git-send-email-yangtiezhu::40loongson.cn:0drivers:pci:pcie:portdrv_core.c> --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c index 50a9522..1991aca 100644 --- a/drivers/pci/pcie/portdrv_core.c +++ b/drivers/pci/pcie/portdrv_core.c @@ -491,7 +491,6 @@ void pcie_port_device_remove(struct pci_dev *dev) {
     device_for_each_child(&dev->dev, NULL, remove_iter);
     pci_free_irq_vectors(dev);
- pci_disable_device(dev);   }


Thanks,

Lukas




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux