Skip to content

Commit 6360efb

Browse files
Mani-Sadhasivambjorn-helgaas
authored andcommitted
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: 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 a1f6c3d commit 6360efb

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
@@ -758,6 +758,32 @@ void pci_epc_init_notify(struct pci_epc *epc)
758758
}
759759
EXPORT_SYMBOL_GPL(pci_epc_init_notify);
760760

761+
/**
762+
* pci_epc_bme_notify() - Notify the EPF device that the EPC device has received
763+
* the BME event from the Root complex
764+
* @epc: the EPC device that received the BME event
765+
*
766+
* Invoke to Notify the EPF device that the EPC device has received the Bus
767+
* Master Enable (BME) event from the Root complex
768+
*/
769+
void pci_epc_bme_notify(struct pci_epc *epc)
770+
{
771+
struct pci_epf *epf;
772+
773+
if (!epc || IS_ERR(epc))
774+
return;
775+
776+
mutex_lock(&epc->list_lock);
777+
list_for_each_entry(epf, &epc->pci_epf, list) {
778+
mutex_lock(&epf->lock);
779+
if (epf->event_ops && epf->event_ops->bme)
780+
epf->event_ops->bme(epf);
781+
mutex_unlock(&epf->lock);
782+
}
783+
mutex_unlock(&epc->list_lock);
784+
}
785+
EXPORT_SYMBOL_GPL(pci_epc_bme_notify);
786+
761787
/**
762788
* pci_epc_destroy() - destroy the EPC device
763789
* @epc: the EPC device that has to be destroyed

include/linux/pci-epc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf,
205205
void pci_epc_linkup(struct pci_epc *epc);
206206
void pci_epc_linkdown(struct pci_epc *epc);
207207
void pci_epc_init_notify(struct pci_epc *epc);
208+
void pci_epc_bme_notify(struct pci_epc *epc);
208209
void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf,
209210
enum pci_epc_interface_type type);
210211
int pci_epc_write_header(struct pci_epc *epc, u8 func_no, u8 vfunc_no,

include/linux/pci-epf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ struct pci_epf_ops {
7272
* @core_init: Callback for the EPC initialization complete event
7373
* @link_up: Callback for the EPC link up event
7474
* @link_down: Callback for the EPC link down event
75+
* @bme: Callback for the EPC BME (Bus Master Enable) event
7576
*/
7677
struct pci_epc_event_ops {
7778
int (*core_init)(struct pci_epf *epf);
7879
int (*link_up)(struct pci_epf *epf);
7980
int (*link_down)(struct pci_epf *epf);
81+
int (*bme)(struct pci_epf *epf);
8082
};
8183

8284
/**

0 commit comments

Comments
 (0)