* [PATCH v2 3/8] PCI: epf-mhi: Add dtate change op
[not found] <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com>
@ 2023-06-30 10:52 ` Krishna chaitanya chundru
2023-07-07 5:59 ` Manivannan Sadhasivam
2023-06-30 10:52 ` [PATCH v2 7/8] PCI: epf-mhi: Add wakeup host op Krishna chaitanya chundru
2023-06-30 10:52 ` [PATCH v2 8/8] bus: mhi: ep: wake up host is the MHI state is in M3 Krishna chaitanya chundru
2 siblings, 1 reply; 9+ messages in thread
From: Krishna chaitanya chundru @ 2023-06-30 10:52 UTC (permalink / raw)
To: manivannan.sadhasivam
Cc: helgaas, linux-pci, linux-arm-msm, linux-kernel, quic_vbadigan,
quic_nitegupt, quic_skananth, quic_ramkri, krzysztof.kozlowski,
Krishna chaitanya chundru, Manivannan Sadhasivam,
Lorenzo Pieralisi, Krzysztof Wilczyński,
Kishon Vijay Abraham I, Bjorn Helgaas, Jeffrey Hugo,
open list:MHI BUS
Add dstate host op for MHI EPF.
Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
---
drivers/pci/endpoint/functions/pci-epf-mhi.c | 13 +++++++++++++
include/linux/mhi_ep.h | 3 +++
2 files changed, 16 insertions(+)
diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
index 9c1f5a1..64ff37d 100644
--- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
+++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
@@ -339,6 +339,18 @@ static int pci_epf_mhi_bme(struct pci_epf *epf)
return 0;
}
+static int pci_epf_mhi_dstate_change(struct pci_epf *epf, pci_power_t state)
+{
+ struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
+ struct mhi_ep_cntrl *mhi_cntrl = &epf_mhi->mhi_cntrl;
+ struct device *dev = &epf->dev;
+
+ mhi_cntrl->dstate = state;
+ dev_info(dev, "D-state changeg to %s\n", pci_power_name(state));
+
+ return 0;
+}
+
static int pci_epf_mhi_bind(struct pci_epf *epf)
{
struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
@@ -394,6 +406,7 @@ static struct pci_epc_event_ops pci_epf_mhi_event_ops = {
.link_up = pci_epf_mhi_link_up,
.link_down = pci_epf_mhi_link_down,
.bme = pci_epf_mhi_bme,
+ .dstate_change = pci_epf_mhi_dstate_change,
};
static int pci_epf_mhi_probe(struct pci_epf *epf,
diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h
index f198a8a..c3a0685 100644
--- a/include/linux/mhi_ep.h
+++ b/include/linux/mhi_ep.h
@@ -8,6 +8,7 @@
#include <linux/dma-direction.h>
#include <linux/mhi.h>
+#include <linux/pci.h>
#define MHI_EP_DEFAULT_MTU 0x8000
@@ -139,6 +140,8 @@ struct mhi_ep_cntrl {
enum mhi_state mhi_state;
+ pci_power_t dstate;
+
u32 max_chan;
u32 mru;
u32 event_rings;
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 7/8] PCI: epf-mhi: Add wakeup host op
[not found] <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com>
2023-06-30 10:52 ` [PATCH v2 3/8] PCI: epf-mhi: Add dtate change op Krishna chaitanya chundru
@ 2023-06-30 10:52 ` Krishna chaitanya chundru
2023-07-07 6:14 ` Manivannan Sadhasivam
2023-06-30 10:52 ` [PATCH v2 8/8] bus: mhi: ep: wake up host is the MHI state is in M3 Krishna chaitanya chundru
2 siblings, 1 reply; 9+ messages in thread
From: Krishna chaitanya chundru @ 2023-06-30 10:52 UTC (permalink / raw)
To: manivannan.sadhasivam
Cc: helgaas, linux-pci, linux-arm-msm, linux-kernel, quic_vbadigan,
quic_nitegupt, quic_skananth, quic_ramkri, krzysztof.kozlowski,
Krishna chaitanya chundru, Manivannan Sadhasivam,
Lorenzo Pieralisi, Krzysztof Wilczyński,
Kishon Vijay Abraham I, Bjorn Helgaas, Jeffrey Hugo,
open list:MHI BUS
Add wakeup host op for MHI EPF.
If the D-state is in D3cold toggle wake signal, otherwise send PME.
Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
---
drivers/pci/endpoint/functions/pci-epf-mhi.c | 19 +++++++++++++++++++
include/linux/mhi_ep.h | 1 +
2 files changed, 20 insertions(+)
diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
index 64ff37d..deb742c 100644
--- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
+++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
@@ -237,6 +237,24 @@ static int pci_epf_mhi_write_to_host(struct mhi_ep_cntrl *mhi_cntrl,
return 0;
}
+static int pci_epf_mhi_wakeup_host(struct mhi_ep_cntrl *mhi_cntrl)
+{
+ struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
+ struct pci_epf *epf = epf_mhi->epf;
+ struct pci_epc *epc = epf->epc;
+ int ret;
+
+ if (mhi_cntrl->dstate == PCI_D3cold)
+ ret = pci_epc_wakeup_host(epc, epf->func_no,
+ epf->vfunc_no, PCI_WAKEUP_TOGGLE_WAKE);
+ else
+ ret = pci_epc_wakeup_host(epc, epf->func_no,
+ epf->vfunc_no, PCI_WAKEUP_SEND_PME);
+
+ return ret;
+
+}
+
static int pci_epf_mhi_core_init(struct pci_epf *epf)
{
struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
@@ -293,6 +311,7 @@ static int pci_epf_mhi_link_up(struct pci_epf *epf)
mhi_cntrl->unmap_free = pci_epf_mhi_unmap_free;
mhi_cntrl->read_from_host = pci_epf_mhi_read_from_host;
mhi_cntrl->write_to_host = pci_epf_mhi_write_to_host;
+ mhi_cntrl->wakeup_host = pci_epf_mhi_wakeup_host;
/* Register the MHI EP controller */
ret = mhi_ep_register_controller(mhi_cntrl, info->config);
diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h
index c3a0685..e353c429 100644
--- a/include/linux/mhi_ep.h
+++ b/include/linux/mhi_ep.h
@@ -137,6 +137,7 @@ struct mhi_ep_cntrl {
void __iomem *virt, size_t size);
int (*read_from_host)(struct mhi_ep_cntrl *mhi_cntrl, u64 from, void *to, size_t size);
int (*write_to_host)(struct mhi_ep_cntrl *mhi_cntrl, void *from, u64 to, size_t size);
+ int (*wakeup_host)(struct mhi_ep_cntrl *mhi_cntrl);
enum mhi_state mhi_state;
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 8/8] bus: mhi: ep: wake up host is the MHI state is in M3
[not found] <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com>
2023-06-30 10:52 ` [PATCH v2 3/8] PCI: epf-mhi: Add dtate change op Krishna chaitanya chundru
2023-06-30 10:52 ` [PATCH v2 7/8] PCI: epf-mhi: Add wakeup host op Krishna chaitanya chundru
@ 2023-06-30 10:52 ` Krishna chaitanya chundru
2023-07-07 6:20 ` Manivannan Sadhasivam
2 siblings, 1 reply; 9+ messages in thread
From: Krishna chaitanya chundru @ 2023-06-30 10:52 UTC (permalink / raw)
To: manivannan.sadhasivam
Cc: helgaas, linux-pci, linux-arm-msm, linux-kernel, quic_vbadigan,
quic_nitegupt, quic_skananth, quic_ramkri, krzysztof.kozlowski,
Krishna chaitanya chundru, Manivannan Sadhasivam, Jeffrey Hugo,
Rafael J. Wysocki, Dan Carpenter, Greg Kroah-Hartman, Bo Liu,
open list:MHI BUS
If the MHI state is in M3 then the most probably the host kept the
device in D3 hot or D3 cold, due to that endpoint transctions will not
be read by the host, so endpoint needs to bring the host to D0 which
eventually bring back the MHI state to M0.
Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
---
drivers/bus/mhi/ep/main.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
index 6008818..42d3791 100644
--- a/drivers/bus/mhi/ep/main.c
+++ b/drivers/bus/mhi/ep/main.c
@@ -451,12 +451,14 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
struct mhi_ep_cntrl *mhi_cntrl = mhi_dev->mhi_cntrl;
struct mhi_ep_chan *mhi_chan = mhi_dev->dl_chan;
struct device *dev = &mhi_chan->mhi_dev->dev;
+ u32 buf_left, read_offset, count = 0;
struct mhi_ring_element *el;
- u32 buf_left, read_offset;
struct mhi_ep_ring *ring;
enum mhi_ev_ccs code;
+ enum mhi_state state;
void *read_addr;
u64 write_addr;
+ bool mhi_reset;
size_t tr_len;
u32 tre_len;
int ret;
@@ -464,6 +466,18 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
buf_left = skb->len;
ring = &mhi_cntrl->mhi_chan[mhi_chan->chan].ring;
+ if (mhi_cntrl->mhi_state == MHI_STATE_M3) {
+ dev_dbg(dev, "wake up by ch id %x\n", mhi_chan->chan);
+ mhi_cntrl->wakeup_host(mhi_cntrl);
+ }
+
+ /* Wait for Host to set the M0 state */
+ do {
+ msleep(M0_WAIT_DELAY_MS);
+ mhi_ep_mmio_get_mhi_state(mhi_cntrl, &state, &mhi_reset);
+ count++;
+ } while (state != MHI_STATE_M0 && count < M0_WAIT_COUNT);
+
mutex_lock(&mhi_chan->lock);
do {
--
2.7.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/8] PCI: epf-mhi: Add dtate change op
2023-06-30 10:52 ` [PATCH v2 3/8] PCI: epf-mhi: Add dtate change op Krishna chaitanya chundru
@ 2023-07-07 5:59 ` Manivannan Sadhasivam
2023-07-07 10:55 ` Krishna Chaitanya Chundru
0 siblings, 1 reply; 9+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-07 5:59 UTC (permalink / raw)
To: Krishna chaitanya chundru
Cc: manivannan.sadhasivam, helgaas, linux-pci, linux-arm-msm,
linux-kernel, quic_vbadigan, quic_nitegupt, quic_skananth,
quic_ramkri, krzysztof.kozlowski, Lorenzo Pieralisi,
Krzysztof Wilczyński, Kishon Vijay Abraham I, Bjorn Helgaas,
Jeffrey Hugo, open list:MHI BUS
On Fri, Jun 30, 2023 at 04:22:06PM +0530, Krishna chaitanya chundru wrote:
> Add dstate host op for MHI EPF.
>
Use "D-state" everywhere. Also the subject should be:
"PCI: epf-mhi: Add support for handling D-state notification from EPC"
Fix the commit message accordingly.
> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
> ---
> drivers/pci/endpoint/functions/pci-epf-mhi.c | 13 +++++++++++++
> include/linux/mhi_ep.h | 3 +++
> 2 files changed, 16 insertions(+)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
> index 9c1f5a1..64ff37d 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
> @@ -339,6 +339,18 @@ static int pci_epf_mhi_bme(struct pci_epf *epf)
> return 0;
> }
>
> +static int pci_epf_mhi_dstate_change(struct pci_epf *epf, pci_power_t state)
> +{
> + struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
> + struct mhi_ep_cntrl *mhi_cntrl = &epf_mhi->mhi_cntrl;
> + struct device *dev = &epf->dev;
> +
> + mhi_cntrl->dstate = state;
> + dev_info(dev, "D-state changeg to %s\n", pci_power_name(state));
This can be removed since we already print the state in pci driver.
- Mani
> +
> + return 0;
> +}
> +
> static int pci_epf_mhi_bind(struct pci_epf *epf)
> {
> struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
> @@ -394,6 +406,7 @@ static struct pci_epc_event_ops pci_epf_mhi_event_ops = {
> .link_up = pci_epf_mhi_link_up,
> .link_down = pci_epf_mhi_link_down,
> .bme = pci_epf_mhi_bme,
> + .dstate_change = pci_epf_mhi_dstate_change,
> };
>
> static int pci_epf_mhi_probe(struct pci_epf *epf,
> diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h
> index f198a8a..c3a0685 100644
> --- a/include/linux/mhi_ep.h
> +++ b/include/linux/mhi_ep.h
> @@ -8,6 +8,7 @@
>
> #include <linux/dma-direction.h>
> #include <linux/mhi.h>
> +#include <linux/pci.h>
>
> #define MHI_EP_DEFAULT_MTU 0x8000
>
> @@ -139,6 +140,8 @@ struct mhi_ep_cntrl {
>
> enum mhi_state mhi_state;
>
> + pci_power_t dstate;
> +
> u32 max_chan;
> u32 mru;
> u32 event_rings;
> --
> 2.7.4
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 7/8] PCI: epf-mhi: Add wakeup host op
2023-06-30 10:52 ` [PATCH v2 7/8] PCI: epf-mhi: Add wakeup host op Krishna chaitanya chundru
@ 2023-07-07 6:14 ` Manivannan Sadhasivam
2023-07-07 11:00 ` Krishna Chaitanya Chundru
0 siblings, 1 reply; 9+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-07 6:14 UTC (permalink / raw)
To: Krishna chaitanya chundru
Cc: manivannan.sadhasivam, helgaas, linux-pci, linux-arm-msm,
linux-kernel, quic_vbadigan, quic_nitegupt, quic_skananth,
quic_ramkri, krzysztof.kozlowski, Lorenzo Pieralisi,
Krzysztof Wilczyński, Kishon Vijay Abraham I, Bjorn Helgaas,
Jeffrey Hugo, open list:MHI BUS
On Fri, Jun 30, 2023 at 04:22:10PM +0530, Krishna chaitanya chundru wrote:
> Add wakeup host op for MHI EPF.
> If the D-state is in D3cold toggle wake signal, otherwise send PME.
>
> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
> ---
> drivers/pci/endpoint/functions/pci-epf-mhi.c | 19 +++++++++++++++++++
> include/linux/mhi_ep.h | 1 +
> 2 files changed, 20 insertions(+)
>
> diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
> index 64ff37d..deb742c 100644
> --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
> +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
> @@ -237,6 +237,24 @@ static int pci_epf_mhi_write_to_host(struct mhi_ep_cntrl *mhi_cntrl,
> return 0;
> }
>
> +static int pci_epf_mhi_wakeup_host(struct mhi_ep_cntrl *mhi_cntrl)
> +{
> + struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
> + struct pci_epf *epf = epf_mhi->epf;
> + struct pci_epc *epc = epf->epc;
> + int ret;
> +
> + if (mhi_cntrl->dstate == PCI_D3cold)
> + ret = pci_epc_wakeup_host(epc, epf->func_no,
> + epf->vfunc_no, PCI_WAKEUP_TOGGLE_WAKE);
> + else
> + ret = pci_epc_wakeup_host(epc, epf->func_no,
> + epf->vfunc_no, PCI_WAKEUP_SEND_PME);
> +
If the wakeup argument is of type bool (ie. bool use_pme), then
wakeup = (mhi_cntrl->dstate == PCI_D3cold) ? false : true;
return pci_epc_wakeup_host(epc, epf->func_no, epf->vfunc_no, state);
- Mani
> + return ret;
> +
> +}
> +
> static int pci_epf_mhi_core_init(struct pci_epf *epf)
> {
> struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
> @@ -293,6 +311,7 @@ static int pci_epf_mhi_link_up(struct pci_epf *epf)
> mhi_cntrl->unmap_free = pci_epf_mhi_unmap_free;
> mhi_cntrl->read_from_host = pci_epf_mhi_read_from_host;
> mhi_cntrl->write_to_host = pci_epf_mhi_write_to_host;
> + mhi_cntrl->wakeup_host = pci_epf_mhi_wakeup_host;
>
> /* Register the MHI EP controller */
> ret = mhi_ep_register_controller(mhi_cntrl, info->config);
> diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h
> index c3a0685..e353c429 100644
> --- a/include/linux/mhi_ep.h
> +++ b/include/linux/mhi_ep.h
> @@ -137,6 +137,7 @@ struct mhi_ep_cntrl {
> void __iomem *virt, size_t size);
> int (*read_from_host)(struct mhi_ep_cntrl *mhi_cntrl, u64 from, void *to, size_t size);
> int (*write_to_host)(struct mhi_ep_cntrl *mhi_cntrl, void *from, u64 to, size_t size);
> + int (*wakeup_host)(struct mhi_ep_cntrl *mhi_cntrl);
>
> enum mhi_state mhi_state;
>
> --
> 2.7.4
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 8/8] bus: mhi: ep: wake up host is the MHI state is in M3
2023-06-30 10:52 ` [PATCH v2 8/8] bus: mhi: ep: wake up host is the MHI state is in M3 Krishna chaitanya chundru
@ 2023-07-07 6:20 ` Manivannan Sadhasivam
2023-07-07 11:01 ` Krishna Chaitanya Chundru
0 siblings, 1 reply; 9+ messages in thread
From: Manivannan Sadhasivam @ 2023-07-07 6:20 UTC (permalink / raw)
To: Krishna chaitanya chundru
Cc: manivannan.sadhasivam, helgaas, linux-pci, linux-arm-msm,
linux-kernel, quic_vbadigan, quic_nitegupt, quic_skananth,
quic_ramkri, krzysztof.kozlowski, Jeffrey Hugo, Rafael J. Wysocki,
Dan Carpenter, Greg Kroah-Hartman, Bo Liu, open list:MHI BUS
On Fri, Jun 30, 2023 at 04:22:11PM +0530, Krishna chaitanya chundru wrote:
> If the MHI state is in M3 then the most probably the host kept the
> device in D3 hot or D3 cold, due to that endpoint transctions will not
> be read by the host, so endpoint needs to bring the host to D0 which
> eventually bring back the MHI state to M0.
>
Endpoint cannot bring the host to D0, it can only wake up the host and the host
will bring the device to D0.
> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
> ---
> drivers/bus/mhi/ep/main.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
> index 6008818..42d3791 100644
> --- a/drivers/bus/mhi/ep/main.c
> +++ b/drivers/bus/mhi/ep/main.c
> @@ -451,12 +451,14 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
> struct mhi_ep_cntrl *mhi_cntrl = mhi_dev->mhi_cntrl;
> struct mhi_ep_chan *mhi_chan = mhi_dev->dl_chan;
> struct device *dev = &mhi_chan->mhi_dev->dev;
> + u32 buf_left, read_offset, count = 0;
> struct mhi_ring_element *el;
> - u32 buf_left, read_offset;
> struct mhi_ep_ring *ring;
> enum mhi_ev_ccs code;
> + enum mhi_state state;
> void *read_addr;
> u64 write_addr;
> + bool mhi_reset;
> size_t tr_len;
> u32 tre_len;
> int ret;
> @@ -464,6 +466,18 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
> buf_left = skb->len;
> ring = &mhi_cntrl->mhi_chan[mhi_chan->chan].ring;
>
> + if (mhi_cntrl->mhi_state == MHI_STATE_M3) {
> + dev_dbg(dev, "wake up by ch id %x\n", mhi_chan->chan);
This is not needed.
> + mhi_cntrl->wakeup_host(mhi_cntrl);
> + }
> +
> + /* Wait for Host to set the M0 state */
> + do {
> + msleep(M0_WAIT_DELAY_MS);
> + mhi_ep_mmio_get_mhi_state(mhi_cntrl, &state, &mhi_reset);
> + count++;
> + } while (state != MHI_STATE_M0 && count < M0_WAIT_COUNT);
> +
Move this change to a function like mhi_ep_wake_host().
- Mani
> mutex_lock(&mhi_chan->lock);
>
> do {
> --
> 2.7.4
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 3/8] PCI: epf-mhi: Add dtate change op
2023-07-07 5:59 ` Manivannan Sadhasivam
@ 2023-07-07 10:55 ` Krishna Chaitanya Chundru
0 siblings, 0 replies; 9+ messages in thread
From: Krishna Chaitanya Chundru @ 2023-07-07 10:55 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: manivannan.sadhasivam, helgaas, linux-pci, linux-arm-msm,
linux-kernel, quic_vbadigan, quic_nitegupt, quic_skananth,
quic_ramkri, krzysztof.kozlowski, Lorenzo Pieralisi,
Krzysztof Wilczyński, Kishon Vijay Abraham I, Bjorn Helgaas,
Jeffrey Hugo, open list:MHI BUS
On 7/7/2023 11:29 AM, Manivannan Sadhasivam wrote:
> On Fri, Jun 30, 2023 at 04:22:06PM +0530, Krishna chaitanya chundru wrote:
>> Add dstate host op for MHI EPF.
>>
> Use "D-state" everywhere. Also the subject should be:
>
> "PCI: epf-mhi: Add support for handling D-state notification from EPC"
>
> Fix the commit message accordingly.
I will change it as you suggested.
>
>> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
>> ---
>> drivers/pci/endpoint/functions/pci-epf-mhi.c | 13 +++++++++++++
>> include/linux/mhi_ep.h | 3 +++
>> 2 files changed, 16 insertions(+)
>>
>> diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
>> index 9c1f5a1..64ff37d 100644
>> --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
>> +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
>> @@ -339,6 +339,18 @@ static int pci_epf_mhi_bme(struct pci_epf *epf)
>> return 0;
>> }
>>
>> +static int pci_epf_mhi_dstate_change(struct pci_epf *epf, pci_power_t state)
>> +{
>> + struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
>> + struct mhi_ep_cntrl *mhi_cntrl = &epf_mhi->mhi_cntrl;
>> + struct device *dev = &epf->dev;
>> +
>> + mhi_cntrl->dstate = state;
>> + dev_info(dev, "D-state changeg to %s\n", pci_power_name(state));
> This can be removed since we already print the state in pci driver.
>
> - Mani
ok
- KC
>
>> +
>> + return 0;
>> +}
>> +
>> static int pci_epf_mhi_bind(struct pci_epf *epf)
>> {
>> struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
>> @@ -394,6 +406,7 @@ static struct pci_epc_event_ops pci_epf_mhi_event_ops = {
>> .link_up = pci_epf_mhi_link_up,
>> .link_down = pci_epf_mhi_link_down,
>> .bme = pci_epf_mhi_bme,
>> + .dstate_change = pci_epf_mhi_dstate_change,
>> };
>>
>> static int pci_epf_mhi_probe(struct pci_epf *epf,
>> diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h
>> index f198a8a..c3a0685 100644
>> --- a/include/linux/mhi_ep.h
>> +++ b/include/linux/mhi_ep.h
>> @@ -8,6 +8,7 @@
>>
>> #include <linux/dma-direction.h>
>> #include <linux/mhi.h>
>> +#include <linux/pci.h>
>>
>> #define MHI_EP_DEFAULT_MTU 0x8000
>>
>> @@ -139,6 +140,8 @@ struct mhi_ep_cntrl {
>>
>> enum mhi_state mhi_state;
>>
>> + pci_power_t dstate;
>> +
>> u32 max_chan;
>> u32 mru;
>> u32 event_rings;
>> --
>> 2.7.4
>>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 7/8] PCI: epf-mhi: Add wakeup host op
2023-07-07 6:14 ` Manivannan Sadhasivam
@ 2023-07-07 11:00 ` Krishna Chaitanya Chundru
0 siblings, 0 replies; 9+ messages in thread
From: Krishna Chaitanya Chundru @ 2023-07-07 11:00 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: manivannan.sadhasivam, helgaas, linux-pci, linux-arm-msm,
linux-kernel, quic_vbadigan, quic_nitegupt, quic_skananth,
quic_ramkri, krzysztof.kozlowski, Lorenzo Pieralisi,
Krzysztof Wilczyński, Kishon Vijay Abraham I, Bjorn Helgaas,
Jeffrey Hugo, open list:MHI BUS
On 7/7/2023 11:44 AM, Manivannan Sadhasivam wrote:
> On Fri, Jun 30, 2023 at 04:22:10PM +0530, Krishna chaitanya chundru wrote:
>> Add wakeup host op for MHI EPF.
>> If the D-state is in D3cold toggle wake signal, otherwise send PME.
>>
>> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
>> ---
>> drivers/pci/endpoint/functions/pci-epf-mhi.c | 19 +++++++++++++++++++
>> include/linux/mhi_ep.h | 1 +
>> 2 files changed, 20 insertions(+)
>>
>> diff --git a/drivers/pci/endpoint/functions/pci-epf-mhi.c b/drivers/pci/endpoint/functions/pci-epf-mhi.c
>> index 64ff37d..deb742c 100644
>> --- a/drivers/pci/endpoint/functions/pci-epf-mhi.c
>> +++ b/drivers/pci/endpoint/functions/pci-epf-mhi.c
>> @@ -237,6 +237,24 @@ static int pci_epf_mhi_write_to_host(struct mhi_ep_cntrl *mhi_cntrl,
>> return 0;
>> }
>>
>> +static int pci_epf_mhi_wakeup_host(struct mhi_ep_cntrl *mhi_cntrl)
>> +{
>> + struct pci_epf_mhi *epf_mhi = to_epf_mhi(mhi_cntrl);
>> + struct pci_epf *epf = epf_mhi->epf;
>> + struct pci_epc *epc = epf->epc;
>> + int ret;
>> +
>> + if (mhi_cntrl->dstate == PCI_D3cold)
>> + ret = pci_epc_wakeup_host(epc, epf->func_no,
>> + epf->vfunc_no, PCI_WAKEUP_TOGGLE_WAKE);
>> + else
>> + ret = pci_epc_wakeup_host(epc, epf->func_no,
>> + epf->vfunc_no, PCI_WAKEUP_SEND_PME);
>> +
> If the wakeup argument is of type bool (ie. bool use_pme), then
>
> wakeup = (mhi_cntrl->dstate == PCI_D3cold) ? false : true;
>
> return pci_epc_wakeup_host(epc, epf->func_no, epf->vfunc_no, state);
>
> - Mani
better to use type as it as it has more readability
but I have taken your inputs here and will change the code as suggetsed.
- KC
>> + return ret;
>> +
>> +}
>> +
>> static int pci_epf_mhi_core_init(struct pci_epf *epf)
>> {
>> struct pci_epf_mhi *epf_mhi = epf_get_drvdata(epf);
>> @@ -293,6 +311,7 @@ static int pci_epf_mhi_link_up(struct pci_epf *epf)
>> mhi_cntrl->unmap_free = pci_epf_mhi_unmap_free;
>> mhi_cntrl->read_from_host = pci_epf_mhi_read_from_host;
>> mhi_cntrl->write_to_host = pci_epf_mhi_write_to_host;
>> + mhi_cntrl->wakeup_host = pci_epf_mhi_wakeup_host;
>>
>> /* Register the MHI EP controller */
>> ret = mhi_ep_register_controller(mhi_cntrl, info->config);
>> diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h
>> index c3a0685..e353c429 100644
>> --- a/include/linux/mhi_ep.h
>> +++ b/include/linux/mhi_ep.h
>> @@ -137,6 +137,7 @@ struct mhi_ep_cntrl {
>> void __iomem *virt, size_t size);
>> int (*read_from_host)(struct mhi_ep_cntrl *mhi_cntrl, u64 from, void *to, size_t size);
>> int (*write_to_host)(struct mhi_ep_cntrl *mhi_cntrl, void *from, u64 to, size_t size);
>> + int (*wakeup_host)(struct mhi_ep_cntrl *mhi_cntrl);
>>
>> enum mhi_state mhi_state;
>>
>> --
>> 2.7.4
>>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 8/8] bus: mhi: ep: wake up host is the MHI state is in M3
2023-07-07 6:20 ` Manivannan Sadhasivam
@ 2023-07-07 11:01 ` Krishna Chaitanya Chundru
0 siblings, 0 replies; 9+ messages in thread
From: Krishna Chaitanya Chundru @ 2023-07-07 11:01 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: manivannan.sadhasivam, helgaas, linux-pci, linux-arm-msm,
linux-kernel, quic_vbadigan, quic_nitegupt, quic_skananth,
quic_ramkri, krzysztof.kozlowski, Jeffrey Hugo, Rafael J. Wysocki,
Dan Carpenter, Greg Kroah-Hartman, Bo Liu, open list:MHI BUS
On 7/7/2023 11:50 AM, Manivannan Sadhasivam wrote:
> On Fri, Jun 30, 2023 at 04:22:11PM +0530, Krishna chaitanya chundru wrote:
>> If the MHI state is in M3 then the most probably the host kept the
>> device in D3 hot or D3 cold, due to that endpoint transctions will not
>> be read by the host, so endpoint needs to bring the host to D0 which
>> eventually bring back the MHI state to M0.
>>
> Endpoint cannot bring the host to D0, it can only wake up the host and the host
> will bring the device to D0.
>
>> Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com>
>> ---
>> drivers/bus/mhi/ep/main.c | 16 +++++++++++++++-
>> 1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c
>> index 6008818..42d3791 100644
>> --- a/drivers/bus/mhi/ep/main.c
>> +++ b/drivers/bus/mhi/ep/main.c
>> @@ -451,12 +451,14 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
>> struct mhi_ep_cntrl *mhi_cntrl = mhi_dev->mhi_cntrl;
>> struct mhi_ep_chan *mhi_chan = mhi_dev->dl_chan;
>> struct device *dev = &mhi_chan->mhi_dev->dev;
>> + u32 buf_left, read_offset, count = 0;
>> struct mhi_ring_element *el;
>> - u32 buf_left, read_offset;
>> struct mhi_ep_ring *ring;
>> enum mhi_ev_ccs code;
>> + enum mhi_state state;
>> void *read_addr;
>> u64 write_addr;
>> + bool mhi_reset;
>> size_t tr_len;
>> u32 tre_len;
>> int ret;
>> @@ -464,6 +466,18 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb)
>> buf_left = skb->len;
>> ring = &mhi_cntrl->mhi_chan[mhi_chan->chan].ring;
>>
>> + if (mhi_cntrl->mhi_state == MHI_STATE_M3) {
>> + dev_dbg(dev, "wake up by ch id %x\n", mhi_chan->chan);
> This is not needed.
>
>> + mhi_cntrl->wakeup_host(mhi_cntrl);
>> + }
>> +
>> + /* Wait for Host to set the M0 state */
>> + do {
>> + msleep(M0_WAIT_DELAY_MS);
>> + mhi_ep_mmio_get_mhi_state(mhi_cntrl, &state, &mhi_reset);
>> + count++;
>> + } while (state != MHI_STATE_M0 && count < M0_WAIT_COUNT);
>> +
> Move this change to a function like mhi_ep_wake_host().
>
> - Mani
Sure I will change it in next patch.
- KC
>
>> mutex_lock(&mhi_chan->lock);
>>
>> do {
>> --
>> 2.7.4
>>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-07-07 11:01 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1688122331-25478-1-git-send-email-quic_krichai@quicinc.com>
2023-06-30 10:52 ` [PATCH v2 3/8] PCI: epf-mhi: Add dtate change op Krishna chaitanya chundru
2023-07-07 5:59 ` Manivannan Sadhasivam
2023-07-07 10:55 ` Krishna Chaitanya Chundru
2023-06-30 10:52 ` [PATCH v2 7/8] PCI: epf-mhi: Add wakeup host op Krishna chaitanya chundru
2023-07-07 6:14 ` Manivannan Sadhasivam
2023-07-07 11:00 ` Krishna Chaitanya Chundru
2023-06-30 10:52 ` [PATCH v2 8/8] bus: mhi: ep: wake up host is the MHI state is in M3 Krishna chaitanya chundru
2023-07-07 6:20 ` Manivannan Sadhasivam
2023-07-07 11:01 ` Krishna Chaitanya Chundru
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox