Skip to content

Commit a1f6c3d

Browse files
Mani-Sadhasivambjorn-helgaas
authored andcommitted
PCI: endpoint: Add linkdown notifier support
Add support to notify the EPF device about the linkdown event from the EPC device. Link: https://lore.kernel.org/r/20230602114756.36586-5-manivannan.sadhasivam@linaro.org Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Kishon Vijay Abraham I <kishon@kernel.org> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
1 parent a504c96 commit a1f6c3d

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

drivers/pci/endpoint/pci-epc-core.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,32 @@ void pci_epc_linkup(struct pci_epc *epc)
706706
}
707707
EXPORT_SYMBOL_GPL(pci_epc_linkup);
708708

709+
/**
710+
* pci_epc_linkdown() - Notify the EPF device that EPC device has dropped the
711+
* connection with the Root Complex.
712+
* @epc: the EPC device which has dropped the link with the host
713+
*
714+
* Invoke to Notify the EPF device that the EPC device has dropped the
715+
* connection with the Root Complex.
716+
*/
717+
void pci_epc_linkdown(struct pci_epc *epc)
718+
{
719+
struct pci_epf *epf;
720+
721+
if (!epc || IS_ERR(epc))
722+
return;
723+
724+
mutex_lock(&epc->list_lock);
725+
list_for_each_entry(epf, &epc->pci_epf, list) {
726+
mutex_lock(&epf->lock);
727+
if (epf->event_ops && epf->event_ops->link_down)
728+
epf->event_ops->link_down(epf);
729+
mutex_unlock(&epf->lock);
730+
}
731+
mutex_unlock(&epc->list_lock);
732+
}
733+
EXPORT_SYMBOL_GPL(pci_epc_linkdown);
734+
709735
/**
710736
* pci_epc_init_notify() - Notify the EPF device that EPC device's core
711737
* initialization is completed.

include/linux/pci-epc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ void pci_epc_destroy(struct pci_epc *epc);
203203
int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf,
204204
enum pci_epc_interface_type type);
205205
void pci_epc_linkup(struct pci_epc *epc);
206+
void pci_epc_linkdown(struct pci_epc *epc);
206207
void pci_epc_init_notify(struct pci_epc *epc);
207208
void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf,
208209
enum pci_epc_interface_type type);

include/linux/pci-epf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ struct pci_epf_ops {
7171
* struct pci_epf_event_ops - Callbacks for capturing the EPC events
7272
* @core_init: Callback for the EPC initialization complete event
7373
* @link_up: Callback for the EPC link up event
74+
* @link_down: Callback for the EPC link down event
7475
*/
7576
struct pci_epc_event_ops {
7677
int (*core_init)(struct pci_epf *epf);
7778
int (*link_up)(struct pci_epf *epf);
79+
int (*link_down)(struct pci_epf *epf);
7880
};
7981

8082
/**

0 commit comments

Comments
 (0)