All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI: Enable ATS at the device state restore
@ 2011-12-17 13:24 Hao, Xudong
  0 siblings, 0 replies; 3+ messages in thread
From: Hao, Xudong @ 2011-12-17 13:24 UTC (permalink / raw)
  To: jbarnes, linux-pci; +Cc: linux-kernel, kvm, Zhang, Xiantao

When system go to S3 or S4 sleep and then return, some register of PCI device does not be restored correctly, such as ATS capability. The same problem happen on pci reset function.

This patch enables ATS at the device state restore if PCI device has ATS capability.

Signed-off-by: Xudong Hao <xudong.hao@intel.com>
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
---
 drivers/pci/ats.c |   17 +++++++++++++++++
 drivers/pci/pci.c |    1 +
 drivers/pci/pci.h |    8 ++++++++
 3 files changed, 26 insertions(+), 0 deletions(-)
 
diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c
index 7ec56fb..a6c2b35 100644
--- a/drivers/pci/ats.c
+++ b/drivers/pci/ats.c
@@ -127,6 +127,23 @@ void pci_disable_ats(struct pci_dev *dev)
 }
 EXPORT_SYMBOL_GPL(pci_disable_ats);
 
+void pci_restore_ats_state(struct pci_dev *dev)
+{
+	u16 ctrl;
+
+	if (!pci_ats_enabled(dev))
+		return;
+	if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS))
+		BUG();
+
+	ctrl = PCI_ATS_CTRL_ENABLE;
+	if (!dev->is_virtfn)
+		ctrl |= PCI_ATS_CTRL_STU(dev->ats->stu - PCI_ATS_MIN_STU);
+
+	pci_write_config_word(dev, dev->ats->pos + PCI_ATS_CTRL, ctrl);
+}
+EXPORT_SYMBOL_GPL(pci_restore_ats_state);
+
 /**
  * pci_ats_queue_depth - query the ATS Invalidate Queue Depth
  * @dev: the PCI device
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 6f45a73..6dafc1d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -956,6 +956,7 @@ void pci_restore_state(struct pci_dev *dev)
 
 	/* PCI Express register must be restored first */
 	pci_restore_pcie_state(dev);
+	pci_restore_ats_state(dev);
 
 	/*
 	 * The Base Address register should be programmed before the command
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index b74084e..a4f3140 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -249,6 +249,14 @@ struct pci_sriov {
 	u8 __iomem *mstate;	/* VF Migration State Array */
 };
 
+#ifdef CONFIG_PCI_ATS
+extern void pci_restore_ats_state(struct pci_dev *dev);
+#else
+static inline void pci_restore_ats_state(struct pci_dev *dev)
+{
+}
+#endif /* CONFIG_PCI_ATS */
+
 #ifdef CONFIG_PCI_IOV
 extern int pci_iov_init(struct pci_dev *dev);
 extern void pci_iov_release(struct pci_dev *dev);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: Enable ATS at the device state restore
  2011-12-20 10:15 Hao, Xudong
@ 2012-01-04 17:35 ` Jesse Barnes
  0 siblings, 0 replies; 3+ messages in thread
From: Jesse Barnes @ 2012-01-04 17:35 UTC (permalink / raw)
  To: Hao, Xudong; +Cc: linux-pci, linux-kernel, kvm, Zhang, Xiantao

[-- Attachment #1: Type: text/plain, Size: 3075 bytes --]

No looks fine, just applied to my linux-next branch.  Thanks.

Jesse

On Tue, 20 Dec 2011 18:15:42 +0800
"Hao, Xudong" <xudong.hao@intel.com> wrote:

> Hi, Jesse
> Do you have any comments for this fix patch?
> 
> Thanks,
> -Xudong
> 
> > -----Original Message-----
> > From: Hao, Xudong
> > Sent: Saturday, December 17, 2011 9:25 PM
> > To: 'jbarnes@virtuousgeek.org'; 'linux-pci@vger.kernel.org'
> > Cc: linux-kernel@vger.kernel.org; kvm@vger.kernel.org; Zhang, Xiantao
> > Subject: [PATCH] PCI: Enable ATS at the device state restore
> > 
> > When system go to S3 or S4 sleep and then return, some register of PCI device
> > does not be restored correctly, such as ATS capability. The same problem
> > happen on pci reset function.
> > 
> > This patch enables ATS at the device state restore if PCI device has ATS
> > capability.
> > 
> > Signed-off-by: Xudong Hao <xudong.hao@intel.com>
> > Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
> > ---
> >  drivers/pci/ats.c |   17 +++++++++++++++++
> >  drivers/pci/pci.c |    1 +
> >  drivers/pci/pci.h |    8 ++++++++
> >  3 files changed, 26 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c index 7ec56fb..a6c2b35 100644
> > --- a/drivers/pci/ats.c
> > +++ b/drivers/pci/ats.c
> > @@ -127,6 +127,23 @@ void pci_disable_ats(struct pci_dev *dev)  }
> > EXPORT_SYMBOL_GPL(pci_disable_ats);
> > 
> > +void pci_restore_ats_state(struct pci_dev *dev) {
> > +	u16 ctrl;
> > +
> > +	if (!pci_ats_enabled(dev))
> > +		return;
> > +	if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS))
> > +		BUG();
> > +
> > +	ctrl = PCI_ATS_CTRL_ENABLE;
> > +	if (!dev->is_virtfn)
> > +		ctrl |= PCI_ATS_CTRL_STU(dev->ats->stu - PCI_ATS_MIN_STU);
> > +
> > +	pci_write_config_word(dev, dev->ats->pos + PCI_ATS_CTRL, ctrl); }
> > +EXPORT_SYMBOL_GPL(pci_restore_ats_state);
> > +
> >  /**
> >   * pci_ats_queue_depth - query the ATS Invalidate Queue Depth
> >   * @dev: the PCI device
> > diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6f45a73..6dafc1d 100644
> > --- a/drivers/pci/pci.c
> > +++ b/drivers/pci/pci.c
> > @@ -956,6 +956,7 @@ void pci_restore_state(struct pci_dev *dev)
> > 
> >  	/* PCI Express register must be restored first */
> >  	pci_restore_pcie_state(dev);
> > +	pci_restore_ats_state(dev);
> > 
> >  	/*
> >  	 * The Base Address register should be programmed before the command
> > diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index b74084e..a4f3140 100644
> > --- a/drivers/pci/pci.h
> > +++ b/drivers/pci/pci.h
> > @@ -249,6 +249,14 @@ struct pci_sriov {
> >  	u8 __iomem *mstate;	/* VF Migration State Array */
> >  };
> > 
> > +#ifdef CONFIG_PCI_ATS
> > +extern void pci_restore_ats_state(struct pci_dev *dev); #else static
> > +inline void pci_restore_ats_state(struct pci_dev *dev) { } #endif /*
> > +CONFIG_PCI_ATS */
> > +
> >  #ifdef CONFIG_PCI_IOV
> >  extern int pci_iov_init(struct pci_dev *dev);  extern void
> > pci_iov_release(struct pci_dev *dev);
> 



[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] PCI: Enable ATS at the device state restore
@ 2011-12-20 10:15 Hao, Xudong
  2012-01-04 17:35 ` Jesse Barnes
  0 siblings, 1 reply; 3+ messages in thread
