All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: kishon@ti.com, lorenzo.pieralisi@arm.com, bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, hemantk@codeaurora.org,
	smohanad@codeaurora.org,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Subject: [PATCH 4/5] PCI: endpoint: Add D_STATE notifier support
Date: Wed, 16 Jun 2021 17:29:12 +0530	[thread overview]
Message-ID: <20210616115913.138778-5-manivannan.sadhasivam@linaro.org> (raw)
In-Reply-To: <20210616115913.138778-1-manivannan.sadhasivam@linaro.org>

Add support to notify the EPF device about the Device State (D_STATE)
event received by the EPC device from the Root complex.

Usage:
======

EPC
---

```
static irqreturn_t pcie_ep_irq(int irq, void *data)
{
...
	case PCIE_EP_INT_D_STATE:
		dstate = dw_pcie_readl_dbi(pci, DBI_CON_STATUS) & 0x3;
		pci_epc_d_state_notify(epc, dstate);
		break;
...
}
```

EPF
---

```
static int pci_epf_notifier(struct notifier_block *nb, unsigned long val,
			    void *data)
{
...
	case D_STATE:
		dstate = data;
		if (dstate == PCIE_EP_D0)
			/* Handle D0 event */
		else if (dstate == PCIE_EP_D3)
			/* Handle D3 event */
		break;
...
}
```

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

diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c
index 63fe90dbbba2..b4a7bb3caa97 100644
--- a/drivers/pci/endpoint/pci-epc-core.c
+++ b/drivers/pci/endpoint/pci-epc-core.c
@@ -710,6 +710,24 @@ void pci_epc_pme_notify(struct pci_epc *epc, void *data)
 }
 EXPORT_SYMBOL_GPL(pci_epc_pme_notify);
 
+/**
+ * pci_epc_d_state_notify() - Notify the EPF device that the EPC device has
+ *			      received the Device State event from Root complex
+ * @epc: the EPC device that received the Device State event
+ * @data: Data for the D_STATE notifier
+ *
+ * Invoke to notify the EPF device that the EPC device has received the Device
+ * State (D_STATE) event from the Root complex
+ */
+void pci_epc_d_state_notify(struct pci_epc *epc, void *data)
+{
+	if (!epc || IS_ERR(epc))
+		return;
+
+	atomic_notifier_call_chain(&epc->notifier, D_STATE, data);
+}
+EXPORT_SYMBOL_GPL(pci_epc_d_state_notify);
+
 /**
  * pci_epc_destroy() - destroy the EPC device
  * @epc: the EPC device that has to be destroyed
diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h
index 37dbcade1780..94c66fae8a88 100644
--- a/include/linux/pci-epc.h
+++ b/include/linux/pci-epc.h
@@ -206,6 +206,7 @@ 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_pme_notify(struct pci_epc *epc, void *data);
+void pci_epc_d_state_notify(struct pci_epc *epc, void *data);
 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,
diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h
index c162a73eb836..ca020c080431 100644
--- a/include/linux/pci-epf.h
+++ b/include/linux/pci-epf.h
@@ -23,6 +23,7 @@ enum pci_notify_event {
 	LINK_DOWN,
 	BME,
 	PME,
+	D_STATE,
 };
 
 enum pci_barno {
-- 
2.25.1


  parent reply	other threads:[~2021-06-16 12:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 11:59 [PATCH 0/5] PCI: endpoint: Add support for additional notifiers Manivannan Sadhasivam
2021-06-16 11:59 ` [PATCH 1/5] PCI: endpoint: Add linkdown notifier support Manivannan Sadhasivam
2021-06-16 18:22   ` Om Prakash Singh
2021-06-16 18:30     ` Manivannan Sadhasivam
2021-06-16 11:59 ` [PATCH 2/5] PCI: endpoint: Add BME " Manivannan Sadhasivam
2021-06-16 11:59 ` [PATCH 3/5] PCI: endpoint: Add PME " Manivannan Sadhasivam
2021-06-16 11:59 ` Manivannan Sadhasivam [this message]
2021-06-16 11:59 ` [PATCH 5/5] PCI: endpoint: Add custom " Manivannan Sadhasivam
2021-06-16 19:12 ` [PATCH 0/5] PCI: endpoint: Add support for additional notifiers Om Prakash Singh
2021-06-17 17:05   ` Manivannan Sadhasivam
2021-08-19 13:06 ` Manivannan Sadhasivam
2021-08-19 14:15 ` Kishon Vijay Abraham I
2021-08-19 14:22   ` Manivannan Sadhasivam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210616115913.138778-5-manivannan.sadhasivam@linaro.org \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=bhelgaas@google.com \
    --cc=hemantk@codeaurora.org \
    --cc=kishon@ti.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=smohanad@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.