* [PATCH] PCI: mvebu: add suspend/resume support
@ 2015-03-17 14:55 ` Thomas Petazzoni
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2015-03-17 14:55 UTC (permalink / raw)
To: Bjorn Helgaas, linux-pci
Cc: linux-arm-kernel, Jason Cooper, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Tawfik Bayouk,
Nadav Haklai, Lior Amsalem, Thomas Petazzoni
This commit implements suspend/resume support for the mvebu PCIe host
driver. Without this commit, the system will panic at resume time when
PCIe devices are connected.
Note that we have to use the ->suspend_noirq() and ->resume_noirq()
hooks, because at resume time, the PCI fixups are done at
->resume_noirq() time, so the PCIe controller has to be ready at this
point.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/pci/host/pci-mvebu.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 1309cfb..1ab8635 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -129,6 +129,7 @@ struct mvebu_pcie_port {
size_t memwin_size;
phys_addr_t iowin_base;
size_t iowin_size;
+ u32 saved_pcie_stat;
};
static inline void mvebu_writel(struct mvebu_pcie_port *port, u32 val, u32 reg)
@@ -899,6 +900,35 @@ static void mvebu_pcie_msi_enable(struct mvebu_pcie *pcie)
pcie->msi->dev = &pcie->pdev->dev;
}
+static int mvebu_pcie_suspend(struct device *dev)
+{
+ struct mvebu_pcie *pcie;
+ int i;
+
+ pcie = dev_get_drvdata(dev);
+ for (i = 0; i < pcie->nports; i++) {
+ struct mvebu_pcie_port *port = pcie->ports + i;
+ port->saved_pcie_stat = mvebu_readl(port, PCIE_STAT_OFF);
+ }
+
+ return 0;
+}
+
+static int mvebu_pcie_resume(struct device *dev)
+{
+ struct mvebu_pcie *pcie;
+ int i;
+
+ pcie = dev_get_drvdata(dev);
+ for (i = 0; i < pcie->nports; i++) {
+ struct mvebu_pcie_port *port = pcie->ports + i;
+ mvebu_writel(port, port->saved_pcie_stat, PCIE_STAT_OFF);
+ mvebu_pcie_setup_hw(port);
+ }
+
+ return 0;
+}
+
static int mvebu_pcie_probe(struct platform_device *pdev)
{
struct mvebu_pcie *pcie;
@@ -1056,6 +1086,8 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
mvebu_pcie_msi_enable(pcie);
mvebu_pcie_enable(pcie);
+ platform_set_drvdata(pdev, pcie);
+
return 0;
}
@@ -1068,12 +1100,18 @@ static const struct of_device_id mvebu_pcie_of_match_table[] = {
};
MODULE_DEVICE_TABLE(of, mvebu_pcie_of_match_table);
+static struct dev_pm_ops mvebu_pcie_pm_ops = {
+ .suspend_noirq = mvebu_pcie_suspend,
+ .resume_noirq = mvebu_pcie_resume,
+};
+
static struct platform_driver mvebu_pcie_driver = {
.driver = {
.name = "mvebu-pcie",
.of_match_table = mvebu_pcie_of_match_table,
/* driver unloading/unbinding currently not supported */
.suppress_bind_attrs = true,
+ .pm = &mvebu_pcie_pm_ops,
},
.probe = mvebu_pcie_probe,
};
--
2.1.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] PCI: mvebu: add suspend/resume support
@ 2015-03-17 14:55 ` Thomas Petazzoni
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2015-03-17 14:55 UTC (permalink / raw)
To: linux-arm-kernel
This commit implements suspend/resume support for the mvebu PCIe host
driver. Without this commit, the system will panic at resume time when
PCIe devices are connected.
Note that we have to use the ->suspend_noirq() and ->resume_noirq()
hooks, because at resume time, the PCI fixups are done at
->resume_noirq() time, so the PCIe controller has to be ready at this
point.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/pci/host/pci-mvebu.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 1309cfb..1ab8635 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -129,6 +129,7 @@ struct mvebu_pcie_port {
size_t memwin_size;
phys_addr_t iowin_base;
size_t iowin_size;
+ u32 saved_pcie_stat;
};
static inline void mvebu_writel(struct mvebu_pcie_port *port, u32 val, u32 reg)
@@ -899,6 +900,35 @@ static void mvebu_pcie_msi_enable(struct mvebu_pcie *pcie)
pcie->msi->dev = &pcie->pdev->dev;
}
+static int mvebu_pcie_suspend(struct device *dev)
+{
+ struct mvebu_pcie *pcie;
+ int i;
+
+ pcie = dev_get_drvdata(dev);
+ for (i = 0; i < pcie->nports; i++) {
+ struct mvebu_pcie_port *port = pcie->ports + i;
+ port->saved_pcie_stat = mvebu_readl(port, PCIE_STAT_OFF);
+ }
+
+ return 0;
+}
+
+static int mvebu_pcie_resume(struct device *dev)
+{
+ struct mvebu_pcie *pcie;
+ int i;
+
+ pcie = dev_get_drvdata(dev);
+ for (i = 0; i < pcie->nports; i++) {
+ struct mvebu_pcie_port *port = pcie->ports + i;
+ mvebu_writel(port, port->saved_pcie_stat, PCIE_STAT_OFF);
+ mvebu_pcie_setup_hw(port);
+ }
+
+ return 0;
+}
+
static int mvebu_pcie_probe(struct platform_device *pdev)
{
struct mvebu_pcie *pcie;
@@ -1056,6 +1086,8 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
mvebu_pcie_msi_enable(pcie);
mvebu_pcie_enable(pcie);
+ platform_set_drvdata(pdev, pcie);
+
return 0;
}
@@ -1068,12 +1100,18 @@ static const struct of_device_id mvebu_pcie_of_match_table[] = {
};
MODULE_DEVICE_TABLE(of, mvebu_pcie_of_match_table);
+static struct dev_pm_ops mvebu_pcie_pm_ops = {
+ .suspend_noirq = mvebu_pcie_suspend,
+ .resume_noirq = mvebu_pcie_resume,
+};
+
static struct platform_driver mvebu_pcie_driver = {
.driver = {
.name = "mvebu-pcie",
.of_match_table = mvebu_pcie_of_match_table,
/* driver unloading/unbinding currently not supported */
.suppress_bind_attrs = true,
+ .pm = &mvebu_pcie_pm_ops,
},
.probe = mvebu_pcie_probe,
};
--
2.1.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] PCI: mvebu: add suspend/resume support
2015-03-17 14:55 ` Thomas Petazzoni
@ 2015-03-17 15:15 ` Jason Cooper
-1 siblings, 0 replies; 8+ messages in thread
From: Jason Cooper @ 2015-03-17 15:15 UTC (permalink / raw)
To: Thomas Petazzoni
Cc: Bjorn Helgaas, linux-pci, linux-arm-kernel, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Tawfik Bayouk,
Nadav Haklai, Lior Amsalem
Hey Thomas,
On Tue, Mar 17, 2015 at 03:55:45PM +0100, Thomas Petazzoni wrote:
> This commit implements suspend/resume support for the mvebu PCIe host
> driver. Without this commit, the system will panic at resume time when
> PCIe devices are connected.
>
> Note that we have to use the ->suspend_noirq() and ->resume_noirq()
> hooks, because at resume time, the PCI fixups are done at
> ->resume_noirq() time, so the PCIe controller has to be ready at this
> point.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
> drivers/pci/host/pci-mvebu.c | 38 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> index 1309cfb..1ab8635 100644
> --- a/drivers/pci/host/pci-mvebu.c
> +++ b/drivers/pci/host/pci-mvebu.c
> @@ -129,6 +129,7 @@ struct mvebu_pcie_port {
> size_t memwin_size;
> phys_addr_t iowin_base;
> size_t iowin_size;
> + u32 saved_pcie_stat;
nit: It's already in the pcie port struct, why not just call it saved_state?
Either way,
Acked-by: Jason Cooper <jason@lakedaemon.net>
thx,
Jason.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] PCI: mvebu: add suspend/resume support
@ 2015-03-17 15:15 ` Jason Cooper
0 siblings, 0 replies; 8+ messages in thread
From: Jason Cooper @ 2015-03-17 15:15 UTC (permalink / raw)
To: linux-arm-kernel
Hey Thomas,
On Tue, Mar 17, 2015 at 03:55:45PM +0100, Thomas Petazzoni wrote:
> This commit implements suspend/resume support for the mvebu PCIe host
> driver. Without this commit, the system will panic at resume time when
> PCIe devices are connected.
>
> Note that we have to use the ->suspend_noirq() and ->resume_noirq()
> hooks, because at resume time, the PCI fixups are done at
> ->resume_noirq() time, so the PCIe controller has to be ready at this
> point.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
> drivers/pci/host/pci-mvebu.c | 38 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> index 1309cfb..1ab8635 100644
> --- a/drivers/pci/host/pci-mvebu.c
> +++ b/drivers/pci/host/pci-mvebu.c
> @@ -129,6 +129,7 @@ struct mvebu_pcie_port {
> size_t memwin_size;
> phys_addr_t iowin_base;
> size_t iowin_size;
> + u32 saved_pcie_stat;
nit: It's already in the pcie port struct, why not just call it saved_state?
Either way,
Acked-by: Jason Cooper <jason@lakedaemon.net>
thx,
Jason.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] PCI: mvebu: add suspend/resume support
2015-03-17 15:15 ` Jason Cooper
@ 2015-03-19 8:24 ` Thomas Petazzoni
-1 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2015-03-19 8:24 UTC (permalink / raw)
To: Jason Cooper
Cc: Bjorn Helgaas, linux-pci, linux-arm-kernel, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Tawfik Bayouk,
Nadav Haklai, Lior Amsalem
Dear Jason Cooper,
On Tue, 17 Mar 2015 15:15:01 +0000, Jason Cooper wrote:
> > diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> > index 1309cfb..1ab8635 100644
> > --- a/drivers/pci/host/pci-mvebu.c
> > +++ b/drivers/pci/host/pci-mvebu.c
> > @@ -129,6 +129,7 @@ struct mvebu_pcie_port {
> > size_t memwin_size;
> > phys_addr_t iowin_base;
> > size_t iowin_size;
> > + u32 saved_pcie_stat;
>
> nit: It's already in the pcie port struct, why not just call it saved_state?
Well the "stat" does not mean "state", but refers to the register being
saved in this field. The register is called: PCIE_STAT_OFF. Hence the
name saved_pcie_stat. But I'm fine with changing this to some other
name, I really don't care :)
> Either way,
>
> Acked-by: Jason Cooper <jason@lakedaemon.net>
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] PCI: mvebu: add suspend/resume support
@ 2015-03-19 8:24 ` Thomas Petazzoni
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2015-03-19 8:24 UTC (permalink / raw)
To: linux-arm-kernel
Dear Jason Cooper,
On Tue, 17 Mar 2015 15:15:01 +0000, Jason Cooper wrote:
> > diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> > index 1309cfb..1ab8635 100644
> > --- a/drivers/pci/host/pci-mvebu.c
> > +++ b/drivers/pci/host/pci-mvebu.c
> > @@ -129,6 +129,7 @@ struct mvebu_pcie_port {
> > size_t memwin_size;
> > phys_addr_t iowin_base;
> > size_t iowin_size;
> > + u32 saved_pcie_stat;
>
> nit: It's already in the pcie port struct, why not just call it saved_state?
Well the "stat" does not mean "state", but refers to the register being
saved in this field. The register is called: PCIE_STAT_OFF. Hence the
name saved_pcie_stat. But I'm fine with changing this to some other
name, I really don't care :)
> Either way,
>
> Acked-by: Jason Cooper <jason@lakedaemon.net>
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] PCI: mvebu: add suspend/resume support
2015-03-17 14:55 ` Thomas Petazzoni
@ 2015-03-20 23:27 ` Bjorn Helgaas
-1 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2015-03-20 23:27 UTC (permalink / raw)
To: Thomas Petazzoni
Cc: linux-pci, linux-arm-kernel, Jason Cooper, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Tawfik Bayouk,
Nadav Haklai, Lior Amsalem
On Tue, Mar 17, 2015 at 03:55:45PM +0100, Thomas Petazzoni wrote:
> This commit implements suspend/resume support for the mvebu PCIe host
> driver. Without this commit, the system will panic at resume time when
> PCIe devices are connected.
>
> Note that we have to use the ->suspend_noirq() and ->resume_noirq()
> hooks, because at resume time, the PCI fixups are done at
> ->resume_noirq() time, so the PCIe controller has to be ready at this
> point.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Applied with Jason's ack to pci/host-mvebu for v4.1, thanks!
> ---
> drivers/pci/host/pci-mvebu.c | 38 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> index 1309cfb..1ab8635 100644
> --- a/drivers/pci/host/pci-mvebu.c
> +++ b/drivers/pci/host/pci-mvebu.c
> @@ -129,6 +129,7 @@ struct mvebu_pcie_port {
> size_t memwin_size;
> phys_addr_t iowin_base;
> size_t iowin_size;
> + u32 saved_pcie_stat;
> };
>
> static inline void mvebu_writel(struct mvebu_pcie_port *port, u32 val, u32 reg)
> @@ -899,6 +900,35 @@ static void mvebu_pcie_msi_enable(struct mvebu_pcie *pcie)
> pcie->msi->dev = &pcie->pdev->dev;
> }
>
> +static int mvebu_pcie_suspend(struct device *dev)
> +{
> + struct mvebu_pcie *pcie;
> + int i;
> +
> + pcie = dev_get_drvdata(dev);
> + for (i = 0; i < pcie->nports; i++) {
> + struct mvebu_pcie_port *port = pcie->ports + i;
> + port->saved_pcie_stat = mvebu_readl(port, PCIE_STAT_OFF);
> + }
> +
> + return 0;
> +}
> +
> +static int mvebu_pcie_resume(struct device *dev)
> +{
> + struct mvebu_pcie *pcie;
> + int i;
> +
> + pcie = dev_get_drvdata(dev);
> + for (i = 0; i < pcie->nports; i++) {
> + struct mvebu_pcie_port *port = pcie->ports + i;
> + mvebu_writel(port, port->saved_pcie_stat, PCIE_STAT_OFF);
> + mvebu_pcie_setup_hw(port);
> + }
> +
> + return 0;
> +}
> +
> static int mvebu_pcie_probe(struct platform_device *pdev)
> {
> struct mvebu_pcie *pcie;
> @@ -1056,6 +1086,8 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
> mvebu_pcie_msi_enable(pcie);
> mvebu_pcie_enable(pcie);
>
> + platform_set_drvdata(pdev, pcie);
> +
> return 0;
> }
>
> @@ -1068,12 +1100,18 @@ static const struct of_device_id mvebu_pcie_of_match_table[] = {
> };
> MODULE_DEVICE_TABLE(of, mvebu_pcie_of_match_table);
>
> +static struct dev_pm_ops mvebu_pcie_pm_ops = {
> + .suspend_noirq = mvebu_pcie_suspend,
> + .resume_noirq = mvebu_pcie_resume,
> +};
> +
> static struct platform_driver mvebu_pcie_driver = {
> .driver = {
> .name = "mvebu-pcie",
> .of_match_table = mvebu_pcie_of_match_table,
> /* driver unloading/unbinding currently not supported */
> .suppress_bind_attrs = true,
> + .pm = &mvebu_pcie_pm_ops,
> },
> .probe = mvebu_pcie_probe,
> };
> --
> 2.1.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] PCI: mvebu: add suspend/resume support
@ 2015-03-20 23:27 ` Bjorn Helgaas
0 siblings, 0 replies; 8+ messages in thread
From: Bjorn Helgaas @ 2015-03-20 23:27 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Mar 17, 2015 at 03:55:45PM +0100, Thomas Petazzoni wrote:
> This commit implements suspend/resume support for the mvebu PCIe host
> driver. Without this commit, the system will panic at resume time when
> PCIe devices are connected.
>
> Note that we have to use the ->suspend_noirq() and ->resume_noirq()
> hooks, because at resume time, the PCI fixups are done at
> ->resume_noirq() time, so the PCIe controller has to be ready at this
> point.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Applied with Jason's ack to pci/host-mvebu for v4.1, thanks!
> ---
> drivers/pci/host/pci-mvebu.c | 38 ++++++++++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
> index 1309cfb..1ab8635 100644
> --- a/drivers/pci/host/pci-mvebu.c
> +++ b/drivers/pci/host/pci-mvebu.c
> @@ -129,6 +129,7 @@ struct mvebu_pcie_port {
> size_t memwin_size;
> phys_addr_t iowin_base;
> size_t iowin_size;
> + u32 saved_pcie_stat;
> };
>
> static inline void mvebu_writel(struct mvebu_pcie_port *port, u32 val, u32 reg)
> @@ -899,6 +900,35 @@ static void mvebu_pcie_msi_enable(struct mvebu_pcie *pcie)
> pcie->msi->dev = &pcie->pdev->dev;
> }
>
> +static int mvebu_pcie_suspend(struct device *dev)
> +{
> + struct mvebu_pcie *pcie;
> + int i;
> +
> + pcie = dev_get_drvdata(dev);
> + for (i = 0; i < pcie->nports; i++) {
> + struct mvebu_pcie_port *port = pcie->ports + i;
> + port->saved_pcie_stat = mvebu_readl(port, PCIE_STAT_OFF);
> + }
> +
> + return 0;
> +}
> +
> +static int mvebu_pcie_resume(struct device *dev)
> +{
> + struct mvebu_pcie *pcie;
> + int i;
> +
> + pcie = dev_get_drvdata(dev);
> + for (i = 0; i < pcie->nports; i++) {
> + struct mvebu_pcie_port *port = pcie->ports + i;
> + mvebu_writel(port, port->saved_pcie_stat, PCIE_STAT_OFF);
> + mvebu_pcie_setup_hw(port);
> + }
> +
> + return 0;
> +}
> +
> static int mvebu_pcie_probe(struct platform_device *pdev)
> {
> struct mvebu_pcie *pcie;
> @@ -1056,6 +1086,8 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
> mvebu_pcie_msi_enable(pcie);
> mvebu_pcie_enable(pcie);
>
> + platform_set_drvdata(pdev, pcie);
> +
> return 0;
> }
>
> @@ -1068,12 +1100,18 @@ static const struct of_device_id mvebu_pcie_of_match_table[] = {
> };
> MODULE_DEVICE_TABLE(of, mvebu_pcie_of_match_table);
>
> +static struct dev_pm_ops mvebu_pcie_pm_ops = {
> + .suspend_noirq = mvebu_pcie_suspend,
> + .resume_noirq = mvebu_pcie_resume,
> +};
> +
> static struct platform_driver mvebu_pcie_driver = {
> .driver = {
> .name = "mvebu-pcie",
> .of_match_table = mvebu_pcie_of_match_table,
> /* driver unloading/unbinding currently not supported */
> .suppress_bind_attrs = true,
> + .pm = &mvebu_pcie_pm_ops,
> },
> .probe = mvebu_pcie_probe,
> };
> --
> 2.1.0
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-03-20 23:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-17 14:55 [PATCH] PCI: mvebu: add suspend/resume support Thomas Petazzoni
2015-03-17 14:55 ` Thomas Petazzoni
2015-03-17 15:15 ` Jason Cooper
2015-03-17 15:15 ` Jason Cooper
2015-03-19 8:24 ` Thomas Petazzoni
2015-03-19 8:24 ` Thomas Petazzoni
2015-03-20 23:27 ` Bjorn Helgaas
2015-03-20 23:27 ` Bjorn Helgaas
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.