Commit 6360efb9 authored by Manivannan Sadhasivam's avatar Manivannan Sadhasivam Committed by Bjorn Helgaas
Browse files

PCI: endpoint: Add BME notifier support

Add support to notify the EPF device about the Bus Master Enable (BME)
event received by the EPC device from the Root complex.

Link: https://lore.kernel.org/r/20230602114756.36586-6-manivannan.sadhasivam@linaro.org


Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: default avatarLorenzo Pieralisi <lpieralisi@kernel.org>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: default avatarKishon Vijay Abraham I <kishon@kernel.org>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
parent a1f6c3d7
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -758,6 +758,32 @@ void pci_epc_init_notify(struct pci_epc *epc)
}
EXPORT_SYMBOL_GPL(pci_epc_init_notify);

/**
 * pci_epc_bme_notify() - Notify the EPF device that the EPC device has received
 *			  the BME event from the Root complex
 * @epc: the EPC device that received the BME event
 *
 * Invoke to Notify the EPF device that the EPC device has received the Bus
 * Master Enable (BME) event from the Root complex
 */
void pci_epc_bme_notify(struct pci_epc *epc)
{
	struct pci_epf *epf;

	if (!epc || IS_ERR(epc))
		return;

	mutex_lock(&epc->list_lock);
	list_for_each_entry(epf, &epc->pci_epf, list) {
		mutex_lock(&epf->lock);
		if (epf->event_ops && epf->event_ops->bme)
			epf->event_ops->bme(epf);
		mutex_unlock(&epf->lock);
	}
	mutex_unlock(&epc->list_lock);
}
EXPORT_SYMBOL_GPL(pci_epc_bme_notify);

/**
 * pci_epc_destroy() - destroy the EPC device
 * @epc: the EPC device that has to be destroyed
+1 −0
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf,
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_bme_notify(struct pci_epc *epc);
void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf,
			enum pci_epc_interface_type type);
int pci_epc_write_header(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
+2 −0
Original line number Diff line number Diff line
@@ -72,11 +72,13 @@ struct pci_epf_ops {
 * @core_init: Callback for the EPC initialization complete event
 * @link_up: Callback for the EPC link up event
 * @link_down: Callback for the EPC link down event
 * @bme: Callback for the EPC BME (Bus Master Enable) event
 */
struct pci_epc_event_ops {
	int (*core_init)(struct pci_epf *epf);
	int (*link_up)(struct pci_epf *epf);
	int (*link_down)(struct pci_epf *epf);
	int (*bme)(struct pci_epf *epf);
};

/**