From: Hao, Xudong @ 2011-12-20 10:15 UTC (permalink / raw)
  To: jbarnes, linux-pci; +Cc: linux-kernel, kvm, Zhang, Xiantao

Hi, Jesse
Do you have any comments for this fix patch?

Thanks,
-Xudong

> -----Original Message-----
> From: Hao, Xudong
> Sent: Saturday, December 17, 2011 9:25 PM
> To: 'jbarnes@virtuousgeek.org'; 'linux-pci@vger.kernel.org'
> Cc: linux-kernel@vger.kernel.org; kvm@vger.kernel.org; Zhang, Xiantao
> Subject: [PATCH] PCI: Enable ATS at the device state restore
> 
> When system go to S3 or S4 sleep and then return, some register of PCI device
> does not be restored correctly, such as ATS capability. The same problem
> happen on pci reset function.
> 
> This patch enables ATS at the device state restore if PCI device has ATS
> capability.
> 
> Signed-off-by: Xudong Hao <xudong.hao@intel.com>
> Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
> ---
>  drivers/pci/ats.c |   17 +++++++++++++++++
>  drivers/pci/pci.c |    1 +
>  drivers/pci/pci.h |    8 ++++++++
>  3 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/pci/ats.c b/drivers/pci/ats.c index 7ec56fb..a6c2b35 100644
> --- a/drivers/pci/ats.c
> +++ b/drivers/pci/ats.c
> @@ -127,6 +127,23 @@ void pci_disable_ats(struct pci_dev *dev)  }
> EXPORT_SYMBOL_GPL(pci_disable_ats);
> 
> +void pci_restore_ats_state(struct pci_dev *dev) {
> +	u16 ctrl;
> +
> +	if (!pci_ats_enabled(dev))
> +		return;
> +	if (!pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS))
> +		BUG();
> +
> +	ctrl = PCI_ATS_CTRL_ENABLE;
> +	if (!dev->is_virtfn)
> +		ctrl |= PCI_ATS_CTRL_STU(dev->ats->stu - PCI_ATS_MIN_STU);
> +
> +	pci_write_config_word(dev, dev->ats->pos + PCI_ATS_CTRL, ctrl); }
> +EXPORT_SYMBOL_GPL(pci_restore_ats_state);
> +
>  /**
>   * pci_ats_queue_depth - query the ATS Invalidate Queue Depth
>   * @dev: the PCI device
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 6f45a73..6dafc1d 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -956,6 +956,7 @@ void pci_restore_state(struct pci_dev *dev)
> 
>  	/* PCI Express register must be restored first */
>  	pci_restore_pcie_state(dev);
> +	pci_restore_ats_state(dev);
> 
>  	/*
>  	 * The Base Address register should be programmed before the command
> diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index b74084e..a4f3140 100644
> --- a/drivers/pci/pci.h
> +++ b/drivers/pci/pci.h
> @@ -249,6 +249,14 @@ struct pci_sriov {
>  	u8 __iomem *mstate;	/* VF Migration State Array */
>  };
> 
> +#ifdef CONFIG_PCI_ATS
> +extern void pci_restore_ats_state(struct pci_dev *dev); #else static
> +inline void pci_restore_ats_state(struct pci_dev *dev) { } #endif /*
> +CONFIG_PCI_ATS */
> +
>  #ifdef CONFIG_PCI_IOV
>  extern int pci_iov_init(struct pci_dev *dev);  extern void
> pci_iov_release(struct pci_dev *dev);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-01-04 17:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-17 13:24 [PATCH] PCI: Enable ATS at the device state restore Hao, Xudong
2011-12-20 10:15 Hao, Xudong
2012-01-04 17:35 ` Jesse Barnes

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.