Re: [PATCH 1/5] PCI: endpoint: Add linkdown notifier support

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

 





On 6/16/2021 5:29 PM, Manivannan Sadhasivam wrote:
External email: Use caution opening links or attachments


Add support to notify the EPF device about the linkdown event from the
EPC device.

Usage:
======

EPC
---

```
static irqreturn_t pcie_ep_irq(int irq, void *data)
{
...
         case PCIE_EP_INT_LINK_DOWN:
                 pci_epc_linkdown(epc);
                 break;
Can you provide use case/scenario when epc will get LINK_DOWN interrupt?

...
}
```

EPF
---

```
static int pci_epf_notifier(struct notifier_block *nb, unsigned long val,
                             void *data)
{
...
         case LINK_DOWN:
                 /* Handle link down event */
                 break;
...
}
```

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@xxxxxxxxxx>
---
  drivers/pci/endpoint/pci-epc-core.c | 17 +++++++++++++++++
  include/linux/pci-epc.h             |  1 +
  include/linux/pci-epf.h             |  1 +
  3 files changed, 19 insertions(+)

diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
index adec9bee72cf..f29d78c18438 100644
--- a/drivers/pci/endpoint/pci-epc-core.c
+++ b/drivers/pci/endpoint/pci-epc-core.c
@@ -641,6 +641,23 @@ void pci_epc_linkup(struct pci_epc *epc)
  }
  EXPORT_SYMBOL_GPL(pci_epc_linkup);

+/**
+ * pci_epc_linkdown() - Notify the EPF device that EPC device has dropped the
+ *                     connection with the Root Complex.
+ * @epc: the EPC device which has dropped the link with the host
+ *
+ * Invoke to Notify the EPF device that the EPC device has dropped the
+ * connection with the Root Complex.
+ */
+void pci_epc_linkdown(struct pci_epc *epc)
+{
+       if (!epc || IS_ERR(epc))
+               return;
+
+       atomic_notifier_call_chain(&epc->notifier, LINK_DOWN, NULL);
+}
+EXPORT_SYMBOL_GPL(pci_epc_linkdown);
+
  /**
   * pci_epc_init_notify() - Notify the EPF device that EPC device's core
   *                        initialization is completed.
diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h
index b82c9b100e97..23590efc13e7 100644
--- a/include/linux/pci-epc.h
+++ b/include/linux/pci-epc.h
@@ -202,6 +202,7 @@ void pci_epc_destroy(struct pci_epc *epc);
  int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf,
                     enum pci_epc_interface_type type);
  void pci_epc_linkup(struct pci_epc *epc);
+void pci_epc_linkdown(struct pci_epc *epc);
  void pci_epc_init_notify(struct pci_epc *epc);
  void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf,
                         enum pci_epc_interface_type type);
diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h
index 6833e2160ef1..e9ad634b1575 100644
--- a/include/linux/pci-epf.h
+++ b/include/linux/pci-epf.h
@@ -20,6 +20,7 @@ enum pci_epc_interface_type;
  enum pci_notify_event {
         CORE_INIT,
         LINK_UP,
+       LINK_DOWN,
  };

  enum pci_barno {
--
2.25.1




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux